{"id":17654737,"url":"https://github.com/lujjjh/node-cpu-count","last_synced_at":"2025-05-07T09:15:54.577Z","repository":{"id":85069608,"uuid":"448209665","full_name":"lujjjh/node-cpu-count","owner":"lujjjh","description":"A container-friendly alternative to os.cpus().length. Both cgroups v1 and cgroups v2 are supported.","archived":false,"fork":false,"pushed_at":"2023-06-28T00:58:53.000Z","size":127,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T09:15:44.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-cpu-count","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lujjjh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"lujjjh","custom":"https://afdian.net/@lujjjh"}},"created_at":"2022-01-15T07:23:22.000Z","updated_at":"2024-10-29T19:41:01.000Z","dependencies_parsed_at":"2025-03-10T23:32:51.584Z","dependency_job_id":"580835b1-b119-4c8c-8056-f9a5d0a3e0ac","html_url":"https://github.com/lujjjh/node-cpu-count","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujjjh%2Fnode-cpu-count","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujjjh%2Fnode-cpu-count/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujjjh%2Fnode-cpu-count/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lujjjh%2Fnode-cpu-count/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lujjjh","download_url":"https://codeload.github.com/lujjjh/node-cpu-count/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252847524,"owners_count":21813458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-23T12:35:57.646Z","updated_at":"2025-05-07T09:15:54.519Z","avatar_url":"https://github.com/lujjjh.png","language":"TypeScript","readme":"# node-cpu-count\n\nA container-friendly alternative to `os.cpus().length`. Both cgroups v1 and cgroups v2 are supported.\n\n## Installation\n\n```sh\n$ npm install node-cpu-count\n```\n\n## Usage\n\n#### `cpuCount(min = 1, max = os.cpus().length, ceiling = true): Promise\u003cnumber\u003e`\n\nGet available logical CPU count (CPU quota / CPU period for cgroups, fallback to `os.cpus().length`).\n\nBy default, it returns an integer by ceiling the result. The result can be used as the number of cluster workers.\n\n`min` or `max` can be specified to determine the minimal and the maximum CPU count (which also overrides the fallback value).\n\n#### `cpuCountSync(min = 1, max = os.cpus().length, ceiling = true): number`\n\nA synchronous version of `cpuCount`.\n\n## Examples\n\n```sh\n$ git clone https://github.com/lujjjh/node-cpu-count.git \u0026\u0026 cd node-cpu-count\n\n$ docker run --rm -it -v $(pwd):/app node node /app/examples\n8\n8\n\n$ docker run --rm -it -v $(pwd):/app --cpus=2 node node /app/examples\n2\n2\n\n$ docker run --rm -it -v $(pwd):/app --cpus=2.1 node node /app/examples\n3\n3\n```\n","funding_links":["https://ko-fi.com/lujjjh","https://afdian.net/@lujjjh"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flujjjh%2Fnode-cpu-count","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flujjjh%2Fnode-cpu-count","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flujjjh%2Fnode-cpu-count/lists"}