Throttle promise-returning & async functions
It also works with normal functions.
Useful for rate limiting calls to an external API, for example.
NOTE: This is a fork of p-throttle, but without ES6 in the source code.
$ npm install throttle-promise
Here, the trottled function is only called twice a second:
const throttle = ;const now = Date;const throttled =;for let i = 1; i <= 6; i++;//=> 1: 0s//=> 2: 0s//=> 3: 1s//=> 4: 1s//=> 5: 2s//=> 6: 2s
throttle(fn, limit, interval)
Returns a throttled version of
Promise-returning/async function or a normal function.
Maximum number of calls within an
limit in milliseconds.
Abort pending executions. All unresolved promises are rejected with a
- p-debounce - Debounce promise-returning & async functions
- p-limit - Run multiple promise-returning & async functions with limited concurrency
- p-memoize - Memoize promise-returning & async functions
MIT © Sindre Sorhus