co-transform
1.1.0 • Public • Published co-transform
stream.Transform with generator
Usage
transform(generator, options)
generator
transform(function* () {
this instanceof require('stream').Transform;
let chunk = yield;
throw new Error('SomeError')
return
})
options
is stream.Transform options,
so, stream.Readable options and
stream.Writable options
example
String
const transform = require('co-transform');
process.stdin
.setEncoding('utf8')
.pipe(transform(function* () {
let chunk;
while(chunk = yield) {
this.push(chunk.toUpperCase());
}
}, {decodeStrings: false}))
.pipe(process.stdout);
Object
objectStream
.pipe(transform(function* () {
let obj;
while(obj = yield) {
this.push(obj);
}
}, {objectMode: true}))
.pipe(distStream);
Package Sidebar
Install
Weekly Downloads