const readable = new Readable({
read: function () {
try {
let chunk: string;
let canPush = true;
// Push all chunks as long as we can push and as long as
// the underlying reader returns strings to us
while (canPush && typeof (chunk = reader.read()) === 'string') {
canPush = this.push(chunk);
}
// Signal EOS by pushing NULL
if (typeof chunk !== 'string') {
this.push(null);
}
} catch (error) {
this.emit('error', error);
}
}
});
In this case I am happily calling this.push(null) even though maybe the last push signald I should wait?
Thanks for feedback,
Ben