diff --git a/hardware-concurrency.js b/hardware-concurrency.js new file mode 100644 index 0000000..9632ede --- /dev/null +++ b/hardware-concurrency.js @@ -0,0 +1,23 @@ +let unsupported; + +if (typeof navigator !== "undefined" && "hardwareConcurrency" in navigator) { + unsupported = false; +} else { + unsupported = true; +} + +let initialHardwareConcurrency; + +if (!unsupported) { + initialHardwareConcurrency = { + numberOfLogicalProcessors: navigator.hardwareConcurrency + }; +} else { + initialHardwareConcurrency = { unsupported: true }; +} + +const useHardwareConcurrency = () => { + return { ...initialHardwareConcurrency }; +}; + +export { useHardwareConcurrency };