A function pipe eases the construction of extensible processing pipelines.
Each step in the pipeline takes the result of the prior step as input, and produces its own result, which in turn, is used by the next step in the pipeline, until processing is complete and a final result is produced. Each step in the pipeline can be thought of as middleware, but unlike the connect framework, the inputs and outputs are not related to nodejs' original callback pattern.
2018 Breaking Changes
The 2018 version 1.0.0 has very little in common with the version published in 2012. The 2018 version of the
Pipe is exclusively ES6, and is intended for use in nodejs.
Create a pipeline by constructing an instance of the
Pipe class, optionally specifying initial processing steps, then as needed, add additional processing steps using the
.pipe() method, and eventually, execute the pipeline using the
const res = await fn1;console;
The result of each step in the process cascades into the next step, just like
arg ---vfn1(arg1) ---vfn2(arg2) ---vfn3(arg3) ---vresult
The constructor can take multiple steps...
const res = await fn1 fn2 fn3;console;
.pipe() can take multiple steps...
const res = await fn2;
Arguments passed to
.process() are projected into the first step...
const res = await x + y;
Each step's result can be projected down stream in the pipe...
const res = await x * 2 y * 5 true;
Errors propagate to the caller...
const stdout = consolelog;tryconst res = await;catch errassert;