diff options
author | Rui He <118280419+ruihe774@users.noreply.github.com> | 2023-09-30 22:21:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-30 19:51:06 +0530 |
commit | 74e4c7f80ff1cee534f2da2870d0ddf73f7cb932 (patch) | |
tree | 86cfcf055c0c9569392c576d6789b80c8e1363dc /ext/node/polyfills | |
parent | 9017e789df59aa8fba400f3ad8ae3b8b8290b4a8 (diff) |
feat(node/os): Add `availableParallelism` (#20745)
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r-- | ext/node/polyfills/os.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/node/polyfills/os.ts b/ext/node/polyfills/os.ts index 3245ad7ab..06de4ad44 100644 --- a/ext/node/polyfills/os.ts +++ b/ext/node/polyfills/os.ts @@ -103,6 +103,9 @@ export function arch(): string { } // deno-lint-ignore no-explicit-any +(availableParallelism as any)[Symbol.toPrimitive] = (): number => + availableParallelism(); +// deno-lint-ignore no-explicit-any (arch as any)[Symbol.toPrimitive] = (): string => process.arch; // deno-lint-ignore no-explicit-any (endianness as any)[Symbol.toPrimitive] = (): string => endianness(); @@ -354,10 +357,16 @@ export function userInfo( }; } +/* Returns an estimate of the default amount of parallelism a program should use. */ +export function availableParallelism(): number { + return navigator.hardwareConcurrency; +} + export const EOL = isWindows ? "\r\n" : "\n"; export const devNull = isWindows ? "\\\\.\\nul" : "/dev/null"; export default { + availableParallelism, arch, cpus, endianness, |