{"name":"thread-it","version":"1.0.3","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"wrap any sync module to thread worker","homepage":"http://github.com/coderaiser/node-thread-it","main":"lib/thread-it.js","repository":{"type":"git","url":"git://github.com/coderaiser/node-thread-it.git"},"nyc":{"exclude":["madrun.js","test"]},"keywords":["worker","threads","worker_threads","promise"],"scripts":{"test":"madrun test","coverage":"madrun coverage","lint":"madrun lint","fix:lint":"madrun fix:lint","report":"madrun report","watcher":"madrun watcher","watch:test":"madrun watch:test","watch:lint":"madrun watch:lint","watch:tape":"madrun watch:tape","watch:coverage:base":"madrun watch:coverage:base","watch:coverage:tape":"madrun watch:coverage:tape","watch:coverage":"madrun watch:coverage"},"dependencies":{"@iocmd/hold-up":"^1.1.0","try-catch":"^2.0.0"},"license":"MIT","devDependencies":{"@cloudcmd/stub":"^2.3.1","coveralls":"^3.0.2","eslint":"^6.1.0","eslint-plugin-node":"^9.1.0","madrun":"^2.5.0","mock-require":"^3.0.3","nodemon":"^1.11.0","nyc":"^14.1.1","putout":"^5.5.0","redrun":"^7.0.0","supertape":"^1.2.3","try-to-catch":"^1.1.1"},"engines":{"node":">=8.3"},"publishConfig":{"access":"public"},"gitHead":"a2e78c6f3f3aea1359fb601436b76aeca53a035f","bugs":{"url":"https://github.com/coderaiser/node-thread-it/issues"},"_id":"thread-it@1.0.3","_nodeVersion":"12.8.1","_npmVersion":"6.10.0","dist":{"integrity":"sha512-crW8DZCcSkzhWI2kCTThpYEIy5ky3dgn7nHKS8ti+JcV3SS487bHqO6rtM9sOSTrB08bY04efHtx2pzfQr+p6A==","shasum":"3a99e5ea0c70f709cf48aa0af5c0267672bfe45b","tarball":"http://registry-npm.ywwl.com/thread-it/download/thread-it-1.0.3.tgz","fileCount":6,"unpackedSize":8373,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdVpP8CRA9TVsSAnZWagAAGcIP/jWuRxOpdj8BVgwEpPMx\nrFaH+uDjdp9YlOzNR/cD+l7q03Im4SmSYLBX2LhwLjn/Woi1ul55+5bYK0Eh\nfosbAQnxUUk2Xbm3Z8+J8nIUdaQXwvuE/28uBawzJIVXD0p/ipilfCCtkr+u\nm+UkaPcz3Fe0R8c/lpA+ZPIeqvYoOI0k1uEwFZvm48cgG5nLrZl6CqsbEJz9\nF140BAKMluxwYYUASB7ao1d7xjYSlUdwbQwWPpu0Tno9MY07uqlVdOlMFWlo\nVJdJhkux0Kh9+FMlpfxwBTSbQegzD97zSAlIhuTTuTy5/ZO/qzdS8KssJj9e\nzQAKRT9gdCNL4OnADLT6IJ6HYAE8xdIkb/dxXc8skz+Lj8u7jw3xBJ2nk+8/\naKn/Wu6ENlzLouiGThaHW3x/qzOwHJoQRrg370eZUionJoz/ajMmqcPKzgx4\n9w3ZJPEEF4eRGZT0kXnQ4Gu/bIqafrVlF+51NE8aKV54G6/ZPjxqGhTKYjTA\nHywJjwvnVRJCMaJC02DuX3oygL3G0iX33CjzchAiVNqQPIaJ3syVB8zt3cPp\nXDKet4Msf58qCpPC4BYWUIvp24FouChXMQMQZWWc+KkB6BwLeno547sd+8nn\nIBkOitYeX7SRrCdv+G20z3+dU8teWb5CTYoo+lPaQITchHNXkpoLVxyjAGek\nDPLc\r\n=ZQjs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCvaBhcNtK2lXp4D8WDDZmUFwo2Wrvehj852rTmnnlI4AIhAKQg+BV983+Y7I0C7J5cDxe4XOz4oIzkABPUJOxWCPWU"}],"size":3446,"noattachment":false,"key":"/thread-it/-/thread-it-1.0.3.tgz"},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/thread-it_1.0.3_1565955067629_0.2929518079052116"},"_hasShrinkwrap":false,"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: () => {}, // 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&service=github\n","publish_time":1565955067972,"_cnpm_publish_time":1565955067972,"dist-tags":{"latest":"3.0.0"}}