diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-07-19 19:49:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-19 19:49:44 +0200 |
commit | fa61956f03491101b6ef64423ea2f1f73af26a73 (patch) | |
tree | c3800702071ca78aa4dd71bdd0a59a9bbe460bdd /cli/js/ops/fs/read_dir.ts | |
parent | 53adde866dd399aa2509d14508642fce37afb8f5 (diff) |
Port internal TS code to JS (#6793)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/js/ops/fs/read_dir.ts')
-rw-r--r-- | cli/js/ops/fs/read_dir.ts | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/cli/js/ops/fs/read_dir.ts b/cli/js/ops/fs/read_dir.ts deleted file mode 100644 index 6ffe6116e..000000000 --- a/cli/js/ops/fs/read_dir.ts +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -import { sendSync, sendAsync } from "../dispatch_json.ts"; -import { pathFromURL } from "../../util.ts"; - -export interface DirEntry { - name: string; - isFile: boolean; - isDirectory: boolean; - isSymlink: boolean; -} - -interface ReadDirResponse { - entries: DirEntry[]; -} - -function res(response: ReadDirResponse): DirEntry[] { - return response.entries; -} - -export function readDirSync(path: string | URL): Iterable<DirEntry> { - return res(sendSync("op_read_dir", { path: pathFromURL(path) }))[ - Symbol.iterator - ](); -} - -export function readDir(path: string | URL): AsyncIterable<DirEntry> { - const array = sendAsync("op_read_dir", { path: pathFromURL(path) }).then(res); - return { - async *[Symbol.asyncIterator](): AsyncIterableIterator<DirEntry> { - yield* await array; - }, - }; -} |