runn

Versitale and easy to use funciton running

npm install runn
4 downloads in the last week
8 downloads in the last month

Runn

Middleware style function invocation, run a series of asynchronus functions in order.

Example


var Runn = require('runn');

var run = new Runn();

// Runn callbacks are passed `data` and `done`.
// `done` is a callback that you fire manually when you function is done executing.
run.before(function(data, done){
    data.foo = 'bar';

    asyncOp(function(err, data){
        done(err);
    });
}, function(data, done){
    data = syncOp(data);
    done();
});

run.middle(function(data, done){
    db.update(query, data, function(err, data){
        data = data;
        done(err);
    });
});

run.after(function(data, done){
    data = translateObj(data);
    done();
});

run.exec({foo:'bar'}, function(err, data){
    console.log(err); // boolean
    console.log(data); // your data
});

API

Runn

Constructor, returns a fresh instance.

.before, .middle, .after

Accepts any number of named or anonymous functions as arguments. Runn will run these functions in series.

.exec

Accepts an Object and a callback.

When .exec is called, the functions passed into .before, .middle and .after will be executed in order, passing the first argument of the .exec method in each time.

Running Tests

$ npm test. The tests use http://github.com/visionmedia/mocha as their test runner.

npm loves you