Skip to content

Instantly share code, notes, and snippets.

@aoberoi
Created May 3, 2018 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aoberoi/9a54fa4266dd0fdccd08198dca9ff209 to your computer and use it in GitHub Desktop.
Save aoberoi/9a54fa4266dd0fdccd08198dca9ff209 to your computer and use it in GitHub Desktop.
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!
/// <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