f-throttle
v0.1.1
Published
Limit concurrency of a function returning a promise.
Downloads
11
Readme
f-throttle
Limit concurrency of a function returning a promise.
Usage
var throttle = require("f-throttle")
var throttledFn = throttle(concurrency, anyFn)
throttleFn
functions like anyFn
, but throttled to a concurrency of concurrency
, where concurency is a number equal or higher than one.
Notes
throttledFn
returns a promise.anyFn
must return a promise. If it does not, the promise returned bythrottledFn
will be rejected.- You may pass any number of arguments
- Function context is preserved, so can work for when throttling a function that's a method for an object.
- When you throttle a function to a concurrency of 1, this results in execution in a serial fashion.
Credits
The initial structure of this module was generated by Jumpstart, using the Jumpstart Black Coffee template.
License
f-throttle is released under the MIT License.
Copyright (c) 2013 Meryn Stol