WIP Add some backpressure tests for compose

This commit is contained in:
Jerry Kurian
2019-09-07 11:04:33 -04:00
parent d5f3fd8bd8
commit cd10649d44
7 changed files with 221 additions and 66 deletions

View File

@@ -1,11 +1,4 @@
import {
pipeline,
Duplex,
Transform,
Readable,
Writable,
DuplexOptions,
} from "stream";
import { pipeline, Duplex, DuplexOptions } from "stream";
/**
* Return a Readable stream of readable streams concatenated together
@@ -39,7 +32,7 @@ enum EventSubscription {
const eventsTarget = {
close: EventSubscription.Last,
data: EventSubscription.Last,
drain: EventSubscription.First,
drain: EventSubscription.Self,
end: EventSubscription.Last,
error: EventSubscription.Self,
finish: EventSubscription.Last,
@@ -56,6 +49,7 @@ type AllStreams =
| NodeJS.WritableStream;
export class Compose extends Duplex {
public writable: boolean;
private first: AllStreams;
private last: AllStreams;
private streams: AllStreams[];
@@ -75,9 +69,7 @@ export class Compose extends Duplex {
}
public _write(chunk: any, encoding: string, cb: any) {
const res = (this.first as NodeJS.WritableStream).write(chunk);
cb();
return res;
(this.first as NodeJS.WritableStream).write(chunk, encoding, cb);
}
public bubble(...events: string[]) {