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