3.0.4-d • Published 7 years ago
throttled-async v3.0.4-d
Deprecated in favor to Wraperizer.throttleAsync. No longer support.
Throttled
Create wrapper for a function that returns a promise. Uses to throttle frequent or repeated calls.
Parameters
fnfunction function that returns a promiseconfigobject? config objectconfig.stayfunction function that checks isfninvokes is necessary (optional, defaultfunction(){returnfalse})config.logsany? determines is internal logs needed
Examples
const Throttled = require('throttled-async');
const config = {}
const fn = (params) => new Promise((resolve, reject) => setTimeout(() => resolve(params), 100));
let throttled = new Throttled(fn, config);
let params = {};
const r1 = throttled.run(params); // will invoke `fn` and return Promise
const r2 = throttled.run(params); // will return old Promise
setTimeout(() => {
const r3 = throttled.run(params); // will invoke `fn` and return new Promise
}, 300)run
invokes fn and returns resulting promise
Parameters
paramsObject arguments for fn call
- Throws Error throws an error if result returned
fnis not a Promise
Returns Promise
stay
getter - returns current stay function
Returns function
stay
setter - set new value of stay function
Parameters
valuefunction
- Throws Error throws an error if value is not a function
3.0.4-d
7 years ago
3.0.4
7 years ago
3.0.3
7 years ago
3.0.2
8 years ago
3.0.1
8 years ago
2.0.11
8 years ago
2.0.10
8 years ago
2.0.9
8 years ago
2.0.8
8 years ago
2.0.7
8 years ago
2.0.6
8 years ago
2.0.5
8 years ago
2.0.4
8 years ago
2.0.3
8 years ago
2.0.2
8 years ago
2.0.1
8 years ago
2.0.0
8 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago