filt is for simple filters:
node -e 'require("filt")(line => line.toUpperCase())'
This module allows you to quickly write command-line filters - programs that read standard input line by line and print something on standard output.
It prints an extra newline at the end - the split module used internally is apparently running the callback with an extra empty line at the end when there is none - I need to fix it.
Install to use in your project, updating the dependencies in package.json:
npm install filt --save
It currently has one dependency: split ...
Require the module:
var filt = require('filt');
Now filt
is a function that gets a function that is called for each line of stdin.
Most basic usage:
filt(function (line) {
console.log(line.toUpperCase());
});
Instead of calling console.log()
you can also return a line to print:
filt(function (line) {
return line.toUpperCase();
});
The same using ES6 syntax:
filt(line => line.toUpperCase());
Using require in the same line - this is the entire program:
require('filt')(line => line.toUpperCase());
Or straight from the command line:
node -e 'require("filt")(line => line.toUpperCase());'
For any bug reports or feature requests please post an issue on GitHub.
Rafał Pocztarski - https://github.com/rsp
MIT License (Expat). See LICENSE.md for details.