mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for multipipe (#37860)
This commit is contained in:
parent
713f17231e
commit
5b1c88ac24
144
types/multipipe/index.d.ts
vendored
Normal file
144
types/multipipe/index.d.ts
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
// Type definitions for multipipe 3.0
|
||||
// Project: https://github.com/juliangruber/multipipe#readme
|
||||
// Definitions by: Michael de Wit <https://github.com/mjwwit>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import stream = require("stream");
|
||||
|
||||
/**
|
||||
* Pass a variable number of streams and each will be piped to the next one.
|
||||
*
|
||||
* A stream will be returned that wraps passed in streams in a way that errors will be forwarded and you can write to and/or read from it.
|
||||
*
|
||||
* Pass an object as the second to last or last argument to pass as options to the underlying stream constructors.
|
||||
*
|
||||
* Pass a function as last argument to be called on error or finish of the last stream.
|
||||
*/
|
||||
declare function multipipe(callback?: (err?: Error) => any): stream.PassThrough;
|
||||
declare function multipipe(options?: stream.DuplexOptions, callback?: (err?: Error) => any): stream.PassThrough;
|
||||
|
||||
declare function multipipe(stream: stream.Duplex | ReadonlyArray<stream.Stream>, callback?: (err?: Error) => any): stream.Duplex;
|
||||
declare function multipipe(stream: stream.Duplex | ReadonlyArray<stream.Stream>, options?: stream.DuplexOptions, callback?: (err?: Error) => any): stream.Duplex;
|
||||
|
||||
declare function multipipe(source: stream.Readable, destination: stream.Writable, callback?: (err?: Error) => any): stream.Duplex;
|
||||
declare function multipipe(source: stream.Readable, destination: stream.Writable, options?: stream.DuplexOptions, callback?: (err?: Error) => any): stream.Duplex;
|
||||
|
||||
declare function multipipe(source: stream.Readable, transform: stream.Duplex, destination: stream.Writable, callback?: (err?: Error) => any): stream.Duplex;
|
||||
declare function multipipe(source: stream.Readable, transform: stream.Duplex, destination: stream.Writable, options: stream.DuplexOptions, callback?: (err?: Error) => any): stream.Duplex;
|
||||
|
||||
declare function multipipe(source: stream.Readable, t1: stream.Duplex, t2: stream.Duplex, destination: stream.Writable, callback?: (err?: Error) => any): stream.Duplex;
|
||||
declare function multipipe(source: stream.Readable, t1: stream.Duplex, t2: stream.Duplex, destination: stream.Writable, options: stream.DuplexOptions, callback?: (err?: Error) => any): stream.Duplex;
|
||||
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
options: stream.DuplexOptions,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
t4: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
t4: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
options: stream.DuplexOptions,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
t4: stream.Duplex,
|
||||
t5: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
t4: stream.Duplex,
|
||||
t5: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
options: stream.DuplexOptions,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
t4: stream.Duplex,
|
||||
t5: stream.Duplex,
|
||||
t6: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
t4: stream.Duplex,
|
||||
t5: stream.Duplex,
|
||||
t6: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
options: stream.DuplexOptions,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
t4: stream.Duplex,
|
||||
t5: stream.Duplex,
|
||||
t6: stream.Duplex,
|
||||
t7: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
declare function multipipe(
|
||||
source: stream.Readable,
|
||||
t1: stream.Duplex,
|
||||
t2: stream.Duplex,
|
||||
t3: stream.Duplex,
|
||||
t4: stream.Duplex,
|
||||
t5: stream.Duplex,
|
||||
t6: stream.Duplex,
|
||||
t7: stream.Duplex,
|
||||
destination: stream.Writable,
|
||||
options: stream.DuplexOptions,
|
||||
callback?: (err?: Error) => any
|
||||
): stream.Duplex;
|
||||
|
||||
export = multipipe;
|
||||
32
types/multipipe/multipipe-tests.ts
Normal file
32
types/multipipe/multipipe-tests.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import stream = require('stream');
|
||||
import multipipe = require('multipipe');
|
||||
|
||||
let rws: stream.Duplex;
|
||||
|
||||
const rs = new stream.Readable();
|
||||
const ws = new stream.Writable();
|
||||
const ts = new stream.Transform();
|
||||
|
||||
rws = multipipe(rs, ws);
|
||||
rws = multipipe(rs, ws, { objectMode: true });
|
||||
rws = multipipe(rs, ws, err => {
|
||||
console.error(err);
|
||||
});
|
||||
rws = multipipe(rs, ws, { objectMode: true }, err => {
|
||||
console.error(err);
|
||||
});
|
||||
rws = multipipe(rs, ts, ws);
|
||||
rws = multipipe();
|
||||
rws = multipipe(ts);
|
||||
|
||||
// with an array of streams
|
||||
rws = multipipe([rs, ts, ws]);
|
||||
rws = multipipe([rs, ts, ws], { objectMode: true });
|
||||
rws = multipipe([rs, ts, ws], err => {
|
||||
console.error(err);
|
||||
});
|
||||
rws = multipipe([rs, ts, ws], { objectMode: true }, err => {
|
||||
console.error(err);
|
||||
});
|
||||
rws = multipipe([]);
|
||||
rws = multipipe([ts]);
|
||||
23
types/multipipe/tsconfig.json
Normal file
23
types/multipipe/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"multipipe-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/multipipe/tslint.json
Normal file
1
types/multipipe/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user