{"name":"throat","version":"6.0.0","description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"devDependencies":{"coveralls":"^3.0.0","flow-bin":"^0.73.0","istanbul":"^0.4.5","jest":"^22.1.4","promise":"^8.0.0","sauce-test":"^1.0.0","test-result":"^2.0.0","testit":"^3.1.0","typescript":"^3.4.5"},"jest":{"testEnvironment":"node"},"scripts":{"tsc":"tsc --noEmit","flow":"flow","test":"node test/index.js && npm run test:types","test:types":"jest","coverage":"istanbul cover test/index.js","coveralls":"npm run coverage && cat ./coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/throat.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"f8ced5e317bbad5b331d618743d03814784afe4c","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat#readme","_id":"throat@6.0.0","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","dist":{"integrity":"sha512-xFKdqx9QpWfXq471eaKQ/ao7xOFye4CKc8pyNJ9wU+oa6R4EKPTVY6V7JMqPVMZhB8TUbY5TB/mgU4AYA4Y8dA==","shasum":"e5d793bff24e2d329e25239978ba79b9c797b3a6","tarball":"http://registry-npm.ywwl.com/throat/download/throat-6.0.0.tgz","fileCount":6,"unpackedSize":8025,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCECHCRA9TVsSAnZWagAAS8wP/3/dnS+u3A53QYcYK3pS\nqsuRg63LhFla9IbzkH/M1X/nDxira2arsG+FvVRWHGJSpQrI+RIZoR0zMZ1e\nwWeyMLBS/FSSfNOAByxrLTxuN53YUbgIpN7GaIJLgH+XskaR2fAqSS/qyFht\n4GzFoF5Thby4RXFE7TXI81pkS/ZbDrzxQP7WUZMWAareEbTAFGr8/7fzCr1R\nyjwckfbmqH2caENrRMzeWF8DUJl0YMPwtiuxxRgmm9DcHeppc6nXdmj7nLb3\n7Rb4ket01+4tGCvYx9tHUT70RER7DdwckoQAOkRk7UunfnnZ2hM+e3oK7nvA\nD1jejsI5Sd2ffPP0AjrAGJE+5WsgzH7ETjpEA0zklvDAL6rfmxtzBqBSKQU6\ng5hPCywCcGCRsEIKV2EAuUEjQtsfPpONuu5uqO6/4cipwjeXF7C3HV14MbNM\nOJaAH6JM2ndFdUVBcv4Mn8C3zBFmOvMagNC6KI+yDuFe9XqLeDIEDAJfMWM/\n94naQnQNA7R+CfCCn907bWapKhbWVOaegvSv1RuFjlYK4Dqojt7puNZgl4zj\nYoW+m9j1IN/pN8i/RoMqHL5ykdTm01c42M6F9JC/+/RMysLaxGLgoEtzVM9w\nYFAJRTF3A1/LgUWDHSmxWcIjMbUuxTZM7X9qgRNXSqGV9YySK7sGQKPY0k96\n4Yj5\r\n=X8J1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBeU17xPZg4sBzQpOz4CBlltEy6Ol9Q9qk2ZIqVre+J0AiAB2E5/2BfOUGKX6jI/n6W7eZfa63UZYr8e+R6Pbzz4Dw=="}],"size":3201,"noattachment":false,"key":"/throat/-/throat-6.0.0.tgz"},"_npmUser":{"name":"throat-bot","email":"forbeslindesay+throat@hey.com"},"directories":{},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},{"name":"throat-bot","email":"forbeslindesay+throat@hey.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/throat_6.0.0_1611153543049_0.1604649463138732"},"_hasShrinkwrap":false,"readme":"# throat\n\nThrottle the parallelism of an asynchronous, promise returning, function / functions. This has special utility when you set the concurrency to `1`. That way you get a mutually exclusive lock.\n\n[Professionally supported throat is now available](https://tidelift.com/subscription/pkg/npm-throat?utm_source=npm-throat&utm_medium=referral&utm_campaign=readme)\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/ForbesLindesay/throat/test.yml?branch=master&style=for-the-badge)](https://github.com/ForbesLindesay/throat/actions/workflows/test.yml?query=branch%3Amaster)\n[![Coveralls github branch](https://img.shields.io/coveralls/github/ForbesLindesay/throat/master?color=brightgreen&style=for-the-badge)](https://coveralls.io/github/ForbesLindesay/throat)\n[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen?style=for-the-badge)](https://rollingversions.com/ForbesLindesay/throat)\n[![NPM version](https://img.shields.io/npm/v/throat?style=for-the-badge)](https://www.npmjs.com/package/throat)\n\n## Installation\n\n    npm install throat\n\n## API\n\n### throat(concurrency)\n\nThis returns a function that acts a bit like a lock (exactly as a lock if concurrency is 1).\n\nExample, only 2 of the following functions will execute at any one time:\n\n```js\nconst throat = require('throat')(2);\n\nconst resA = throat(async () => {\n  /* async stuff... */\n});\nconst resB = throat(async () => {\n  /* async stuff... */\n});\nconst resC = throat(async () => {\n  /* async stuff... */\n});\nconst resD = throat(async () => {\n  /* async stuff... */\n});\nconst resE = throat(async () => {\n  /* async stuff... */\n});\n```\n\n### throat(concurrency, worker)\n\nThis returns a function that is an exact copy of `worker` except that it will only execute up to `concurrency` times in parallel before further requests are queued:\n\n```js\nconst throat = require('throat');\n\nconst input = ['fileA.txt', 'fileB.txt', 'fileC.txt', 'fileD.txt'];\nconst data = Promise.all(\n  input.map(throat(2, (fileName) => readFile(fileName)))\n);\n```\n\nOnly 2 files will be read at a time, sometimes limiting parallelism in this way can improve scalability.\n\n## Security contact information\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.\n\n## License\n\nMIT\n","publish_time":1611153543205,"_cnpm_publish_time":1611153543205,"dist-tags":{"latest":"6.0.2"}}