Skip to content

Instantly share code, notes, and snippets.

@ipiyer
Last active January 5, 2018 19:35
Show Gist options
  • Select an option

  • Save ipiyer/24fd8583255e1dd280ecb02c1f18aa01 to your computer and use it in GitHub Desktop.

Select an option

Save ipiyer/24fd8583255e1dd280ecb02c1f18aa01 to your computer and use it in GitHub Desktop.
const { Transform } = require('stream');
const {aStream, bStream } = require("other_file");
class Convert extends Transform {
constructor() {
super();
this.aStream
.pipe(bStream)
bStream
.on('data', data => this.cb(null, this.chunk));
}
_transform(chunk, encoding, cb) {
// is there a better way to do this without assigining cb to this?
this.cb = cb;
this.chunk = chunk;
this.aStream.write(chunk);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment