eventseries
v0.0.4
Published
Serialise a series of asynchronous events which you'd normally prefer to have synchronous but can't afford to block.
Downloads
3
Readme
eventseries
Serialise a series of asynchronous events which you'd normally prefer to have synchronous but can't afford to block.
Have you ever wanted to run a function on an array of objects and tried something like:
array.forEach(function(o) { console.log(o); });
and noticed that they're not guaranteed to be in order?
require('eventseries');
var exptSequence = new eventseries({
'order' : ['fred','betty','barney','wilma'], /* the sequence in which to fire named callbacks */
'callbacks' : {
/* Named callbacks.
Each is passed the sequence object.
Each should call next() when finished */
'fred' : function(seq) { console.log("one"); seq.next(); },
'betty' : function(seq) { console.log("two"); seq.next(); },
'barney' : function(seq) { console.log("three"); seq.next(); },
'wilma' : function(seq) { console.log("four"); seq.next(); }
}
});