sequeue
v2.1.1
Published
very basic sequential function queue
Downloads
20
Readme
sequeue
# installation
$ npm install sequeue
Sequeue can be used in node, with AMD (require.js) or without any module loader.
Node:
var sequeue = require('sequeue');
sequeue([
function(next) {
setTimeout(function() {
console.log(1);
next();
}, 1000);
},
function() {
console.log(2);
// last function should not call next()
// otherwise you will get an "undefined is not a function"
}
]);
// will output:
// 1
// 2
AMD:
define(['./sequeue'], function (sequeue) {
// usage
var sequeue = require('sequeue');
sequeue([
function(next) {
setTimeout(function() {
console.log(1);
next();
}, 1000);
},
function() {
console.log(2);
// last function should not call next()
// otherwise you will get an "undefined is not a function"
}
]);
// will output:
// 1
// 2
});
Without module loader:
(function(window) {
// usage
var sequeue = window.sequeue;
sequeue([
function(next) {
setTimeout(function() {
console.log(1);
next();
}, 1000);
},
function() {
console.log(2);
// last function should not call next()
// otherwise you will get an "undefined is not a function"
}
]);
// will output:
// 1
// 2
})(window);