Merge pull request #28671 from Alorel/through2-concurrent-types

Add through2-concurrent types
This commit is contained in:
Mine Starks
2018-09-07 16:24:23 -07:00
committed by GitHub
5 changed files with 86 additions and 8 deletions
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for through2-concurrent 2.0
// Project: https://github.com/almost/through2-concurrent
// Definitions by: Alorel <https://github.com/Alorel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
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;
@@ -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);
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+12 -8
View File
@@ -1,19 +1,19 @@
// Type definitions for through2 v 2.0
// Project: https://github.com/rvagg/through2
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, jedmao <https://github.com/jedmao>, Georgios Valotasios <https://github.com/valotas>
// Ben Chauvette < https://github.com/bdchauvette>, TeamworkGuy2 <https://github.com/TeamworkGuy2>
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>,
// jedmao <https://github.com/jedmao>,
// Georgios Valotasios <https://github.com/valotas>,
// Ben Chauvette < https://github.com/bdchauvette>,
// TeamworkGuy2 <https://github.com/TeamworkGuy2>,
// Alorel <https://github.com/Alorel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
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
*/