delay-map

1.0.1 • Public • Published

delay-map

In order to delay map func running with a timeout.

Basically, iterable object passed to map function will be executed one after another immediately. there is a situation you want to simluate a running with timeout. such as the next one should run with 300ms delay.

Usage

const delayMap = require('./delay-map');
 
const dm = new delayMap([5,8,9], function(value, key) {
  return value + key;
}, {
  timeout: 1000,
})
 
dm.then((res) => {
  console.log('res ', res);
})
 
// res: [5, 9, 11]

API

delay-map(iterable, func, [options])

input

Type: Iterable<Promise|any>

func(item, index)

Type: Function

options

Type: Object

timeout

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i delay-map

Weekly Downloads

22

Version

1.0.1

License

MIT

Last publish

Collaborators

  • ryuyutyo