Skip to content

Commit

Permalink
Make the NodeStream type more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 13, 2019
1 parent c25b606 commit aeb3f74
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference lib="es2018"/>
/// <reference lib="dom"/>
/// <reference types="node"/>

export type Class<T = unknown> = new (...args: any[]) => T;

Expand Down Expand Up @@ -330,8 +331,9 @@ is.observable = (value: unknown): value is ObservableLike => {
return false;
};

// eslint-disable-next-line @typescript-eslint/ban-types
export type NodeStream = object & {readonly pipe: Function};
export interface NodeStream extends NodeJS.EventEmitter {
pipe<T extends NodeJS.WritableStream>(destination: T, options?: {end?: boolean}): T;
}

is.nodeStream = (value: unknown): value is NodeStream => is.object(value) && is.function_((value as NodeStream).pipe) && !is.observable(value);

Expand Down

0 comments on commit aeb3f74

Please sign in to comment.