Update demux

This commit is contained in:
Jerry Kurian 2019-11-27 16:55:13 -05:00
parent 9b31479406
commit c690185ab7
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@jogogo/mhysa",
"version": "0.0.1-beta.2",
"version": "0.0.1-beta.4",
"description": "Streams and event emitter utils for Node.js",
"keywords": [
"promise",

View File

@ -51,10 +51,10 @@ class Demux extends Writable {
this.streamsByKey = {};
}
public _write(chunk: any, encoding: any, cb: any) {
public async _write(chunk: any, encoding: any, cb: any) {
const destKey = this.demuxer(chunk);
if (this.streamsByKey[destKey] === undefined) {
this.streamsByKey[destKey] = this.construct(destKey);
this.streamsByKey[destKey] = await this.construct(destKey);
}
if (!this.streamsByKey[destKey].write(chunk, encoding)) {
this.streamsByKey[destKey].once("drain", () => {