Nightmarish Pawnshop Mystic
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    coilpublic

    Coil

    build status

    Description

    Coil is a simple library to control the flow.

    Usage

    On server install Coil via npm first

    npm install coil
    

    and then include it in your project with:

    var myCoil = require('coil').create();
    

    api

    coil#use(task1, task2..)

    function to make it processing in pipeline can be registered.

    task to make it processing in parallel is realizable by passing more than one as an argument at once.

    coil#handle(arg1, arg2,…arg[x-1], callback);

    The argument from arg1 to arg[x-1] is set to the registered tasks.

    callback has the argument from arg1 to arg[x-1] and error which were passed to handle set, and is called after an end of task.

    Example

    The following codes are the examples of the module which changes the parameter in pipeline.

    var paramConverter = require('coil').create()
      , model = require('some/data/access/object')
      ;
    
    paramConverter.use(convertA);
    paramConverter.use(convertB);
    paramConverter.use(convertC);
    paramConverter.use(convertD);
    
    exports.handle = function (param, callback) {
      paramConverter.handle(param. callback);
    };
    
    function convertA(param, next) {
      model.get('A', function (err, data) {
        param.a = data;
        next(err);
      });
    }
    
    function convertB(param, next) {
      model.get('B', function (err, data) {
        param.b = data;
        next(err);
      });
    }
    
    // …
    

    Registration of processing can also be performed in parallel.

    var paramConverter = require('coil').create()
      , model = require('some/data/access/object')
      ;
    
    paramConverter.use(convertA);
    paramConverter.use(convertB, convertC); // parallel call
    paramConverter.use(convertD);
    
    exports.handle = function (param, callback) {
      paramConverter.handle(param. callback);
    };
    
    function convertA(param, next) {
      model.get('A', function (err, data) {
        param.a = data;
        next(err);
      });
    }
    
    function convertB(param, next) {
      model.get('B', function (err, data) {
        param.b = data;
        next(err);
      });
    }
    
    // …
    

    Keywords

    none

    install

    npm i coil

    Downloadslast 7 days

    1

    version

    0.0.2

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar