diff --git a/through2/through2-0.4.2-test.ts b/through2/through2-0.4.2-test.ts
new file mode 100644
index 0000000000..79bfef2e27
--- /dev/null
+++ b/through2/through2-0.4.2-test.ts
@@ -0,0 +1,44 @@
+///
+///
+
+import through2 = require('through2');
+
+var rws: NodeJS.ReadWriteStream;
+
+rws = through2({
+ objectMode: true,
+ allowHalfOpen: true
+}, function (entry: any, enc: string, callback: () => void) {
+ this.push('foo');
+ callback();
+}, () => {
+
+});
+
+rws = through2(function (entry: any, enc: string, callback: () => void) {
+ this.push('foo');
+ callback();
+}, () => {
+
+});
+
+rws = through2(function (entry: any, enc: string, callback: () => void) {
+ this.push('foo');
+ callback();
+});
+
+rws = through2();
+
+// obj
+rws = through2.obj(function (entry: any, enc: string, callback: () => void) {
+ this.push('foo');
+ callback();
+}, () => {
+
+});
+
+rws = through2.obj(function (entry: any, enc: string, callback: () => void) {
+ this.push('foo');
+ callback();
+});
+
diff --git a/through2/through2-0.4.2.d.ts b/through2/through2-0.4.2.d.ts
new file mode 100644
index 0000000000..7481fa910f
--- /dev/null
+++ b/through2/through2-0.4.2.d.ts
@@ -0,0 +1,26 @@
+// Type definitions for through2 v 0.4.2
+// Project: https://github.com/rvagg/through2
+// Definitions by: Bart van der Schoor , jedmao
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module 'through2' {
+
+ import stream = require('stream');
+
+ function through2(transform?: (chunk: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
+
+ function through2(opts?: stream.DuplexOptions, transform?: (chunk: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
+
+ module through2 {
+
+ export function obj(transform?: (chunk: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
+
+ export function push(data: any): void;
+
+ }
+
+ export = through2;
+
+}
diff --git a/through2/through2-tests.ts b/through2/through2-tests.ts
index 6ea9a52d5f..e6f97fb712 100644
--- a/through2/through2-tests.ts
+++ b/through2/through2-tests.ts
@@ -22,6 +22,12 @@ rws = through2(function (entry: any, enc: string, callback: () => void) {
});
+rws = through2(function (entry: any, enc: string, callback: (error: any, data?: any) => void) {
+ callback(null, 'foo');
+}, (flushCallback: () => void) => {
+ flushCallback();
+});
+
rws = through2(function (entry: any, enc: string, callback: () => void) {
this.push('foo');
callback();
@@ -42,3 +48,8 @@ rws = through2.obj(function (entry: any, enc: string, callback: () => void) {
callback();
});
+rws = through2.obj(function (entry: any, enc: string, callback: (err: any) => void) {
+ callback('Oups!');
+}, (flashCallback) => {
+ flashCallback();
+});
diff --git a/through2/through2.d.ts b/through2/through2.d.ts
index 7481fa910f..32e566e72e 100644
--- a/through2/through2.d.ts
+++ b/through2/through2.d.ts
@@ -1,6 +1,6 @@
-// Type definitions for through2 v 0.4.2
+// Type definitions for through2 v 2.0.0
// Project: https://github.com/rvagg/through2
-// Definitions by: Bart van der Schoor , jedmao
+// Definitions by: Bart van der Schoor , jedmao , Georgios Valotasios
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///
@@ -8,14 +8,18 @@
declare module 'through2' {
import stream = require('stream');
+
+ type TransfofmCallback = (err?: any, data?: any) => void;
+ type TransformFunction = (chunk: any, enc: string, callback: TransfofmCallback) => void;
+ type FlashCallback = (flushCallback: () => void) => void;
- function through2(transform?: (chunk: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
+ function through2(transform?: TransformFunction, flush?: FlashCallback): NodeJS.ReadWriteStream;
- function through2(opts?: stream.DuplexOptions, transform?: (chunk: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
+ function through2(opts?: stream.DuplexOptions, transform?: TransformFunction, flush?: FlashCallback): NodeJS.ReadWriteStream;
module through2 {
- export function obj(transform?: (chunk: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
+ export function obj(transform?: TransformFunction, flush?: FlashCallback): NodeJS.ReadWriteStream;
export function push(data: any): void;