From 238816d62fcc1cfe16414751902fa5a924b14703 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Sat, 15 Aug 2020 01:43:11 +0800 Subject: refactor(cli/rt): inline single line single use open helper functions (#7046) --- cli/rt/30_files.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/cli/rt/30_files.js b/cli/rt/30_files.js index 0b6d9c67f..9ff2fe368 100644 --- a/cli/rt/30_files.js +++ b/cli/rt/30_files.js @@ -22,25 +22,14 @@ return sendAsync("op_seek", { rid, offset, whence }); } - function opOpenSync(path, options) { - const mode = options?.mode; - return sendSync("op_open", { path: pathFromURL(path), options, mode }); - } - - function opOpen( - path, - options, - ) { - const mode = options?.mode; - return sendAsync("op_open", { path: pathFromURL(path), options, mode }); - } - function openSync( path, options = { read: true }, ) { checkOpenOptions(options); - const rid = opOpenSync(path, options); + const mode = options?.mode; + const rid = sendSync("op_open", { path: pathFromURL(path), options, mode }); + return new File(rid); } @@ -49,7 +38,12 @@ options = { read: true }, ) { checkOpenOptions(options); - const rid = await opOpen(path, options); + const mode = options?.mode; + const rid = await sendAsync( + "op_open", + { path: pathFromURL(path), options, mode }, + ); + return new File(rid); } -- cgit v1.2.3