diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-04-25 00:45:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 00:45:55 +0200 |
commit | 4a8d25646aa58e3e59d622e69c41822b40415c46 (patch) | |
tree | e228581912bfc0a4bdb56e3caec2ca3a1c1b9087 /cli/js/files.ts | |
parent | 0cb1bb98cc2de8dfe51b7adbe992666936146c90 (diff) |
BREAKING CHANGE: remove Deno.OpenMode (#4884)
This commit removes Deno.OpenMode along with overloaded variants
of Deno.open() and Deno.openSync() that used OpenMode.
Diffstat (limited to 'cli/js/files.ts')
-rw-r--r-- | cli/js/files.ts | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/cli/js/files.ts b/cli/js/files.ts index d09fcf8db..97a8c1e2b 100644 --- a/cli/js/files.ts +++ b/cli/js/files.ts @@ -18,60 +18,43 @@ import { open as opOpen, openSync as opOpenSync, OpenOptions, - OpenMode, } from "./ops/fs/open.ts"; -export { OpenOptions, OpenMode } from "./ops/fs/open.ts"; +export { OpenOptions } from "./ops/fs/open.ts"; -export function openSync(path: string, options?: OpenOptions): File; -export function openSync(path: string, openMode?: OpenMode): File; - -/**@internal*/ export function openSync( path: string, - modeOrOptions: OpenOptions | OpenMode = "r" + options: OpenOptions = { read: true } ): File { - let openMode = undefined; - let options = undefined; - - if (typeof modeOrOptions === "string") { - openMode = modeOrOptions; - } else { - checkOpenOptions(modeOrOptions); - options = modeOrOptions as OpenOptions; - } - - const rid = opOpenSync(path, openMode as OpenMode, options); + checkOpenOptions(options); + const rid = opOpenSync(path, options); return new File(rid); } -export async function open(path: string, options?: OpenOptions): Promise<File>; -export async function open(path: string, openMode?: OpenMode): Promise<File>; - -/**@internal*/ export async function open( path: string, - modeOrOptions: OpenOptions | OpenMode = "r" + options: OpenOptions = { read: true } ): Promise<File> { - let openMode = undefined; - let options = undefined; - - if (typeof modeOrOptions === "string") { - openMode = modeOrOptions; - } else { - checkOpenOptions(modeOrOptions); - options = modeOrOptions as OpenOptions; - } - - const rid = await opOpen(path, openMode as OpenMode, options); + checkOpenOptions(options); + const rid = await opOpen(path, options); return new File(rid); } export function createSync(path: string): File { - return openSync(path, "w+"); + return openSync(path, { + read: true, + write: true, + truncate: true, + create: true, + }); } export function create(path: string): Promise<File> { - return open(path, "w+"); + return open(path, { + read: true, + write: true, + truncate: true, + create: true, + }); } export class File |