WritableStream.js 502 B

123456789101112131415161718192021
  1. module.exports = Stream;
  2. var Parser = require("./Parser.js"),
  3. WritableStream = require("stream").Writable || require("readable-stream").Writable;
  4. function Stream(cbs, options){
  5. var parser = this._parser = new Parser(cbs, options);
  6. WritableStream.call(this, {decodeStrings: false});
  7. this.once("finish", function(){
  8. parser.end();
  9. });
  10. }
  11. require("util").inherits(Stream, WritableStream);
  12. WritableStream.prototype._write = function(chunk, encoding, cb){
  13. this._parser.write(chunk);
  14. cb();
  15. };