Wondering what’s next for npm?Check out our public roadmap! »

    callback-pool

    1.0.1 • Public • Published

    callback-pool

    Simple utility to queue callbacks in a pool until the drain has been unplugged.

    npm install callback-pool --save

    Example

    var pool = require('callback-pool');
    var myPool = pool.create();//creates a new pool
     
    //these are queued up
    myPool.add(function(a, b){console.log('foo');});
    myPool.add(function(a, b){console.log('boo');});
     
    myPool.drain(1,2);//all callbacks are executed asynchronously with 1 and 2.
     
    //these are now asynchronously executed immediately with 1 and 2
    myPool.add(function(a, b){console.log('execute me');});
    myPool.add(function(a, b){console.log('me too');});
     
    myPool.plug();//allows you to start over.

    Keywords

    none

    Install

    npm i callback-pool

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • avatar