UNPKG

foxts

Version:

Opinionated collection of common TypeScript utils by @SukkaW

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