push-queue

A simple async queue to do an action one at a time

push-queue

A simple async queue to do an action one at a time

var assert = require("assert")
var setTimeout = require("timers").setTimeout
 
var Queue = require("push-queue")
 
var started = false
 
var enqueue = Queue(function (itemcallback) {
    assert.equal(started, false)
    started = true
 
    console.log("doing", item)
 
    setTimeout(function () {
        console.log("finished", item)
        assert.equal(started, true)
        started = false
        callback()
    }, 100)
})
 
enqueue("one")
enqueue("two")
enqueue("three")

npm install push-queue

  • Raynos