stream footer
This commit is contained in:
parent
a4cf46c0eb
commit
9d04514f8e
3 changed files with 36 additions and 8 deletions
23
server/streamparser.js
Normal file
23
server/streamparser.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
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;
|
Loading…
Add table
Add a link
Reference in a new issue