domany

1.1.0 • Public • Published

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");
    })
})();

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i domany

      Weekly Downloads

      2

      Version

      1.1.0

      License

      ISC

      Unpacked Size

      5.2 kB

      Total Files

      5

      Last publish

      Collaborators

      • professorfish