pumpify: add ctor args, duplexify members, tests (#25524)

* pumpify: add ctor args, duplexify members, tests

* pumpify: add autoDestroy to PumpifyFactoryOptions
This commit is contained in:
Ankur Oberoi
2018-05-07 14:09:10 -07:00
committed by Sheetal Nandi
parent 08e6b3d918
commit e178856691
3 changed files with 33 additions and 10 deletions
+24 -6
View File
@@ -1,17 +1,35 @@
// Type definitions for pumpify 1.4
// Project: https://github.com/mafintosh/pumpify
// Definitions by: Justin Beckwith <https://github.com/JustinBeckwith>
// Ankur Oberoi <https://github.com/aoberoi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Stream, Duplex } from 'stream';
import { Stream, Writable, Readable, Duplex } from 'stream';
import * as duplexify from 'duplexify';
export = pumpify;
declare class Pumpify extends Duplex implements duplexify.Duplexify {
constructor(...streams: Stream[]);
constructor(streams: Stream[]);
setPipeline(...streams: Stream[]): void;
setPipeline(streams: Stream[]): void;
declare class pumpify extends Duplex {
constructor();
setPipeline(...args: Stream[]): void;
// Duplexify members
setWritable(writable: Writable): void;
setReadable(readable: Readable): void;
}
declare namespace pumpify {}
interface PumpifyFactoryOptions {
autoDestroy: boolean;
destroy: boolean;
objectMode: boolean;
highWaterMark: number;
}
declare namespace Pumpify {
let obj: typeof Pumpify;
function ctor(opts: PumpifyFactoryOptions): typeof Pumpify;
}
export = Pumpify;
+9 -3
View File
@@ -1,7 +1,11 @@
import pumpify from 'pumpify';
import { Duplex, Transform, PassThrough } from 'stream';
import * as Pumpify from 'pumpify';
import { Duplex, Transform, PassThrough, Writable } from 'stream';
class Pumpy extends pumpify {
new Pumpify();
new Pumpify(new Writable(), new Writable());
const pumpify = new Pumpify([new Writable(), new Writable()]);
class Pumpy extends Pumpify {
constructor() {
super();
const dup1 = new Duplex();
@@ -12,3 +16,5 @@ class Pumpy extends pumpify {
const pumpy = new Pumpy();
pumpy.pipe(new PassThrough());
pumpify.setPipeline(pumpy);
-1
View File
@@ -8,7 +8,6 @@
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "../",
"typeRoots": [
"../"