send/server/streamparser.js
2018-06-25 14:27:56 -07:00

15 lines
298 B
JavaScript

const { Duplex } = require('stream');
class StreamParser extends Duplex {
_write(chunk, encoding, callback) {
if (chunk.byteLength === 1 && chunk[0] === 0) {
this.push(null);
} else {
this.push(chunk);
}
callback();
}
_read() {}
}
module.exports = StreamParser;