throttle async and promise-returning functions. Other packages don't do it right.
npm install --save @jcoreio/async-throttle
Creates a throttled function that only invokes
func at most once per every
wait milliseconds, and also waits for the
Promise returned by the previous invocation to finish (it won't invoke
func in parallel).
The promise returned by the throttled function will track the promise returned by the next invocation of
wait is falsy, it is treated as 0, which causes
func to be invoked on the next tick afte the previous invocation
func is called with the most recent arguments to the throttled function. You can change this with the
getNextArgs option -- for example, if you want to invoke
func with the minimum of all arguments since the last
const throttled =// foo will be called with 1// time passes...// foo will be called with 4