1.0.2 • Published 5 years ago
delay-iteratee v1.0.2
DelayIteratee(time, iteratee)
Make sure that iterateen will be invoked after min time(ms) from the iterateen - 1 invoking.
Param | Type | Description |
---|---|---|
time | number | (ms) |
iteratee | function |
Example
const DelayIteratee = require('delay-iteratee');
const start_at = Date.now();
const coll = ['A', 'B', 'C', 'D', 'E', 'F'];
const iteratee = async item => console.log(`at ${Date.now() - start_at}ms ${item}`);
Promise.all(coll.map(DelayIteratee(200, iteratee)));
// or
const asyncLib = require('async');
asyncLib.eachLimit(coll, 3, DelayIteratee(200, iteratee));
// will print like:
at 2ms A
at 201ms B
at 400ms C
at 603ms D
at 802ms E
at 1005ms F