Kojo.gg
Kojo.gg15mo ago

Deno equivalent os.cpus().length

What’s the Deno Equivalent for os.cpus().length?
6 Replies
markthree
markthree15mo ago
No built-in api, but compatible with node you can try it in deno 👇
import os from "node:os";

console.log(os.cpus().length);
import os from "node:os";

console.log(os.cpus().length);
Kojo.gg
Kojo.ggOP15mo ago
That’s strange that there’s no Deno native implementation but the Node compatibility layer is already there 🤔
markthree
markthree15mo ago
Yes, I also think this is the missing part of the deno native api
AapoAlas
AapoAlas15mo ago
Navigator: hardwareConcurrency property - Web APIs | MDN
The navigator.hardwareConcurrency read-only property returns the number of logical processors available to run threads on the user's computer.
markthree
markthree15mo ago
I've raised an issue for all to discuss https://github.com/denoland/deno/issues/20933
GitHub
deno native os api enhancements · Issue #20933 · denoland/deno
Ref context: https://discord.com/channels/684898665143206084/1164090264852369458 deno native os api seems to be missing a lot of node compatibility layers for example 👇 import os from "node:os...
AapoAlas
AapoAlas15mo ago
Since the standard hardware concurrency API exists I don't think a custom alternative would serve any purpose.