0.0.2 • Published 11 years ago

coil v0.0.2

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

Coil

build status

Description

Tube is a simple library to control the flow.

Usage

On server install Tube via npm first

npm install tube

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,…argx-1, callback);

The argument from arg1 to argx-1 is set to the registered tasks.

callback has the argument from arg1 to argx-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);
  });
}

// …
0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago