Skip to content

Commit

Permalink
🤖 Merge PR #67108 fix: missing exports finished and pipeline by @tplu…
Browse files Browse the repository at this point in the history
…scode

* fix: missing exports

* test finished/pipeline

* style: fixed formatting
  • Loading branch information
tpluscode committed Nov 20, 2023
1 parent b7e92fe commit e245e11
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions types/readable-stream/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="node" />

import * as SafeBuffer from "safe-buffer";
import type * as NodeStream from "stream";

declare class StringDecoder {
constructor(encoding?: BufferEncoding | string);
Expand Down Expand Up @@ -658,6 +659,9 @@ declare namespace _Readable {
options?: { signal: AbortSignal },
): T;
}

const finished: typeof NodeStream.finished;
const pipeline: typeof NodeStream.pipeline;
}

export = _Readable;
Expand Down
27 changes: 27 additions & 0 deletions types/readable-stream/readable-stream-tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import stream = require("stream");
import RStream = require("readable-stream");
import { dot, spec, tap } from "node:test/reporters";
import ErrnoException = NodeJS.ErrnoException;

function testTypes() {
const ANY: any = undefined;
Expand Down Expand Up @@ -149,6 +150,32 @@ function test() {
};
}

function callback(err: ErrnoException | undefined | null) {
}

function testFinished() {
const _readable: stream.Readable = <any> {};
RStream.finished(_readable, callback);

const _writable: stream.Writable = <any> {};
RStream.finished(_writable, callback);

const _transform: stream.Transform = <any> {};
RStream.finished(_transform, callback);

const _duplex: stream.Duplex = <any> {};
RStream.finished(_duplex, callback);
}

function testPipeline() {
const _readable: stream.Readable = <any> {};
const _transform: stream.Transform = <any> {};
const _writable: stream.Writable = <any> {};

RStream.pipeline([_readable], callback);
RStream.pipeline([_readable], _transform, _writable, callback);
}

function assertType<T>(value: T, msg?: string): T {
if (!(typeof value)) throw new Error(msg);
return value;
Expand Down

0 comments on commit e245e11

Please sign in to comment.