a promise queue
This is just another promise queue. Simple.
- Native es6
- No concurency
- Optional retry attempts for failed promises
- Option to use your faviour promise flavour (Bluebird, Q)
Install
You know this:
npm install a-promise-queue
Interface
Example:
var PromiseQueue = require('a-promise-queue');
var delay = (ms) => () => new Promise(resolve => setTimeout(resolve, ms));
var queue = new PromiseQueue(() => console.log('Queue is empty'));
queue.add(delay(100)).then(() => console.log('first this'));
queue.add(() => Promise.reject('then this fails')).catch((e) => console.log('Errored:', e));
queue.add(delay(10)).then(() => console.log('and this succeeds'));
queue.add(delay(10), { priority: 1 }).then(() => console.log('but not before this one jumps the queue.'));