npm.io
2.0.1 • Published 3 years ago

estimate-cores

Licence
MIT
Version
2.0.1
Deps
1
Size
6 kB
Vulns
0
Weekly
0
Stars
1

estimate-cores

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.

Example

const estimateCores = require('estimate-cores');

estimateCores((error, coreCount) => {
  if (error) {
    // handle error
    return;
  }

  console.log(coreCount);
  // => 4
});

Installation

$ npm install estimate-cores

API

const estimateCores = require('estimate-cores');
estimateCores([force=false], callback)

Estimates the number of possible concurrent processes. The core count is cached for future calls. To force a recount, pass true for force.

Keywords