
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
node-cpu-count
Advanced tools
A container-friendly alternative to os.cpus().length. Both cgroups v1 and cgroups v2 are supported.
A container-friendly alternative to os.cpus().length
. Both cgroups v1 and cgroups v2 are supported.
$ npm install node-cpu-count
cpuCount(min = 1, max = os.cpus().length, ceiling = true): Promise<number>
Get available logical CPU count (CPU quota / CPU period for cgroups, fallback to os.cpus().length
).
By default, it returns an integer by ceiling the result. The result can be used as the number of cluster workers.
min
or max
can be specified to determine the minimal and the maximum CPU count (which also overrides the fallback value).
cpuCountSync(min = 1, max = os.cpus().length, ceiling = true): number
A synchronous version of cpuCount
.
$ git clone https://github.com/lujjjh/node-cpu-count.git && cd node-cpu-count
$ docker run --rm -it -v $(pwd):/app node node /app/examples
8
8
$ docker run --rm -it -v $(pwd):/app --cpus=2 node node /app/examples
2
2
$ docker run --rm -it -v $(pwd):/app --cpus=2.1 node node /app/examples
3
3
FAQs
A container-friendly alternative to os.cpus().length. Both cgroups v1 and cgroups v2 are supported.
We found that node-cpu-count demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.