{"id":29189373,"url":"https://github.com/coderaiser/node-thread-it","last_synced_at":"2025-07-01T23:07:22.474Z","repository":{"id":65412383,"uuid":"202696748","full_name":"coderaiser/node-thread-it","owner":"coderaiser","description":"Wrap any sync module to thread worker ","archived":false,"fork":false,"pushed_at":"2025-04-24T14:19:15.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-26T18:18:20.968Z","etag":null,"topics":["worker-pool","workers"],"latest_commit_sha":null,"homepage":"","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/coderaiser.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","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},"funding":{"github":"coderaiser","patreon":"coderaiser","open_collective":"cloudcmd","ko_fi":"coderaiser"}},"created_at":"2019-08-16T09:11:49.000Z","updated_at":"2025-04-24T14:19:18.000Z","dependencies_parsed_at":"2023-01-22T07:55:25.763Z","dependency_job_id":null,"html_url":"https://github.com/coderaiser/node-thread-it","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/coderaiser/node-thread-it","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fnode-thread-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fnode-thread-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fnode-thread-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fnode-thread-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderaiser","download_url":"https://codeload.github.com/coderaiser/node-thread-it/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fnode-thread-it/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262243045,"owners_count":23280979,"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":["worker-pool","workers"],"created_at":"2025-07-01T23:07:21.696Z","updated_at":"2025-07-01T23:07:22.366Z","avatar_url":"https://github.com/coderaiser.png","language":"JavaScript","funding_links":["https://github.com/sponsors/coderaiser","https://patreon.com/coderaiser","https://opencollective.com/cloudcmd","https://ko-fi.com/coderaiser"],"categories":[],"sub_categories":[],"readme":"# Thread It [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\nDrastically simplified [worker threads](https://nodejs.org/dist/latest-v12.x/docs/api/worker_threads.html), on node `v8` or `v10` without `--experimental-worker` just\nwraps your code with a promise so you don't have to warry about a thing, just use `thread it` and it will use `workers` where can.\n\nChoose any sync module from `npm` and instead of `require` use `threadIt`.\n\n*Caution: not all data types can be passed to Worker Thread, for example you just can't pass a function, read carefully [what types are supported](https://nodejs.org/dist/latest-v12.x/docs/api/worker_threads.html#worker_threads_port_postmessage_value_transferlist).*\n\n## Install\n\n`npm i thread-it`\n\n## API\n\n### threadIt(name[, options])\n\nUnder the hood `threadId` uses [holdUp](https://github.com/coderaiser/hold-up) so you can use the same options to find a free worker from queue.\n\n- `name` - string\n- `options` - options may contain:\n  - `log`\n  - `count`\n  - `time`\n\nAlso you can set `THREAD_IT_COUNT` env variable to workers count, if `0` it means disabled worker threads.\n\n```js\nconst threadIt = require('thread-it');\n\n// init workers, depend on os.cpus()\nthreadIt.init();\n\nconst putout = threadIt('putout');\nconst result = await putout(`const t = 'hello'`);\n\n// when you need to override options use\nthreadIt('putout', {\n    count: 5, // default\n    time: 1000, // default\n    log: () =\u003e {}, // default\n});\n\n// terminate workers when no need anymore\nthreadIt.terminate();\n```\n\n## Related\n\n- [hold-up](https://github.com/iocmd/hold-up \"Hold Up\") - setInterval with promises, counter and error handling\n- [currify](https://github.com/coderaiser/currify \"currify\") - translate the evaluation of a function that takes multiple arguments into evaluating a sequence of functions, each with a single or more arguments.\n- [fullstore](https://github.com/coderaiser/fullstore \"fullstore\") - functional variables.\n- [wraptile](https://github.com/coderaiser/wraptile \"wraptile\") - translate the evaluation of a function that takes multiple arguments into evaluating a sequence of 2 functions, each with a any count of arguments.\n\n## License\n\nMIT\n\n[NPMIMGURL]: https://img.shields.io/npm/v/thread-it.svg?style=flat\n[BuildStatusIMGURL]: https://travis-ci.com/coderaiser/node-thread-it.svg?branch=master\n[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[NPMURL]: https://npmjs.org/package/thread-it \"npm\"\n[BuildStatusURL]: https://travis-ci.com/coderaiser/node-thread-it \"Build Status\"\n[LicenseURL]: https://tldrlegal.com/license/mit-license \"MIT License\"\n[CoverageURL]: https://coveralls.io/github/coderaiser/node-thread-it?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/node-thread-it/badge.svg?branch=master\u0026service=github\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Fnode-thread-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderaiser%2Fnode-thread-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Fnode-thread-it/lists"}