Throttle promise-returning & async functions
MIT License
Bot releases are hidden (Show)
onDelay
hook (#47) 362f1e1https://github.com/sindresorhus/p-throttle/compare/v6.0.0...v6.1.0
{strict: true}
with many long delays a1b3d77https://github.com/sindresorhus/p-throttle/compare/v5.1.0...v6.0.0
https://github.com/sindresorhus/p-throttle/compare/v5.0.0...v5.1.0
https://github.com/sindresorhus/p-throttle/compare/v4.1.1...v5.0.0
https://github.com/sindresorhus/p-throttle/compare/v4.1.0...v4.1.1
strict
option (#27) 242d410.isEnabled
(#24) cdcde4ehttps://github.com/sindresorhus/p-throttle/compare/v4.0.0...v4.1.0
const pThrottle = require('p-throttle');
const now = Date.now();
-const throttled = pThrottle(index => {
+const throttled = pThrottle({limit: 2, interval: 1000})(index => {
const secDiff = ((Date.now() - now) / 1000).toFixed();
return Promise.resolve(`${index}: ${secDiff}s`);
-}, 2, 1000);
+);
for (let i = 1; i <= 6; i++) {
throttled(i).then(console.log);
}
This has the benefit that it allows reusing the throttled
instance. See: https://github.com/sindresorhus/p-throttle/issues/16
https://github.com/sindresorhus/p-throttle/compare/v3.1.0...v4.0.0
https://github.com/sindresorhus/p-throttle/compare/v3.0.0...v3.1.0
Breaking:
It's only breaking for TypeScript users. If you don't use TypeScript, nothing has changed.
https://github.com/sindresorhus/p-throttle/compare/v2.1.1...v3.0.0
https://github.com/sindresorhus/p-throttle/compare/v2.1.0...v2.1.1