diff options
author | 2023-08-15 21:51:43 -0700 | |
---|---|---|
committer | 2023-08-15 21:51:43 -0700 | |
commit | 9efeef2e245acbb4f7d83b737e107c4972287527 (patch) | |
tree | ce0eabc70138f4d5f41f563af8ef94171bbcd35b | |
parent | 67a8b75183996f1b0f981e4a035f3685018be287 (diff) | |
download | bun-9efeef2e245acbb4f7d83b737e107c4972287527.tar.gz bun-9efeef2e245acbb4f7d83b737e107c4972287527.tar.zst bun-9efeef2e245acbb4f7d83b737e107c4972287527.zip |
res.then
-rw-r--r-- | src/js/node/fs.js | 2 | ||||
-rw-r--r-- | src/js/out/InternalModuleRegistryConstants.h | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/js/node/fs.js b/src/js/node/fs.js index e837816e9..3dc3e2da7 100644 --- a/src/js/node/fs.js +++ b/src/js/node/fs.js @@ -601,7 +601,7 @@ ReadStream = (function (InternalReadStream) { if ($isPromise(res)) { var then = res?.then; if (then && $isCallable(then)) { - then( + res.then( () => { this[kIoDone] = true; // Tell ._destroy() that it's safe to close the fd now. diff --git a/src/js/out/InternalModuleRegistryConstants.h b/src/js/out/InternalModuleRegistryConstants.h index 2101014ec..ba004e845 100644 --- a/src/js/out/InternalModuleRegistryConstants.h +++ b/src/js/out/InternalModuleRegistryConstants.h @@ -70,7 +70,7 @@ static constexpr ASCIILiteral NodeEventsCode = "(function () {\"use strict\";\n // // -static constexpr ASCIILiteral NodeFSCode = "(function () {\"use strict\";\n var $, ReadStream, WriteStream;\n const EventEmitter = @getInternalField(@internalModuleRegistry, 15) || @createInternalModuleById(15), promises = @getInternalField(@internalModuleRegistry, 17) || @createInternalModuleById(17), Stream = @getInternalField(@internalModuleRegistry, 34) || @createInternalModuleById(34);\n var fs = Bun.fs();\n\n class FSWatcher extends EventEmitter {\n #watcher;\n #listener;\n constructor(path, options, listener) {\n super();\n if (typeof options === \"function\")\n listener = options, options = {};\n else if (typeof options === \"string\")\n options = { encoding: options };\n if (typeof listener !== \"function\")\n listener = () => {\n };\n this.#listener = listener;\n try {\n this.#watcher = fs.watch(path, options || {}, this.#onEvent.bind(this));\n } catch (e) {\n if (!e.message\?.startsWith(\"FileNotFound\"))\n throw e;\n const notFound = new Error(`ENOENT: no such file or directory, watch '${path}'`);\n throw notFound.code = \"ENOENT\", notFound.errno = -2, notFound.path = path, notFound.syscall = \"watch\", notFound.filename = path, notFound;\n }\n }\n #onEvent(eventType, filenameOrError) {\n if (eventType === \"error\" || eventType === \"close\")\n this.emit(eventType, filenameOrError);\n else\n this.emit(\"change\", eventType, filenameOrError), this.#listener(eventType, filenameOrError);\n }\n close() {\n this.#watcher\?.close(), this.#watcher = null;\n }\n ref() {\n this.#watcher\?.ref();\n }\n unref() {\n this.#watcher\?.unref();\n }\n }\n var access = function access(...args) {\n callbackify(fs.accessSync, args);\n }, appendFile = function appendFile(...args) {\n callbackify(fs.appendFileSync, args);\n }, close = function close(...args) {\n callbackify(fs.closeSync, args);\n }, rm = function rm(...args) {\n callbackify(fs.rmSync, args);\n }, rmdir = function rmdir(...args) {\n callbackify(fs.rmdirSync, args);\n }, copyFile = function copyFile(...args) {\n callbackify(fs.copyFileSync, args);\n }, exists = function exists(...args) {\n callbackify(fs.existsSync, args);\n }, chown = function chown(...args) {\n callbackify(fs.chownSync, args);\n }, chmod = function chmod(...args) {\n callbackify(fs.chmodSync, args);\n }, fchmod = function fchmod(...args) {\n callbackify(fs.fchmodSync, args);\n }, fchown = function fchown(...args) {\n callbackify(fs.fchownSync, args);\n }, fstat = function fstat(...args) {\n callbackify(fs.fstatSync, args);\n }, fsync = function fsync(...args) {\n callbackify(fs.fsyncSync, args);\n }, ftruncate = function ftruncate(...args) {\n callbackify(fs.ftruncateSync, args);\n }, futimes = function futimes(...args) {\n callbackify(fs.futimesSync, args);\n }, lchmod = function lchmod(...args) {\n callbackify(fs.lchmodSync, args);\n }, lchown = function lchown(...args) {\n callbackify(fs.lchownSync, args);\n }, link = function link(...args) {\n callbackify(fs.linkSync, args);\n }, mkdir = function mkdir(...args) {\n callbackify(fs.mkdirSync, args);\n }, mkdtemp = function mkdtemp(...args) {\n callbackify(fs.mkdtempSync, args);\n }, open = function open(...args) {\n callbackify(fs.openSync, args);\n }, read = function read(...args) {\n callbackify(fs.readSync, args);\n }, write = function write(...args) {\n callbackify(fs.writeSync, args);\n }, readdir = function readdir(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readdir(...args).then((result) => callback(null, result), callback);\n }, readFile = function readFile(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readFile(...args).then((result) => callback(null, result), callback);\n }, writeFile = function writeFile(...args) {\n callbackify(fs.writeFileSync, args);\n }, readlink = function readlink(...args) {\n callbackify(fs.readlinkSync, args);\n }, realpath = function realpath(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.realpath(...args).then((result) => callback(null, result), callback);\n }, rename = function rename(...args) {\n callbackify(fs.renameSync, args);\n }, lstat = function lstat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.lstat(...args).then((result) => callback(null, result), callback);\n }, stat = function stat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.stat(...args).then((result) => callback(null, result), callback);\n }, symlink = function symlink(...args) {\n callbackify(fs.symlinkSync, args);\n }, truncate = function truncate(...args) {\n callbackify(fs.truncateSync, args);\n }, unlink = function unlink(...args) {\n callbackify(fs.unlinkSync, args);\n }, utimes = function utimes(...args) {\n callbackify(fs.utimesSync, args);\n }, lutimes = function lutimes(...args) {\n callbackify(fs.lutimesSync, args);\n }, accessSync = fs.accessSync.bind(fs), appendFileSync = fs.appendFileSync.bind(fs), closeSync = fs.closeSync.bind(fs), copyFileSync = fs.copyFileSync.bind(fs), existsSync = fs.existsSync.bind(fs), chownSync = fs.chownSync.bind(fs), chmodSync = fs.chmodSync.bind(fs), fchmodSync = fs.fchmodSync.bind(fs), fchownSync = fs.fchownSync.bind(fs), fstatSync = fs.fstatSync.bind(fs), fsyncSync = fs.fsyncSync.bind(fs), ftruncateSync = fs.ftruncateSync.bind(fs), futimesSync = fs.futimesSync.bind(fs), lchmodSync = fs.lchmodSync.bind(fs), lchownSync = fs.lchownSync.bind(fs), linkSync = fs.linkSync.bind(fs), lstatSync = fs.lstatSync.bind(fs), mkdirSync = fs.mkdirSync.bind(fs), mkdtempSync = fs.mkdtempSync.bind(fs), openSync = fs.openSync.bind(fs), readSync = fs.readSync.bind(fs), writeSync = fs.writeSync.bind(fs), readdirSync = fs.readdirSync.bind(fs), readFileSync = fs.readFileSync.bind(fs), writeFileSync = fs.writeFileSync.bind(fs), readlinkSync = fs.readlinkSync.bind(fs), realpathSync = fs.realpathSync.bind(fs), renameSync = fs.renameSync.bind(fs), statSync = fs.statSync.bind(fs), symlinkSync = fs.symlinkSync.bind(fs), truncateSync = fs.truncateSync.bind(fs), unlinkSync = fs.unlinkSync.bind(fs), utimesSync = fs.utimesSync.bind(fs), lutimesSync = fs.lutimesSync.bind(fs), rmSync = fs.rmSync.bind(fs), rmdirSync = fs.rmdirSync.bind(fs), writev = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.writevSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, writevSync = fs.writevSync.bind(fs), readv = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.readvSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, readvSync = fs.readvSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch(path, options, listener) {\n return new FSWatcher(path, options, listener);\n };\n function callbackify(fsFunction, args) {\n try {\n const result = fsFunction.apply(fs, args.slice(0, args.length - 1)), callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(null, result));\n } catch (e) {\n const callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(e));\n }\n }\n var readStreamPathFastPathSymbol = Symbol.for(\"Bun.Node.readStreamPathFastPath\");\n const readStreamSymbol = Symbol.for(\"Bun.NodeReadStream\"), readStreamPathOrFdSymbol = Symbol.for(\"Bun.NodeReadStreamPathOrFd\"), writeStreamSymbol = Symbol.for(\"Bun.NodeWriteStream\");\n var writeStreamPathFastPathSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPath\"), writeStreamPathFastPathCallSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"), kIoDone = Symbol.for(\"kIoDone\"), defaultReadStreamOptions = {\n file: void 0,\n fd: void 0,\n flags: \"r\",\n encoding: void 0,\n mode: 438,\n autoClose: !0,\n emitClose: !0,\n start: 0,\n end: Infinity,\n highWaterMark: 65536,\n fs: {\n read,\n open: (path, flags, mode, cb) => {\n var fd;\n try {\n fd = openSync(path, flags, mode);\n } catch (e) {\n cb(e);\n return;\n }\n cb(null, fd);\n },\n openSync,\n close\n },\n autoDestroy: !0\n }, ReadStreamClass;\n ReadStream = function(InternalReadStream) {\n ReadStreamClass = InternalReadStream, Object.defineProperty(ReadStreamClass.prototype, Symbol.toStringTag, {\n value: \"ReadStream\",\n enumerable: !1\n });\n function ReadStream2(path, options) {\n return new InternalReadStream(path, options);\n }\n return ReadStream2.prototype = InternalReadStream.prototype, Object.defineProperty(ReadStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalReadStream;\n }\n });\n }(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2, Stream.Readable) {\n constructor(pathOrFd, options = defaultReadStreamOptions) {\n if (typeof options !== \"object\" || !options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n flags = defaultReadStreamOptions.flags,\n encoding = defaultReadStreamOptions.encoding,\n mode = defaultReadStreamOptions.mode,\n autoClose = defaultReadStreamOptions.autoClose,\n emitClose = defaultReadStreamOptions.emitClose,\n start = defaultReadStreamOptions.start,\n end = defaultReadStreamOptions.end,\n autoDestroy = defaultReadStreamOptions.autoClose,\n fs: fs2 = defaultReadStreamOptions.fs,\n highWaterMark = defaultReadStreamOptions.highWaterMark\n } = options;\n if (pathOrFd\?.constructor\?.name === \"URL\")\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n var tempThis = {};\n if (typeof pathOrFd === \"string\") {\n if (pathOrFd.startsWith(\"file://\"))\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n if (pathOrFd.length === 0)\n @throwTypeError(\"Expected path to be a non-empty string\");\n tempThis.path = tempThis.file = tempThis[readStreamPathOrFdSymbol] = pathOrFd;\n } else if (typeof pathOrFd === \"number\") {\n if (pathOrFd |= 0, pathOrFd < 0)\n @throwTypeError(\"Expected fd to be a positive integer\");\n tempThis.fd = tempThis[readStreamPathOrFdSymbol] = pathOrFd, tempThis.autoClose = !1;\n } else\n @throwTypeError(\"Expected a path or file descriptor\");\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(pathOrFd, flags, mode);\n var fileRef = Bun.file(tempThis.fd), stream = fileRef.stream(), native = @direct(stream);\n if (!native)\n throw new Error(\"no native readable stream\");\n var { stream: ptr } = native;\n super(ptr, {\n ...options,\n encoding,\n autoDestroy,\n autoClose,\n emitClose,\n highWaterMark\n });\n if (Object.assign(this, tempThis), this.#fileRef = fileRef, this.end = end, this._read = this.#internalRead, this.start = start, this.flags = flags, this.mode = mode, this.emitClose = emitClose, this[readStreamPathFastPathSymbol] = start === 0 && end === Infinity && autoClose && fs2 === defaultReadStreamOptions.fs && (encoding === \"buffer\" || encoding === \"binary\" || encoding == null || encoding === \"utf-8\" || encoding === \"utf8\"), this._readableState.autoClose = autoDestroy = autoClose, this._readableState.highWaterMark = highWaterMark, start !== void 0)\n this.pos = start;\n }\n #fileRef;\n #fs;\n file;\n path;\n fd = null;\n flags;\n mode;\n start;\n end;\n pos;\n bytesRead = 0;\n #fileSize = -1;\n _read;\n [readStreamSymbol] = !0;\n [readStreamPathOrFdSymbol];\n [readStreamPathFastPathSymbol];\n _construct(callback) {\n if (super._construct)\n super._construct(callback);\n else\n callback();\n this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n super._destroy(err, cb);\n try {\n var fd = this.fd;\n if (this[readStreamPathFastPathSymbol] = !1, !fd)\n cb(err);\n else\n this.#fs.close(fd, (er) => {\n cb(er || err);\n }), this.fd = null;\n } catch (e) {\n throw e;\n }\n }\n close(cb) {\n if (typeof cb === \"function\")\n eos_()(this, cb);\n this.destroy();\n }\n push(chunk) {\n var bytesRead = chunk\?.length \?\? 0;\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n var currPos = this.pos;\n if (currPos !== void 0) {\n if (this.bytesRead < currPos)\n return !0;\n if (currPos === this.start) {\n var n = this.bytesRead - currPos;\n chunk = chunk.slice(-n);\n var [_, ...rest] = arguments;\n if (this.pos = this.bytesRead, this.end !== void 0 && this.bytesRead > this.end)\n chunk = chunk.slice(0, this.end - this.start + 1);\n return super.push(chunk, ...rest);\n }\n var end = this.end;\n if (end !== void 0 && this.bytesRead > end) {\n chunk = chunk.slice(0, end - currPos + 1);\n var [_, ...rest] = arguments;\n return this.pos = this.bytesRead, super.push(chunk, ...rest);\n }\n this.pos = this.bytesRead;\n }\n }\n return super.push(...arguments);\n }\n #internalRead(n) {\n var { pos, end, bytesRead, fd, encoding } = this;\n if (n = pos !== void 0 \? Math.min(end - pos + 1, n) : Math.min(end - bytesRead + 1, n), n <= 0) {\n this.push(null);\n return;\n }\n if (this.#fileSize === -1 && bytesRead === 0 && pos === void 0) {\n var stat2 = fstatSync(fd);\n if (this.#fileSize = stat2.size, this.#fileSize > 0 && n > this.#fileSize)\n n = this.#fileSize + 1;\n }\n this[kIoDone] = !1;\n var res = super._read(n);\n if (@isPromise(res)) {\n var then = res\?.then;\n if (then && @isCallable(then))\n then(() => {\n if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone);\n }, (er) => {\n this[kIoDone] = !0, this.#errorOrDestroy(er);\n });\n } else if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone), this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"));\n }\n #errorOrDestroy(err, sync = null) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n pause() {\n return this[readStreamPathFastPathSymbol] = !1, super.pause();\n }\n resume() {\n return this[readStreamPathFastPathSymbol] = !1, super.resume();\n }\n unshift(...args) {\n return this[readStreamPathFastPathSymbol] = !1, super.unshift(...args);\n }\n pipe(dest, pipeOpts) {\n if (this[readStreamPathFastPathSymbol] && (pipeOpts\?.end \?\? !0) && this._readableState\?.pipes\?.length === 0) {\n if ((writeStreamPathFastPathSymbol in dest) && dest[writeStreamPathFastPathSymbol]) {\n if (dest[writeStreamPathFastPathCallSymbol](this, pipeOpts))\n return this;\n }\n }\n return this[readStreamPathFastPathSymbol] = !1, super.pipe(dest, pipeOpts);\n }\n });\n function createReadStream(path, options) {\n return new ReadStream(path, options);\n }\n var defaultWriteStreamOptions = {\n fd: null,\n start: void 0,\n pos: void 0,\n encoding: void 0,\n flags: \"w\",\n mode: 438,\n fs: {\n write,\n close,\n open,\n openSync\n }\n }, WriteStreamClass;\n WriteStream = function(InternalWriteStream) {\n WriteStreamClass = InternalWriteStream, Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, {\n value: \"WritesStream\",\n enumerable: !1\n });\n function WriteStream2(path, options) {\n return new InternalWriteStream(path, options);\n }\n return WriteStream2.prototype = InternalWriteStream.prototype, Object.defineProperty(WriteStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalWriteStream;\n }\n });\n }(class WriteStream2 extends Stream.NativeWritable {\n constructor(path, options = defaultWriteStreamOptions) {\n if (!options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n fs: fs2 = defaultWriteStreamOptions.fs,\n start = defaultWriteStreamOptions.start,\n flags = defaultWriteStreamOptions.flags,\n mode = defaultWriteStreamOptions.mode,\n autoClose = !0,\n emitClose = !1,\n autoDestroy = autoClose,\n encoding = defaultWriteStreamOptions.encoding,\n fd = defaultWriteStreamOptions.fd,\n pos = defaultWriteStreamOptions.pos\n } = options, tempThis = {};\n if (typeof path === \"string\") {\n if (path.length === 0)\n @throwTypeError(\"Expected a non-empty path\");\n if (path.startsWith(\"file:\"))\n path = Bun.fileURLToPath(path);\n tempThis.path = path, tempThis.fd = null, tempThis[writeStreamPathFastPathSymbol] = autoClose && (start === void 0 || start === 0) && fs2.write === defaultWriteStreamOptions.fs.write && fs2.close === defaultWriteStreamOptions.fs.close;\n } else\n tempThis.fd = fd, tempThis[writeStreamPathFastPathSymbol] = !1;\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(path, flags, mode);\n super(tempThis.fd, {\n ...options,\n decodeStrings: !1,\n autoDestroy,\n emitClose,\n fd: tempThis\n });\n if (Object.assign(this, tempThis), typeof fs2\?.write !== \"function\")\n @throwTypeError(\"Expected fs.write to be a function\");\n if (typeof fs2\?.close !== \"function\")\n @throwTypeError(\"Expected fs.close to be a function\");\n if (typeof fs2\?.open !== \"function\")\n @throwTypeError(\"Expected fs.open to be a function\");\n if (typeof path === \"object\" && path) {\n if (path instanceof URL)\n path = Bun.fileURLToPath(path);\n }\n if (typeof path !== \"string\" && typeof fd !== \"number\")\n @throwTypeError(\"Expected a path or file descriptor\");\n if (this.start = start, this.#fs = fs2, this.flags = flags, this.mode = mode, this.start !== void 0)\n this.pos = this.start;\n if (encoding !== defaultWriteStreamOptions.encoding) {\n if (this.setDefaultEncoding(encoding), encoding !== \"buffer\" && encoding !== \"utf8\" && encoding !== \"utf-8\" && encoding !== \"binary\")\n this[writeStreamPathFastPathSymbol] = !1;\n }\n }\n get autoClose() {\n return this._writableState.autoDestroy;\n }\n set autoClose(val) {\n this._writableState.autoDestroy = val;\n }\n destroySoon = this.end;\n open() {\n }\n path;\n fd;\n flags;\n mode;\n #fs;\n bytesWritten = 0;\n pos;\n [writeStreamPathFastPathSymbol];\n [writeStreamSymbol] = !0;\n start;\n [writeStreamPathFastPathCallSymbol](readStream, pipeOpts) {\n if (!this[writeStreamPathFastPathSymbol])\n return !1;\n if (this.fd !== null)\n return this[writeStreamPathFastPathSymbol] = !1, !1;\n return this[kIoDone] = !1, readStream[kIoDone] = !1, Bun.write(this[writeStreamPathFastPathSymbol], readStream[readStreamPathOrFdSymbol]).then((bytesWritten) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.bytesWritten += bytesWritten, readStream.bytesRead += bytesWritten, this.end(), readStream.close();\n }, (err) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.#errorOrDestroy(err), readStream.emit(\"error\", err);\n });\n }\n isBunFastPathEnabled() {\n return this[writeStreamPathFastPathSymbol];\n }\n disableBunFastPath() {\n this[writeStreamPathFastPathSymbol] = !1;\n }\n #handleWrite(er, bytes) {\n if (er)\n return this.#errorOrDestroy(er);\n this.bytesWritten += bytes;\n }\n #internalClose(err, cb) {\n this[writeStreamPathFastPathSymbol] = !1;\n var fd = this.fd;\n this.#fs.close(fd, (er) => {\n this.fd = null, cb(err || er);\n });\n }\n _construct(callback) {\n if (typeof this.fd === \"number\") {\n callback();\n return;\n }\n callback(), this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n if (this.fd === null)\n return cb(err);\n if (this[kIoDone]) {\n this.once(kIoDone, () => this.#internalClose(err, cb));\n return;\n }\n this.#internalClose(err, cb);\n }\n [kIoDone] = !1;\n close(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on(\"close\", cb);\n }\n if (!this.autoClose)\n this.on(\"finish\", this.destroy);\n this.end();\n }\n write(chunk, encoding = this._writableState.defaultEncoding, cb) {\n if (this[writeStreamPathFastPathSymbol] = !1, typeof chunk === \"string\")\n chunk = Buffer.from(chunk, encoding);\n var native = this.pos === void 0;\n return this[kIoDone] = !0, super.write(chunk, encoding, native \? (err, bytes) => {\n if (this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), cb)\n !err \? cb() : cb(err);\n } : () => {\n }, native);\n }\n #internalWriteSlow(chunk, encoding, cb) {\n this.#fs.write(this.fd, chunk, 0, chunk.length, this.pos, (err, bytes) => {\n this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), !err \? cb() : cb(err);\n });\n }\n end(chunk, encoding, cb) {\n var native = this.pos === void 0;\n return super.end(chunk, encoding, cb, native);\n }\n _write = this.#internalWriteSlow;\n _writev = void 0;\n get pending() {\n return this.fd === null;\n }\n _destroy(err, cb) {\n this.close(err, cb);\n }\n #errorOrDestroy(err) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n });\n function createWriteStream(path, options) {\n return new WriteStream(path, options);\n }\n return Object.defineProperties(fs, {\n createReadStream: {\n value: createReadStream\n },\n createWriteStream: {\n value: createWriteStream\n },\n ReadStream: {\n value: ReadStream\n },\n WriteStream: {\n value: WriteStream\n }\n }), realpath.native = realpath, realpathSync.native = realpathSync, $ = {\n access,\n accessSync,\n appendFile,\n appendFileSync,\n chmod,\n chmodSync,\n chown,\n chownSync,\n close,\n closeSync,\n constants: promises.constants,\n copyFile,\n copyFileSync,\n createReadStream,\n createWriteStream,\n Dirent,\n exists,\n existsSync,\n fchmod,\n fchmodSync,\n fchown,\n fchownSync,\n fstat,\n fstatSync,\n fsync,\n fsyncSync,\n ftruncate,\n ftruncateSync,\n futimes,\n futimesSync,\n lchmod,\n lchmodSync,\n lchown,\n lchownSync,\n link,\n linkSync,\n lstat,\n lstatSync,\n lutimes,\n lutimesSync,\n mkdir,\n mkdirSync,\n mkdtemp,\n mkdtempSync,\n open,\n openSync,\n promises,\n read,\n readFile,\n readFileSync,\n readSync,\n readdir,\n readdirSync,\n readlink,\n readlinkSync,\n realpath,\n realpathSync,\n rename,\n renameSync,\n rm,\n rmSync,\n rmdir,\n rmdirSync,\n stat,\n statSync,\n Stats,\n symlink,\n symlinkSync,\n truncate,\n truncateSync,\n unlink,\n unlinkSync,\n utimes,\n utimesSync,\n write,\n writeFile,\n writeFileSync,\n writeSync,\n WriteStream,\n ReadStream,\n watch,\n FSWatcher,\n writev,\n writevSync,\n readv,\n readvSync,\n [Symbol.for(\"::bunternal::\")]: {\n ReadStreamClass,\n WriteStreamClass\n }\n }, $;\n})\n"_s; +static constexpr ASCIILiteral NodeFSCode = "(function () {\"use strict\";\n var $, ReadStream, WriteStream;\n const EventEmitter = @getInternalField(@internalModuleRegistry, 15) || @createInternalModuleById(15), promises = @getInternalField(@internalModuleRegistry, 17) || @createInternalModuleById(17), Stream = @getInternalField(@internalModuleRegistry, 34) || @createInternalModuleById(34);\n var fs = Bun.fs();\n\n class FSWatcher extends EventEmitter {\n #watcher;\n #listener;\n constructor(path, options, listener) {\n super();\n if (typeof options === \"function\")\n listener = options, options = {};\n else if (typeof options === \"string\")\n options = { encoding: options };\n if (typeof listener !== \"function\")\n listener = () => {\n };\n this.#listener = listener;\n try {\n this.#watcher = fs.watch(path, options || {}, this.#onEvent.bind(this));\n } catch (e) {\n if (!e.message\?.startsWith(\"FileNotFound\"))\n throw e;\n const notFound = new Error(`ENOENT: no such file or directory, watch '${path}'`);\n throw notFound.code = \"ENOENT\", notFound.errno = -2, notFound.path = path, notFound.syscall = \"watch\", notFound.filename = path, notFound;\n }\n }\n #onEvent(eventType, filenameOrError) {\n if (eventType === \"error\" || eventType === \"close\")\n this.emit(eventType, filenameOrError);\n else\n this.emit(\"change\", eventType, filenameOrError), this.#listener(eventType, filenameOrError);\n }\n close() {\n this.#watcher\?.close(), this.#watcher = null;\n }\n ref() {\n this.#watcher\?.ref();\n }\n unref() {\n this.#watcher\?.unref();\n }\n }\n var access = function access(...args) {\n callbackify(fs.accessSync, args);\n }, appendFile = function appendFile(...args) {\n callbackify(fs.appendFileSync, args);\n }, close = function close(...args) {\n callbackify(fs.closeSync, args);\n }, rm = function rm(...args) {\n callbackify(fs.rmSync, args);\n }, rmdir = function rmdir(...args) {\n callbackify(fs.rmdirSync, args);\n }, copyFile = function copyFile(...args) {\n callbackify(fs.copyFileSync, args);\n }, exists = function exists(...args) {\n callbackify(fs.existsSync, args);\n }, chown = function chown(...args) {\n callbackify(fs.chownSync, args);\n }, chmod = function chmod(...args) {\n callbackify(fs.chmodSync, args);\n }, fchmod = function fchmod(...args) {\n callbackify(fs.fchmodSync, args);\n }, fchown = function fchown(...args) {\n callbackify(fs.fchownSync, args);\n }, fstat = function fstat(...args) {\n callbackify(fs.fstatSync, args);\n }, fsync = function fsync(...args) {\n callbackify(fs.fsyncSync, args);\n }, ftruncate = function ftruncate(...args) {\n callbackify(fs.ftruncateSync, args);\n }, futimes = function futimes(...args) {\n callbackify(fs.futimesSync, args);\n }, lchmod = function lchmod(...args) {\n callbackify(fs.lchmodSync, args);\n }, lchown = function lchown(...args) {\n callbackify(fs.lchownSync, args);\n }, link = function link(...args) {\n callbackify(fs.linkSync, args);\n }, mkdir = function mkdir(...args) {\n callbackify(fs.mkdirSync, args);\n }, mkdtemp = function mkdtemp(...args) {\n callbackify(fs.mkdtempSync, args);\n }, open = function open(...args) {\n callbackify(fs.openSync, args);\n }, read = function read(...args) {\n callbackify(fs.readSync, args);\n }, write = function write(...args) {\n callbackify(fs.writeSync, args);\n }, readdir = function readdir(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readdir(...args).then((result) => callback(null, result), callback);\n }, readFile = function readFile(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readFile(...args).then((result) => callback(null, result), callback);\n }, writeFile = function writeFile(...args) {\n callbackify(fs.writeFileSync, args);\n }, readlink = function readlink(...args) {\n callbackify(fs.readlinkSync, args);\n }, realpath = function realpath(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.realpath(...args).then((result) => callback(null, result), callback);\n }, rename = function rename(...args) {\n callbackify(fs.renameSync, args);\n }, lstat = function lstat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.lstat(...args).then((result) => callback(null, result), callback);\n }, stat = function stat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.stat(...args).then((result) => callback(null, result), callback);\n }, symlink = function symlink(...args) {\n callbackify(fs.symlinkSync, args);\n }, truncate = function truncate(...args) {\n callbackify(fs.truncateSync, args);\n }, unlink = function unlink(...args) {\n callbackify(fs.unlinkSync, args);\n }, utimes = function utimes(...args) {\n callbackify(fs.utimesSync, args);\n }, lutimes = function lutimes(...args) {\n callbackify(fs.lutimesSync, args);\n }, accessSync = fs.accessSync.bind(fs), appendFileSync = fs.appendFileSync.bind(fs), closeSync = fs.closeSync.bind(fs), copyFileSync = fs.copyFileSync.bind(fs), existsSync = fs.existsSync.bind(fs), chownSync = fs.chownSync.bind(fs), chmodSync = fs.chmodSync.bind(fs), fchmodSync = fs.fchmodSync.bind(fs), fchownSync = fs.fchownSync.bind(fs), fstatSync = fs.fstatSync.bind(fs), fsyncSync = fs.fsyncSync.bind(fs), ftruncateSync = fs.ftruncateSync.bind(fs), futimesSync = fs.futimesSync.bind(fs), lchmodSync = fs.lchmodSync.bind(fs), lchownSync = fs.lchownSync.bind(fs), linkSync = fs.linkSync.bind(fs), lstatSync = fs.lstatSync.bind(fs), mkdirSync = fs.mkdirSync.bind(fs), mkdtempSync = fs.mkdtempSync.bind(fs), openSync = fs.openSync.bind(fs), readSync = fs.readSync.bind(fs), writeSync = fs.writeSync.bind(fs), readdirSync = fs.readdirSync.bind(fs), readFileSync = fs.readFileSync.bind(fs), writeFileSync = fs.writeFileSync.bind(fs), readlinkSync = fs.readlinkSync.bind(fs), realpathSync = fs.realpathSync.bind(fs), renameSync = fs.renameSync.bind(fs), statSync = fs.statSync.bind(fs), symlinkSync = fs.symlinkSync.bind(fs), truncateSync = fs.truncateSync.bind(fs), unlinkSync = fs.unlinkSync.bind(fs), utimesSync = fs.utimesSync.bind(fs), lutimesSync = fs.lutimesSync.bind(fs), rmSync = fs.rmSync.bind(fs), rmdirSync = fs.rmdirSync.bind(fs), writev = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.writevSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, writevSync = fs.writevSync.bind(fs), readv = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.readvSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, readvSync = fs.readvSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch(path, options, listener) {\n return new FSWatcher(path, options, listener);\n };\n function callbackify(fsFunction, args) {\n try {\n const result = fsFunction.apply(fs, args.slice(0, args.length - 1)), callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(null, result));\n } catch (e) {\n const callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(e));\n }\n }\n var readStreamPathFastPathSymbol = Symbol.for(\"Bun.Node.readStreamPathFastPath\");\n const readStreamSymbol = Symbol.for(\"Bun.NodeReadStream\"), readStreamPathOrFdSymbol = Symbol.for(\"Bun.NodeReadStreamPathOrFd\"), writeStreamSymbol = Symbol.for(\"Bun.NodeWriteStream\");\n var writeStreamPathFastPathSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPath\"), writeStreamPathFastPathCallSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"), kIoDone = Symbol.for(\"kIoDone\"), defaultReadStreamOptions = {\n file: void 0,\n fd: void 0,\n flags: \"r\",\n encoding: void 0,\n mode: 438,\n autoClose: !0,\n emitClose: !0,\n start: 0,\n end: Infinity,\n highWaterMark: 65536,\n fs: {\n read,\n open: (path, flags, mode, cb) => {\n var fd;\n try {\n fd = openSync(path, flags, mode);\n } catch (e) {\n cb(e);\n return;\n }\n cb(null, fd);\n },\n openSync,\n close\n },\n autoDestroy: !0\n }, ReadStreamClass;\n ReadStream = function(InternalReadStream) {\n ReadStreamClass = InternalReadStream, Object.defineProperty(ReadStreamClass.prototype, Symbol.toStringTag, {\n value: \"ReadStream\",\n enumerable: !1\n });\n function ReadStream2(path, options) {\n return new InternalReadStream(path, options);\n }\n return ReadStream2.prototype = InternalReadStream.prototype, Object.defineProperty(ReadStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalReadStream;\n }\n });\n }(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2, Stream.Readable) {\n constructor(pathOrFd, options = defaultReadStreamOptions) {\n if (typeof options !== \"object\" || !options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n flags = defaultReadStreamOptions.flags,\n encoding = defaultReadStreamOptions.encoding,\n mode = defaultReadStreamOptions.mode,\n autoClose = defaultReadStreamOptions.autoClose,\n emitClose = defaultReadStreamOptions.emitClose,\n start = defaultReadStreamOptions.start,\n end = defaultReadStreamOptions.end,\n autoDestroy = defaultReadStreamOptions.autoClose,\n fs: fs2 = defaultReadStreamOptions.fs,\n highWaterMark = defaultReadStreamOptions.highWaterMark\n } = options;\n if (pathOrFd\?.constructor\?.name === \"URL\")\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n var tempThis = {};\n if (typeof pathOrFd === \"string\") {\n if (pathOrFd.startsWith(\"file://\"))\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n if (pathOrFd.length === 0)\n @throwTypeError(\"Expected path to be a non-empty string\");\n tempThis.path = tempThis.file = tempThis[readStreamPathOrFdSymbol] = pathOrFd;\n } else if (typeof pathOrFd === \"number\") {\n if (pathOrFd |= 0, pathOrFd < 0)\n @throwTypeError(\"Expected fd to be a positive integer\");\n tempThis.fd = tempThis[readStreamPathOrFdSymbol] = pathOrFd, tempThis.autoClose = !1;\n } else\n @throwTypeError(\"Expected a path or file descriptor\");\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(pathOrFd, flags, mode);\n var fileRef = Bun.file(tempThis.fd), stream = fileRef.stream(), native = @direct(stream);\n if (!native)\n throw new Error(\"no native readable stream\");\n var { stream: ptr } = native;\n super(ptr, {\n ...options,\n encoding,\n autoDestroy,\n autoClose,\n emitClose,\n highWaterMark\n });\n if (Object.assign(this, tempThis), this.#fileRef = fileRef, this.end = end, this._read = this.#internalRead, this.start = start, this.flags = flags, this.mode = mode, this.emitClose = emitClose, this[readStreamPathFastPathSymbol] = start === 0 && end === Infinity && autoClose && fs2 === defaultReadStreamOptions.fs && (encoding === \"buffer\" || encoding === \"binary\" || encoding == null || encoding === \"utf-8\" || encoding === \"utf8\"), this._readableState.autoClose = autoDestroy = autoClose, this._readableState.highWaterMark = highWaterMark, start !== void 0)\n this.pos = start;\n }\n #fileRef;\n #fs;\n file;\n path;\n fd = null;\n flags;\n mode;\n start;\n end;\n pos;\n bytesRead = 0;\n #fileSize = -1;\n _read;\n [readStreamSymbol] = !0;\n [readStreamPathOrFdSymbol];\n [readStreamPathFastPathSymbol];\n _construct(callback) {\n if (super._construct)\n super._construct(callback);\n else\n callback();\n this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n super._destroy(err, cb);\n try {\n var fd = this.fd;\n if (this[readStreamPathFastPathSymbol] = !1, !fd)\n cb(err);\n else\n this.#fs.close(fd, (er) => {\n cb(er || err);\n }), this.fd = null;\n } catch (e) {\n throw e;\n }\n }\n close(cb) {\n if (typeof cb === \"function\")\n eos_()(this, cb);\n this.destroy();\n }\n push(chunk) {\n var bytesRead = chunk\?.length \?\? 0;\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n var currPos = this.pos;\n if (currPos !== void 0) {\n if (this.bytesRead < currPos)\n return !0;\n if (currPos === this.start) {\n var n = this.bytesRead - currPos;\n chunk = chunk.slice(-n);\n var [_, ...rest] = arguments;\n if (this.pos = this.bytesRead, this.end !== void 0 && this.bytesRead > this.end)\n chunk = chunk.slice(0, this.end - this.start + 1);\n return super.push(chunk, ...rest);\n }\n var end = this.end;\n if (end !== void 0 && this.bytesRead > end) {\n chunk = chunk.slice(0, end - currPos + 1);\n var [_, ...rest] = arguments;\n return this.pos = this.bytesRead, super.push(chunk, ...rest);\n }\n this.pos = this.bytesRead;\n }\n }\n return super.push(...arguments);\n }\n #internalRead(n) {\n var { pos, end, bytesRead, fd, encoding } = this;\n if (n = pos !== void 0 \? Math.min(end - pos + 1, n) : Math.min(end - bytesRead + 1, n), n <= 0) {\n this.push(null);\n return;\n }\n if (this.#fileSize === -1 && bytesRead === 0 && pos === void 0) {\n var stat2 = fstatSync(fd);\n if (this.#fileSize = stat2.size, this.#fileSize > 0 && n > this.#fileSize)\n n = this.#fileSize + 1;\n }\n this[kIoDone] = !1;\n var res = super._read(n);\n if (@isPromise(res)) {\n var then = res\?.then;\n if (then && @isCallable(then))\n res.then(() => {\n if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone);\n }, (er) => {\n this[kIoDone] = !0, this.#errorOrDestroy(er);\n });\n } else if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone), this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"));\n }\n #errorOrDestroy(err, sync = null) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n pause() {\n return this[readStreamPathFastPathSymbol] = !1, super.pause();\n }\n resume() {\n return this[readStreamPathFastPathSymbol] = !1, super.resume();\n }\n unshift(...args) {\n return this[readStreamPathFastPathSymbol] = !1, super.unshift(...args);\n }\n pipe(dest, pipeOpts) {\n if (this[readStreamPathFastPathSymbol] && (pipeOpts\?.end \?\? !0) && this._readableState\?.pipes\?.length === 0) {\n if ((writeStreamPathFastPathSymbol in dest) && dest[writeStreamPathFastPathSymbol]) {\n if (dest[writeStreamPathFastPathCallSymbol](this, pipeOpts))\n return this;\n }\n }\n return this[readStreamPathFastPathSymbol] = !1, super.pipe(dest, pipeOpts);\n }\n });\n function createReadStream(path, options) {\n return new ReadStream(path, options);\n }\n var defaultWriteStreamOptions = {\n fd: null,\n start: void 0,\n pos: void 0,\n encoding: void 0,\n flags: \"w\",\n mode: 438,\n fs: {\n write,\n close,\n open,\n openSync\n }\n }, WriteStreamClass;\n WriteStream = function(InternalWriteStream) {\n WriteStreamClass = InternalWriteStream, Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, {\n value: \"WritesStream\",\n enumerable: !1\n });\n function WriteStream2(path, options) {\n return new InternalWriteStream(path, options);\n }\n return WriteStream2.prototype = InternalWriteStream.prototype, Object.defineProperty(WriteStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalWriteStream;\n }\n });\n }(class WriteStream2 extends Stream.NativeWritable {\n constructor(path, options = defaultWriteStreamOptions) {\n if (!options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n fs: fs2 = defaultWriteStreamOptions.fs,\n start = defaultWriteStreamOptions.start,\n flags = defaultWriteStreamOptions.flags,\n mode = defaultWriteStreamOptions.mode,\n autoClose = !0,\n emitClose = !1,\n autoDestroy = autoClose,\n encoding = defaultWriteStreamOptions.encoding,\n fd = defaultWriteStreamOptions.fd,\n pos = defaultWriteStreamOptions.pos\n } = options, tempThis = {};\n if (typeof path === \"string\") {\n if (path.length === 0)\n @throwTypeError(\"Expected a non-empty path\");\n if (path.startsWith(\"file:\"))\n path = Bun.fileURLToPath(path);\n tempThis.path = path, tempThis.fd = null, tempThis[writeStreamPathFastPathSymbol] = autoClose && (start === void 0 || start === 0) && fs2.write === defaultWriteStreamOptions.fs.write && fs2.close === defaultWriteStreamOptions.fs.close;\n } else\n tempThis.fd = fd, tempThis[writeStreamPathFastPathSymbol] = !1;\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(path, flags, mode);\n super(tempThis.fd, {\n ...options,\n decodeStrings: !1,\n autoDestroy,\n emitClose,\n fd: tempThis\n });\n if (Object.assign(this, tempThis), typeof fs2\?.write !== \"function\")\n @throwTypeError(\"Expected fs.write to be a function\");\n if (typeof fs2\?.close !== \"function\")\n @throwTypeError(\"Expected fs.close to be a function\");\n if (typeof fs2\?.open !== \"function\")\n @throwTypeError(\"Expected fs.open to be a function\");\n if (typeof path === \"object\" && path) {\n if (path instanceof URL)\n path = Bun.fileURLToPath(path);\n }\n if (typeof path !== \"string\" && typeof fd !== \"number\")\n @throwTypeError(\"Expected a path or file descriptor\");\n if (this.start = start, this.#fs = fs2, this.flags = flags, this.mode = mode, this.start !== void 0)\n this.pos = this.start;\n if (encoding !== defaultWriteStreamOptions.encoding) {\n if (this.setDefaultEncoding(encoding), encoding !== \"buffer\" && encoding !== \"utf8\" && encoding !== \"utf-8\" && encoding !== \"binary\")\n this[writeStreamPathFastPathSymbol] = !1;\n }\n }\n get autoClose() {\n return this._writableState.autoDestroy;\n }\n set autoClose(val) {\n this._writableState.autoDestroy = val;\n }\n destroySoon = this.end;\n open() {\n }\n path;\n fd;\n flags;\n mode;\n #fs;\n bytesWritten = 0;\n pos;\n [writeStreamPathFastPathSymbol];\n [writeStreamSymbol] = !0;\n start;\n [writeStreamPathFastPathCallSymbol](readStream, pipeOpts) {\n if (!this[writeStreamPathFastPathSymbol])\n return !1;\n if (this.fd !== null)\n return this[writeStreamPathFastPathSymbol] = !1, !1;\n return this[kIoDone] = !1, readStream[kIoDone] = !1, Bun.write(this[writeStreamPathFastPathSymbol], readStream[readStreamPathOrFdSymbol]).then((bytesWritten) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.bytesWritten += bytesWritten, readStream.bytesRead += bytesWritten, this.end(), readStream.close();\n }, (err) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.#errorOrDestroy(err), readStream.emit(\"error\", err);\n });\n }\n isBunFastPathEnabled() {\n return this[writeStreamPathFastPathSymbol];\n }\n disableBunFastPath() {\n this[writeStreamPathFastPathSymbol] = !1;\n }\n #handleWrite(er, bytes) {\n if (er)\n return this.#errorOrDestroy(er);\n this.bytesWritten += bytes;\n }\n #internalClose(err, cb) {\n this[writeStreamPathFastPathSymbol] = !1;\n var fd = this.fd;\n this.#fs.close(fd, (er) => {\n this.fd = null, cb(err || er);\n });\n }\n _construct(callback) {\n if (typeof this.fd === \"number\") {\n callback();\n return;\n }\n callback(), this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n if (this.fd === null)\n return cb(err);\n if (this[kIoDone]) {\n this.once(kIoDone, () => this.#internalClose(err, cb));\n return;\n }\n this.#internalClose(err, cb);\n }\n [kIoDone] = !1;\n close(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on(\"close\", cb);\n }\n if (!this.autoClose)\n this.on(\"finish\", this.destroy);\n this.end();\n }\n write(chunk, encoding = this._writableState.defaultEncoding, cb) {\n if (this[writeStreamPathFastPathSymbol] = !1, typeof chunk === \"string\")\n chunk = Buffer.from(chunk, encoding);\n var native = this.pos === void 0;\n return this[kIoDone] = !0, super.write(chunk, encoding, native \? (err, bytes) => {\n if (this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), cb)\n !err \? cb() : cb(err);\n } : () => {\n }, native);\n }\n #internalWriteSlow(chunk, encoding, cb) {\n this.#fs.write(this.fd, chunk, 0, chunk.length, this.pos, (err, bytes) => {\n this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), !err \? cb() : cb(err);\n });\n }\n end(chunk, encoding, cb) {\n var native = this.pos === void 0;\n return super.end(chunk, encoding, cb, native);\n }\n _write = this.#internalWriteSlow;\n _writev = void 0;\n get pending() {\n return this.fd === null;\n }\n _destroy(err, cb) {\n this.close(err, cb);\n }\n #errorOrDestroy(err) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n });\n function createWriteStream(path, options) {\n return new WriteStream(path, options);\n }\n return Object.defineProperties(fs, {\n createReadStream: {\n value: createReadStream\n },\n createWriteStream: {\n value: createWriteStream\n },\n ReadStream: {\n value: ReadStream\n },\n WriteStream: {\n value: WriteStream\n }\n }), realpath.native = realpath, realpathSync.native = realpathSync, $ = {\n access,\n accessSync,\n appendFile,\n appendFileSync,\n chmod,\n chmodSync,\n chown,\n chownSync,\n close,\n closeSync,\n constants: promises.constants,\n copyFile,\n copyFileSync,\n createReadStream,\n createWriteStream,\n Dirent,\n exists,\n existsSync,\n fchmod,\n fchmodSync,\n fchown,\n fchownSync,\n fstat,\n fstatSync,\n fsync,\n fsyncSync,\n ftruncate,\n ftruncateSync,\n futimes,\n futimesSync,\n lchmod,\n lchmodSync,\n lchown,\n lchownSync,\n link,\n linkSync,\n lstat,\n lstatSync,\n lutimes,\n lutimesSync,\n mkdir,\n mkdirSync,\n mkdtemp,\n mkdtempSync,\n open,\n openSync,\n promises,\n read,\n readFile,\n readFileSync,\n readSync,\n readdir,\n readdirSync,\n readlink,\n readlinkSync,\n realpath,\n realpathSync,\n rename,\n renameSync,\n rm,\n rmSync,\n rmdir,\n rmdirSync,\n stat,\n statSync,\n Stats,\n symlink,\n symlinkSync,\n truncate,\n truncateSync,\n unlink,\n unlinkSync,\n utimes,\n utimesSync,\n write,\n writeFile,\n writeFileSync,\n writeSync,\n WriteStream,\n ReadStream,\n watch,\n FSWatcher,\n writev,\n writevSync,\n readv,\n readvSync,\n [Symbol.for(\"::bunternal::\")]: {\n ReadStreamClass,\n WriteStreamClass\n }\n }, $;\n})\n"_s; // // @@ -295,7 +295,7 @@ static constexpr ASCIILiteral NodeEventsCode = "(function () {\"use strict\";\n // // -static constexpr ASCIILiteral NodeFSCode = "(function () {\"use strict\";\n var $, ReadStream, WriteStream;\n const EventEmitter = @getInternalField(@internalModuleRegistry, 15) || @createInternalModuleById(15), promises = @getInternalField(@internalModuleRegistry, 17) || @createInternalModuleById(17), Stream = @getInternalField(@internalModuleRegistry, 34) || @createInternalModuleById(34);\n var fs = Bun.fs();\n\n class FSWatcher extends EventEmitter {\n #watcher;\n #listener;\n constructor(path, options, listener) {\n super();\n if (typeof options === \"function\")\n listener = options, options = {};\n else if (typeof options === \"string\")\n options = { encoding: options };\n if (typeof listener !== \"function\")\n listener = () => {\n };\n this.#listener = listener;\n try {\n this.#watcher = fs.watch(path, options || {}, this.#onEvent.bind(this));\n } catch (e) {\n if (!e.message\?.startsWith(\"FileNotFound\"))\n throw e;\n const notFound = new Error(`ENOENT: no such file or directory, watch '${path}'`);\n throw notFound.code = \"ENOENT\", notFound.errno = -2, notFound.path = path, notFound.syscall = \"watch\", notFound.filename = path, notFound;\n }\n }\n #onEvent(eventType, filenameOrError) {\n if (eventType === \"error\" || eventType === \"close\")\n this.emit(eventType, filenameOrError);\n else\n this.emit(\"change\", eventType, filenameOrError), this.#listener(eventType, filenameOrError);\n }\n close() {\n this.#watcher\?.close(), this.#watcher = null;\n }\n ref() {\n this.#watcher\?.ref();\n }\n unref() {\n this.#watcher\?.unref();\n }\n }\n var access = function access(...args) {\n callbackify(fs.accessSync, args);\n }, appendFile = function appendFile(...args) {\n callbackify(fs.appendFileSync, args);\n }, close = function close(...args) {\n callbackify(fs.closeSync, args);\n }, rm = function rm(...args) {\n callbackify(fs.rmSync, args);\n }, rmdir = function rmdir(...args) {\n callbackify(fs.rmdirSync, args);\n }, copyFile = function copyFile(...args) {\n callbackify(fs.copyFileSync, args);\n }, exists = function exists(...args) {\n callbackify(fs.existsSync, args);\n }, chown = function chown(...args) {\n callbackify(fs.chownSync, args);\n }, chmod = function chmod(...args) {\n callbackify(fs.chmodSync, args);\n }, fchmod = function fchmod(...args) {\n callbackify(fs.fchmodSync, args);\n }, fchown = function fchown(...args) {\n callbackify(fs.fchownSync, args);\n }, fstat = function fstat(...args) {\n callbackify(fs.fstatSync, args);\n }, fsync = function fsync(...args) {\n callbackify(fs.fsyncSync, args);\n }, ftruncate = function ftruncate(...args) {\n callbackify(fs.ftruncateSync, args);\n }, futimes = function futimes(...args) {\n callbackify(fs.futimesSync, args);\n }, lchmod = function lchmod(...args) {\n callbackify(fs.lchmodSync, args);\n }, lchown = function lchown(...args) {\n callbackify(fs.lchownSync, args);\n }, link = function link(...args) {\n callbackify(fs.linkSync, args);\n }, mkdir = function mkdir(...args) {\n callbackify(fs.mkdirSync, args);\n }, mkdtemp = function mkdtemp(...args) {\n callbackify(fs.mkdtempSync, args);\n }, open = function open(...args) {\n callbackify(fs.openSync, args);\n }, read = function read(...args) {\n callbackify(fs.readSync, args);\n }, write = function write(...args) {\n callbackify(fs.writeSync, args);\n }, readdir = function readdir(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readdir(...args).then((result) => callback(null, result), callback);\n }, readFile = function readFile(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readFile(...args).then((result) => callback(null, result), callback);\n }, writeFile = function writeFile(...args) {\n callbackify(fs.writeFileSync, args);\n }, readlink = function readlink(...args) {\n callbackify(fs.readlinkSync, args);\n }, realpath = function realpath(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.realpath(...args).then((result) => callback(null, result), callback);\n }, rename = function rename(...args) {\n callbackify(fs.renameSync, args);\n }, lstat = function lstat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.lstat(...args).then((result) => callback(null, result), callback);\n }, stat = function stat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.stat(...args).then((result) => callback(null, result), callback);\n }, symlink = function symlink(...args) {\n callbackify(fs.symlinkSync, args);\n }, truncate = function truncate(...args) {\n callbackify(fs.truncateSync, args);\n }, unlink = function unlink(...args) {\n callbackify(fs.unlinkSync, args);\n }, utimes = function utimes(...args) {\n callbackify(fs.utimesSync, args);\n }, lutimes = function lutimes(...args) {\n callbackify(fs.lutimesSync, args);\n }, accessSync = fs.accessSync.bind(fs), appendFileSync = fs.appendFileSync.bind(fs), closeSync = fs.closeSync.bind(fs), copyFileSync = fs.copyFileSync.bind(fs), existsSync = fs.existsSync.bind(fs), chownSync = fs.chownSync.bind(fs), chmodSync = fs.chmodSync.bind(fs), fchmodSync = fs.fchmodSync.bind(fs), fchownSync = fs.fchownSync.bind(fs), fstatSync = fs.fstatSync.bind(fs), fsyncSync = fs.fsyncSync.bind(fs), ftruncateSync = fs.ftruncateSync.bind(fs), futimesSync = fs.futimesSync.bind(fs), lchmodSync = fs.lchmodSync.bind(fs), lchownSync = fs.lchownSync.bind(fs), linkSync = fs.linkSync.bind(fs), lstatSync = fs.lstatSync.bind(fs), mkdirSync = fs.mkdirSync.bind(fs), mkdtempSync = fs.mkdtempSync.bind(fs), openSync = fs.openSync.bind(fs), readSync = fs.readSync.bind(fs), writeSync = fs.writeSync.bind(fs), readdirSync = fs.readdirSync.bind(fs), readFileSync = fs.readFileSync.bind(fs), writeFileSync = fs.writeFileSync.bind(fs), readlinkSync = fs.readlinkSync.bind(fs), realpathSync = fs.realpathSync.bind(fs), renameSync = fs.renameSync.bind(fs), statSync = fs.statSync.bind(fs), symlinkSync = fs.symlinkSync.bind(fs), truncateSync = fs.truncateSync.bind(fs), unlinkSync = fs.unlinkSync.bind(fs), utimesSync = fs.utimesSync.bind(fs), lutimesSync = fs.lutimesSync.bind(fs), rmSync = fs.rmSync.bind(fs), rmdirSync = fs.rmdirSync.bind(fs), writev = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.writevSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, writevSync = fs.writevSync.bind(fs), readv = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.readvSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, readvSync = fs.readvSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch(path, options, listener) {\n return new FSWatcher(path, options, listener);\n };\n function callbackify(fsFunction, args) {\n try {\n const result = fsFunction.apply(fs, args.slice(0, args.length - 1)), callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(null, result));\n } catch (e) {\n const callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(e));\n }\n }\n var readStreamPathFastPathSymbol = Symbol.for(\"Bun.Node.readStreamPathFastPath\");\n const readStreamSymbol = Symbol.for(\"Bun.NodeReadStream\"), readStreamPathOrFdSymbol = Symbol.for(\"Bun.NodeReadStreamPathOrFd\"), writeStreamSymbol = Symbol.for(\"Bun.NodeWriteStream\");\n var writeStreamPathFastPathSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPath\"), writeStreamPathFastPathCallSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"), kIoDone = Symbol.for(\"kIoDone\"), defaultReadStreamOptions = {\n file: void 0,\n fd: void 0,\n flags: \"r\",\n encoding: void 0,\n mode: 438,\n autoClose: !0,\n emitClose: !0,\n start: 0,\n end: Infinity,\n highWaterMark: 65536,\n fs: {\n read,\n open: (path, flags, mode, cb) => {\n var fd;\n try {\n fd = openSync(path, flags, mode);\n } catch (e) {\n cb(e);\n return;\n }\n cb(null, fd);\n },\n openSync,\n close\n },\n autoDestroy: !0\n }, ReadStreamClass;\n ReadStream = function(InternalReadStream) {\n ReadStreamClass = InternalReadStream, Object.defineProperty(ReadStreamClass.prototype, Symbol.toStringTag, {\n value: \"ReadStream\",\n enumerable: !1\n });\n function ReadStream2(path, options) {\n return new InternalReadStream(path, options);\n }\n return ReadStream2.prototype = InternalReadStream.prototype, Object.defineProperty(ReadStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalReadStream;\n }\n });\n }(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2, Stream.Readable) {\n constructor(pathOrFd, options = defaultReadStreamOptions) {\n if (typeof options !== \"object\" || !options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n flags = defaultReadStreamOptions.flags,\n encoding = defaultReadStreamOptions.encoding,\n mode = defaultReadStreamOptions.mode,\n autoClose = defaultReadStreamOptions.autoClose,\n emitClose = defaultReadStreamOptions.emitClose,\n start = defaultReadStreamOptions.start,\n end = defaultReadStreamOptions.end,\n autoDestroy = defaultReadStreamOptions.autoClose,\n fs: fs2 = defaultReadStreamOptions.fs,\n highWaterMark = defaultReadStreamOptions.highWaterMark\n } = options;\n if (pathOrFd\?.constructor\?.name === \"URL\")\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n var tempThis = {};\n if (typeof pathOrFd === \"string\") {\n if (pathOrFd.startsWith(\"file://\"))\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n if (pathOrFd.length === 0)\n @throwTypeError(\"Expected path to be a non-empty string\");\n tempThis.path = tempThis.file = tempThis[readStreamPathOrFdSymbol] = pathOrFd;\n } else if (typeof pathOrFd === \"number\") {\n if (pathOrFd |= 0, pathOrFd < 0)\n @throwTypeError(\"Expected fd to be a positive integer\");\n tempThis.fd = tempThis[readStreamPathOrFdSymbol] = pathOrFd, tempThis.autoClose = !1;\n } else\n @throwTypeError(\"Expected a path or file descriptor\");\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(pathOrFd, flags, mode);\n var fileRef = Bun.file(tempThis.fd), stream = fileRef.stream(), native = @direct(stream);\n if (!native)\n throw new Error(\"no native readable stream\");\n var { stream: ptr } = native;\n super(ptr, {\n ...options,\n encoding,\n autoDestroy,\n autoClose,\n emitClose,\n highWaterMark\n });\n if (Object.assign(this, tempThis), this.#fileRef = fileRef, this.end = end, this._read = this.#internalRead, this.start = start, this.flags = flags, this.mode = mode, this.emitClose = emitClose, this[readStreamPathFastPathSymbol] = start === 0 && end === Infinity && autoClose && fs2 === defaultReadStreamOptions.fs && (encoding === \"buffer\" || encoding === \"binary\" || encoding == null || encoding === \"utf-8\" || encoding === \"utf8\"), this._readableState.autoClose = autoDestroy = autoClose, this._readableState.highWaterMark = highWaterMark, start !== void 0)\n this.pos = start;\n }\n #fileRef;\n #fs;\n file;\n path;\n fd = null;\n flags;\n mode;\n start;\n end;\n pos;\n bytesRead = 0;\n #fileSize = -1;\n _read;\n [readStreamSymbol] = !0;\n [readStreamPathOrFdSymbol];\n [readStreamPathFastPathSymbol];\n _construct(callback) {\n if (super._construct)\n super._construct(callback);\n else\n callback();\n this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n super._destroy(err, cb);\n try {\n var fd = this.fd;\n if (this[readStreamPathFastPathSymbol] = !1, !fd)\n cb(err);\n else\n this.#fs.close(fd, (er) => {\n cb(er || err);\n }), this.fd = null;\n } catch (e) {\n throw e;\n }\n }\n close(cb) {\n if (typeof cb === \"function\")\n eos_()(this, cb);\n this.destroy();\n }\n push(chunk) {\n var bytesRead = chunk\?.length \?\? 0;\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n var currPos = this.pos;\n if (currPos !== void 0) {\n if (this.bytesRead < currPos)\n return !0;\n if (currPos === this.start) {\n var n = this.bytesRead - currPos;\n chunk = chunk.slice(-n);\n var [_, ...rest] = arguments;\n if (this.pos = this.bytesRead, this.end !== void 0 && this.bytesRead > this.end)\n chunk = chunk.slice(0, this.end - this.start + 1);\n return super.push(chunk, ...rest);\n }\n var end = this.end;\n if (end !== void 0 && this.bytesRead > end) {\n chunk = chunk.slice(0, end - currPos + 1);\n var [_, ...rest] = arguments;\n return this.pos = this.bytesRead, super.push(chunk, ...rest);\n }\n this.pos = this.bytesRead;\n }\n }\n return super.push(...arguments);\n }\n #internalRead(n) {\n var { pos, end, bytesRead, fd, encoding } = this;\n if (n = pos !== void 0 \? Math.min(end - pos + 1, n) : Math.min(end - bytesRead + 1, n), n <= 0) {\n this.push(null);\n return;\n }\n if (this.#fileSize === -1 && bytesRead === 0 && pos === void 0) {\n var stat2 = fstatSync(fd);\n if (this.#fileSize = stat2.size, this.#fileSize > 0 && n > this.#fileSize)\n n = this.#fileSize + 1;\n }\n this[kIoDone] = !1;\n var res = super._read(n);\n if (@isPromise(res)) {\n var then = res\?.then;\n if (then && @isCallable(then))\n then(() => {\n if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone);\n }, (er) => {\n this[kIoDone] = !0, this.#errorOrDestroy(er);\n });\n } else if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone), this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"));\n }\n #errorOrDestroy(err, sync = null) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n pause() {\n return this[readStreamPathFastPathSymbol] = !1, super.pause();\n }\n resume() {\n return this[readStreamPathFastPathSymbol] = !1, super.resume();\n }\n unshift(...args) {\n return this[readStreamPathFastPathSymbol] = !1, super.unshift(...args);\n }\n pipe(dest, pipeOpts) {\n if (this[readStreamPathFastPathSymbol] && (pipeOpts\?.end \?\? !0) && this._readableState\?.pipes\?.length === 0) {\n if ((writeStreamPathFastPathSymbol in dest) && dest[writeStreamPathFastPathSymbol]) {\n if (dest[writeStreamPathFastPathCallSymbol](this, pipeOpts))\n return this;\n }\n }\n return this[readStreamPathFastPathSymbol] = !1, super.pipe(dest, pipeOpts);\n }\n });\n function createReadStream(path, options) {\n return new ReadStream(path, options);\n }\n var defaultWriteStreamOptions = {\n fd: null,\n start: void 0,\n pos: void 0,\n encoding: void 0,\n flags: \"w\",\n mode: 438,\n fs: {\n write,\n close,\n open,\n openSync\n }\n }, WriteStreamClass;\n WriteStream = function(InternalWriteStream) {\n WriteStreamClass = InternalWriteStream, Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, {\n value: \"WritesStream\",\n enumerable: !1\n });\n function WriteStream2(path, options) {\n return new InternalWriteStream(path, options);\n }\n return WriteStream2.prototype = InternalWriteStream.prototype, Object.defineProperty(WriteStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalWriteStream;\n }\n });\n }(class WriteStream2 extends Stream.NativeWritable {\n constructor(path, options = defaultWriteStreamOptions) {\n if (!options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n fs: fs2 = defaultWriteStreamOptions.fs,\n start = defaultWriteStreamOptions.start,\n flags = defaultWriteStreamOptions.flags,\n mode = defaultWriteStreamOptions.mode,\n autoClose = !0,\n emitClose = !1,\n autoDestroy = autoClose,\n encoding = defaultWriteStreamOptions.encoding,\n fd = defaultWriteStreamOptions.fd,\n pos = defaultWriteStreamOptions.pos\n } = options, tempThis = {};\n if (typeof path === \"string\") {\n if (path.length === 0)\n @throwTypeError(\"Expected a non-empty path\");\n if (path.startsWith(\"file:\"))\n path = Bun.fileURLToPath(path);\n tempThis.path = path, tempThis.fd = null, tempThis[writeStreamPathFastPathSymbol] = autoClose && (start === void 0 || start === 0) && fs2.write === defaultWriteStreamOptions.fs.write && fs2.close === defaultWriteStreamOptions.fs.close;\n } else\n tempThis.fd = fd, tempThis[writeStreamPathFastPathSymbol] = !1;\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(path, flags, mode);\n super(tempThis.fd, {\n ...options,\n decodeStrings: !1,\n autoDestroy,\n emitClose,\n fd: tempThis\n });\n if (Object.assign(this, tempThis), typeof fs2\?.write !== \"function\")\n @throwTypeError(\"Expected fs.write to be a function\");\n if (typeof fs2\?.close !== \"function\")\n @throwTypeError(\"Expected fs.close to be a function\");\n if (typeof fs2\?.open !== \"function\")\n @throwTypeError(\"Expected fs.open to be a function\");\n if (typeof path === \"object\" && path) {\n if (path instanceof URL)\n path = Bun.fileURLToPath(path);\n }\n if (typeof path !== \"string\" && typeof fd !== \"number\")\n @throwTypeError(\"Expected a path or file descriptor\");\n if (this.start = start, this.#fs = fs2, this.flags = flags, this.mode = mode, this.start !== void 0)\n this.pos = this.start;\n if (encoding !== defaultWriteStreamOptions.encoding) {\n if (this.setDefaultEncoding(encoding), encoding !== \"buffer\" && encoding !== \"utf8\" && encoding !== \"utf-8\" && encoding !== \"binary\")\n this[writeStreamPathFastPathSymbol] = !1;\n }\n }\n get autoClose() {\n return this._writableState.autoDestroy;\n }\n set autoClose(val) {\n this._writableState.autoDestroy = val;\n }\n destroySoon = this.end;\n open() {\n }\n path;\n fd;\n flags;\n mode;\n #fs;\n bytesWritten = 0;\n pos;\n [writeStreamPathFastPathSymbol];\n [writeStreamSymbol] = !0;\n start;\n [writeStreamPathFastPathCallSymbol](readStream, pipeOpts) {\n if (!this[writeStreamPathFastPathSymbol])\n return !1;\n if (this.fd !== null)\n return this[writeStreamPathFastPathSymbol] = !1, !1;\n return this[kIoDone] = !1, readStream[kIoDone] = !1, Bun.write(this[writeStreamPathFastPathSymbol], readStream[readStreamPathOrFdSymbol]).then((bytesWritten) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.bytesWritten += bytesWritten, readStream.bytesRead += bytesWritten, this.end(), readStream.close();\n }, (err) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.#errorOrDestroy(err), readStream.emit(\"error\", err);\n });\n }\n isBunFastPathEnabled() {\n return this[writeStreamPathFastPathSymbol];\n }\n disableBunFastPath() {\n this[writeStreamPathFastPathSymbol] = !1;\n }\n #handleWrite(er, bytes) {\n if (er)\n return this.#errorOrDestroy(er);\n this.bytesWritten += bytes;\n }\n #internalClose(err, cb) {\n this[writeStreamPathFastPathSymbol] = !1;\n var fd = this.fd;\n this.#fs.close(fd, (er) => {\n this.fd = null, cb(err || er);\n });\n }\n _construct(callback) {\n if (typeof this.fd === \"number\") {\n callback();\n return;\n }\n callback(), this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n if (this.fd === null)\n return cb(err);\n if (this[kIoDone]) {\n this.once(kIoDone, () => this.#internalClose(err, cb));\n return;\n }\n this.#internalClose(err, cb);\n }\n [kIoDone] = !1;\n close(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on(\"close\", cb);\n }\n if (!this.autoClose)\n this.on(\"finish\", this.destroy);\n this.end();\n }\n write(chunk, encoding = this._writableState.defaultEncoding, cb) {\n if (this[writeStreamPathFastPathSymbol] = !1, typeof chunk === \"string\")\n chunk = Buffer.from(chunk, encoding);\n var native = this.pos === void 0;\n return this[kIoDone] = !0, super.write(chunk, encoding, native \? (err, bytes) => {\n if (this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), cb)\n !err \? cb() : cb(err);\n } : () => {\n }, native);\n }\n #internalWriteSlow(chunk, encoding, cb) {\n this.#fs.write(this.fd, chunk, 0, chunk.length, this.pos, (err, bytes) => {\n this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), !err \? cb() : cb(err);\n });\n }\n end(chunk, encoding, cb) {\n var native = this.pos === void 0;\n return super.end(chunk, encoding, cb, native);\n }\n _write = this.#internalWriteSlow;\n _writev = void 0;\n get pending() {\n return this.fd === null;\n }\n _destroy(err, cb) {\n this.close(err, cb);\n }\n #errorOrDestroy(err) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n });\n function createWriteStream(path, options) {\n return new WriteStream(path, options);\n }\n return Object.defineProperties(fs, {\n createReadStream: {\n value: createReadStream\n },\n createWriteStream: {\n value: createWriteStream\n },\n ReadStream: {\n value: ReadStream\n },\n WriteStream: {\n value: WriteStream\n }\n }), realpath.native = realpath, realpathSync.native = realpathSync, $ = {\n access,\n accessSync,\n appendFile,\n appendFileSync,\n chmod,\n chmodSync,\n chown,\n chownSync,\n close,\n closeSync,\n constants: promises.constants,\n copyFile,\n copyFileSync,\n createReadStream,\n createWriteStream,\n Dirent,\n exists,\n existsSync,\n fchmod,\n fchmodSync,\n fchown,\n fchownSync,\n fstat,\n fstatSync,\n fsync,\n fsyncSync,\n ftruncate,\n ftruncateSync,\n futimes,\n futimesSync,\n lchmod,\n lchmodSync,\n lchown,\n lchownSync,\n link,\n linkSync,\n lstat,\n lstatSync,\n lutimes,\n lutimesSync,\n mkdir,\n mkdirSync,\n mkdtemp,\n mkdtempSync,\n open,\n openSync,\n promises,\n read,\n readFile,\n readFileSync,\n readSync,\n readdir,\n readdirSync,\n readlink,\n readlinkSync,\n realpath,\n realpathSync,\n rename,\n renameSync,\n rm,\n rmSync,\n rmdir,\n rmdirSync,\n stat,\n statSync,\n Stats,\n symlink,\n symlinkSync,\n truncate,\n truncateSync,\n unlink,\n unlinkSync,\n utimes,\n utimesSync,\n write,\n writeFile,\n writeFileSync,\n writeSync,\n WriteStream,\n ReadStream,\n watch,\n FSWatcher,\n writev,\n writevSync,\n readv,\n readvSync,\n [Symbol.for(\"::bunternal::\")]: {\n ReadStreamClass,\n WriteStreamClass\n }\n }, $;\n})\n"_s; +static constexpr ASCIILiteral NodeFSCode = "(function () {\"use strict\";\n var $, ReadStream, WriteStream;\n const EventEmitter = @getInternalField(@internalModuleRegistry, 15) || @createInternalModuleById(15), promises = @getInternalField(@internalModuleRegistry, 17) || @createInternalModuleById(17), Stream = @getInternalField(@internalModuleRegistry, 34) || @createInternalModuleById(34);\n var fs = Bun.fs();\n\n class FSWatcher extends EventEmitter {\n #watcher;\n #listener;\n constructor(path, options, listener) {\n super();\n if (typeof options === \"function\")\n listener = options, options = {};\n else if (typeof options === \"string\")\n options = { encoding: options };\n if (typeof listener !== \"function\")\n listener = () => {\n };\n this.#listener = listener;\n try {\n this.#watcher = fs.watch(path, options || {}, this.#onEvent.bind(this));\n } catch (e) {\n if (!e.message\?.startsWith(\"FileNotFound\"))\n throw e;\n const notFound = new Error(`ENOENT: no such file or directory, watch '${path}'`);\n throw notFound.code = \"ENOENT\", notFound.errno = -2, notFound.path = path, notFound.syscall = \"watch\", notFound.filename = path, notFound;\n }\n }\n #onEvent(eventType, filenameOrError) {\n if (eventType === \"error\" || eventType === \"close\")\n this.emit(eventType, filenameOrError);\n else\n this.emit(\"change\", eventType, filenameOrError), this.#listener(eventType, filenameOrError);\n }\n close() {\n this.#watcher\?.close(), this.#watcher = null;\n }\n ref() {\n this.#watcher\?.ref();\n }\n unref() {\n this.#watcher\?.unref();\n }\n }\n var access = function access(...args) {\n callbackify(fs.accessSync, args);\n }, appendFile = function appendFile(...args) {\n callbackify(fs.appendFileSync, args);\n }, close = function close(...args) {\n callbackify(fs.closeSync, args);\n }, rm = function rm(...args) {\n callbackify(fs.rmSync, args);\n }, rmdir = function rmdir(...args) {\n callbackify(fs.rmdirSync, args);\n }, copyFile = function copyFile(...args) {\n callbackify(fs.copyFileSync, args);\n }, exists = function exists(...args) {\n callbackify(fs.existsSync, args);\n }, chown = function chown(...args) {\n callbackify(fs.chownSync, args);\n }, chmod = function chmod(...args) {\n callbackify(fs.chmodSync, args);\n }, fchmod = function fchmod(...args) {\n callbackify(fs.fchmodSync, args);\n }, fchown = function fchown(...args) {\n callbackify(fs.fchownSync, args);\n }, fstat = function fstat(...args) {\n callbackify(fs.fstatSync, args);\n }, fsync = function fsync(...args) {\n callbackify(fs.fsyncSync, args);\n }, ftruncate = function ftruncate(...args) {\n callbackify(fs.ftruncateSync, args);\n }, futimes = function futimes(...args) {\n callbackify(fs.futimesSync, args);\n }, lchmod = function lchmod(...args) {\n callbackify(fs.lchmodSync, args);\n }, lchown = function lchown(...args) {\n callbackify(fs.lchownSync, args);\n }, link = function link(...args) {\n callbackify(fs.linkSync, args);\n }, mkdir = function mkdir(...args) {\n callbackify(fs.mkdirSync, args);\n }, mkdtemp = function mkdtemp(...args) {\n callbackify(fs.mkdtempSync, args);\n }, open = function open(...args) {\n callbackify(fs.openSync, args);\n }, read = function read(...args) {\n callbackify(fs.readSync, args);\n }, write = function write(...args) {\n callbackify(fs.writeSync, args);\n }, readdir = function readdir(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readdir(...args).then((result) => callback(null, result), callback);\n }, readFile = function readFile(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readFile(...args).then((result) => callback(null, result), callback);\n }, writeFile = function writeFile(...args) {\n callbackify(fs.writeFileSync, args);\n }, readlink = function readlink(...args) {\n callbackify(fs.readlinkSync, args);\n }, realpath = function realpath(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.realpath(...args).then((result) => callback(null, result), callback);\n }, rename = function rename(...args) {\n callbackify(fs.renameSync, args);\n }, lstat = function lstat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.lstat(...args).then((result) => callback(null, result), callback);\n }, stat = function stat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.stat(...args).then((result) => callback(null, result), callback);\n }, symlink = function symlink(...args) {\n callbackify(fs.symlinkSync, args);\n }, truncate = function truncate(...args) {\n callbackify(fs.truncateSync, args);\n }, unlink = function unlink(...args) {\n callbackify(fs.unlinkSync, args);\n }, utimes = function utimes(...args) {\n callbackify(fs.utimesSync, args);\n }, lutimes = function lutimes(...args) {\n callbackify(fs.lutimesSync, args);\n }, accessSync = fs.accessSync.bind(fs), appendFileSync = fs.appendFileSync.bind(fs), closeSync = fs.closeSync.bind(fs), copyFileSync = fs.copyFileSync.bind(fs), existsSync = fs.existsSync.bind(fs), chownSync = fs.chownSync.bind(fs), chmodSync = fs.chmodSync.bind(fs), fchmodSync = fs.fchmodSync.bind(fs), fchownSync = fs.fchownSync.bind(fs), fstatSync = fs.fstatSync.bind(fs), fsyncSync = fs.fsyncSync.bind(fs), ftruncateSync = fs.ftruncateSync.bind(fs), futimesSync = fs.futimesSync.bind(fs), lchmodSync = fs.lchmodSync.bind(fs), lchownSync = fs.lchownSync.bind(fs), linkSync = fs.linkSync.bind(fs), lstatSync = fs.lstatSync.bind(fs), mkdirSync = fs.mkdirSync.bind(fs), mkdtempSync = fs.mkdtempSync.bind(fs), openSync = fs.openSync.bind(fs), readSync = fs.readSync.bind(fs), writeSync = fs.writeSync.bind(fs), readdirSync = fs.readdirSync.bind(fs), readFileSync = fs.readFileSync.bind(fs), writeFileSync = fs.writeFileSync.bind(fs), readlinkSync = fs.readlinkSync.bind(fs), realpathSync = fs.realpathSync.bind(fs), renameSync = fs.renameSync.bind(fs), statSync = fs.statSync.bind(fs), symlinkSync = fs.symlinkSync.bind(fs), truncateSync = fs.truncateSync.bind(fs), unlinkSync = fs.unlinkSync.bind(fs), utimesSync = fs.utimesSync.bind(fs), lutimesSync = fs.lutimesSync.bind(fs), rmSync = fs.rmSync.bind(fs), rmdirSync = fs.rmdirSync.bind(fs), writev = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.writevSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, writevSync = fs.writevSync.bind(fs), readv = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.readvSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, readvSync = fs.readvSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch(path, options, listener) {\n return new FSWatcher(path, options, listener);\n };\n function callbackify(fsFunction, args) {\n try {\n const result = fsFunction.apply(fs, args.slice(0, args.length - 1)), callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(null, result));\n } catch (e) {\n const callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(e));\n }\n }\n var readStreamPathFastPathSymbol = Symbol.for(\"Bun.Node.readStreamPathFastPath\");\n const readStreamSymbol = Symbol.for(\"Bun.NodeReadStream\"), readStreamPathOrFdSymbol = Symbol.for(\"Bun.NodeReadStreamPathOrFd\"), writeStreamSymbol = Symbol.for(\"Bun.NodeWriteStream\");\n var writeStreamPathFastPathSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPath\"), writeStreamPathFastPathCallSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"), kIoDone = Symbol.for(\"kIoDone\"), defaultReadStreamOptions = {\n file: void 0,\n fd: void 0,\n flags: \"r\",\n encoding: void 0,\n mode: 438,\n autoClose: !0,\n emitClose: !0,\n start: 0,\n end: Infinity,\n highWaterMark: 65536,\n fs: {\n read,\n open: (path, flags, mode, cb) => {\n var fd;\n try {\n fd = openSync(path, flags, mode);\n } catch (e) {\n cb(e);\n return;\n }\n cb(null, fd);\n },\n openSync,\n close\n },\n autoDestroy: !0\n }, ReadStreamClass;\n ReadStream = function(InternalReadStream) {\n ReadStreamClass = InternalReadStream, Object.defineProperty(ReadStreamClass.prototype, Symbol.toStringTag, {\n value: \"ReadStream\",\n enumerable: !1\n });\n function ReadStream2(path, options) {\n return new InternalReadStream(path, options);\n }\n return ReadStream2.prototype = InternalReadStream.prototype, Object.defineProperty(ReadStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalReadStream;\n }\n });\n }(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2, Stream.Readable) {\n constructor(pathOrFd, options = defaultReadStreamOptions) {\n if (typeof options !== \"object\" || !options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n flags = defaultReadStreamOptions.flags,\n encoding = defaultReadStreamOptions.encoding,\n mode = defaultReadStreamOptions.mode,\n autoClose = defaultReadStreamOptions.autoClose,\n emitClose = defaultReadStreamOptions.emitClose,\n start = defaultReadStreamOptions.start,\n end = defaultReadStreamOptions.end,\n autoDestroy = defaultReadStreamOptions.autoClose,\n fs: fs2 = defaultReadStreamOptions.fs,\n highWaterMark = defaultReadStreamOptions.highWaterMark\n } = options;\n if (pathOrFd\?.constructor\?.name === \"URL\")\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n var tempThis = {};\n if (typeof pathOrFd === \"string\") {\n if (pathOrFd.startsWith(\"file://\"))\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n if (pathOrFd.length === 0)\n @throwTypeError(\"Expected path to be a non-empty string\");\n tempThis.path = tempThis.file = tempThis[readStreamPathOrFdSymbol] = pathOrFd;\n } else if (typeof pathOrFd === \"number\") {\n if (pathOrFd |= 0, pathOrFd < 0)\n @throwTypeError(\"Expected fd to be a positive integer\");\n tempThis.fd = tempThis[readStreamPathOrFdSymbol] = pathOrFd, tempThis.autoClose = !1;\n } else\n @throwTypeError(\"Expected a path or file descriptor\");\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(pathOrFd, flags, mode);\n var fileRef = Bun.file(tempThis.fd), stream = fileRef.stream(), native = @direct(stream);\n if (!native)\n throw new Error(\"no native readable stream\");\n var { stream: ptr } = native;\n super(ptr, {\n ...options,\n encoding,\n autoDestroy,\n autoClose,\n emitClose,\n highWaterMark\n });\n if (Object.assign(this, tempThis), this.#fileRef = fileRef, this.end = end, this._read = this.#internalRead, this.start = start, this.flags = flags, this.mode = mode, this.emitClose = emitClose, this[readStreamPathFastPathSymbol] = start === 0 && end === Infinity && autoClose && fs2 === defaultReadStreamOptions.fs && (encoding === \"buffer\" || encoding === \"binary\" || encoding == null || encoding === \"utf-8\" || encoding === \"utf8\"), this._readableState.autoClose = autoDestroy = autoClose, this._readableState.highWaterMark = highWaterMark, start !== void 0)\n this.pos = start;\n }\n #fileRef;\n #fs;\n file;\n path;\n fd = null;\n flags;\n mode;\n start;\n end;\n pos;\n bytesRead = 0;\n #fileSize = -1;\n _read;\n [readStreamSymbol] = !0;\n [readStreamPathOrFdSymbol];\n [readStreamPathFastPathSymbol];\n _construct(callback) {\n if (super._construct)\n super._construct(callback);\n else\n callback();\n this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n super._destroy(err, cb);\n try {\n var fd = this.fd;\n if (this[readStreamPathFastPathSymbol] = !1, !fd)\n cb(err);\n else\n this.#fs.close(fd, (er) => {\n cb(er || err);\n }), this.fd = null;\n } catch (e) {\n throw e;\n }\n }\n close(cb) {\n if (typeof cb === \"function\")\n eos_()(this, cb);\n this.destroy();\n }\n push(chunk) {\n var bytesRead = chunk\?.length \?\? 0;\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n var currPos = this.pos;\n if (currPos !== void 0) {\n if (this.bytesRead < currPos)\n return !0;\n if (currPos === this.start) {\n var n = this.bytesRead - currPos;\n chunk = chunk.slice(-n);\n var [_, ...rest] = arguments;\n if (this.pos = this.bytesRead, this.end !== void 0 && this.bytesRead > this.end)\n chunk = chunk.slice(0, this.end - this.start + 1);\n return super.push(chunk, ...rest);\n }\n var end = this.end;\n if (end !== void 0 && this.bytesRead > end) {\n chunk = chunk.slice(0, end - currPos + 1);\n var [_, ...rest] = arguments;\n return this.pos = this.bytesRead, super.push(chunk, ...rest);\n }\n this.pos = this.bytesRead;\n }\n }\n return super.push(...arguments);\n }\n #internalRead(n) {\n var { pos, end, bytesRead, fd, encoding } = this;\n if (n = pos !== void 0 \? Math.min(end - pos + 1, n) : Math.min(end - bytesRead + 1, n), n <= 0) {\n this.push(null);\n return;\n }\n if (this.#fileSize === -1 && bytesRead === 0 && pos === void 0) {\n var stat2 = fstatSync(fd);\n if (this.#fileSize = stat2.size, this.#fileSize > 0 && n > this.#fileSize)\n n = this.#fileSize + 1;\n }\n this[kIoDone] = !1;\n var res = super._read(n);\n if (@isPromise(res)) {\n var then = res\?.then;\n if (then && @isCallable(then))\n res.then(() => {\n if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone);\n }, (er) => {\n this[kIoDone] = !0, this.#errorOrDestroy(er);\n });\n } else if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone), this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"));\n }\n #errorOrDestroy(err, sync = null) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n pause() {\n return this[readStreamPathFastPathSymbol] = !1, super.pause();\n }\n resume() {\n return this[readStreamPathFastPathSymbol] = !1, super.resume();\n }\n unshift(...args) {\n return this[readStreamPathFastPathSymbol] = !1, super.unshift(...args);\n }\n pipe(dest, pipeOpts) {\n if (this[readStreamPathFastPathSymbol] && (pipeOpts\?.end \?\? !0) && this._readableState\?.pipes\?.length === 0) {\n if ((writeStreamPathFastPathSymbol in dest) && dest[writeStreamPathFastPathSymbol]) {\n if (dest[writeStreamPathFastPathCallSymbol](this, pipeOpts))\n return this;\n }\n }\n return this[readStreamPathFastPathSymbol] = !1, super.pipe(dest, pipeOpts);\n }\n });\n function createReadStream(path, options) {\n return new ReadStream(path, options);\n }\n var defaultWriteStreamOptions = {\n fd: null,\n start: void 0,\n pos: void 0,\n encoding: void 0,\n flags: \"w\",\n mode: 438,\n fs: {\n write,\n close,\n open,\n openSync\n }\n }, WriteStreamClass;\n WriteStream = function(InternalWriteStream) {\n WriteStreamClass = InternalWriteStream, Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, {\n value: \"WritesStream\",\n enumerable: !1\n });\n function WriteStream2(path, options) {\n return new InternalWriteStream(path, options);\n }\n return WriteStream2.prototype = InternalWriteStream.prototype, Object.defineProperty(WriteStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalWriteStream;\n }\n });\n }(class WriteStream2 extends Stream.NativeWritable {\n constructor(path, options = defaultWriteStreamOptions) {\n if (!options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n fs: fs2 = defaultWriteStreamOptions.fs,\n start = defaultWriteStreamOptions.start,\n flags = defaultWriteStreamOptions.flags,\n mode = defaultWriteStreamOptions.mode,\n autoClose = !0,\n emitClose = !1,\n autoDestroy = autoClose,\n encoding = defaultWriteStreamOptions.encoding,\n fd = defaultWriteStreamOptions.fd,\n pos = defaultWriteStreamOptions.pos\n } = options, tempThis = {};\n if (typeof path === \"string\") {\n if (path.length === 0)\n @throwTypeError(\"Expected a non-empty path\");\n if (path.startsWith(\"file:\"))\n path = Bun.fileURLToPath(path);\n tempThis.path = path, tempThis.fd = null, tempThis[writeStreamPathFastPathSymbol] = autoClose && (start === void 0 || start === 0) && fs2.write === defaultWriteStreamOptions.fs.write && fs2.close === defaultWriteStreamOptions.fs.close;\n } else\n tempThis.fd = fd, tempThis[writeStreamPathFastPathSymbol] = !1;\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(path, flags, mode);\n super(tempThis.fd, {\n ...options,\n decodeStrings: !1,\n autoDestroy,\n emitClose,\n fd: tempThis\n });\n if (Object.assign(this, tempThis), typeof fs2\?.write !== \"function\")\n @throwTypeError(\"Expected fs.write to be a function\");\n if (typeof fs2\?.close !== \"function\")\n @throwTypeError(\"Expected fs.close to be a function\");\n if (typeof fs2\?.open !== \"function\")\n @throwTypeError(\"Expected fs.open to be a function\");\n if (typeof path === \"object\" && path) {\n if (path instanceof URL)\n path = Bun.fileURLToPath(path);\n }\n if (typeof path !== \"string\" && typeof fd !== \"number\")\n @throwTypeError(\"Expected a path or file descriptor\");\n if (this.start = start, this.#fs = fs2, this.flags = flags, this.mode = mode, this.start !== void 0)\n this.pos = this.start;\n if (encoding !== defaultWriteStreamOptions.encoding) {\n if (this.setDefaultEncoding(encoding), encoding !== \"buffer\" && encoding !== \"utf8\" && encoding !== \"utf-8\" && encoding !== \"binary\")\n this[writeStreamPathFastPathSymbol] = !1;\n }\n }\n get autoClose() {\n return this._writableState.autoDestroy;\n }\n set autoClose(val) {\n this._writableState.autoDestroy = val;\n }\n destroySoon = this.end;\n open() {\n }\n path;\n fd;\n flags;\n mode;\n #fs;\n bytesWritten = 0;\n pos;\n [writeStreamPathFastPathSymbol];\n [writeStreamSymbol] = !0;\n start;\n [writeStreamPathFastPathCallSymbol](readStream, pipeOpts) {\n if (!this[writeStreamPathFastPathSymbol])\n return !1;\n if (this.fd !== null)\n return this[writeStreamPathFastPathSymbol] = !1, !1;\n return this[kIoDone] = !1, readStream[kIoDone] = !1, Bun.write(this[writeStreamPathFastPathSymbol], readStream[readStreamPathOrFdSymbol]).then((bytesWritten) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.bytesWritten += bytesWritten, readStream.bytesRead += bytesWritten, this.end(), readStream.close();\n }, (err) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.#errorOrDestroy(err), readStream.emit(\"error\", err);\n });\n }\n isBunFastPathEnabled() {\n return this[writeStreamPathFastPathSymbol];\n }\n disableBunFastPath() {\n this[writeStreamPathFastPathSymbol] = !1;\n }\n #handleWrite(er, bytes) {\n if (er)\n return this.#errorOrDestroy(er);\n this.bytesWritten += bytes;\n }\n #internalClose(err, cb) {\n this[writeStreamPathFastPathSymbol] = !1;\n var fd = this.fd;\n this.#fs.close(fd, (er) => {\n this.fd = null, cb(err || er);\n });\n }\n _construct(callback) {\n if (typeof this.fd === \"number\") {\n callback();\n return;\n }\n callback(), this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n if (this.fd === null)\n return cb(err);\n if (this[kIoDone]) {\n this.once(kIoDone, () => this.#internalClose(err, cb));\n return;\n }\n this.#internalClose(err, cb);\n }\n [kIoDone] = !1;\n close(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on(\"close\", cb);\n }\n if (!this.autoClose)\n this.on(\"finish\", this.destroy);\n this.end();\n }\n write(chunk, encoding = this._writableState.defaultEncoding, cb) {\n if (this[writeStreamPathFastPathSymbol] = !1, typeof chunk === \"string\")\n chunk = Buffer.from(chunk, encoding);\n var native = this.pos === void 0;\n return this[kIoDone] = !0, super.write(chunk, encoding, native \? (err, bytes) => {\n if (this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), cb)\n !err \? cb() : cb(err);\n } : () => {\n }, native);\n }\n #internalWriteSlow(chunk, encoding, cb) {\n this.#fs.write(this.fd, chunk, 0, chunk.length, this.pos, (err, bytes) => {\n this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), !err \? cb() : cb(err);\n });\n }\n end(chunk, encoding, cb) {\n var native = this.pos === void 0;\n return super.end(chunk, encoding, cb, native);\n }\n _write = this.#internalWriteSlow;\n _writev = void 0;\n get pending() {\n return this.fd === null;\n }\n _destroy(err, cb) {\n this.close(err, cb);\n }\n #errorOrDestroy(err) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n });\n function createWriteStream(path, options) {\n return new WriteStream(path, options);\n }\n return Object.defineProperties(fs, {\n createReadStream: {\n value: createReadStream\n },\n createWriteStream: {\n value: createWriteStream\n },\n ReadStream: {\n value: ReadStream\n },\n WriteStream: {\n value: WriteStream\n }\n }), realpath.native = realpath, realpathSync.native = realpathSync, $ = {\n access,\n accessSync,\n appendFile,\n appendFileSync,\n chmod,\n chmodSync,\n chown,\n chownSync,\n close,\n closeSync,\n constants: promises.constants,\n copyFile,\n copyFileSync,\n createReadStream,\n createWriteStream,\n Dirent,\n exists,\n existsSync,\n fchmod,\n fchmodSync,\n fchown,\n fchownSync,\n fstat,\n fstatSync,\n fsync,\n fsyncSync,\n ftruncate,\n ftruncateSync,\n futimes,\n futimesSync,\n lchmod,\n lchmodSync,\n lchown,\n lchownSync,\n link,\n linkSync,\n lstat,\n lstatSync,\n lutimes,\n lutimesSync,\n mkdir,\n mkdirSync,\n mkdtemp,\n mkdtempSync,\n open,\n openSync,\n promises,\n read,\n readFile,\n readFileSync,\n readSync,\n readdir,\n readdirSync,\n readlink,\n readlinkSync,\n realpath,\n realpathSync,\n rename,\n renameSync,\n rm,\n rmSync,\n rmdir,\n rmdirSync,\n stat,\n statSync,\n Stats,\n symlink,\n symlinkSync,\n truncate,\n truncateSync,\n unlink,\n unlinkSync,\n utimes,\n utimesSync,\n write,\n writeFile,\n writeFileSync,\n writeSync,\n WriteStream,\n ReadStream,\n watch,\n FSWatcher,\n writev,\n writevSync,\n readv,\n readvSync,\n [Symbol.for(\"::bunternal::\")]: {\n ReadStreamClass,\n WriteStreamClass\n }\n }, $;\n})\n"_s; // // @@ -521,7 +521,7 @@ static constexpr ASCIILiteral NodeEventsCode = "(function () {\"use strict\";\n // // -static constexpr ASCIILiteral NodeFSCode = "(function () {\"use strict\";\n var $, ReadStream, WriteStream;\n const EventEmitter = @getInternalField(@internalModuleRegistry, 15) || @createInternalModuleById(15), promises = @getInternalField(@internalModuleRegistry, 17) || @createInternalModuleById(17), Stream = @getInternalField(@internalModuleRegistry, 34) || @createInternalModuleById(34);\n var fs = Bun.fs();\n\n class FSWatcher extends EventEmitter {\n #watcher;\n #listener;\n constructor(path, options, listener) {\n super();\n if (typeof options === \"function\")\n listener = options, options = {};\n else if (typeof options === \"string\")\n options = { encoding: options };\n if (typeof listener !== \"function\")\n listener = () => {\n };\n this.#listener = listener;\n try {\n this.#watcher = fs.watch(path, options || {}, this.#onEvent.bind(this));\n } catch (e) {\n if (!e.message\?.startsWith(\"FileNotFound\"))\n throw e;\n const notFound = new Error(`ENOENT: no such file or directory, watch '${path}'`);\n throw notFound.code = \"ENOENT\", notFound.errno = -2, notFound.path = path, notFound.syscall = \"watch\", notFound.filename = path, notFound;\n }\n }\n #onEvent(eventType, filenameOrError) {\n if (eventType === \"error\" || eventType === \"close\")\n this.emit(eventType, filenameOrError);\n else\n this.emit(\"change\", eventType, filenameOrError), this.#listener(eventType, filenameOrError);\n }\n close() {\n this.#watcher\?.close(), this.#watcher = null;\n }\n ref() {\n this.#watcher\?.ref();\n }\n unref() {\n this.#watcher\?.unref();\n }\n }\n var access = function access(...args) {\n callbackify(fs.accessSync, args);\n }, appendFile = function appendFile(...args) {\n callbackify(fs.appendFileSync, args);\n }, close = function close(...args) {\n callbackify(fs.closeSync, args);\n }, rm = function rm(...args) {\n callbackify(fs.rmSync, args);\n }, rmdir = function rmdir(...args) {\n callbackify(fs.rmdirSync, args);\n }, copyFile = function copyFile(...args) {\n callbackify(fs.copyFileSync, args);\n }, exists = function exists(...args) {\n callbackify(fs.existsSync, args);\n }, chown = function chown(...args) {\n callbackify(fs.chownSync, args);\n }, chmod = function chmod(...args) {\n callbackify(fs.chmodSync, args);\n }, fchmod = function fchmod(...args) {\n callbackify(fs.fchmodSync, args);\n }, fchown = function fchown(...args) {\n callbackify(fs.fchownSync, args);\n }, fstat = function fstat(...args) {\n callbackify(fs.fstatSync, args);\n }, fsync = function fsync(...args) {\n callbackify(fs.fsyncSync, args);\n }, ftruncate = function ftruncate(...args) {\n callbackify(fs.ftruncateSync, args);\n }, futimes = function futimes(...args) {\n callbackify(fs.futimesSync, args);\n }, lchmod = function lchmod(...args) {\n callbackify(fs.lchmodSync, args);\n }, lchown = function lchown(...args) {\n callbackify(fs.lchownSync, args);\n }, link = function link(...args) {\n callbackify(fs.linkSync, args);\n }, mkdir = function mkdir(...args) {\n callbackify(fs.mkdirSync, args);\n }, mkdtemp = function mkdtemp(...args) {\n callbackify(fs.mkdtempSync, args);\n }, open = function open(...args) {\n callbackify(fs.openSync, args);\n }, read = function read(...args) {\n callbackify(fs.readSync, args);\n }, write = function write(...args) {\n callbackify(fs.writeSync, args);\n }, readdir = function readdir(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readdir(...args).then((result) => callback(null, result), callback);\n }, readFile = function readFile(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readFile(...args).then((result) => callback(null, result), callback);\n }, writeFile = function writeFile(...args) {\n callbackify(fs.writeFileSync, args);\n }, readlink = function readlink(...args) {\n callbackify(fs.readlinkSync, args);\n }, realpath = function realpath(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.realpath(...args).then((result) => callback(null, result), callback);\n }, rename = function rename(...args) {\n callbackify(fs.renameSync, args);\n }, lstat = function lstat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.lstat(...args).then((result) => callback(null, result), callback);\n }, stat = function stat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.stat(...args).then((result) => callback(null, result), callback);\n }, symlink = function symlink(...args) {\n callbackify(fs.symlinkSync, args);\n }, truncate = function truncate(...args) {\n callbackify(fs.truncateSync, args);\n }, unlink = function unlink(...args) {\n callbackify(fs.unlinkSync, args);\n }, utimes = function utimes(...args) {\n callbackify(fs.utimesSync, args);\n }, lutimes = function lutimes(...args) {\n callbackify(fs.lutimesSync, args);\n }, accessSync = fs.accessSync.bind(fs), appendFileSync = fs.appendFileSync.bind(fs), closeSync = fs.closeSync.bind(fs), copyFileSync = fs.copyFileSync.bind(fs), existsSync = fs.existsSync.bind(fs), chownSync = fs.chownSync.bind(fs), chmodSync = fs.chmodSync.bind(fs), fchmodSync = fs.fchmodSync.bind(fs), fchownSync = fs.fchownSync.bind(fs), fstatSync = fs.fstatSync.bind(fs), fsyncSync = fs.fsyncSync.bind(fs), ftruncateSync = fs.ftruncateSync.bind(fs), futimesSync = fs.futimesSync.bind(fs), lchmodSync = fs.lchmodSync.bind(fs), lchownSync = fs.lchownSync.bind(fs), linkSync = fs.linkSync.bind(fs), lstatSync = fs.lstatSync.bind(fs), mkdirSync = fs.mkdirSync.bind(fs), mkdtempSync = fs.mkdtempSync.bind(fs), openSync = fs.openSync.bind(fs), readSync = fs.readSync.bind(fs), writeSync = fs.writeSync.bind(fs), readdirSync = fs.readdirSync.bind(fs), readFileSync = fs.readFileSync.bind(fs), writeFileSync = fs.writeFileSync.bind(fs), readlinkSync = fs.readlinkSync.bind(fs), realpathSync = fs.realpathSync.bind(fs), renameSync = fs.renameSync.bind(fs), statSync = fs.statSync.bind(fs), symlinkSync = fs.symlinkSync.bind(fs), truncateSync = fs.truncateSync.bind(fs), unlinkSync = fs.unlinkSync.bind(fs), utimesSync = fs.utimesSync.bind(fs), lutimesSync = fs.lutimesSync.bind(fs), rmSync = fs.rmSync.bind(fs), rmdirSync = fs.rmdirSync.bind(fs), writev = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.writevSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, writevSync = fs.writevSync.bind(fs), readv = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.readvSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, readvSync = fs.readvSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch(path, options, listener) {\n return new FSWatcher(path, options, listener);\n };\n function callbackify(fsFunction, args) {\n try {\n const result = fsFunction.apply(fs, args.slice(0, args.length - 1)), callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(null, result));\n } catch (e) {\n const callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(e));\n }\n }\n var readStreamPathFastPathSymbol = Symbol.for(\"Bun.Node.readStreamPathFastPath\");\n const readStreamSymbol = Symbol.for(\"Bun.NodeReadStream\"), readStreamPathOrFdSymbol = Symbol.for(\"Bun.NodeReadStreamPathOrFd\"), writeStreamSymbol = Symbol.for(\"Bun.NodeWriteStream\");\n var writeStreamPathFastPathSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPath\"), writeStreamPathFastPathCallSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"), kIoDone = Symbol.for(\"kIoDone\"), defaultReadStreamOptions = {\n file: void 0,\n fd: void 0,\n flags: \"r\",\n encoding: void 0,\n mode: 438,\n autoClose: !0,\n emitClose: !0,\n start: 0,\n end: Infinity,\n highWaterMark: 65536,\n fs: {\n read,\n open: (path, flags, mode, cb) => {\n var fd;\n try {\n fd = openSync(path, flags, mode);\n } catch (e) {\n cb(e);\n return;\n }\n cb(null, fd);\n },\n openSync,\n close\n },\n autoDestroy: !0\n }, ReadStreamClass;\n ReadStream = function(InternalReadStream) {\n ReadStreamClass = InternalReadStream, Object.defineProperty(ReadStreamClass.prototype, Symbol.toStringTag, {\n value: \"ReadStream\",\n enumerable: !1\n });\n function ReadStream2(path, options) {\n return new InternalReadStream(path, options);\n }\n return ReadStream2.prototype = InternalReadStream.prototype, Object.defineProperty(ReadStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalReadStream;\n }\n });\n }(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2, Stream.Readable) {\n constructor(pathOrFd, options = defaultReadStreamOptions) {\n if (typeof options !== \"object\" || !options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n flags = defaultReadStreamOptions.flags,\n encoding = defaultReadStreamOptions.encoding,\n mode = defaultReadStreamOptions.mode,\n autoClose = defaultReadStreamOptions.autoClose,\n emitClose = defaultReadStreamOptions.emitClose,\n start = defaultReadStreamOptions.start,\n end = defaultReadStreamOptions.end,\n autoDestroy = defaultReadStreamOptions.autoClose,\n fs: fs2 = defaultReadStreamOptions.fs,\n highWaterMark = defaultReadStreamOptions.highWaterMark\n } = options;\n if (pathOrFd\?.constructor\?.name === \"URL\")\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n var tempThis = {};\n if (typeof pathOrFd === \"string\") {\n if (pathOrFd.startsWith(\"file://\"))\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n if (pathOrFd.length === 0)\n @throwTypeError(\"Expected path to be a non-empty string\");\n tempThis.path = tempThis.file = tempThis[readStreamPathOrFdSymbol] = pathOrFd;\n } else if (typeof pathOrFd === \"number\") {\n if (pathOrFd |= 0, pathOrFd < 0)\n @throwTypeError(\"Expected fd to be a positive integer\");\n tempThis.fd = tempThis[readStreamPathOrFdSymbol] = pathOrFd, tempThis.autoClose = !1;\n } else\n @throwTypeError(\"Expected a path or file descriptor\");\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(pathOrFd, flags, mode);\n var fileRef = Bun.file(tempThis.fd), stream = fileRef.stream(), native = @direct(stream);\n if (!native)\n throw new Error(\"no native readable stream\");\n var { stream: ptr } = native;\n super(ptr, {\n ...options,\n encoding,\n autoDestroy,\n autoClose,\n emitClose,\n highWaterMark\n });\n if (Object.assign(this, tempThis), this.#fileRef = fileRef, this.end = end, this._read = this.#internalRead, this.start = start, this.flags = flags, this.mode = mode, this.emitClose = emitClose, this[readStreamPathFastPathSymbol] = start === 0 && end === Infinity && autoClose && fs2 === defaultReadStreamOptions.fs && (encoding === \"buffer\" || encoding === \"binary\" || encoding == null || encoding === \"utf-8\" || encoding === \"utf8\"), this._readableState.autoClose = autoDestroy = autoClose, this._readableState.highWaterMark = highWaterMark, start !== void 0)\n this.pos = start;\n }\n #fileRef;\n #fs;\n file;\n path;\n fd = null;\n flags;\n mode;\n start;\n end;\n pos;\n bytesRead = 0;\n #fileSize = -1;\n _read;\n [readStreamSymbol] = !0;\n [readStreamPathOrFdSymbol];\n [readStreamPathFastPathSymbol];\n _construct(callback) {\n if (super._construct)\n super._construct(callback);\n else\n callback();\n this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n super._destroy(err, cb);\n try {\n var fd = this.fd;\n if (this[readStreamPathFastPathSymbol] = !1, !fd)\n cb(err);\n else\n this.#fs.close(fd, (er) => {\n cb(er || err);\n }), this.fd = null;\n } catch (e) {\n throw e;\n }\n }\n close(cb) {\n if (typeof cb === \"function\")\n eos_()(this, cb);\n this.destroy();\n }\n push(chunk) {\n var bytesRead = chunk\?.length \?\? 0;\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n var currPos = this.pos;\n if (currPos !== void 0) {\n if (this.bytesRead < currPos)\n return !0;\n if (currPos === this.start) {\n var n = this.bytesRead - currPos;\n chunk = chunk.slice(-n);\n var [_, ...rest] = arguments;\n if (this.pos = this.bytesRead, this.end !== void 0 && this.bytesRead > this.end)\n chunk = chunk.slice(0, this.end - this.start + 1);\n return super.push(chunk, ...rest);\n }\n var end = this.end;\n if (end !== void 0 && this.bytesRead > end) {\n chunk = chunk.slice(0, end - currPos + 1);\n var [_, ...rest] = arguments;\n return this.pos = this.bytesRead, super.push(chunk, ...rest);\n }\n this.pos = this.bytesRead;\n }\n }\n return super.push(...arguments);\n }\n #internalRead(n) {\n var { pos, end, bytesRead, fd, encoding } = this;\n if (n = pos !== void 0 \? Math.min(end - pos + 1, n) : Math.min(end - bytesRead + 1, n), n <= 0) {\n this.push(null);\n return;\n }\n if (this.#fileSize === -1 && bytesRead === 0 && pos === void 0) {\n var stat2 = fstatSync(fd);\n if (this.#fileSize = stat2.size, this.#fileSize > 0 && n > this.#fileSize)\n n = this.#fileSize + 1;\n }\n this[kIoDone] = !1;\n var res = super._read(n);\n if (@isPromise(res)) {\n var then = res\?.then;\n if (then && @isCallable(then))\n then(() => {\n if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone);\n }, (er) => {\n this[kIoDone] = !0, this.#errorOrDestroy(er);\n });\n } else if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone), this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"));\n }\n #errorOrDestroy(err, sync = null) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n pause() {\n return this[readStreamPathFastPathSymbol] = !1, super.pause();\n }\n resume() {\n return this[readStreamPathFastPathSymbol] = !1, super.resume();\n }\n unshift(...args) {\n return this[readStreamPathFastPathSymbol] = !1, super.unshift(...args);\n }\n pipe(dest, pipeOpts) {\n if (this[readStreamPathFastPathSymbol] && (pipeOpts\?.end \?\? !0) && this._readableState\?.pipes\?.length === 0) {\n if ((writeStreamPathFastPathSymbol in dest) && dest[writeStreamPathFastPathSymbol]) {\n if (dest[writeStreamPathFastPathCallSymbol](this, pipeOpts))\n return this;\n }\n }\n return this[readStreamPathFastPathSymbol] = !1, super.pipe(dest, pipeOpts);\n }\n });\n function createReadStream(path, options) {\n return new ReadStream(path, options);\n }\n var defaultWriteStreamOptions = {\n fd: null,\n start: void 0,\n pos: void 0,\n encoding: void 0,\n flags: \"w\",\n mode: 438,\n fs: {\n write,\n close,\n open,\n openSync\n }\n }, WriteStreamClass;\n WriteStream = function(InternalWriteStream) {\n WriteStreamClass = InternalWriteStream, Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, {\n value: \"WritesStream\",\n enumerable: !1\n });\n function WriteStream2(path, options) {\n return new InternalWriteStream(path, options);\n }\n return WriteStream2.prototype = InternalWriteStream.prototype, Object.defineProperty(WriteStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalWriteStream;\n }\n });\n }(class WriteStream2 extends Stream.NativeWritable {\n constructor(path, options = defaultWriteStreamOptions) {\n if (!options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n fs: fs2 = defaultWriteStreamOptions.fs,\n start = defaultWriteStreamOptions.start,\n flags = defaultWriteStreamOptions.flags,\n mode = defaultWriteStreamOptions.mode,\n autoClose = !0,\n emitClose = !1,\n autoDestroy = autoClose,\n encoding = defaultWriteStreamOptions.encoding,\n fd = defaultWriteStreamOptions.fd,\n pos = defaultWriteStreamOptions.pos\n } = options, tempThis = {};\n if (typeof path === \"string\") {\n if (path.length === 0)\n @throwTypeError(\"Expected a non-empty path\");\n if (path.startsWith(\"file:\"))\n path = Bun.fileURLToPath(path);\n tempThis.path = path, tempThis.fd = null, tempThis[writeStreamPathFastPathSymbol] = autoClose && (start === void 0 || start === 0) && fs2.write === defaultWriteStreamOptions.fs.write && fs2.close === defaultWriteStreamOptions.fs.close;\n } else\n tempThis.fd = fd, tempThis[writeStreamPathFastPathSymbol] = !1;\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(path, flags, mode);\n super(tempThis.fd, {\n ...options,\n decodeStrings: !1,\n autoDestroy,\n emitClose,\n fd: tempThis\n });\n if (Object.assign(this, tempThis), typeof fs2\?.write !== \"function\")\n @throwTypeError(\"Expected fs.write to be a function\");\n if (typeof fs2\?.close !== \"function\")\n @throwTypeError(\"Expected fs.close to be a function\");\n if (typeof fs2\?.open !== \"function\")\n @throwTypeError(\"Expected fs.open to be a function\");\n if (typeof path === \"object\" && path) {\n if (path instanceof URL)\n path = Bun.fileURLToPath(path);\n }\n if (typeof path !== \"string\" && typeof fd !== \"number\")\n @throwTypeError(\"Expected a path or file descriptor\");\n if (this.start = start, this.#fs = fs2, this.flags = flags, this.mode = mode, this.start !== void 0)\n this.pos = this.start;\n if (encoding !== defaultWriteStreamOptions.encoding) {\n if (this.setDefaultEncoding(encoding), encoding !== \"buffer\" && encoding !== \"utf8\" && encoding !== \"utf-8\" && encoding !== \"binary\")\n this[writeStreamPathFastPathSymbol] = !1;\n }\n }\n get autoClose() {\n return this._writableState.autoDestroy;\n }\n set autoClose(val) {\n this._writableState.autoDestroy = val;\n }\n destroySoon = this.end;\n open() {\n }\n path;\n fd;\n flags;\n mode;\n #fs;\n bytesWritten = 0;\n pos;\n [writeStreamPathFastPathSymbol];\n [writeStreamSymbol] = !0;\n start;\n [writeStreamPathFastPathCallSymbol](readStream, pipeOpts) {\n if (!this[writeStreamPathFastPathSymbol])\n return !1;\n if (this.fd !== null)\n return this[writeStreamPathFastPathSymbol] = !1, !1;\n return this[kIoDone] = !1, readStream[kIoDone] = !1, Bun.write(this[writeStreamPathFastPathSymbol], readStream[readStreamPathOrFdSymbol]).then((bytesWritten) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.bytesWritten += bytesWritten, readStream.bytesRead += bytesWritten, this.end(), readStream.close();\n }, (err) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.#errorOrDestroy(err), readStream.emit(\"error\", err);\n });\n }\n isBunFastPathEnabled() {\n return this[writeStreamPathFastPathSymbol];\n }\n disableBunFastPath() {\n this[writeStreamPathFastPathSymbol] = !1;\n }\n #handleWrite(er, bytes) {\n if (er)\n return this.#errorOrDestroy(er);\n this.bytesWritten += bytes;\n }\n #internalClose(err, cb) {\n this[writeStreamPathFastPathSymbol] = !1;\n var fd = this.fd;\n this.#fs.close(fd, (er) => {\n this.fd = null, cb(err || er);\n });\n }\n _construct(callback) {\n if (typeof this.fd === \"number\") {\n callback();\n return;\n }\n callback(), this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n if (this.fd === null)\n return cb(err);\n if (this[kIoDone]) {\n this.once(kIoDone, () => this.#internalClose(err, cb));\n return;\n }\n this.#internalClose(err, cb);\n }\n [kIoDone] = !1;\n close(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on(\"close\", cb);\n }\n if (!this.autoClose)\n this.on(\"finish\", this.destroy);\n this.end();\n }\n write(chunk, encoding = this._writableState.defaultEncoding, cb) {\n if (this[writeStreamPathFastPathSymbol] = !1, typeof chunk === \"string\")\n chunk = Buffer.from(chunk, encoding);\n var native = this.pos === void 0;\n return this[kIoDone] = !0, super.write(chunk, encoding, native \? (err, bytes) => {\n if (this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), cb)\n !err \? cb() : cb(err);\n } : () => {\n }, native);\n }\n #internalWriteSlow(chunk, encoding, cb) {\n this.#fs.write(this.fd, chunk, 0, chunk.length, this.pos, (err, bytes) => {\n this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), !err \? cb() : cb(err);\n });\n }\n end(chunk, encoding, cb) {\n var native = this.pos === void 0;\n return super.end(chunk, encoding, cb, native);\n }\n _write = this.#internalWriteSlow;\n _writev = void 0;\n get pending() {\n return this.fd === null;\n }\n _destroy(err, cb) {\n this.close(err, cb);\n }\n #errorOrDestroy(err) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n });\n function createWriteStream(path, options) {\n return new WriteStream(path, options);\n }\n return Object.defineProperties(fs, {\n createReadStream: {\n value: createReadStream\n },\n createWriteStream: {\n value: createWriteStream\n },\n ReadStream: {\n value: ReadStream\n },\n WriteStream: {\n value: WriteStream\n }\n }), realpath.native = realpath, realpathSync.native = realpathSync, $ = {\n access,\n accessSync,\n appendFile,\n appendFileSync,\n chmod,\n chmodSync,\n chown,\n chownSync,\n close,\n closeSync,\n constants: promises.constants,\n copyFile,\n copyFileSync,\n createReadStream,\n createWriteStream,\n Dirent,\n exists,\n existsSync,\n fchmod,\n fchmodSync,\n fchown,\n fchownSync,\n fstat,\n fstatSync,\n fsync,\n fsyncSync,\n ftruncate,\n ftruncateSync,\n futimes,\n futimesSync,\n lchmod,\n lchmodSync,\n lchown,\n lchownSync,\n link,\n linkSync,\n lstat,\n lstatSync,\n lutimes,\n lutimesSync,\n mkdir,\n mkdirSync,\n mkdtemp,\n mkdtempSync,\n open,\n openSync,\n promises,\n read,\n readFile,\n readFileSync,\n readSync,\n readdir,\n readdirSync,\n readlink,\n readlinkSync,\n realpath,\n realpathSync,\n rename,\n renameSync,\n rm,\n rmSync,\n rmdir,\n rmdirSync,\n stat,\n statSync,\n Stats,\n symlink,\n symlinkSync,\n truncate,\n truncateSync,\n unlink,\n unlinkSync,\n utimes,\n utimesSync,\n write,\n writeFile,\n writeFileSync,\n writeSync,\n WriteStream,\n ReadStream,\n watch,\n FSWatcher,\n writev,\n writevSync,\n readv,\n readvSync,\n [Symbol.for(\"::bunternal::\")]: {\n ReadStreamClass,\n WriteStreamClass\n }\n }, $;\n})\n"_s; +static constexpr ASCIILiteral NodeFSCode = "(function () {\"use strict\";\n var $, ReadStream, WriteStream;\n const EventEmitter = @getInternalField(@internalModuleRegistry, 15) || @createInternalModuleById(15), promises = @getInternalField(@internalModuleRegistry, 17) || @createInternalModuleById(17), Stream = @getInternalField(@internalModuleRegistry, 34) || @createInternalModuleById(34);\n var fs = Bun.fs();\n\n class FSWatcher extends EventEmitter {\n #watcher;\n #listener;\n constructor(path, options, listener) {\n super();\n if (typeof options === \"function\")\n listener = options, options = {};\n else if (typeof options === \"string\")\n options = { encoding: options };\n if (typeof listener !== \"function\")\n listener = () => {\n };\n this.#listener = listener;\n try {\n this.#watcher = fs.watch(path, options || {}, this.#onEvent.bind(this));\n } catch (e) {\n if (!e.message\?.startsWith(\"FileNotFound\"))\n throw e;\n const notFound = new Error(`ENOENT: no such file or directory, watch '${path}'`);\n throw notFound.code = \"ENOENT\", notFound.errno = -2, notFound.path = path, notFound.syscall = \"watch\", notFound.filename = path, notFound;\n }\n }\n #onEvent(eventType, filenameOrError) {\n if (eventType === \"error\" || eventType === \"close\")\n this.emit(eventType, filenameOrError);\n else\n this.emit(\"change\", eventType, filenameOrError), this.#listener(eventType, filenameOrError);\n }\n close() {\n this.#watcher\?.close(), this.#watcher = null;\n }\n ref() {\n this.#watcher\?.ref();\n }\n unref() {\n this.#watcher\?.unref();\n }\n }\n var access = function access(...args) {\n callbackify(fs.accessSync, args);\n }, appendFile = function appendFile(...args) {\n callbackify(fs.appendFileSync, args);\n }, close = function close(...args) {\n callbackify(fs.closeSync, args);\n }, rm = function rm(...args) {\n callbackify(fs.rmSync, args);\n }, rmdir = function rmdir(...args) {\n callbackify(fs.rmdirSync, args);\n }, copyFile = function copyFile(...args) {\n callbackify(fs.copyFileSync, args);\n }, exists = function exists(...args) {\n callbackify(fs.existsSync, args);\n }, chown = function chown(...args) {\n callbackify(fs.chownSync, args);\n }, chmod = function chmod(...args) {\n callbackify(fs.chmodSync, args);\n }, fchmod = function fchmod(...args) {\n callbackify(fs.fchmodSync, args);\n }, fchown = function fchown(...args) {\n callbackify(fs.fchownSync, args);\n }, fstat = function fstat(...args) {\n callbackify(fs.fstatSync, args);\n }, fsync = function fsync(...args) {\n callbackify(fs.fsyncSync, args);\n }, ftruncate = function ftruncate(...args) {\n callbackify(fs.ftruncateSync, args);\n }, futimes = function futimes(...args) {\n callbackify(fs.futimesSync, args);\n }, lchmod = function lchmod(...args) {\n callbackify(fs.lchmodSync, args);\n }, lchown = function lchown(...args) {\n callbackify(fs.lchownSync, args);\n }, link = function link(...args) {\n callbackify(fs.linkSync, args);\n }, mkdir = function mkdir(...args) {\n callbackify(fs.mkdirSync, args);\n }, mkdtemp = function mkdtemp(...args) {\n callbackify(fs.mkdtempSync, args);\n }, open = function open(...args) {\n callbackify(fs.openSync, args);\n }, read = function read(...args) {\n callbackify(fs.readSync, args);\n }, write = function write(...args) {\n callbackify(fs.writeSync, args);\n }, readdir = function readdir(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readdir(...args).then((result) => callback(null, result), callback);\n }, readFile = function readFile(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.readFile(...args).then((result) => callback(null, result), callback);\n }, writeFile = function writeFile(...args) {\n callbackify(fs.writeFileSync, args);\n }, readlink = function readlink(...args) {\n callbackify(fs.readlinkSync, args);\n }, realpath = function realpath(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.realpath(...args).then((result) => callback(null, result), callback);\n }, rename = function rename(...args) {\n callbackify(fs.renameSync, args);\n }, lstat = function lstat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.lstat(...args).then((result) => callback(null, result), callback);\n }, stat = function stat(...args) {\n const callback = args[args.length - 1];\n if (typeof callback !== \"function\")\n @throwTypeError(\"Callback must be a function\");\n fs.stat(...args).then((result) => callback(null, result), callback);\n }, symlink = function symlink(...args) {\n callbackify(fs.symlinkSync, args);\n }, truncate = function truncate(...args) {\n callbackify(fs.truncateSync, args);\n }, unlink = function unlink(...args) {\n callbackify(fs.unlinkSync, args);\n }, utimes = function utimes(...args) {\n callbackify(fs.utimesSync, args);\n }, lutimes = function lutimes(...args) {\n callbackify(fs.lutimesSync, args);\n }, accessSync = fs.accessSync.bind(fs), appendFileSync = fs.appendFileSync.bind(fs), closeSync = fs.closeSync.bind(fs), copyFileSync = fs.copyFileSync.bind(fs), existsSync = fs.existsSync.bind(fs), chownSync = fs.chownSync.bind(fs), chmodSync = fs.chmodSync.bind(fs), fchmodSync = fs.fchmodSync.bind(fs), fchownSync = fs.fchownSync.bind(fs), fstatSync = fs.fstatSync.bind(fs), fsyncSync = fs.fsyncSync.bind(fs), ftruncateSync = fs.ftruncateSync.bind(fs), futimesSync = fs.futimesSync.bind(fs), lchmodSync = fs.lchmodSync.bind(fs), lchownSync = fs.lchownSync.bind(fs), linkSync = fs.linkSync.bind(fs), lstatSync = fs.lstatSync.bind(fs), mkdirSync = fs.mkdirSync.bind(fs), mkdtempSync = fs.mkdtempSync.bind(fs), openSync = fs.openSync.bind(fs), readSync = fs.readSync.bind(fs), writeSync = fs.writeSync.bind(fs), readdirSync = fs.readdirSync.bind(fs), readFileSync = fs.readFileSync.bind(fs), writeFileSync = fs.writeFileSync.bind(fs), readlinkSync = fs.readlinkSync.bind(fs), realpathSync = fs.realpathSync.bind(fs), renameSync = fs.renameSync.bind(fs), statSync = fs.statSync.bind(fs), symlinkSync = fs.symlinkSync.bind(fs), truncateSync = fs.truncateSync.bind(fs), unlinkSync = fs.unlinkSync.bind(fs), utimesSync = fs.utimesSync.bind(fs), lutimesSync = fs.lutimesSync.bind(fs), rmSync = fs.rmSync.bind(fs), rmdirSync = fs.rmdirSync.bind(fs), writev = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.writevSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, writevSync = fs.writevSync.bind(fs), readv = (fd, buffers, position, callback) => {\n if (typeof position === \"function\")\n callback = position, position = null;\n queueMicrotask(() => {\n try {\n var written = fs.readvSync(fd, buffers, position);\n } catch (e) {\n callback(e);\n }\n callback(null, written, buffers);\n });\n }, readvSync = fs.readvSync.bind(fs), Dirent = fs.Dirent, Stats = fs.Stats, watch = function watch(path, options, listener) {\n return new FSWatcher(path, options, listener);\n };\n function callbackify(fsFunction, args) {\n try {\n const result = fsFunction.apply(fs, args.slice(0, args.length - 1)), callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(null, result));\n } catch (e) {\n const callback = args[args.length - 1];\n if (typeof callback === \"function\")\n queueMicrotask(() => callback(e));\n }\n }\n var readStreamPathFastPathSymbol = Symbol.for(\"Bun.Node.readStreamPathFastPath\");\n const readStreamSymbol = Symbol.for(\"Bun.NodeReadStream\"), readStreamPathOrFdSymbol = Symbol.for(\"Bun.NodeReadStreamPathOrFd\"), writeStreamSymbol = Symbol.for(\"Bun.NodeWriteStream\");\n var writeStreamPathFastPathSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPath\"), writeStreamPathFastPathCallSymbol = Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"), kIoDone = Symbol.for(\"kIoDone\"), defaultReadStreamOptions = {\n file: void 0,\n fd: void 0,\n flags: \"r\",\n encoding: void 0,\n mode: 438,\n autoClose: !0,\n emitClose: !0,\n start: 0,\n end: Infinity,\n highWaterMark: 65536,\n fs: {\n read,\n open: (path, flags, mode, cb) => {\n var fd;\n try {\n fd = openSync(path, flags, mode);\n } catch (e) {\n cb(e);\n return;\n }\n cb(null, fd);\n },\n openSync,\n close\n },\n autoDestroy: !0\n }, ReadStreamClass;\n ReadStream = function(InternalReadStream) {\n ReadStreamClass = InternalReadStream, Object.defineProperty(ReadStreamClass.prototype, Symbol.toStringTag, {\n value: \"ReadStream\",\n enumerable: !1\n });\n function ReadStream2(path, options) {\n return new InternalReadStream(path, options);\n }\n return ReadStream2.prototype = InternalReadStream.prototype, Object.defineProperty(ReadStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalReadStream;\n }\n });\n }(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2, Stream.Readable) {\n constructor(pathOrFd, options = defaultReadStreamOptions) {\n if (typeof options !== \"object\" || !options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n flags = defaultReadStreamOptions.flags,\n encoding = defaultReadStreamOptions.encoding,\n mode = defaultReadStreamOptions.mode,\n autoClose = defaultReadStreamOptions.autoClose,\n emitClose = defaultReadStreamOptions.emitClose,\n start = defaultReadStreamOptions.start,\n end = defaultReadStreamOptions.end,\n autoDestroy = defaultReadStreamOptions.autoClose,\n fs: fs2 = defaultReadStreamOptions.fs,\n highWaterMark = defaultReadStreamOptions.highWaterMark\n } = options;\n if (pathOrFd\?.constructor\?.name === \"URL\")\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n var tempThis = {};\n if (typeof pathOrFd === \"string\") {\n if (pathOrFd.startsWith(\"file://\"))\n pathOrFd = Bun.fileURLToPath(pathOrFd);\n if (pathOrFd.length === 0)\n @throwTypeError(\"Expected path to be a non-empty string\");\n tempThis.path = tempThis.file = tempThis[readStreamPathOrFdSymbol] = pathOrFd;\n } else if (typeof pathOrFd === \"number\") {\n if (pathOrFd |= 0, pathOrFd < 0)\n @throwTypeError(\"Expected fd to be a positive integer\");\n tempThis.fd = tempThis[readStreamPathOrFdSymbol] = pathOrFd, tempThis.autoClose = !1;\n } else\n @throwTypeError(\"Expected a path or file descriptor\");\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(pathOrFd, flags, mode);\n var fileRef = Bun.file(tempThis.fd), stream = fileRef.stream(), native = @direct(stream);\n if (!native)\n throw new Error(\"no native readable stream\");\n var { stream: ptr } = native;\n super(ptr, {\n ...options,\n encoding,\n autoDestroy,\n autoClose,\n emitClose,\n highWaterMark\n });\n if (Object.assign(this, tempThis), this.#fileRef = fileRef, this.end = end, this._read = this.#internalRead, this.start = start, this.flags = flags, this.mode = mode, this.emitClose = emitClose, this[readStreamPathFastPathSymbol] = start === 0 && end === Infinity && autoClose && fs2 === defaultReadStreamOptions.fs && (encoding === \"buffer\" || encoding === \"binary\" || encoding == null || encoding === \"utf-8\" || encoding === \"utf8\"), this._readableState.autoClose = autoDestroy = autoClose, this._readableState.highWaterMark = highWaterMark, start !== void 0)\n this.pos = start;\n }\n #fileRef;\n #fs;\n file;\n path;\n fd = null;\n flags;\n mode;\n start;\n end;\n pos;\n bytesRead = 0;\n #fileSize = -1;\n _read;\n [readStreamSymbol] = !0;\n [readStreamPathOrFdSymbol];\n [readStreamPathFastPathSymbol];\n _construct(callback) {\n if (super._construct)\n super._construct(callback);\n else\n callback();\n this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n super._destroy(err, cb);\n try {\n var fd = this.fd;\n if (this[readStreamPathFastPathSymbol] = !1, !fd)\n cb(err);\n else\n this.#fs.close(fd, (er) => {\n cb(er || err);\n }), this.fd = null;\n } catch (e) {\n throw e;\n }\n }\n close(cb) {\n if (typeof cb === \"function\")\n eos_()(this, cb);\n this.destroy();\n }\n push(chunk) {\n var bytesRead = chunk\?.length \?\? 0;\n if (bytesRead > 0) {\n this.bytesRead += bytesRead;\n var currPos = this.pos;\n if (currPos !== void 0) {\n if (this.bytesRead < currPos)\n return !0;\n if (currPos === this.start) {\n var n = this.bytesRead - currPos;\n chunk = chunk.slice(-n);\n var [_, ...rest] = arguments;\n if (this.pos = this.bytesRead, this.end !== void 0 && this.bytesRead > this.end)\n chunk = chunk.slice(0, this.end - this.start + 1);\n return super.push(chunk, ...rest);\n }\n var end = this.end;\n if (end !== void 0 && this.bytesRead > end) {\n chunk = chunk.slice(0, end - currPos + 1);\n var [_, ...rest] = arguments;\n return this.pos = this.bytesRead, super.push(chunk, ...rest);\n }\n this.pos = this.bytesRead;\n }\n }\n return super.push(...arguments);\n }\n #internalRead(n) {\n var { pos, end, bytesRead, fd, encoding } = this;\n if (n = pos !== void 0 \? Math.min(end - pos + 1, n) : Math.min(end - bytesRead + 1, n), n <= 0) {\n this.push(null);\n return;\n }\n if (this.#fileSize === -1 && bytesRead === 0 && pos === void 0) {\n var stat2 = fstatSync(fd);\n if (this.#fileSize = stat2.size, this.#fileSize > 0 && n > this.#fileSize)\n n = this.#fileSize + 1;\n }\n this[kIoDone] = !1;\n var res = super._read(n);\n if (@isPromise(res)) {\n var then = res\?.then;\n if (then && @isCallable(then))\n res.then(() => {\n if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone);\n }, (er) => {\n this[kIoDone] = !0, this.#errorOrDestroy(er);\n });\n } else if (this[kIoDone] = !0, this.destroyed)\n this.emit(kIoDone), this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"));\n }\n #errorOrDestroy(err, sync = null) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n pause() {\n return this[readStreamPathFastPathSymbol] = !1, super.pause();\n }\n resume() {\n return this[readStreamPathFastPathSymbol] = !1, super.resume();\n }\n unshift(...args) {\n return this[readStreamPathFastPathSymbol] = !1, super.unshift(...args);\n }\n pipe(dest, pipeOpts) {\n if (this[readStreamPathFastPathSymbol] && (pipeOpts\?.end \?\? !0) && this._readableState\?.pipes\?.length === 0) {\n if ((writeStreamPathFastPathSymbol in dest) && dest[writeStreamPathFastPathSymbol]) {\n if (dest[writeStreamPathFastPathCallSymbol](this, pipeOpts))\n return this;\n }\n }\n return this[readStreamPathFastPathSymbol] = !1, super.pipe(dest, pipeOpts);\n }\n });\n function createReadStream(path, options) {\n return new ReadStream(path, options);\n }\n var defaultWriteStreamOptions = {\n fd: null,\n start: void 0,\n pos: void 0,\n encoding: void 0,\n flags: \"w\",\n mode: 438,\n fs: {\n write,\n close,\n open,\n openSync\n }\n }, WriteStreamClass;\n WriteStream = function(InternalWriteStream) {\n WriteStreamClass = InternalWriteStream, Object.defineProperty(WriteStreamClass.prototype, Symbol.toStringTag, {\n value: \"WritesStream\",\n enumerable: !1\n });\n function WriteStream2(path, options) {\n return new InternalWriteStream(path, options);\n }\n return WriteStream2.prototype = InternalWriteStream.prototype, Object.defineProperty(WriteStream2, Symbol.hasInstance, {\n value(instance) {\n return instance instanceof InternalWriteStream;\n }\n });\n }(class WriteStream2 extends Stream.NativeWritable {\n constructor(path, options = defaultWriteStreamOptions) {\n if (!options)\n @throwTypeError(\"Expected options to be an object\");\n var {\n fs: fs2 = defaultWriteStreamOptions.fs,\n start = defaultWriteStreamOptions.start,\n flags = defaultWriteStreamOptions.flags,\n mode = defaultWriteStreamOptions.mode,\n autoClose = !0,\n emitClose = !1,\n autoDestroy = autoClose,\n encoding = defaultWriteStreamOptions.encoding,\n fd = defaultWriteStreamOptions.fd,\n pos = defaultWriteStreamOptions.pos\n } = options, tempThis = {};\n if (typeof path === \"string\") {\n if (path.length === 0)\n @throwTypeError(\"Expected a non-empty path\");\n if (path.startsWith(\"file:\"))\n path = Bun.fileURLToPath(path);\n tempThis.path = path, tempThis.fd = null, tempThis[writeStreamPathFastPathSymbol] = autoClose && (start === void 0 || start === 0) && fs2.write === defaultWriteStreamOptions.fs.write && fs2.close === defaultWriteStreamOptions.fs.close;\n } else\n tempThis.fd = fd, tempThis[writeStreamPathFastPathSymbol] = !1;\n if (!tempThis.fd)\n tempThis.fd = fs2.openSync(path, flags, mode);\n super(tempThis.fd, {\n ...options,\n decodeStrings: !1,\n autoDestroy,\n emitClose,\n fd: tempThis\n });\n if (Object.assign(this, tempThis), typeof fs2\?.write !== \"function\")\n @throwTypeError(\"Expected fs.write to be a function\");\n if (typeof fs2\?.close !== \"function\")\n @throwTypeError(\"Expected fs.close to be a function\");\n if (typeof fs2\?.open !== \"function\")\n @throwTypeError(\"Expected fs.open to be a function\");\n if (typeof path === \"object\" && path) {\n if (path instanceof URL)\n path = Bun.fileURLToPath(path);\n }\n if (typeof path !== \"string\" && typeof fd !== \"number\")\n @throwTypeError(\"Expected a path or file descriptor\");\n if (this.start = start, this.#fs = fs2, this.flags = flags, this.mode = mode, this.start !== void 0)\n this.pos = this.start;\n if (encoding !== defaultWriteStreamOptions.encoding) {\n if (this.setDefaultEncoding(encoding), encoding !== \"buffer\" && encoding !== \"utf8\" && encoding !== \"utf-8\" && encoding !== \"binary\")\n this[writeStreamPathFastPathSymbol] = !1;\n }\n }\n get autoClose() {\n return this._writableState.autoDestroy;\n }\n set autoClose(val) {\n this._writableState.autoDestroy = val;\n }\n destroySoon = this.end;\n open() {\n }\n path;\n fd;\n flags;\n mode;\n #fs;\n bytesWritten = 0;\n pos;\n [writeStreamPathFastPathSymbol];\n [writeStreamSymbol] = !0;\n start;\n [writeStreamPathFastPathCallSymbol](readStream, pipeOpts) {\n if (!this[writeStreamPathFastPathSymbol])\n return !1;\n if (this.fd !== null)\n return this[writeStreamPathFastPathSymbol] = !1, !1;\n return this[kIoDone] = !1, readStream[kIoDone] = !1, Bun.write(this[writeStreamPathFastPathSymbol], readStream[readStreamPathOrFdSymbol]).then((bytesWritten) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.bytesWritten += bytesWritten, readStream.bytesRead += bytesWritten, this.end(), readStream.close();\n }, (err) => {\n readStream[kIoDone] = this[kIoDone] = !0, this.#errorOrDestroy(err), readStream.emit(\"error\", err);\n });\n }\n isBunFastPathEnabled() {\n return this[writeStreamPathFastPathSymbol];\n }\n disableBunFastPath() {\n this[writeStreamPathFastPathSymbol] = !1;\n }\n #handleWrite(er, bytes) {\n if (er)\n return this.#errorOrDestroy(er);\n this.bytesWritten += bytes;\n }\n #internalClose(err, cb) {\n this[writeStreamPathFastPathSymbol] = !1;\n var fd = this.fd;\n this.#fs.close(fd, (er) => {\n this.fd = null, cb(err || er);\n });\n }\n _construct(callback) {\n if (typeof this.fd === \"number\") {\n callback();\n return;\n }\n callback(), this.emit(\"open\", this.fd), this.emit(\"ready\");\n }\n _destroy(err, cb) {\n if (this.fd === null)\n return cb(err);\n if (this[kIoDone]) {\n this.once(kIoDone, () => this.#internalClose(err, cb));\n return;\n }\n this.#internalClose(err, cb);\n }\n [kIoDone] = !1;\n close(cb) {\n if (cb) {\n if (this.closed) {\n process.nextTick(cb);\n return;\n }\n this.on(\"close\", cb);\n }\n if (!this.autoClose)\n this.on(\"finish\", this.destroy);\n this.end();\n }\n write(chunk, encoding = this._writableState.defaultEncoding, cb) {\n if (this[writeStreamPathFastPathSymbol] = !1, typeof chunk === \"string\")\n chunk = Buffer.from(chunk, encoding);\n var native = this.pos === void 0;\n return this[kIoDone] = !0, super.write(chunk, encoding, native \? (err, bytes) => {\n if (this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), cb)\n !err \? cb() : cb(err);\n } : () => {\n }, native);\n }\n #internalWriteSlow(chunk, encoding, cb) {\n this.#fs.write(this.fd, chunk, 0, chunk.length, this.pos, (err, bytes) => {\n this[kIoDone] = !1, this.#handleWrite(err, bytes), this.emit(kIoDone), !err \? cb() : cb(err);\n });\n }\n end(chunk, encoding, cb) {\n var native = this.pos === void 0;\n return super.end(chunk, encoding, cb, native);\n }\n _write = this.#internalWriteSlow;\n _writev = void 0;\n get pending() {\n return this.fd === null;\n }\n _destroy(err, cb) {\n this.close(err, cb);\n }\n #errorOrDestroy(err) {\n var {\n _readableState: r = { destroyed: !1, autoDestroy: !1 },\n _writableState: w = { destroyed: !1, autoDestroy: !1 }\n } = this;\n if (w\?.destroyed || r\?.destroyed)\n return this;\n if (r\?.autoDestroy || w\?.autoDestroy)\n this.destroy(err);\n else if (err)\n this.emit(\"error\", err);\n }\n });\n function createWriteStream(path, options) {\n return new WriteStream(path, options);\n }\n return Object.defineProperties(fs, {\n createReadStream: {\n value: createReadStream\n },\n createWriteStream: {\n value: createWriteStream\n },\n ReadStream: {\n value: ReadStream\n },\n WriteStream: {\n value: WriteStream\n }\n }), realpath.native = realpath, realpathSync.native = realpathSync, $ = {\n access,\n accessSync,\n appendFile,\n appendFileSync,\n chmod,\n chmodSync,\n chown,\n chownSync,\n close,\n closeSync,\n constants: promises.constants,\n copyFile,\n copyFileSync,\n createReadStream,\n createWriteStream,\n Dirent,\n exists,\n existsSync,\n fchmod,\n fchmodSync,\n fchown,\n fchownSync,\n fstat,\n fstatSync,\n fsync,\n fsyncSync,\n ftruncate,\n ftruncateSync,\n futimes,\n futimesSync,\n lchmod,\n lchmodSync,\n lchown,\n lchownSync,\n link,\n linkSync,\n lstat,\n lstatSync,\n lutimes,\n lutimesSync,\n mkdir,\n mkdirSync,\n mkdtemp,\n mkdtempSync,\n open,\n openSync,\n promises,\n read,\n readFile,\n readFileSync,\n readSync,\n readdir,\n readdirSync,\n readlink,\n readlinkSync,\n realpath,\n realpathSync,\n rename,\n renameSync,\n rm,\n rmSync,\n rmdir,\n rmdirSync,\n stat,\n statSync,\n Stats,\n symlink,\n symlinkSync,\n truncate,\n truncateSync,\n unlink,\n unlinkSync,\n utimes,\n utimesSync,\n write,\n writeFile,\n writeFileSync,\n writeSync,\n WriteStream,\n ReadStream,\n watch,\n FSWatcher,\n writev,\n writevSync,\n readv,\n readvSync,\n [Symbol.for(\"::bunternal::\")]: {\n ReadStreamClass,\n WriteStreamClass\n }\n }, $;\n})\n"_s; // // |