Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including delay-iteratee with all npm packages installed. Try it out:

var delayIteratee = require("delay-iteratee")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

delay-iteratee v1.0.2

delay asynchronous iteratee

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.

ParamTypeDescription
timenumber(ms)
iterateefunction

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
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free