promise-fifo
A FIFO (first-in-first-out) queue using promises
You can use any promise library supporting the following format by passing the promise constructor to .use
{ }; var Fifo = ;
Installation
Installation is like any other node module:
npm install promise-fifo
Usage
Bluebird Example
var Promise = ; var Fifo = ; var myFifo = "foo"; myFifo; myFifo ;
Q Example
Using with Q is very similar, though based on your version, the constructor name may have a lower/uppercase p
See the Q API-Reference: https://github.com/kriskowal/q/wiki/API-Reference#qpromiseresolver
var Q = ; // > 0.9.7 var Fifo = ; // <= 0.9.7 var Fifo = ;
Rate Limiting Example
Here we are limiting the amount of concurrent work done between .get
and .put
to the number of cpus on the machine.
//preload the Fifo with 'cpus().length' number of blank entries var myFifo = oslength; { //get returns a promise return myFifo //use finally so we call .put even when an error was thrown ; }