Merge pull request #30150 from kinwa91/duplexify-3.6

[duplexify] Add missing method types: obj(), cork() and uncork()
This commit is contained in:
Daniel Rosenwasser 2018-11-04 23:30:58 -08:00 committed by GitHub
commit e31b168ef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -8,9 +8,17 @@ duplexify(writable, readable);
duplexify(writable);
duplexify(undefined, readable);
duplexify.obj();
duplexify.obj(writable);
duplexify.obj(writable, readable);
duplexify.obj(writable, readable, {});
const d: duplexify.Duplexify = duplexify();
d.setReadable(readable);
d.setReadable(); // $ExpectError
d.setWritable(writable);
d.setWritable(); // $ExpectError
d.cork();
d.uncork();
const f: Duplex = d;

View File

@ -1,6 +1,7 @@
// Type definitions for duplexify 3.5
// Type definitions for duplexify 3.6
// Project: https://github.com/mafintosh/duplexify
// Definitions by: Sami Kukkonen <https://github.com/strax>
// Jonathan Lui <https://github.com/kinwa91>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@ -11,10 +12,14 @@ export = duplexify;
interface DuplexifyConstructor {
(writable?: stream.Writable, readable?: stream.Readable, streamOptions?: stream.DuplexOptions): duplexify.Duplexify;
new (writable?: stream.Writable, readable?: stream.Readable, streamOptions?: stream.DuplexOptions): duplexify.Duplexify;
obj(writable?: stream.Writable, readable?: stream.Readable, streamOptions?: stream.DuplexOptions): duplexify.Duplexify;
}
declare var duplexify: DuplexifyConstructor;
declare namespace duplexify {
interface Duplexify extends stream.Duplex {
cork(): void;
uncork(): void;
setWritable(writable: stream.Writable): void;
setReadable(readable: stream.Readable): void;
}