Skip to content

Commit

Permalink
fix(fromnodestream): type fromNodeStream to accept NodeJS.ReadableStr…
Browse files Browse the repository at this point in the history
…eam interface
  • Loading branch information
trxcllnt committed Nov 19, 2017
1 parent 8f1ebd6 commit 3cbf2dd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/asynciterable/fromnodestream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Readable } from 'stream';
import { AsyncIterableX } from './asynciterablex';

const NON_FLOWING = 0;
Expand All @@ -8,13 +7,13 @@ const ERRORED = 3;

export class ReadableStreamAsyncIterable extends AsyncIterableX<string | Buffer>
implements AsyncIterator<string | Buffer> {
private _stream: Readable;
private _stream: NodeJS.ReadableStream;
private _size?: number;
private _state: number;
private _error: any;
private _rejectFns: Set<(err: any) => void>;

constructor(stream: Readable, size?: number) {
constructor(stream: NodeJS.ReadableStream, size?: number) {
super();
this._stream = stream;
this._size = size;
Expand Down Expand Up @@ -92,6 +91,9 @@ export class ReadableStreamAsyncIterable extends AsyncIterableX<string | Buffer>
}
}

export function fromNodeStream(stream: Readable, size?: number): AsyncIterableX<string | Buffer> {
export function fromNodeStream(
stream: NodeJS.ReadableStream,
size?: number
): AsyncIterableX<string | Buffer> {
return new ReadableStreamAsyncIterable(stream, size);
}

0 comments on commit 3cbf2dd

Please sign in to comment.