farofy

1.0.0 • Public • Published

farofy

Manipulate arrays using async function but wait each promise finish to execute next one.

Problem

const data = [1,2,3,4,5, ...100];
const result = data.map(async (number) => {
    return number * 2;
});
console.log(result); // Result is an Array with 100 Promises

Solution

const data = [1,2,3,4,5, ...100];
const result = await data.asyncMap(async (number) => {
    return number * 2;
});
console.log(result); // Result is an Array with 100 numbers

Readme

Keywords

Package Sidebar

Install

npm i farofy

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

2.56 kB

Total Files

4

Last publish

Collaborators

  • pedrosoares