{"name":"throat","version":"6.0.1","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":"8fd7a02dce52ce26743b368f62a33f8752c68a4e","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat#readme","_id":"throat@6.0.1","_nodeVersion":"12.20.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w==","shasum":"d514fedad95740c12c2d7fc70ea863eb51ade375","tarball":"http://registry-npm.ywwl.com/throat/download/throat-6.0.1.tgz","fileCount":6,"unpackedSize":9160,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCJlACRA9TVsSAnZWagAAdhkP/A8/HjtfkgtWc3uPBFPK\nuE3UbPFr/wqI1XG0jp80fyD5ZmAeGFcH8vqbPG/92I5fU64aSP7nhljjAv04\nd8CInvZD8j0WtTfBqxuVX58bbwg1FdNSc5CttEkaadWAQAuP42C8/soGIWga\nM9mrBEvCowGU9Dtts3pGPejkpUJko4LVXIrpmQPoQyIz35XMeqnTe0uVId9Q\nldwI4/3Bp9ep+kVd36OqZh8w0lKGtSQAPjh7CChx8BEsV+TJjcIbjjBkyK84\nFtwJpKAdYtOzqUgNqJZe5CYSPwdENTNUldh+Bvi/6Iq8K61C3VY+9hw5pnVA\ntzwL4sr1LAMAJEH8RHf/ZkFZhOdNab6OXYcPekPIIzHvkmExnGnMSUFkd8fl\nJotyba4P/TpSdIVldI0qbnba64/49rRUcf/oAFUb8Q2G/dNk726/0bxrJueQ\nByWI8iW15MAG++AruTNe1ZQm8TgiCoBVSb+9LXyGq2KFwfL7SibWE+KLrfBY\nIfx3Z6yRo+NuTo2KhGhUQ4nAmNBsWo6+2e/+5Wr702uGR//Wxx5GrLH1dBFp\ndEKR2XxDnbrmZicyUKDTIJSrT8kjQg4QqVzIR7ewZKmSBOrocX9nBm3uuLP+\nxzHSbGSVKNrfE0Wlj3jFr/XBTN9idvUocRk8CEenffszsgqvODVpp50ZyiUG\nE2Ge\r\n=naB3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG3j4H+1JX9xM+8d4xMCpFqR+67sRsc90x0DGoOPESTnAiBR6u1mwacAFvMMqeNZRcvVHvcQIVimTp3uZDZcvmX2ng=="}],"size":3516,"noattachment":false,"key":"/throat/-/throat-6.0.1.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.1_1611176255606_0.9271045948425778"},"_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":1611176255710,"_cnpm_publish_time":1611176255710,"dist-tags":{"latest":"6.0.2"}}