Skip to content

hoangtd97/delay-iteratee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published