added defs for some (stream) utils

This commit is contained in:
Bart van der Schoor
2014-05-26 14:31:30 +02:00
parent 568cb00761
commit cc82b36997
10 changed files with 163 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
/// <reference path="./through2.d.ts" />
/// <reference path="../node/node.d.ts" />
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();
});
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for through2 v 0.4.2
// Project: https://github.com/rvagg/through2
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module 'through2' {
import stream = require('stream');
var mod: mod.Through2;
module mod {
interface Through2 {
(transform?: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
(opts: stream.DuplexOptions, transform?: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
obj(transform: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
push(data: any): void;
}
}
export = mod;
}