diff options
Diffstat (limited to 'runtime/js/30_os.js')
-rw-r--r-- | runtime/js/30_os.js | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 5f88bd27e..b35f34e1a 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -1,49 +1,68 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import { core, primordials } from "ext:core/mod.js"; -const ops = core.ops; -import { Event, EventTarget } from "ext:deno_web/02_event.js"; +const { + op_delete_env, + op_env, + op_exec_path, + op_exit, + op_get_env, + op_gid, + op_hostname, + op_loadavg, + op_network_interfaces, + op_os_release, + op_os_uptime, + op_set_env, + op_system_memory_info, + op_uid, +} = core.ensureFastOps(); +const { + op_set_exit_code, +} = core.ensureFastOps(true); const { Error, FunctionPrototypeBind, SymbolFor, } = primordials; +import { Event, EventTarget } from "ext:deno_web/02_event.js"; + const windowDispatchEvent = FunctionPrototypeBind( EventTarget.prototype.dispatchEvent, globalThis, ); function loadavg() { - return ops.op_loadavg(); + return op_loadavg(); } function hostname() { - return ops.op_hostname(); + return op_hostname(); } function osRelease() { - return ops.op_os_release(); + return op_os_release(); } function osUptime() { - return ops.op_os_uptime(); + return op_os_uptime(); } function systemMemoryInfo() { - return ops.op_system_memory_info(); + return op_system_memory_info(); } function networkInterfaces() { - return ops.op_network_interfaces(); + return op_network_interfaces(); } function gid() { - return ops.op_gid(); + return op_gid(); } function uid() { - return ops.op_uid(); + return op_uid(); } // This is an internal only method used by the test harness to override the @@ -56,7 +75,7 @@ function setExitHandler(fn) { function exit(code) { // Set exit code first so unload event listeners can override it. if (typeof code === "number") { - ops.op_set_exit_code(code); + op_set_exit_code(code); } else { code = 0; } @@ -73,26 +92,26 @@ function exit(code) { return; } - ops.op_exit(); + op_exit(); throw new Error("Code not reachable"); } function setEnv(key, value) { - ops.op_set_env(key, value); + op_set_env(key, value); } function getEnv(key) { - return ops.op_get_env(key) ?? undefined; + return op_get_env(key) ?? undefined; } function deleteEnv(key) { - ops.op_delete_env(key); + op_delete_env(key); } const env = { get: getEnv, toObject() { - return ops.op_env(); + return op_env(); }, set: setEnv, has(key) { @@ -102,7 +121,7 @@ const env = { }; function execPath() { - return ops.op_exec_path(); + return op_exec_path(); } export { |