mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
constructors part 2 electric boogaloo
This commit is contained in:
@@ -40,6 +40,8 @@ const { kOnConstructed } = require("internal/streams/utils");
|
||||
function Duplex(options) {
|
||||
if (!(this instanceof Duplex)) return new Duplex(options);
|
||||
|
||||
this.constructor = Duplex;
|
||||
|
||||
this._events ??= {
|
||||
close: undefined,
|
||||
error: undefined,
|
||||
|
||||
@@ -8,6 +8,7 @@ const EE = require("node:events");
|
||||
|
||||
function Stream(opts) {
|
||||
EE.$call(this, opts);
|
||||
this.constructor = Stream;
|
||||
}
|
||||
Stream.constructor = Stream;
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ ObjectSetPrototypeOf(PassThrough, Transform);
|
||||
function PassThrough(options) {
|
||||
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
||||
|
||||
this.constructor = PassThrough;
|
||||
|
||||
Transform.$call(this, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -311,6 +311,7 @@ ReadableState.prototype[kOnConstructed] = function onConstructed(stream) {
|
||||
function Readable(options) {
|
||||
if (!(this instanceof Readable)) return new Readable(options);
|
||||
|
||||
this.constructor = Readable;
|
||||
this._events ??= {
|
||||
close: undefined,
|
||||
error: undefined,
|
||||
|
||||
@@ -77,6 +77,8 @@ const kCallback = Symbol("kCallback");
|
||||
function Transform(options) {
|
||||
if (!(this instanceof Transform)) return new Transform(options);
|
||||
|
||||
this.constructor = Transform;
|
||||
|
||||
// TODO (ronag): This should preferably always be
|
||||
// applied but would be semver-major. Or even better;
|
||||
// make Transform a Readable with the Writable interface.
|
||||
|
||||
@@ -388,6 +388,7 @@ WritableState.prototype[kOnConstructed] = function onConstructed(stream) {
|
||||
function Writable(options) {
|
||||
if (!(this instanceof Writable)) return new Writable(options);
|
||||
|
||||
this.constructor = Writable;
|
||||
this._events ??= {
|
||||
close: undefined,
|
||||
error: undefined,
|
||||
|
||||
Reference in New Issue
Block a user