Need private packages and team management tools?Check out npm Teams »

delay-iteratee

1.0.2 • Public • Published

Build Status Coverage Status

DelayIteratee(time, iteratee)

Make sure that iteratee[n] will be invoked after min time(ms) from the iteratee[n - 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

Install

npm i delay-iteratee

DownloadsWeekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

4.97 kB

Total Files

6

Last publish

Collaborators

  • avatar