DoMany
A simple package that runs multiple functions efficiently
Example (Get 100 dog pics):
Asynchronous:
const doMany = require("domany");
(async () => {
let arr = new Array(100).fill("https://dog.ceo/api/breeds/image/random");
let res = await doMany(arr, async (url) => { return await (await fetch(url)).json() }, { maxRetries: 0, amountPerUnit: arr.length / 10, events: false});
console.log(res);
})();
With events:
const doMany = require("domany");
(async () => {
let arr = new Array(100).fill("https://dog.ceo/api/breeds/image/random");
let res = await doMany(arr, async (url) => { return await (await fetch(url)).json() }, { maxRetries: 0, amountPerUnit: arr.length / 10, events: true });
res.on("data", console.log);
res.on("done", data =>{
console.log("Finished with " + data.length + " dog images");
})
})();