map-async-promise

2.0.1 • Public • Published

map-async-promise

Allows mapping of an async function over an array and returns a promise once all items in the array have resolved.

With no dependencies.

Usage

const readFiles = (resolve, reject, element, index, arr) => {
  fs.readFile(element, 'utf8', function (err, data) {
    if (err) return reject(err);
    resolve(data);
  });
};


forEachPromise(readFiles)(['some/path/to/file', 'another/path/to/file'])
  .then(results => {
    console.log(results);
  })
  .catch(err => console.log(err));

Installation

npm install map-async-promise

Package Sidebar

Install

npm i map-async-promise

Weekly Downloads

5

Version

2.0.1

License

MIT

Last publish

Collaborators

  • otissv