diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-12-28 09:08:50 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-28 09:08:50 +0530 |
commit | c08319262afeca47d1b9f3dbfa3254e692a48a2d (patch) | |
tree | e4e1bda6fcda59ea696bd559fbcfa89d855c21c3 /ext/node/polyfills/os.ts | |
parent | 48dae2441c2085db345a8d2d225b2c063e740600 (diff) |
fix(node): Implement os.cpus() (#21697)
Fixes https://github.com/denoland/deno/issues/21666
Zero added dependency and tries to match the libuv implementation
Diffstat (limited to 'ext/node/polyfills/os.ts')
-rw-r--r-- | ext/node/polyfills/os.ts | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/ext/node/polyfills/os.ts b/ext/node/polyfills/os.ts index d1f5e7bfa..283ce5a0b 100644 --- a/ext/node/polyfills/os.ts +++ b/ext/node/polyfills/os.ts @@ -32,6 +32,8 @@ 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 { @@ -129,19 +131,7 @@ export function arch(): string { (uptime as any)[Symbol.toPrimitive] = (): number => uptime(); export function cpus(): CPUCoreInfo[] { - return Array.from(Array(navigator.hardwareConcurrency), () => { - return { - model: "", - speed: 0, - times: { - user: 0, - nice: 0, - sys: 0, - idle: 0, - irq: 0, - }, - }; - }); + return ops.op_cpus(); } /** |