tq

tiny queue

 
var queue = require('tq').queue();
 
 
 
queue.push(function() {
    console.log('next');
 
    this();
 
}).
push(function() {
    
    console.log("next");
 
    this();
}).
start();
 

Another variation

var queue = require('tq').queue();
 
 
[
    function() {
        this();
    },
    function() {
        this()
    },
    function() {
        this();
    }
].forEach(queue.push);
 
queue.start();

pushes a queue to the end

pushes a queue to the beginning (next up)

starts a queue

stops a queue