Improve interface for accumulator

This commit is contained in:
Jerry Kurian
2019-09-12 14:40:47 -04:00
parent 517e281ce5
commit 4c7e9ceb7e
5 changed files with 86 additions and 50 deletions

View File

@@ -58,7 +58,21 @@ class Demux extends Writable {
this.streamsByKey[destKey] = this.construct(destKey);
}
if (!this.streamsByKey[destKey].write(chunk, encoding)) {
console.log(
"waiting drain",
chunk,
this._writableState.length,
this.streamsByKey[destKey]._writableState.length,
this.streamsByKey[destKey]._readableState.length,
);
this.streamsByKey[destKey].once("drain", () => {
console.log(
"calling cb after drain",
chunk,
this._writableState.length,
this.streamsByKey[destKey]._writableState.length,
this.streamsByKey[destKey]._readableState.length,
);
cb();
});
} else {