fox-send/server/streamparser.js

16 lines
298 B
JavaScript
Raw Normal View History

2018-06-25 21:01:08 +00:00
const { Duplex } = require('stream');
2018-06-25 18:26:48 +00:00
2018-06-25 21:01:08 +00:00
class StreamParser extends Duplex {
_write(chunk, encoding, callback) {
2018-06-25 18:26:48 +00:00
if (chunk.byteLength === 1 && chunk[0] === 0) {
2018-06-25 21:01:08 +00:00
this.push(null);
2018-06-25 18:26:48 +00:00
} else {
this.push(chunk);
}
callback();
}
2018-06-25 21:01:08 +00:00
_read() {}
2018-06-25 18:26:48 +00:00
}
module.exports = StreamParser;