UNPKG

foxts

Version:

Opinionated collection of common TypeScript utils by @SukkaW

1 lines 718 B
function n(n){return null==n?"object"==typeof window&&"navigator"in globalThis&&a(globalThis.navigator)?Promise.resolve(globalThis.navigator.hardwareConcurrency||1):import("node:os").then(n=>e(n)?r(n):1).catch(()=>1):e(n)?r(n):a(n)?n.hardwareConcurrency??1:"then"in n&&"function"==typeof n.then?n.then(r):1}function e(n){return"object"==typeof n&&null!==n&&"cpus"in n&&"function"==typeof n.cpus}function a(n){return"object"==typeof n&&null!==n&&"hardwareConcurrency"in n&&"number"==typeof n.hardwareConcurrency}function r(n){return"availableParallelism"in n&&"function"==typeof n.availableParallelism?n.availableParallelism():n.cpus().length||1}export{n as availableParallelism,a as isNavigatorLike,e as isNodeOSLike};