1
0
mirror of https://gitlab.com/timvisee/send.git synced 2024-09-22 00:51:33 +02:00
send/server/streamparser.js
2018-06-25 11:26:48 -07:00

24 lines
432 B
JavaScript

const { Transform } = require('stream');
class StreamParser extends Transform {
constructor() {
super();
let res;
this.promise = new Promise(resolve => {
res = resolve;
});
this.res = res;
}
_transform(chunk, encoding, callback) {
if (chunk.byteLength === 1 && chunk[0] === 0) {
this.res();
} else {
this.push(chunk);
}
callback();
}
}
module.exports = StreamParser;