Skip to content

Commit

Permalink
Add Pipeline helper type
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Jan 10, 2025
1 parent 49e535f commit 2e82db8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ declare class Transform<
constructor(opts?: TransformOptions)
}

type Pipeline<S extends Writable> = [
src: Readable,
...transforms: Duplex[],
dest: S
]

declare namespace Stream {
export {
Stream,
Expand All @@ -192,13 +198,16 @@ declare namespace Stream {
Transform as PassThrough
}

export function pipeline(streams: Stream[], done?: StreamCallback): Stream
export function pipeline<S extends Writable>(
streams: Pipeline<S>,
cb?: StreamCallback
): S

export function pipeline(
...args: [stream: Stream, ...streams: Stream[], done: StreamCallback]
): Stream
export function pipeline<S extends Writable>(...args: [...Pipeline<S>]): S

export function pipeline(stream: Stream, ...streams: Stream[]): Stream
export function pipeline<S extends Writable>(
...args: [...Pipeline<S>, cb: StreamCallback]
): S

export function finished(
stream: Stream,
Expand Down

0 comments on commit 2e82db8

Please sign in to comment.