From 4a8d25646aa58e3e59d622e69c41822b40415c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 25 Apr 2020 00:45:55 +0200 Subject: BREAKING CHANGE: remove Deno.OpenMode (#4884) This commit removes Deno.OpenMode along with overloaded variants of Deno.open() and Deno.openSync() that used OpenMode. --- cli/js/files.ts | 55 +++++++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 36 deletions(-) (limited to 'cli/js/files.ts') 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; -export async function open(path: string, openMode?: OpenMode): Promise; - -/**@internal*/ export async function open( path: string, - modeOrOptions: OpenOptions | OpenMode = "r" + options: OpenOptions = { read: true } ): Promise { - 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 { - return open(path, "w+"); + return open(path, { + read: true, + write: true, + truncate: true, + create: true, + }); } export class File -- cgit v1.2.3