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