{"_id":"p-throttle","_rev":"1112731","name":"p-throttle","description":"Throttle promise-returning & async functions","dist-tags":{"latest":"5.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2021-10-04T16:52:00.000Z","created":"2016-10-21T08:15:52.664Z","5.0.0":"2021-10-04T16:35:04.362Z","4.1.1":"2021-02-26T14:21:06.028Z","4.1.0":"2021-02-21T14:17:06.886Z","4.0.0":"2021-01-19T09:08:38.544Z","3.1.0":"2019-04-06T15:29:22.340Z","3.0.0":"2019-02-20T05:14:54.034Z","2.1.1":"2019-02-18T16:53:55.694Z","2.1.0":"2018-12-15T11:28:49.292Z","2.0.0":"2018-09-17T08:28:37.520Z","1.1.0":"2017-01-05T20:58:20.444Z","1.0.0":"2016-10-21T08:15:52.664Z"},"users":{"direct808":true,"rocket0191":true},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"versions":{"5.0.0":{"name":"p-throttle","version":"5.0.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","in-range":"^3.0.0","time-span":"^5.0.0","tsd":"^0.17.0","xo":"^0.45.0"},"gitHead":"2969d40a681be2bacb83a220bf6bcb95ca7e3ed5","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@5.0.0","_nodeVersion":"12.22.1","_npmVersion":"7.20.3","dist":{"shasum":"b85e9dc56cbf5b54808a2ae29886b0da12537103","size":3216,"noattachment":false,"key":"/p-throttle/-/p-throttle-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-5.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_5.0.0_1633365304214_0.9456503537658745"},"_hasShrinkwrap":false,"publish_time":1633365304362,"_cnpm_publish_time":1633365304362},"4.1.1":{"name":"p-throttle","version":"4.1.1","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^2.4.0","delay":"^5.0.0","in-range":"^2.0.0","time-span":"^4.0.0","tsd":"^0.14.0","xo":"^0.38.1"},"gitHead":"9e210bdf5267dcab4993d3db9e121d5682330b93","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@4.1.1","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"80b1fbd358af40a8bfa1667f9dc8b72b714ad692","size":3316,"noattachment":false,"key":"/p-throttle/-/p-throttle-4.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-4.1.1.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_4.1.1_1614349265861_0.26315476651245984"},"_hasShrinkwrap":false,"publish_time":1614349266028,"_cnpm_publish_time":1614349266028},"4.1.0":{"name":"p-throttle","version":"4.1.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^2.4.0","delay":"^5.0.0","in-range":"^2.0.0","time-span":"^4.0.0","tsd":"^0.14.0","xo":"^0.38.1"},"gitHead":"62ad5bb8d5d84c431b1a8af847e28b815ea4ae4c","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@4.1.0","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"d03661f282d7f7ca952e9eadb0b1ea1315e3ef99","size":3306,"noattachment":false,"key":"/p-throttle/-/p-throttle-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-4.1.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_4.1.0_1613917026256_0.25793907151809825"},"_hasShrinkwrap":false,"publish_time":1613917026886,"_cnpm_publish_time":1613917026886},"4.0.0":{"name":"p-throttle","version":"4.0.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^2.4.0","delay":"^4.4.0","in-range":"^2.0.0","time-span":"^4.0.0","tsd":"^0.14.0","xo":"^0.37.1"},"gitHead":"c10553939e33176ef0a28b580a512cb1f4414614","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@4.0.0","_nodeVersion":"10.22.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"7dd54f7dee6876ddb5945c4fec29edb2842af532","size":2840,"noattachment":false,"key":"/p-throttle/-/p-throttle-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-4.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_4.0.0_1611047318382_0.01201341229443953"},"_hasShrinkwrap":false,"publish_time":1611047318544,"_cnpm_publish_time":1611047318544},"3.1.0":{"name":"p-throttle","version":"3.1.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","in-range":"^1.0.0","time-span":"^2.0.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"abba96994e889877fc76ad51fdb8c655fff8c68e","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@3.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"dee34ce4e77d7cc2dfdc1fea0daedccc64147214","size":2802,"noattachment":false,"key":"/p-throttle/-/p-throttle-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-3.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_3.1.0_1554564562199_0.8644412507113339"},"_hasShrinkwrap":false,"publish_time":1554564562340,"_cnpm_publish_time":1554564562340},"3.0.0":{"name":"p-throttle","version":"3.0.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^1.2.1","delay":"^4.1.0","in-range":"^1.0.0","time-span":"^2.0.0","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"05609e0fadca7a017776489e96171d0ff92ddd6a","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@3.0.0","_nodeVersion":"10.15.0","_npmVersion":"6.8.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"62547f099b07d7803b26465bc5cabbb0296bdfc2","size":2725,"noattachment":false,"key":"/p-throttle/-/p-throttle-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_3.0.0_1550639693877_0.32143432101600755"},"_hasShrinkwrap":false,"publish_time":1550639694034,"_cnpm_publish_time":1550639694034},"2.1.1":{"name":"p-throttle","version":"2.1.1","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^0.25.0","delay":"^4.1.0","in-range":"^1.0.0","time-span":"^2.0.0","tsd-check":"^0.2.1","xo":"^0.23.0"},"gitHead":"a2958846b1df2bfedebc19c7567c4a74fa242bd8","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@2.1.1","_nodeVersion":"10.15.0","_npmVersion":"6.8.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"1b6b43f560157e27ebc21e4ece12d43fd79243d4","size":2620,"noattachment":false,"key":"/p-throttle/-/p-throttle-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-2.1.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_2.1.1_1550508835537_0.10305740940837427"},"_hasShrinkwrap":false,"publish_time":1550508835694,"_cnpm_publish_time":1550508835694},"2.1.0":{"name":"p-throttle","version":"2.1.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^0.25.0","delay":"^4.1.0","in-range":"^1.0.0","time-span":"^2.0.0","tsd-check":"^0.2.1","xo":"^0.23.0"},"gitHead":"82080a57b4d447684857945e7cc1a6db05921b8f","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@2.1.0","_npmVersion":"6.5.0","_nodeVersion":"10.13.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"d3cf3bc7a8aae17b814137270a207222e990da44","size":2613,"noattachment":false,"key":"/p-throttle/-/p-throttle-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_2.1.0_1544873328838_0.5054269634394064"},"_hasShrinkwrap":false,"publish_time":1544873329292,"_cnpm_publish_time":1544873329292},"2.0.0":{"name":"p-throttle","version":"2.0.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"^0.25.0","in-range":"^1.0.0","time-span":"^1.0.0","tsd-check":"^0.2.1","xo":"^0.23.0"},"gitHead":"bccc1fb718bb9fcbaaf3c68cfc5dee789bc8e549","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@2.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.4","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"6c37a705ddade51a9ed55c24cdfd0ed9eb5095f6","size":2651,"noattachment":false,"key":"/p-throttle/-/p-throttle-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-throttle_2.0.0_1537172917086_0.1916255383374177"},"_hasShrinkwrap":false,"publish_time":1537172917520,"_cnpm_publish_time":1537172917520},"1.1.0":{"name":"p-throttle","version":"1.1.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"*","in-range":"^1.0.0","time-span":"^1.0.0","xo":"*"},"xo":{"esnext":true},"gitHead":"4b407d82ff6d56494e779ad8d5827ba415966d6c","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@1.1.0","_shasum":"dd0822247ffc7767a8c7bb1186fcc632fea57075","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"dd0822247ffc7767a8c7bb1186fcc632fea57075","size":2432,"noattachment":false,"key":"/p-throttle/-/p-throttle-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-throttle-1.1.0.tgz_1483649898517_0.8290348295122385"},"directories":{},"publish_time":1483649900444,"_cnpm_publish_time":1483649900444,"_hasShrinkwrap":false},"1.0.0":{"name":"p-throttle","version":"1.0.0","description":"Throttle promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-throttle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","throttle","throat","limit","limited","interval","rate","batch","ratelimit","queue","discard","async","await","promises","time","out","cancel","bluebird"],"devDependencies":{"ava":"*","in-range":"^1.0.0","time-span":"^1.0.0","xo":"*"},"xo":{"esnext":true},"gitHead":"f84d0325f29ad732e031bf54b9692e39cf023e9b","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"homepage":"https://github.com/sindresorhus/p-throttle#readme","_id":"p-throttle@1.0.0","_shasum":"56b0082778ff175b7b330cd779d845a34c2da8f8","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"56b0082778ff175b7b330cd779d845a34c2da8f8","size":2199,"noattachment":false,"key":"/p-throttle/-/p-throttle-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-throttle/download/p-throttle-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-throttle-1.0.0.tgz_1477037750542_0.35164265614002943"},"directories":{},"publish_time":1477037752664,"_cnpm_publish_time":1477037752664,"_hasShrinkwrap":false}},"readme":"# p-throttle\n\n> [Throttle](https://css-tricks.com/debouncing-throttling-explained-examples/) promise-returning & async functions\n\nIt also works with normal functions.\n\nUseful for rate limiting calls to an external API, for example.\n\n## Install\n\n```sh\nnpm install p-throttle\n```\n\n## Usage\n\nHere, the throttled function is only called twice a second:\n\n```js\nimport pThrottle from 'p-throttle';\n\nconst now = Date.now();\n\nconst throttle = pThrottle({\n\tlimit: 2,\n\tinterval: 1000\n});\n\nconst throttled = throttle(async index => {\n\tconst secDiff = ((Date.now() - now) / 1000).toFixed();\n\treturn `${index}: ${secDiff}s`;\n});\n\nfor (let index = 1; index <= 6; index++) {\n\t(async () => {\n\t\tconsole.log(await throttled(index));\n\t})();\n}\n//=> 1: 0s\n//=> 2: 0s\n//=> 3: 1s\n//=> 4: 1s\n//=> 5: 2s\n//=> 6: 2s\n```\n\n## API\n\n### pThrottle(options)\n\nReturns a throttle function.\n\n#### options\n\nType: `object`\n\nBoth the `limit` and `interval` options must be specified.\n\n##### limit\n\nType: `number`\n\nThe maximum number of calls within an `interval`.\n\n##### interval\n\nType: `number`\n\nThe timespan for `limit` in milliseconds.\n\n#### strict\n\nType: `boolean`\\\nDefault: `false`\n\nUse a strict, more resource intensive, throttling algorithm. The default algorithm uses a windowed approach that will work correctly in most cases, limiting the total number of calls at the specified limit per interval window. The strict algorithm throttles each call individually, ensuring the limit is not exceeded for any interval.\n\n### throttle(function_)\n\nReturns a throttled version of `function_`.\n\n#### function_\n\nType: `Function`\n\nA promise-returning/async function or a normal function.\n\n### throttledFn.abort()\n\nAbort pending executions. All unresolved promises are rejected with a `pThrottle.AbortError` error.\n\n### throttledFn.isEnabled\n\nType: `boolean`\\\nDefault: `true`\n\nWhether future function calls should be throttled and count towards throttling thresholds.\n\n## Related\n\n- [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions\n- [p-limit](https://github.com/sindresorhus/p-limit) - Run multiple promise-returning & async functions with limited concurrency\n- [p-memoize](https://github.com/sindresorhus/p-memoize) - Memoize promise-returning & async functions\n- [More…](https://github.com/sindresorhus/promise-fun)\n","_attachments":{},"homepage":"https://github.com/sindresorhus/p-throttle#readme","bugs":{"url":"https://github.com/sindresorhus/p-throttle/issues"},"license":"MIT"}