From e178856691dbdfafd1cd91e5e14f1f79d8c33892 Mon Sep 17 00:00:00 2001 From: Ankur Oberoi Date: Mon, 7 May 2018 14:09:10 -0700 Subject: [PATCH] pumpify: add ctor args, duplexify members, tests (#25524) * pumpify: add ctor args, duplexify members, tests * pumpify: add autoDestroy to PumpifyFactoryOptions --- types/pumpify/index.d.ts | 30 ++++++++++++++++++++++++------ types/pumpify/pumpify-tests.ts | 12 +++++++++--- types/pumpify/tsconfig.json | 1 - 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/types/pumpify/index.d.ts b/types/pumpify/index.d.ts index 474484b95b..067847b1df 100644 --- a/types/pumpify/index.d.ts +++ b/types/pumpify/index.d.ts @@ -1,17 +1,35 @@ // Type definitions for pumpify 1.4 // Project: https://github.com/mafintosh/pumpify // Definitions by: Justin Beckwith +// Ankur Oberoi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -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; diff --git a/types/pumpify/pumpify-tests.ts b/types/pumpify/pumpify-tests.ts index d4dff3bd70..1060c66df0 100644 --- a/types/pumpify/pumpify-tests.ts +++ b/types/pumpify/pumpify-tests.ts @@ -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); diff --git a/types/pumpify/tsconfig.json b/types/pumpify/tsconfig.json index 1404589863..c616e0e309 100644 --- a/types/pumpify/tsconfig.json +++ b/types/pumpify/tsconfig.json @@ -8,7 +8,6 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, - "allowSyntheticDefaultImports": true, "baseUrl": "../", "typeRoots": [ "../"