0.1.4 • Published 11 months ago

hardware-concurrency v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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).