Created
May 3, 2018 00:26
-
-
Save aoberoi/9a54fa4266dd0fdccd08198dca9ff209 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Duplexify = require("duplexify"); | |
new Duplexify(); | |
new Duplexify(writable); | |
new Duplexify(undefined, readable); | |
new Duplexify(undefined, undefined, opts); | |
new Duplexify(writable, readable); | |
new Duplexify(undefined, readable, opts); | |
new Duplexify(writable, undefined, opts); | |
new Duplexify(writable, readable, opts); | |
declare class _MyStream { | |
setPipeline(): void; | |
} | |
// you cannot use `extends Duplexify` above because there will be an error regarding | |
// the static side of the definition not matching. but you can use the following statement | |
// to get a value and type that extends Duplexify | |
const MyStream = _MyStream as (typeof _MyStream & typeof Duplexify); | |
const s = new MyStream(); | |
s.end(); | |
_MyStream.setPipeline(); // <- this is still an error! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="node" /> | |
import { Writable, Readable, Duplex, DuplexOptions } from 'stream'; | |
declare class _Duplexify extends Duplex { | |
constructor(writable?: Writable, readable?: Readable, opts?: DuplexOptions); | |
setWritable(writable: Writable): void; | |
setReadable(readable: Readable): void; | |
} | |
type Duplexify = _Duplexify | |
interface DuplexifyFactory { | |
(writable?: Writable, readable?: Readable, opts?: DuplexOptions): Duplexify; | |
} | |
declare const Duplexify: typeof _Duplexify & DuplexifyFactory; | |
export = Duplexify |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment