README
pipeliner
Chain the execution of node-tasks.
API
pipeliner.run
Given a series of task configurations and some input, pass input into the first task, then run each subsequent task using the output of the previous task as the input for the next. Returns the return value of the last task in the pipeline.
pipeliner.run(pipeline, input)
pipeline
An array of objects with atask
andoptions
key, where task is a valid node-task and options are the options to pass to it when it is run.input
The input for the first task in the pipeline.
var pipeline = [
{ task: require('task-read'),
options: {
use: require('recordio-file')
}
},
{ task: require('task-concat'),
options: {
separator: '-'
}
},
{ task: require('task-wrap'),
options: {
header: '//header',
footer: '//footer'
}
},
{ task: require('task-write'),
options: {
use: require('recordio-file')
}
}
];
var input = [{
src: ['test/fixtures/foo.txt',
'test/fixtures/bar.txt',
'test/fixtures/baz.txt'],
dest: 'tmp/output.txt'
}];
pipeliner(pipeline, input);
pipeliner.plumb
A convenience method to make creating pipeline configurations easier. Returns a pipeline which can be passed to pipeliner.run
.
pipeliner.plumb(tasks, pipelines)
tasks
An object containing tasks to be mapped into a pipeline.pipeline
An array of task names that correspond to keys in thetasks
argument.
var tasks = {
read: {
task: require('task-read'),
options: {
use: require('recordio-file')
}
},
concat: {
task: require('task-concat'),
options: {
separator: '-'
}
},
wrap: {
task: require('task-wrap'),
options: {
header: '//header',
footer: '//footer'
}
},
write: {
task: require('task-write'),
options: {
use: require('recordio-file')
}
}
};
var pipeline = ['read', 'concat', 'wrap', 'write'];
pipeliner.plumb(tasks, pipeline);