diff --git a/types/through2-concurrent/index.d.ts b/types/through2-concurrent/index.d.ts new file mode 100644 index 0000000000..c4c0928b38 --- /dev/null +++ b/types/through2-concurrent/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for through2-concurrent 2.0 +// Project: https://github.com/almost/through2-concurrent +// Definitions by: Alorel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { TransformFunction, FlushCallback } from 'through2'; +import { DuplexOptions, Transform as TransformStream } from 'stream'; + +declare function through2Concurrent(transform?: TransformFunction, flush?: FlushCallback): TransformStream; +declare function through2Concurrent(opts?: through2Concurrent.Through2ConcurrentOptions, transform?: TransformFunction, flush?: FlushCallback): TransformStream; + +declare namespace through2Concurrent { + interface Through2ConcurrentOptions extends DuplexOptions { + maxConcurrency?: number; + } + + function obj(transform?: TransformFunction, flush?: FlushCallback): TransformStream; + function obj(opts?: Through2ConcurrentOptions, transform?: TransformFunction, flush?: FlushCallback): TransformStream; +} + +export = through2Concurrent; diff --git a/types/through2-concurrent/through2-concurrent-tests.ts b/types/through2-concurrent/through2-concurrent-tests.ts new file mode 100644 index 0000000000..f76c2b4d6d --- /dev/null +++ b/types/through2-concurrent/through2-concurrent-tests.ts @@ -0,0 +1,27 @@ +import * as through2 from 'through2-concurrent'; +import { Transform } from 'stream'; + +let str: Transform; + +const transformFn = (err: any, data: any) => {}; +function flushCb(this: Transform, cb: () => void) { + cb(); +} +const opts = { + allowHalfOpen: false, + maxConcurrency: 5 +}; + +str = through2(); +str = through2(opts); +str = through2(transformFn); +str = through2(opts, transformFn); +str = through2(transformFn, flushCb); +str = through2(opts, transformFn, flushCb); + +str = through2.obj(); +str = through2.obj(opts); +str = through2.obj(transformFn); +str = through2.obj(opts, transformFn); +str = through2.obj(transformFn, flushCb); +str = through2.obj(opts, transformFn, flushCb); diff --git a/types/through2-concurrent/tsconfig.json b/types/through2-concurrent/tsconfig.json new file mode 100644 index 0000000000..ecd3066d61 --- /dev/null +++ b/types/through2-concurrent/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "through2-concurrent-tests.ts" + ] +} diff --git a/types/through2-concurrent/tslint.json b/types/through2-concurrent/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/through2-concurrent/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/through2/index.d.ts b/types/through2/index.d.ts index 3ff12ff86d..e24c15a3e3 100644 --- a/types/through2/index.d.ts +++ b/types/through2/index.d.ts @@ -1,19 +1,19 @@ // Type definitions for through2 v 2.0 // Project: https://github.com/rvagg/through2 -// Definitions by: Bart van der Schoor , jedmao , Georgios Valotasios -// Ben Chauvette < https://github.com/bdchauvette>, TeamworkGuy2 +// Definitions by: Bart van der Schoor , +// jedmao , +// Georgios Valotasios , +// Ben Chauvette < https://github.com/bdchauvette>, +// TeamworkGuy2 , +// Alorel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// import stream = require('stream'); -type TransformCallback = (err?: any, data?: any) => void; -type TransformFunction = (this: stream.Transform, chunk: any, enc: string, callback: TransformCallback) => void; -type FlushCallback = (this: stream.Transform, flushCallback: () => void) => void; - -declare function through2(transform?: TransformFunction, flush?: FlushCallback): stream.Transform; -declare function through2(opts?: stream.DuplexOptions, transform?: TransformFunction, flush?: FlushCallback): stream.Transform; +declare function through2(transform?: through2.TransformFunction, flush?: through2.FlushCallback): stream.Transform; +declare function through2(opts?: stream.DuplexOptions, transform?: through2.TransformFunction, flush?: through2.FlushCallback): stream.Transform; declare namespace through2 { interface Through2Constructor extends stream.Transform { @@ -21,6 +21,10 @@ declare namespace through2 { (opts?: stream.DuplexOptions): stream.Transform; } + type TransformCallback = (err?: any, data?: any) => void; + type TransformFunction = (this: stream.Transform, chunk: any, enc: string, callback: TransformCallback) => void; + type FlushCallback = (this: stream.Transform, flushCallback: () => void) => void; + /** * Convenvience method for creating object streams */