Lots of stuff

This commit is contained in:
Jerry Kurian
2019-09-09 14:43:18 -04:00
parent ea2ffdb38c
commit eed36a4fe9
3 changed files with 22 additions and 590 deletions

View File

@@ -118,4 +118,23 @@ class Demux extends Writable {
}
return this;
}
public once(event: string, cb: any) {
switch (eventsTarget[event]) {
case EventSubscription.Self:
super.once(event, cb);
break;
case EventSubscription.All:
Object.keys(this.streamsByKey).forEach(key =>
this.streamsByKey[key].stream.once(event, cb),
);
break;
case EventSubscription.Unhandled:
throw new Error(
"Stream must be multiplexed before handling this event",
);
default:
super.once(event, cb);
}
return this;
}
}