summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_fs/_fs_unlink.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/_fs/_fs_unlink.ts')
-rw-r--r--ext/node/polyfills/_fs/_fs_unlink.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/node/polyfills/_fs/_fs_unlink.ts b/ext/node/polyfills/_fs/_fs_unlink.ts
new file mode 100644
index 000000000..ed43bb1b3
--- /dev/null
+++ b/ext/node/polyfills/_fs/_fs_unlink.ts
@@ -0,0 +1,15 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+import { promisify } from "internal:deno_node/polyfills/internal/util.mjs";
+
+export function unlink(path: string | URL, callback: (err?: Error) => void) {
+ if (!callback) throw new Error("No callback function supplied");
+ Deno.remove(path).then((_) => callback(), callback);
+}
+
+export const unlinkPromise = promisify(unlink) as (
+ path: string | URL,
+) => Promise<void>;
+
+export function unlinkSync(path: string | URL) {
+ Deno.removeSync(path);
+}