0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

refactor(cli/rt): inline single line single use open helper functions (#7046)

This commit is contained in:
Casper Beyer 2020-08-15 01:43:11 +08:00 committed by GitHub
parent a17ea9150d
commit 238816d62f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}