Estimate the number of processes that can be executed concurrently. Useful if you want to figure out how many Web Workers you can spin up. Just remember to save a core for the main thread.
const estimateCores = require('estimate-cores');
estimateCores((error, coreCount) => {
if (error) {
// handle error
return;
}
console.log(coreCount);
// => 4
});
$ npm install estimate-cores
const estimateCores = require('estimate-cores');
Estimates the number of possible concurrent processes. The core count is cached
for future calls. To force a recount, pass true
for force
.