UNPKG

seq-prom

Version:

A small library to allow for sequential operations on an array using Promises

28 lines (24 loc) 552 B
/** * Created by adrianbrowning on 10/11/2016. */ const SeqProm = require('seq-prom'); let seqProm = SeqProm({ list: [1, 2, 3], cb (item, resolve, reject) { console.log(`Item [${item}] called!`); setTimeout(function () { if (item === 3) { return reject("Not sure about this!"); } else { return resolve(); } }, item * 1000); }, errorCB (item, reason) { console.error(`Item [${item}] failed with error: ${reason}`); }, finalCB (){ console.log("All done!"); } }); seqProm.start();