summaryrefslogtreecommitdiff
path: root/std/node/_fs/_fs_exists.ts
diff options
context:
space:
mode:
authorAli Hasani <a.hassssani@gmail.com>2020-04-20 13:59:37 +0430
committerGitHub <noreply@github.com>2020-04-20 11:29:37 +0200
commit437e35ca52227337588148a6896040d3fc3f2d54 (patch)
treec1be28b0ceae5fd4276be087afc686b78eab5629 /std/node/_fs/_fs_exists.ts
parentc1ec042a0011eeba2480b892a335ca7804c59180 (diff)
Add no-async-promise-executor lint rule (#4809)
Diffstat (limited to 'std/node/_fs/_fs_exists.ts')
-rw-r--r--std/node/_fs/_fs_exists.ts24
1 files changed, 11 insertions, 13 deletions
diff --git a/std/node/_fs/_fs_exists.ts b/std/node/_fs/_fs_exists.ts
index cc4f65736..c3bea0d4e 100644
--- a/std/node/_fs/_fs_exists.ts
+++ b/std/node/_fs/_fs_exists.ts
@@ -2,25 +2,23 @@
type ExitsCallback = (exists: boolean) => void;
-/* Deprecated in node api */
-
+/**
+ * TODO: Also accept 'path' parameter as a Node polyfill Buffer or URL type once these
+ * are implemented. See https://github.com/denoland/deno/issues/3403
+ * Deprecated in node api
+ */
export function exists(path: string, callback: ExitsCallback): void {
- new Promise(async (resolve, reject) => {
- try {
- await Deno.lstat(path);
- resolve();
- } catch (err) {
- reject(err);
- }
- })
+ Deno.lstat(path)
.then(() => {
callback(true);
})
- .catch(() => {
- callback(false);
- });
+ .catch(() => callback(false));
}
+/**
+ * TODO: Also accept 'path' parameter as a Node polyfill Buffer or URL type once these
+ * are implemented. See https://github.com/denoland/deno/issues/3403
+ */
export function existsSync(path: string): boolean {
try {
Deno.lstatSync(path);