p-throttle

Throttle promise-returning & async functions

MIT License

Downloads
4.9M
Stars
382
Committers
14

Bot releases are hidden (Show)

p-throttle - Latest Release

Published by sindresorhus 11 months ago

  • Add onDelay hook (#47) 362f1e1
  • Improve performance in some cases (#46) a2c2a66

https://github.com/sindresorhus/p-throttle/compare/v6.0.0...v6.1.0

p-throttle -

Published by sindresorhus 11 months ago

Breaking

  • Require Node.js 18 598642e

Fixes

  • Fix handling of generic functions in the types 329a240
  • Fix timeout overflow with {strict: true} with many long delays a1b3d77

https://github.com/sindresorhus/p-throttle/compare/v5.1.0...v6.0.0

p-throttle -

Published by sindresorhus over 1 year ago

  • Add property to get the queue size (#39) 3e7a732

https://github.com/sindresorhus/p-throttle/compare/v5.0.0...v5.1.0

p-throttle -

Published by sindresorhus about 3 years ago

Breaking

  • Require Node.js 12.20 6420761
  • This package is now pure ESM. Please read this.

https://github.com/sindresorhus/p-throttle/compare/v4.1.1...v5.0.0

p-throttle -

Published by sindresorhus over 3 years ago

p-throttle -

Published by sindresorhus over 3 years ago

  • Add strict option (#27) 242d410
  • Allow disabling throttling with .isEnabled (#24) cdcde4e
  • Fix TypeScript typings (#23) ce1624d

https://github.com/sindresorhus/p-throttle/compare/v4.0.0...v4.1.0

p-throttle -

Published by sindresorhus over 3 years ago

Breaking

  • Require Node.js 10 (#22) 5cb0a4e
  • Currify function and move arguments to an optons-object (#22) 5cb0a4e
 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

p-throttle -

Published by sindresorhus over 5 years ago

  • Refactor TypeScript definition to CommonJS compatible export (#17) b734458

https://github.com/sindresorhus/p-throttle/compare/v3.0.0...v3.1.0

p-throttle -

Published by sindresorhus over 5 years ago

Breaking:

  • Improve TypeScript definitions (#13) c892bc0

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

p-throttle -

Published by sindresorhus over 5 years ago

  • Clear timeout after aborting pending executions (#14) 98b8506

https://github.com/sindresorhus/p-throttle/compare/v2.1.0...v2.1.1

p-throttle -

Published by sindresorhus almost 6 years ago

  • Improve performance and memory usage (#11) 842bd88