{"name":"thread-it","version":"1.1.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":"^3.0.0"},"license":"MIT","devDependencies":{"@cloudcmd/stub":"^2.3.1","coveralls":"^3.0.2","eslint":"^6.1.0","eslint-plugin-node":"^11.0.0","eslint-plugin-putout":"^3.2.1","madrun":"^5.4.4","mock-require":"^3.0.3","nodemon":"^2.0.2","nyc":"^15.0.0","putout":"^7.13.4","supertape":"^1.2.3","try-to-catch":"^3.0.0"},"engines":{"node":">=8.3"},"publishConfig":{"access":"public"},"gitHead":"6ecef91d6cb27082d34de02b8cf51a8c3030b389","bugs":{"url":"https://github.com/coderaiser/node-thread-it/issues"},"_id":"thread-it@1.1.3","_nodeVersion":"13.9.0","_npmVersion":"6.12.1","dist":{"integrity":"sha512-KS3bieRIoRKxk6ixu3C9wxRoXhEFw7DI6UWW7OWEyQlWZ9DNe098UUvmqQjWt6VQK4EdxoTHY8PmT7WXpGpmqw==","shasum":"74fa99dc8be302158aa65549372b61f2affdd5ec","tarball":"http://registry-npm.ywwl.com/thread-it/download/thread-it-1.1.3.tgz","fileCount":6,"unpackedSize":9311,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeVQIKCRA9TVsSAnZWagAAbBMP/jD+wm86nmR2lKfa/HAK\n0/tHzMFfnrHbxpvH1f4mMaVaB0aiWrkKKapqPH55Ky7is8VI5A+VoaQn7Isl\nh6mVLQr/hBkLg+sO1N6FEtpmoewdkQP+tc9HLOR/LXAMs2DsUjz0ZzWtcn1b\ni2/JiBImwBPTC5/pSkWMIp8BoBrJK30S2bYGStyPBot2dtLdUnAJ4mTbTnww\nSlCwLHfHDVhSDMXAMglqDbfYtIENGxpQvJnwXUloJ6XiEjNVnRxNWGtTVwjB\nffmiwUPF5T7fhp86DBEQRvPg7Y+1wXD7ubq1Am5+qxemldQfl+HfHS30hkjy\nRi1bUuWG9HBuKri0Yg0VAgbJlClsnB+B7kWnM9pyN+nMk+y2xMAIFMQXxZtA\nqKJ/lqpKxRRhbUpvSOq7o5iZAdJeyayDHKsrVn9MRInnmua/aLo8WSuUparf\nBmYt+RG0SLVwH5J1rq2XCy43oRR0lKnoiwr/Js4pk62eMxuD0Mhq1aSBr1vz\nMQOBuqZ+Qc9auYoWVxwS9qfFnBTkmA+7kjj79rMzIcn+CVLCNzCfZB16vO0t\nowZ/LeMdm36skVxlnKs+ft54ou5IKthI0kNUJWpIKfkVfSxU40Q9+vj0IzQZ\nh41k9zAqvxiB5u/vHLVMkP+Xbxt8T374GMUqwVp3N/4DbZkH8BNqzTDGpOW5\n0Sng\r\n=0H9i\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBKkPToriRDbCvSy87cEpa5EG9Tk20FxrSm151uTsvVmAiEA6LmvBfxkyRVOby95DDvxUNM4G6jXBjr76uoTp3CUmw0="}],"size":3748,"noattachment":false,"key":"/thread-it/-/thread-it-1.1.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.1.3_1582629386008_0.36705579390759735"},"_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":1582629386114,"_cnpm_publish_time":1582629386114,"dist-tags":{"latest":"3.0.0"}}