Skip to content

BlackGlory/hardware-concurrency

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

hardware-concurrency

Utilities for the number of logical cores.

Install

npm install --save hardware-concurrency
# or
yarn add hardware-concurrency

API

maxCores

function maxCores(): number

Take the number of cores.

Equivalent to navigator.hardwareConcurrency or os.cpus().length.

halfCores

function halfCores(): number

Take half the number of cores and round up.

doubleCores

function doubleCores(): number

Take double the number of cores.

minus1Cores

function minus1Cores(): number

Equivalent to Math.max(maxCores() - 1, 1).

minusCores

function minusCores(num: number): number

Equivalent to Math.max(maxCores() - num, 1).