fnsequence

0.0.4 • Public • Published

fnsequence

build status

run function in sequence

Instalation

bower

$ bower i --save fnsequence

npm

$ npm i --save fnsequence

Example

    var fnsequence = require('fnsequence');

    var f1 = function(ctx) {
        ctx.data = 'hello';
    };
    var f2 = function(ctx) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                ctx.asyncdata = 'foo';
                resolve();
            }, 10);
        });
    };
    var f3 = function(ctx) {
        ctx.data2 = new Date();
    };
    var f4 = function(ctx) {
        ctx.data = ctx.data + ' world';
    };

    var f = fnsequence(f1, [f2, f3], f4);
    f().then(function(ctx) {
        console.log(ctx); 
        // {data: 'hello world', data2: Wed May 25 2016 17:55:47 GMT+0300 (EEST), asyncdata: 'foo'}
    });

Readme

Keywords

Package Sidebar

Install

npm i fnsequence

Weekly Downloads

1

Version

0.0.4

License

ISC

Last publish

Collaborators

  • trskldn