Nightly Pocket Measurement

    async-functions-pool

    1.0.1 • Public • Published

    Current Version NPM Minified size Github Code Size Downloads/Week Issues License Contributors

    NPM

    async-functions-pool

    Minimal Async Tasks Pool Manager

    Usage

    // 1. Import module and execute it to create a pool
    const pool = require('async-functions-pool')();
    
    // 2. Add functions to the queue. For example:
    pool.add(() => fetch('http://someAPI.com/resource/1'));
    pool.add(() => fetch('http://someAPI.com/resource/2'));
    pool.add(() => fetch('http://someAPI.com/resource/3'));
    pool.add(() => fetch('http://someAPI.com/resource/4'));
    pool.add(() => fetch('http://someAPI.com/resource/5'));
    pool.add(() => fetch('http://someAPI.com/resource/6'));
    
    
    // 3. Set number of parallel jobs and run!
    async function foo(){
      const results = await pool.run(3);
      console.log('All jobs have finished');
    }
    foo();
    

    FAQs

    • How minimal it is? 25 Lines of code and no dependencies
    • Can it run common sync functions? Yes
    • Which version of Node is required? > 8.0.0 because it uses async/await

    Install

    npm i async-functions-pool

    DownloadsWeekly Downloads

    1,552

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    5.44 kB

    Total Files

    5

    Last publish

    Collaborators

    • wjsc