{"id":13447905,"url":"https://github.com/watson/worker-threads-pool","last_synced_at":"2025-10-24T18:03:56.429Z","repository":{"id":57399263,"uuid":"138496749","full_name":"watson/worker-threads-pool","owner":"watson","description":"Easily manage a pool of Node.js Worker Threads","archived":false,"fork":false,"pushed_at":"2019-12-30T07:41:53.000Z","size":21,"stargazers_count":429,"open_issues_count":3,"forks_count":18,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-28T16:06:52.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/watson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-24T16:14:46.000Z","updated_at":"2025-02-03T23:14:56.000Z","dependencies_parsed_at":"2022-09-01T08:22:57.651Z","dependency_job_id":null,"html_url":"https://github.com/watson/worker-threads-pool","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watson%2Fworker-threads-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watson%2Fworker-threads-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watson%2Fworker-threads-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/watson%2Fworker-threads-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/watson","download_url":"https://codeload.github.com/watson/worker-threads-pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217180,"owners_count":20903009,"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-07-31T05:01:29.928Z","updated_at":"2025-10-24T18:03:56.315Z","avatar_url":"https://github.com/watson.png","language":"JavaScript","readme":"# worker-threads-pool\n\nEasily manage a pool of [Node.js Worker\nThreads](https://nodejs.org/api/worker_threads.html).\n\n[![npm](https://img.shields.io/npm/v/worker-threads-pool.svg)](https://www.npmjs.com/package/worker-threads-pool)\n[![Build status](https://travis-ci.org/watson/worker-threads-pool.svg?branch=master)](https://travis-ci.org/watson/worker-threads-pool)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n\n## Installation\n\n```\nnpm install worker-threads-pool --save\n```\n\n## Prerequisites\n\nWorker Threads in Node.js are still an experimental feature and is only\nsupported in Node.js v10.5.0 and above. To use Worker Threads, you need\nto run `node` with the `--experimental-worker` flag:\n\n```\nnode --experimental-worker app.js\n```\n\n## Usage\n\n```js\nconst Pool = require('worker-threads-pool')\n\nconst pool = new Pool({max: 5})\n\nfor (let i = 0; i \u003c 100; i++) {\n  pool.acquire('/my/worker.js', function (err, worker) {\n    if (err) throw err\n    console.log(`started worker ${i} (pool size: ${pool.size})`)\n    worker.on('exit', function () {\n      console.log(`worker ${i} exited (pool size: ${pool.size})`)\n    })\n  })\n}\n```\n\n## API\n\n### `pool = new Pool([options])`\n\n`options` is an optional object/dictionary with the any of the following properties:\n\n- `max` - Maximum number of workers allowed in the pool. Other workers\n  will be queued and started once there's room in the pool (default:\n  `1`)\n- `maxWaiting` - Maximum number of workers waiting to be started when\n  the pool is full. The callback to `pool.acquire` will be called with\n  an error in case this limit is reached\n\n### `pool.size`\n\nNumber of active workers in the pool.\n\n### `pool.acquire(filename[, options], callback)`\n\nThe `filename` and `options` arguments are passed directly to [`new\nWorker(filename,\noptions)`](https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options).\n\nThe `callback` argument will be called with the an optional error object\nand the worker once it's created.\n\n### `pool.destroy([callback])`\n\nCalls\n[`worker.terminate()`](https://nodejs.org/api/worker_threads.html#worker_threads_worker_terminate_callback)\non all workers in the pool.\n\nWill call the optional `callback` once all workers have terminated.\n\n## License\n\n[MIT](https://github.com/watson/worker-threads-pool/blob/master/LICENSE)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatson%2Fworker-threads-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwatson%2Fworker-threads-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwatson%2Fworker-threads-pool/lists"}