Skip to content

Commit

Permalink
fix: allow tree-shaking _Duplex
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 8, 2023
1 parent 43fa516 commit 35741ab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/runtime/node/stream/duplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Writable } from "./writable";

type DuplexClass = new () => stream.Duplex;

export const _Duplex: DuplexClass = class {
const __Duplex: DuplexClass = class {
allowHalfOpen: boolean = true;
private _destroy: (error?: Error) => void;

Expand All @@ -19,8 +19,13 @@ export const _Duplex: DuplexClass = class {
}
} as any;

Object.assign(_Duplex.prototype, Readable.prototype);
Object.assign(_Duplex.prototype, Writable.prototype);
function getDuplex() {
Object.assign(__Duplex.prototype, Readable.prototype);
Object.assign(__Duplex.prototype, Writable.prototype);
return __Duplex;
}

export const _Duplex = /* #__PURE__ */ getDuplex();

export const Duplex: typeof stream.Duplex =
(globalThis as any).Duplex || _Duplex;

0 comments on commit 35741ab

Please sign in to comment.