{"name":"throat","version":"5.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 && node test/browser.js","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":"871d50118f07c0a54f670644cafb2f7155891f60","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat#readme","_id":"throat@5.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"dist":{"integrity":"sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==","shasum":"c5199235803aad18754a667d659b5e72ce16764b","tarball":"http://registry-npm.ywwl.com/throat/download/throat-5.0.0.tgz","fileCount":6,"unpackedSize":8901,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc6ADdCRA9TVsSAnZWagAAKKQQAI6eRgF/lgWMnWzCiP2a\n8FQ6PJ1m3dvvpemckVnB1Pe/9oALY/Ft3OrhtstMmjTNWavbztYEEld2kcQh\nEpoPboeHxCUT5i+w04ECrv8BNj4qSUFtq3pGqN4Cw/kaJZNxAlneF2LvQvGc\n8gz6bmrwtqfEmhyvMG02iWw6VhUK3hPkOFDd7kpSQF5gZL9XiK0qPdjTJhdr\n+BXknK+lqLN4HcEejZxE/EHpgrUv9k1SRyK1/YYDtjm0BceG7DqtWTS5TUr9\nBzgEc/TpOKpEZrSTtfZpniXX+wixfEVk02RThiVdaMKvsThOHsfvfeOkiFUS\nS5Vqmv6I5qLc5BWll3n9xsmUdrfKDEmnMkuSRwkVRLCEm/VMm4EO47SFjF2E\ng9wwF/nUIbwXWUd23Q1ZDFhDirL1JdY2Cqz9KOLrlJFgY3nEt6H9DM8Q1EDn\n3QpnhyofE/fFUML/gKzuzB6GNqWvp5CtrFkOlPxV4AI+9NgOUVCS2S0K/NBA\nAjg3ssk+X5eIjUgW6bG2hlIEU/Nl4PFgt7DcrbvUN4QzfkcLQNj40zAcsVdm\nlD2pd9eVF+KN+Nfde7HidzYZsR5aT616tONdJVAtc4iTGX3pxeYcTRx0emJW\nO5U48c1A0wLPWI0MC+RRdIFt00vfO7q23JbJOvOaeZBxA3IoAgxxo2+S/XNF\nFPaW\r\n=4ZAQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC1Y6UGXfS2GOF20G30KiA24r2q+NyZk6Gf9iyFTGS1nAIhANNRNaNMVdtn2/ddyr47Ax0W7vDQFIGUr1ApenIXgD2q"}],"size":3411,"noattachment":false,"key":"/throat/-/throat-5.0.0.tgz"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/throat_5.0.0_1558708444315_0.6548170732872463"},"_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":1558708444404,"_cnpm_publish_time":1558708444404,"dist-tags":{"latest":"6.0.2"}}