streamparser.js 298 B

123456789101112131415
  1. const { Duplex } = require('stream');
  2. class StreamParser extends Duplex {
  3. _write(chunk, encoding, callback) {
  4. if (chunk.byteLength === 1 && chunk[0] === 0) {
  5. this.push(null);
  6. } else {
  7. this.push(chunk);
  8. }
  9. callback();
  10. }
  11. _read() {}
  12. }
  13. module.exports = StreamParser;