chain-of-command
Background
Many commands can be piped together on the command line, to accomplish a task that the single programs can't do alone. There are several advantages to this. For one, the generation of intermediate files between steps can be reduced, or even eliminated totally.
This is accomplished using standard streams. Read the wikipedia article on the subject for more details.
chain-of-command is a Node module that simplifies the task of executing commands from Node. You can take the result of a command, a file, or a stream as the input. You can write the output to a file, or return it as a stream.
Author
- Werner Vesterås wvesteraas@gmail.com
Installation
As with any Node module, use the Node Package Manager to install it:
$ npm install chain-of-command
Usage
var Chain = ; var chain = ; chain ;
In the example above, we do the same as:
ls -l | grep "A" | sort > out.txt
A slightly modified example:
var chain = ; var stream = chain ;
The difference here, is that we return a stream. We could pipe it directly to the response object in a HTTP request:
app;
You can also use a file as the input:
var chain = ; var stream = chain ;
Piping from request to response is also possible:
app;
Examples
See the examples directory.