mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #28813 from dex4er/node
node: stream.finished function
This commit is contained in:
Vendored
+5
@@ -6415,6 +6415,11 @@ declare module "stream" {
|
||||
|
||||
export class PassThrough extends Transform { }
|
||||
|
||||
export function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, callback: (err?: NodeJS.ErrnoException) => void): () => void;
|
||||
export namespace finished {
|
||||
export function __promisify__(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream): Promise<void>;
|
||||
}
|
||||
|
||||
export function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: T, callback?: (err: NodeJS.ErrnoException) => void): T;
|
||||
export function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: T, callback?: (err: NodeJS.ErrnoException) => void): T;
|
||||
export function pipeline<T extends NodeJS.WritableStream>(stream1: NodeJS.ReadableStream, stream2: NodeJS.ReadWriteStream, stream3: NodeJS.ReadWriteStream, stream4: T, callback?: (err: NodeJS.ErrnoException) => void): T;
|
||||
|
||||
@@ -1123,6 +1123,21 @@ function simplified_stream_ctor_test() {
|
||||
});
|
||||
}
|
||||
|
||||
function streamPipelineFinished() {
|
||||
const cancel = stream.finished(process.stdin, (err?: Error) => {});
|
||||
cancel();
|
||||
|
||||
stream.pipeline(process.stdin, process.stdout, (err?: Error) => {});
|
||||
}
|
||||
|
||||
async function asyncStreamPipelineFinished() {
|
||||
const finished = util.promisify(stream.finished);
|
||||
await finished(process.stdin);
|
||||
|
||||
const pipeline = util.promisify(stream.pipeline);
|
||||
await pipeline(process.stdin, process.stdout);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
/// Crypto tests : http://nodejs.org/api/crypto.html ///
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user