{"name":"throat","version":"6.0.2","description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"devDependencies":{"coveralls":"^3.0.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","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":"1231ed7878fb8dfd651ba97f2b920edfa397dd8d","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat#readme","_id":"throat@6.0.2","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-WKexMoJj3vEuK0yFEapj8y64V0A6xcuPuK9Gt1d0R+dzCSJc0lHqQytAbSB4cDAK0dWh4T0E2ETkoLE2WZ41OQ==","shasum":"51a3fbb5e11ae72e2cf74861ed5c8020f89f29fe","tarball":"http://registry-npm.ywwl.com/throat/download/throat-6.0.2.tgz","fileCount":6,"unpackedSize":9145,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDvAE01TneKSRlvcXzWOS+I96DjBmg6tVtm58BOx0ezQIgSKzTzzoxzk9oIIEf0Ms8rCZrW6urnvGhBe5jui7nDZ0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtC5DACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrwbw//bQsQNBITcbfHbW8pnFlCr8Bc4i1RHpqjGzPog2h71VYr+y2X\r\nzBuVVaKG4Sj8I83Sl+gyUo7DeUNzhzkARnAxR1XRVMSDdeTrSw6J3ofBqUdm\r\nRq0IAarCGzQlHDz5iJfo5JYKvk8QLACr0uQW1DJLXGzBwB/FIZXGJQ7sTVIb\r\nL0N13xRWPxJnS+nbRszWh0GKVjtDyh2yczk/R1j8W8nU6DTgjddqFuv0KSb3\r\n2fD0vkTfe8eP6eV3HsHDQlVtqYyAH4C8quOKOxHHNwsgUKst+rKp15qIP2Mo\r\nlsqbTU+Ipu3vLNXmuTeDg6/egH5jxkWRlDGrY94KvYYMCvYPvSM8oSsW3jhH\r\nMAM52NeXOHUsPD+aWeQYAIDhqSv+MZxSxLphk34sS/PoeS7hOCL+0CYIW1E0\r\nwilyN9cLaybewD7RX5PBCqSMefbkrlK6bbqaayqGOlPjRlURGWCEfoPOh+9O\r\nm5CbRNKzKHBqmSSyXZWSl1ZSTQm9H6zGJlxKcKPZYjNweDbLFbkk8XmSuPOw\r\nxmjMuMcrV4asssgDRWpMCotzN7S4FfqD19wMizy+VeGkd9iah+BWs3HGaf2n\r\nAaiHnH9CVduNv+/DGFJ5yfmh37YmHJQG08WCIZ+7c4JQm05MiC4tyzI7j72y\r\nC7CxqPWptftka37kTgDqoKYHZp1Bpg71oTQ=\r\n=FujT\r\n-----END PGP SIGNATURE-----\r\n","size":3508,"noattachment":false,"key":"/throat/-/throat-6.0.2.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.2_1672752707489_0.09786957699584486"},"_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":1672752707643,"_cnpm_publish_time":1672752707643,"dist-tags":{"latest":"6.0.2"}}