{"name":"throat","version":"3.2.0","description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"files":["index.d.ts","index.js","index.js.flow"],"devDependencies":{"coveralls":"^2.11.2","flow-bin":"^0.48.0","istanbul":"^0.4.5","jest":"^20.0.4","promise":"^7.1.1","sauce-test":"^1.0.0","test-result":"^2.0.0","testit":"^2.1.3","typescript":"^2.3.4"},"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":"d3160f52514dda47b52a35295f0d98423da84814","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat#readme","_id":"throat@3.2.0","_npmVersion":"5.0.3","_nodeVersion":"8.0.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"integrity":"sha512-/EY8VpvlqJ+sFtLPeOgc8Pl7kQVOWv0woD87KTXVHPIAE842FGT+rokxIhe8xIUP1cfgrkt0as0vDLjDiMtr8w==","shasum":"50cb0670edbc40237b9e347d7e1f88e4620af836","tarball":"http://registry-npm.ywwl.com/throat/download/throat-3.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA7r1CZ+uRXqyShuId/a/IdtXe97BvWrnWUUpdAURo4lAiBi4ECOB9CbnA4bQL9UI+EuF9xdtNj8VnxCzzuNBYJAtg=="}],"size":3092,"noattachment":false,"key":"/throat/-/throat-3.2.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/throat-3.2.0.tgz_1497359089265_0.8259152092505246"},"directories":{},"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":1497359090148,"_cnpm_publish_time":1497359090148,"dist-tags":{"latest":"6.0.2"}}