0.0.1 • Published 8 years ago

ulmo-partial-map v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

ulmo-partial-map

Create Transform streams to perform conditionally map values or pass them through.

const read = require("fs").createReadStream;
const es = require("event-stream");
const partial = require("ulmo-partial-map");
const transform = require("ulmo-transform");

// read file.txt and uppercase lines containing the word 'apple'
read("file.txt", {encoding: "utf8"})
    .pipe(es.split())                       // split on newline
    .pipe(partial(a => /apple/.test(a), a => a.toUpperCase()))
    .pipe(transform(function(chunk, done) { // put newlines back in
        this.push(chunk);
        this.push("\n");
        done();
    }));
}
0.0.1

8 years ago