ult(this, result, chunk, this[kCloseState][0]); } function handleResult(stream, result, chunk, isClosed) { if (typeof result === "number") { if (result >= stream[kHighWaterMark] && !stream[kHasResized] && !isClosed) adjustHighWaterMark(stream); return handleNumberResult(stream, result, chunk, isClosed); } else if (typeof result === "boolean") return process.nextTick(() => { stream.push(null); }), (chunk?.byteLength ?? 0) > 0 ? chunk : @undefined; else if (@isTypedArrayView(result)) { if (result.byteLength >= stream[kHighWaterMark] && !stream[kHasResized] && !isClosed) adjustHighWaterMark(stream); return handleArrayBufferViewResult(stream, result, chunk, isClosed); } } function handleNumberResult(stream, result, chunk, isClosed) { if (result > 0) { let slice = chunk.subarray(0, result); if (chunk = slice.byteLength < chunk.byteLength ? chunk.subarray(result) : @undefined, slice.byteLength > 0) stream.push(slice); } if (isClosed) process.nextTick(() => { stream.push(null); }); return chunk; } function handleArrayBufferViewResult(stream, result, chunk, isClosed) { if (result.byteLength > 0) stream.push(result); if (isClosed) process.nextTick(() => { stream.push(null); }); return chunk; } function adjustHighWaterMark(stream) { stream[kHighWaterMark] = @min(stream[kHighWaterMark] * 2, 2097152), stream[kHasResized] = !0; } function destroy(error, cb) { let ptr = this.@bunNativePtr; if (ptr) ptr.cancel(error); if (cb) process.nextTick(cb); } function ref() { let ptr = this.@bunNativePtr; if (ptr === @undefined) return; if (this[kRefCount]++ === 0) ptr.updateRef(!0); } function unref() { let ptr = this.@bunNativePtr; if (ptr === @undefined) return; if (this[kRefCount]-- === 1) ptr.updateRef(!1); } $ = { constructNativeReadable }; return $})