async-each-loop

0.4.0 • Public • Published

async-each-loop

CircleCI branch code style: prettier security status

Usage

Install

First install the library with npm or yarn:

$ npm i -S async-each-loop

or

$ yarn add async-each-loop

Usage

  • With async/await:
const { parallelForEach } = require('async-each-loop');
 
const urls = ['https://github.com', 'https://circleci.com/'];
 
const run = async () => {
  await parallelForEach(urls, async (url) => {
    // doSomething with the URL
    await doSomething(url);
  });
  console.log('done');
};
 
run();
  • With Promnise:
const { parallelForEach } = require('async-each-loop');
 
const urls = ['https://github.com', 'https://circleci.com/'];
 
parallelForEach(urls, async (url) => {
  // doSomething with the URL
  await doSomething(url);
}).then(() => {
  console.log('done');
});

API

parallelForEach (iterable, fn)

This function execute the input function fn forEach element of the input iterable. The forEach is running over the elements in parallel.

  • iterable is an Array or Map
  • fn is a function

sequenceForEach (iterable, fn)

This function execute the input function fn forEach element of the input iterable. The execution is in sequence, each function is invoked after the end of the previous element.

  • iterable is an Array or Map
  • fn is a function

Contributing

Anyone and everyone is welcome to contribute.

Issues

Find a bug or want to request a new feature? Please let me know by submitting an issue.

Licensing

Licensed under the MIT License

A copy of the license is available in the repository's LICENSE file.

Readme

Keywords

none

Package Sidebar

Install

npm i async-each-loop

Weekly Downloads

0

Version

0.4.0

License

MIT

Unpacked Size

15 kB

Total Files

22

Last publish

Collaborators

  • tsamaya