diff options
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/11_timers.js | 4 | ||||
-rw-r--r-- | runtime/js/11_workers.js | 12 | ||||
-rw-r--r-- | runtime/js/30_fs.js | 39 | ||||
-rw-r--r-- | runtime/js/30_net.js | 2 | ||||
-rw-r--r-- | runtime/js/30_os.js | 13 | ||||
-rw-r--r-- | runtime/js/40_fs_events.js | 7 | ||||
-rw-r--r-- | runtime/js/40_permissions.js | 6 | ||||
-rw-r--r-- | runtime/js/40_plugins.js | 2 | ||||
-rw-r--r-- | runtime/js/40_process.js | 2 | ||||
-rw-r--r-- | runtime/js/40_signals.js | 14 | ||||
-rw-r--r-- | runtime/js/40_tls.js | 2 | ||||
-rw-r--r-- | runtime/js/40_tty.js | 4 | ||||
-rw-r--r-- | runtime/js/99_main.js | 2 |
13 files changed, 53 insertions, 56 deletions
diff --git a/runtime/js/11_timers.js b/runtime/js/11_timers.js index 200c764b7..046609f75 100644 --- a/runtime/js/11_timers.js +++ b/runtime/js/11_timers.js @@ -10,7 +10,7 @@ } function opStartGlobalTimer(timeout) { - return core.jsonOpSync("op_global_timer_start", { timeout }); + return core.jsonOpSync("op_global_timer_start", timeout); } async function opWaitGlobalTimer() { @@ -22,7 +22,7 @@ } function sleepSync(millis = 0) { - return core.jsonOpSync("op_sleep_sync", { millis }); + return core.jsonOpSync("op_sleep_sync", millis); } // Derived from https://github.com/vadimg/js_bintrees. MIT Licensed. diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js index 2917ec004..b11195713 100644 --- a/runtime/js/11_workers.js +++ b/runtime/js/11_workers.js @@ -28,15 +28,15 @@ } function hostTerminateWorker(id) { - core.jsonOpSync("op_host_terminate_worker", { id }); + core.jsonOpSync("op_host_terminate_worker", id); } function hostPostMessage(id, data) { - core.jsonOpSync("op_host_post_message", { id }, data); + core.jsonOpSync("op_host_post_message", id, data); } function hostGetMessage(id) { - return core.jsonOpAsync("op_host_get_message", { id }); + return core.jsonOpAsync("op_host_get_message", id); } const encoder = new TextEncoder(); @@ -197,7 +197,7 @@ } } - const { id } = createWorker( + const id = createWorker( specifier, hasSourceCode, sourceCode, @@ -270,7 +270,7 @@ } else { core.jsonOpSync( "op_host_unhandled_error", - { message: event.error.message }, + event.error.message, ); } } @@ -289,7 +289,7 @@ } else { core.jsonOpSync( "op_host_unhandled_error", - { message: event.error.message }, + event.error.message, ); } } diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js index f150c38b6..e79247640 100644 --- a/runtime/js/30_fs.js +++ b/runtime/js/30_fs.js @@ -58,7 +58,7 @@ } function chdir(directory) { - core.jsonOpSync("op_chdir", { directory }); + core.jsonOpSync("op_chdir", directory); } function makeTempDirSync(options = {}) { @@ -101,14 +101,8 @@ await core.jsonOpAsync("op_mkdir_async", mkdirArgs(path, options)); } - function res(response) { - return response.entries; - } - function readDirSync(path) { - return res( - core.jsonOpSync("op_read_dir_sync", { path: pathFromURL(path) }), - )[ + return core.jsonOpSync("op_read_dir_sync", pathFromURL(path))[ Symbol.iterator ](); } @@ -116,11 +110,8 @@ function readDir(path) { const array = core.jsonOpAsync( "op_read_dir_async", - { path: pathFromURL(path) }, - ) - .then( - res, - ); + pathFromURL(path), + ); return { async *[Symbol.asyncIterator]() { yield* await array; @@ -129,19 +120,19 @@ } function readLinkSync(path) { - return core.jsonOpSync("op_read_link_sync", { path: pathFromURL(path) }); + return core.jsonOpSync("op_read_link_sync", pathFromURL(path)); } function readLink(path) { - return core.jsonOpAsync("op_read_link_async", { path: pathFromURL(path) }); + return core.jsonOpAsync("op_read_link_async", pathFromURL(path)); } function realPathSync(path) { - return core.jsonOpSync("op_realpath_sync", { path }); + return core.jsonOpSync("op_realpath_sync", path); } function realPath(path) { - return core.jsonOpAsync("op_realpath_async", { path }); + return core.jsonOpAsync("op_realpath_async", path); } function removeSync( @@ -198,11 +189,11 @@ } function fstatSync(rid) { - return parseFileInfo(core.jsonOpSync("op_fstat_sync", { rid })); + return parseFileInfo(core.jsonOpSync("op_fstat_sync", rid)); } async function fstat(rid) { - return parseFileInfo(await core.jsonOpAsync("op_fstat_async", { rid })); + return parseFileInfo(await core.jsonOpAsync("op_fstat_async", rid)); } async function lstat(path) { @@ -262,7 +253,7 @@ } function umask(mask) { - return core.jsonOpSync("op_umask", { mask }); + return core.jsonOpSync("op_umask", mask); } function linkSync(oldpath, newpath) { @@ -359,19 +350,19 @@ } function fdatasyncSync(rid) { - core.jsonOpSync("op_fdatasync_sync", { rid }); + core.jsonOpSync("op_fdatasync_sync", rid); } async function fdatasync(rid) { - await core.jsonOpAsync("op_fdatasync_async", { rid }); + await core.jsonOpAsync("op_fdatasync_async", rid); } function fsyncSync(rid) { - core.jsonOpSync("op_fsync_sync", { rid }); + core.jsonOpSync("op_fsync_sync", rid); } async function fsync(rid) { - await core.jsonOpAsync("op_fsync_async", { rid }); + await core.jsonOpAsync("op_fsync_async", rid); } window.__bootstrap.fs = { diff --git a/runtime/js/30_net.js b/runtime/js/30_net.js index 9081d0ef1..56fb94f26 100644 --- a/runtime/js/30_net.js +++ b/runtime/js/30_net.js @@ -7,7 +7,7 @@ const { read, write } = window.__bootstrap.io; function shutdown(rid) { - return core.jsonOpAsync("op_shutdown", { rid }); + return core.jsonOpAsync("op_shutdown", rid); } function opAccept(rid, transport) { diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 23c3d8de6..0ce831775 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -21,7 +21,12 @@ } function systemCpuInfo() { - return core.jsonOpSync("op_system_cpu_info"); + const { cores, speed } = core.jsonOpSync("op_system_cpu_info"); + // Map nulls to undefined for compatibility + return { + cores: cores ?? undefined, + speed: speed ?? undefined, + }; } // This is an internal only method used by the test harness to override the @@ -44,7 +49,7 @@ return; } - core.jsonOpSync("op_exit", { code }); + core.jsonOpSync("op_exit", code); throw new Error("Code not reachable"); } @@ -53,11 +58,11 @@ } function getEnv(key) { - return core.jsonOpSync("op_get_env", { key })[0]; + return core.jsonOpSync("op_get_env", key) ?? undefined; } function deleteEnv(key) { - core.jsonOpSync("op_delete_env", { key }); + core.jsonOpSync("op_delete_env", key); } const env = { diff --git a/runtime/js/40_fs_events.js b/runtime/js/40_fs_events.js index c48d410f1..06ad3a29c 100644 --- a/runtime/js/40_fs_events.js +++ b/runtime/js/40_fs_events.js @@ -19,9 +19,10 @@ async next() { try { - return await core.jsonOpAsync("op_fs_events_poll", { - rid: this.rid, - }); + const value = await core.jsonOpAsync("op_fs_events_poll", this.rid); + return value + ? { value, done: false } + : { value: undefined, done: true }; } catch (error) { if (error instanceof errors.BadResource) { return { value: undefined, done: true }; diff --git a/runtime/js/40_permissions.js b/runtime/js/40_permissions.js index d7ed5a433..7a81ca425 100644 --- a/runtime/js/40_permissions.js +++ b/runtime/js/40_permissions.js @@ -31,7 +31,7 @@ * @returns {Deno.PermissionState} */ function opQuery(desc) { - return core.jsonOpSync("op_query_permission", desc).state; + return core.jsonOpSync("op_query_permission", desc); } /** @@ -39,7 +39,7 @@ * @returns {Deno.PermissionState} */ function opRevoke(desc) { - return core.jsonOpSync("op_revoke_permission", desc).state; + return core.jsonOpSync("op_revoke_permission", desc); } /** @@ -47,7 +47,7 @@ * @returns {Deno.PermissionState} */ function opRequest(desc) { - return core.jsonOpSync("op_request_permission", desc).state; + return core.jsonOpSync("op_request_permission", desc); } class PermissionStatus extends EventTarget { diff --git a/runtime/js/40_plugins.js b/runtime/js/40_plugins.js index fd037b81f..5ebcfddad 100644 --- a/runtime/js/40_plugins.js +++ b/runtime/js/40_plugins.js @@ -5,7 +5,7 @@ const core = window.Deno.core; function openPlugin(filename) { - return core.jsonOpSync("op_open_plugin", { filename }); + return core.jsonOpSync("op_open_plugin", filename); } window.__bootstrap.plugins = { diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js index 01f554b36..cd8015e94 100644 --- a/runtime/js/40_process.js +++ b/runtime/js/40_process.js @@ -12,7 +12,7 @@ } function opRunStatus(rid) { - return core.jsonOpAsync("op_run_status", { rid }); + return core.jsonOpAsync("op_run_status", rid); } function opRun(request) { diff --git a/runtime/js/40_signals.js b/runtime/js/40_signals.js index 2a70986f8..e222a9199 100644 --- a/runtime/js/40_signals.js +++ b/runtime/js/40_signals.js @@ -7,15 +7,15 @@ const { errors } = window.__bootstrap.errors; function bindSignal(signo) { - return core.jsonOpSync("op_signal_bind", { signo }); + return core.jsonOpSync("op_signal_bind", signo); } function pollSignal(rid) { - return core.jsonOpAsync("op_signal_poll", { rid }); + return core.jsonOpAsync("op_signal_poll", rid); } function unbindSignal(rid) { - core.jsonOpSync("op_signal_unbind", { rid }); + core.jsonOpSync("op_signal_unbind", rid); } // From `kill -l` @@ -209,21 +209,21 @@ #rid = 0; constructor(signo) { - this.#rid = bindSignal(signo).rid; + this.#rid = bindSignal(signo); this.#loop(); } #pollSignal = async () => { - let res; + let done; try { - res = await pollSignal(this.#rid); + done = await pollSignal(this.#rid); } catch (error) { if (error instanceof errors.BadResource) { return true; } throw error; } - return res.done; + return done; }; #loop = async () => { diff --git a/runtime/js/40_tls.js b/runtime/js/40_tls.js index e9f683376..da43afaac 100644 --- a/runtime/js/40_tls.js +++ b/runtime/js/40_tls.js @@ -12,7 +12,7 @@ } function opAcceptTLS(rid) { - return core.jsonOpAsync("op_accept_tls", { rid }); + return core.jsonOpAsync("op_accept_tls", rid); } function opListenTls(args) { diff --git a/runtime/js/40_tty.js b/runtime/js/40_tty.js index 2e98a4f5a..9b23b1ec1 100644 --- a/runtime/js/40_tty.js +++ b/runtime/js/40_tty.js @@ -5,11 +5,11 @@ const core = window.Deno.core; function consoleSize(rid) { - return core.jsonOpSync("op_console_size", { rid }); + return core.jsonOpSync("op_console_size", rid); } function isatty(rid) { - return core.jsonOpSync("op_isatty", { rid }); + return core.jsonOpSync("op_isatty", rid); } const DEFAULT_SET_RAW_OPTIONS = { diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index a2fff2571..596565bed 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -129,7 +129,7 @@ delete Object.prototype.__proto__; } function opPostMessage(data) { - core.jsonOpSync("op_worker_post_message", {}, data); + core.jsonOpSync("op_worker_post_message", null, data); } function opCloseWorker() { |