diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2024-01-11 07:37:25 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-10 15:37:25 -0700 |
commit | 515a34b4de222e35c7ade1b92614d746e73d4c2e (patch) | |
tree | 8284201fc826a33f12597959a8a8be14e0f524bd /ext/node/polyfills/os.ts | |
parent | d4893eb51a01c5a692d8ca74a3b8ff95c5fd1d9f (diff) |
refactor: use `core.ensureFastOps()` (#21888)
Diffstat (limited to 'ext/node/polyfills/os.ts')
-rw-r--r-- | ext/node/polyfills/os.ts | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ext/node/polyfills/os.ts b/ext/node/polyfills/os.ts index 5d354b38b..f95ea1cc8 100644 --- a/ext/node/polyfills/os.ts +++ b/ext/node/polyfills/os.ts @@ -23,7 +23,14 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const core = globalThis.__bootstrap.core; +import { core } from "ext:core/mod.js"; +const { + op_cpus, + op_node_os_get_priority, + op_node_os_set_priority, + op_node_os_username, +} = core.ensureFastOps(); + import { validateIntegerRange } from "ext:deno_node/_utils.ts"; import process from "node:process"; import { isWindows, osType } from "ext:deno_node/_util/os.ts"; @@ -32,8 +39,6 @@ import { os } from "ext:deno_node/internal_binding/constants.ts"; import { osUptime } from "ext:runtime/30_os.js"; import { Buffer } from "ext:deno_node/internal/buffer.mjs"; -const ops = core.ops; - export const constants = os; interface CPUTimes { @@ -133,7 +138,7 @@ export function arch(): string { (machine as any)[Symbol.toPrimitive] = (): string => machine(); export function cpus(): CPUCoreInfo[] { - return ops.op_cpus(); + return op_cpus(); } /** @@ -164,7 +169,7 @@ export function freemem(): number { /** Not yet implemented */ export function getPriority(pid = 0): number { validateIntegerRange(pid, "pid"); - return core.ops.op_node_os_get_priority(pid); + return op_node_os_get_priority(pid); } /** Returns the string path of the current user's home directory. */ @@ -270,7 +275,7 @@ export function setPriority(pid: number, priority?: number) { validateIntegerRange(pid, "pid"); validateIntegerRange(priority, "priority", -20, 19); - core.ops.op_node_os_set_priority(pid, priority); + op_node_os_set_priority(pid, priority); } /** Returns the operating system's default directory for temporary files as a string. */ @@ -350,7 +355,7 @@ export function userInfo( throw new ERR_OS_NO_HOMEDIR(); } let shell = isWindows ? (Deno.env.get("SHELL") || null) : null; - let username = core.ops.op_node_os_username(); + let username = op_node_os_username(); if (options?.encoding === "buffer") { _homedir = _homedir ? Buffer.from(_homedir) : _homedir; |