mirror of
https://github.com/mozilla/send.git
synced 2026-02-06 02:45:06 -05:00
24 lines
432 B
JavaScript
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;
|