diff options
author | 2022-11-08 21:31:21 -0800 | |
---|---|---|
committer | 2022-11-08 21:31:21 -0800 | |
commit | 55c262a3219732ce06e4c417ce0b96acbf082313 (patch) | |
tree | 69761ecc375b5bc21567be6f526b1fc6ede18cce | |
parent | af3931371eb30c11623d3aaecc3fe7cf0e14ec0d (diff) | |
download | bun-55c262a3219732ce06e4c417ce0b96acbf082313.tar.gz bun-55c262a3219732ce06e4c417ce0b96acbf082313.tar.zst bun-55c262a3219732ce06e4c417ce0b96acbf082313.zip |
handle undefined better
-rw-r--r-- | src/bun.js/streams.exports.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/bun.js/streams.exports.js b/src/bun.js/streams.exports.js index 576f3ea89..a7a37b107 100644 --- a/src/bun.js/streams.exports.js +++ b/src/bun.js/streams.exports.js @@ -2096,9 +2096,9 @@ var require_destroy = __commonJS({ } } function emitErrorNT(self, err) { - const r = self._readableState; - const w = self._writableState; - if ((w && w.errorEmitted) || (r && r.errorEmitted)) { + const r = self?._readableState; + const w = self?._writableState; + if (w?.errorEmitted || r?.errorEmitted) { return; } if (w) { @@ -2107,7 +2107,7 @@ var require_destroy = __commonJS({ if (r) { r.errorEmitted = true; } - self.emit("error", err); + self?.emit?.("error", err); } function undestroy() { const r = this._readableState; @@ -2138,8 +2138,8 @@ var require_destroy = __commonJS({ } } function errorOrDestroy(stream, err, sync) { - const r = stream._readableState; - const w = stream._writableState; + const r = stream?._readableState; + const w = stream?._writableState; if ((w && w.destroyed) || (r && r.destroyed)) { return this; } @@ -5561,7 +5561,7 @@ var require_stream = __commonJS({ return value instanceof Uint8Array; }; Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength); + return new Buffer(chunk.buffer, chunk.byteOffset, chunk.byteLength); }; }, }); |