Minor changes to types

This commit is contained in:
Jerry Kurian 2020-05-11 21:13:03 -04:00
parent 7113400cb1
commit 3c75ef88b4

View File

@ -12,7 +12,7 @@ export function demux(
pipelineConstructor: (
destKey?: string,
chunk?: any,
) => DemuxStreams | Array<DemuxStreams>,
) => DemuxStreams | DemuxStreams[],
demuxBy: string | ((chunk: any) => string),
options?: DemuxOptions,
): Duplex {
@ -21,20 +21,20 @@ export function demux(
class Demux extends Duplex {
private streamsByKey: {
[key: string]: Array<DemuxStreams>;
[key: string]: DemuxStreams[];
};
private demuxer: (chunk: any) => string;
private pipelineConstructor: (
destKey?: string,
chunk?: any,
) => Array<DemuxStreams>;
) => DemuxStreams[];
private remultiplex: boolean;
private transform: Transform;
constructor(
pipelineConstructor: (
destKey?: string,
chunk?: any,
) => DemuxStreams | Array<DemuxStreams>,
) => DemuxStreams | DemuxStreams[],
demuxBy: string | ((chunk: any) => string),
options: DemuxOptions = {},
) {
@ -81,7 +81,7 @@ class Demux extends Duplex {
});
}
const pipelines = this.streamsByKey[destKey];
let pendingDrains: Array<Promise<any>> = [];
const pendingDrains: Array<Promise<any>> = [];
pipelines.forEach(pipeline => {
if (!pipeline.write(chunk, encoding)) {
@ -99,7 +99,7 @@ class Demux extends Duplex {
}
public _flush() {
const pipelines: Array<DemuxStreams> = [].concat.apply(
const pipelines: DemuxStreams[] = [].concat.apply(
[],
Object.values(this.streamsByKey),
);
@ -121,7 +121,7 @@ class Demux extends Duplex {
}
public _destroy(error: any, cb: (error?: any) => void) {
const pipelines: Array<DemuxStreams> = [].concat.apply(
const pipelines: DemuxStreams[] = [].concat.apply(
[],
Object.values(this.streamsByKey),
);