0.3.2 • Published 8 years ago

autoq v0.3.2

Weekly downloads
18
License
MIT
Repository
github
Last release
8 years ago

autoq

Simple automatic, dynamic callback queue for node.

NPM Version NPM Downloads

AutoQ lets you chain functions as you need to create them, without needing to juggle Promise objects manually. The main benefit is that you can provide a running asynchronous function with a callback you're generating dynamically (possibly in another asynchronous function).

Installation

$ npm install autoq

Usage

const AutoQ = require('autoq')
const autoq = new AutoQ((err) => {
    console.log('Error during autoq: ', err)
})

autoq.add((arg, next) => {

    // Do something asynchronous.
    setTimeout(function () {
        console.log(arg) // null
        // Pass an argument to the next iteration.
        next(5)
    }, 500)

})

autoq.add((arg, next) => {

    console.log(arg) // 5

    if (arg === 5) {
        // Will be caught by error handler provided
        // by the constructor.
        throw "I don't like the number 5."
    } else {
        setTimeout(function () {
            next(arg + 1)
        }, 500)
    }

})

License

MIT

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago