asyncforeach-promise

0.3.2 • Public • Published

asyncForEach-promise

simple async forEach method with promise support.

Installation

Installation is done using the npm install command:

$ npm install --save asyncforeach-promise

Usage

forEach(arrayOrIterableElement, callbackFunction)

Example:

const forEach = require("asyncforeach-promise");

const array = [34, 24, 54];
forEach(array, (element, index, next) => {
    console.log(element);
    next()
})
.then(() => {
    console.log("finished");
})
.catch(console.error);

Output:

34
24
54
finished

This will be super usefull if you try to interact with a database or a web API. A normal foreach would end up in multiple parallel executing tasks, ...

License

MIT

Package Sidebar

Install

npm i asyncforeach-promise

Weekly Downloads

20

Version

0.3.2

License

MIT

Unpacked Size

13.2 kB

Total Files

5

Last publish

Collaborators

  • fchen