cat-each - Creates a stream by concatenating new streams, each created by a factory from a list
var cat = require("cat-each");
// concatenate a few files; stream the result to standard output
cat(["header.txt", "body.txt", "footer.txt" ], fs.createReadStream)
.pipe(process.stdout);
Iterates over the provided list, creating a stream for each item. Returns a readable stream from which the concatenation of those streams may be read in the order provided.
Concatenate a list of files, while properly handling handling errors:
cat(process.argv.slice(2), function (f) {
return fs.createReadStream(f).on("error", function (e) {
console.error(
"%s: Could not open file or directory: %s",
f, e
);
});
}).pipe(process.stdout);
$ npm install
$ npm test
Me, Chris Taylor
- Not sure of a clean way to allow event emitters to be attached to the created streams. For now, the factory should fully prepare each stream (involving attaching any event listeners).