{"name":"thread-it","version":"1.0.2","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"]},"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":"38fe6523f6ef645b3eb8d4f43ffb847895e9a865","bugs":{"url":"https://github.com/coderaiser/node-thread-it/issues"},"_id":"thread-it@1.0.2","_nodeVersion":"12.8.1","_npmVersion":"6.10.0","dist":{"integrity":"sha512-hAGXUt34DUY+tAaGgfStkT68/UCT7e5ywpcaDpTyZhDmz3Jd6jMFHotONu69Mswk/xgMlGNqgF8apDckuYMKYw==","shasum":"2b9a1ade7bf7f107480de37a847fa60a1a6b5198","tarball":"http://registry-npm.ywwl.com/thread-it/download/thread-it-1.0.2.tgz","fileCount":6,"unpackedSize":8280,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdVpNDCRA9TVsSAnZWagAAUbQP/0Z6klLGp8CwUIiAO+xr\nzjF8eE1IGrMNawrmCVHu9pFV8tWGgHj6edalr951zPY44kQZCPIoiTRoiVIv\nB+kfzcLRa+magA8Edb0NXfyUU2jV7v/QoSqdVpmGz9+SjjPzrds1YfTqWlUr\nnShpOhuL9curyJDxq1Y7IvuUhS2Soi6r4QuQy3j7rpDvk3yFga5OZSdOGPjH\nTytCjniisOGdN9QvBoRshWSXURBxQVNrkoS8PQey6p54Ji81CopKcn11cQPr\n9UsVpMEukx4uOTQjqGtHFtZoeiYQ5aRruZkmnIEz2gDwQ06iIZ9lwdHq38xq\nvupvubQ+fctptaRnwL7l1vOhgWecIxBZAES5/2kvX//5DLoDrYN5U2kyANgX\nxOd/NGCCQ3YRoukHsXLiJfKZyGWD+lec0DzH5+yXLumuyv901fxpTLwFfULI\nc8I6qqnLXcTrejhINfEN09RKDE7iUSk5/v3k2jqOgLNK8SQHfPEI2dHzC/Za\nRJ/qJ/PeLLrfvymgc18eBauwmY09qUxk6zn8vDU6epU/KgdWqJOwgBWjKimG\nccPmQFipaMqYVpJpQ4VX2/yefbdeheqGtroAddtTzt6ODh9CIlx8VtKxAS6j\n5Ku0f9uCh1gLOheVweyfFP8GOlo6A2swhvx5Qvw1t4AMQ+maV8tg1FQpmmfx\ngo3I\r\n=zjsR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAUn4B+kTN9l5116d9JN7YUhZwpfDEkYQTurJIDhDbY7AiEA2f1R2puPxTjxnWP4sqp2shQ4v4VR3qQYPA0zdby+oCc="}],"size":3408,"noattachment":false,"key":"/thread-it/-/thread-it-1.0.2.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.2_1565954882698_0.33130327960853045"},"_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":1565954882810,"_cnpm_publish_time":1565954882810,"dist-tags":{"latest":"3.0.0"}}