mirror of
https://github.com/denoland/deno.git
synced 2024-10-29 08:58:01 -04:00
feat(node/os): Add availableParallelism
(#20745)
This commit is contained in:
parent
9017e789df
commit
74e4c7f80f
2 changed files with 12 additions and 0 deletions
|
@ -125,6 +125,9 @@ const platform = os.platform();
|
|||
is.string(platform);
|
||||
assert.ok(platform.length > 0);
|
||||
|
||||
const availableParallelism = os.availableParallelism();
|
||||
assert.ok(availableParallelism === navigator.hardwareConcurrency);
|
||||
|
||||
const arch = os.arch();
|
||||
is.string(arch);
|
||||
assert.ok(arch.length > 0);
|
||||
|
|
|
@ -102,6 +102,9 @@ export function arch(): string {
|
|||
return process.arch;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue