Skip to content

Commit

Permalink
feat: add hardware concurrency hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
TenviLi committed Nov 19, 2019
1 parent ff7c997 commit a4720c6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hardware-concurrency.js
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit a4720c6

Please sign in to comment.