1.0.12 • Published 10 years ago

pipejs v1.0.12

Weekly downloads
76
License
ISC
Repository
github
Last release
10 years ago

PipeJS

PipeEach and Pipe

npm install pipejs

var Pipe = require('pipejs').Pipe;

var PipeEach = require('pipejs').PipeEach;

##Using Pipe

var Pipe = require('pipejs').Pipe;
var hooks = require('./hooks');
var data = {
    field: {
        "title": "Android Widget",
        "name": "watch",
    }
};

var pipeLine = new Pipe();
pipeline.props ={
    customDataToPass:'some data'
};
pipeLine
    .use(hooks.addArray)
    .use(hooks.addSomeText) 
    //OR
    .use(function(err, obj, next, props) {
        // Use 'porps.customDataToPass' in your handlers 
        if (err) {
            console.log(err);
            return;
        }
        obj.field.newField = 'new field added';
        next();
    })
    .run(data)
    .done(function(errors, data, props){
        //errors - Array of errors
        //data - your modified data
        //props - your props (Can be ued for mutated data result or gouping)
    });

##Using PipeEach

var PipeEach = require('pipejs').PipeEach;
var hooks = require('./hooks');
var data = [{
    data: {
        "title": "Android Widget",
        "name": "watch",
    }
}, {
    data: {
        "title": "iPhone Widget",
        "name": "watch",
    }
}];
var iterator = new PipeEach();
pipeline.props ={
    customDataToPass:'some data'
};
iterator
    .use(hooks.addArray)
    .use(hooks.addSomeText) 
    //OR
    .use(function(err, obj, next, props) { 
         // Use 'porps.customDataToPass' in your handlers
        if (err) {
            console.log(err);
            return;
        }
        obj.data.newField = 'new field added';
        next();
    })
    .run(data)
    .done(function(errors, data, props) {
        //errors - Array of errors
        //data - your modified data
        //props - your props (Can be ued for mutated data result or gouping)
        console.log('Errors', errors);
        console.log('Data', data);
    });
    
1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago