-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser-fs-core.min.js.map
8 lines (8 loc) · 904 KB
/
browser-fs-core.min.js.map
1
2
3
4
5
6
7
8
{
"version": 3,
"sourceRoot": "@browserfs/core/src",
"sources": ["../node_modules/base64-js/index.js", "../node_modules/ieee754/index.js", "../node_modules/buffer/index.js", "../node_modules/readable-stream/lib/ours/primordials.js", "../node_modules/abort-controller/browser.js", "../node_modules/events/events.js", "../node_modules/readable-stream/lib/ours/util.js", "../node_modules/readable-stream/lib/ours/errors.js", "../node_modules/readable-stream/lib/internal/validators.js", "../node_modules/process/browser.js", "../node_modules/readable-stream/lib/internal/streams/utils.js", "../node_modules/readable-stream/lib/internal/streams/end-of-stream.js", "../node_modules/readable-stream/lib/internal/streams/destroy.js", "../node_modules/readable-stream/lib/internal/streams/legacy.js", "../node_modules/readable-stream/lib/internal/streams/add-abort-signal.js", "../node_modules/readable-stream/lib/internal/streams/buffer_list.js", "../node_modules/readable-stream/lib/internal/streams/state.js", "../node_modules/string_decoder/node_modules/safe-buffer/index.js", "../node_modules/string_decoder/lib/string_decoder.js", "../node_modules/readable-stream/lib/internal/streams/from.js", "../node_modules/readable-stream/lib/internal/streams/readable.js", "../node_modules/readable-stream/lib/internal/streams/writable.js", "../node_modules/readable-stream/lib/internal/streams/duplexify.js", "../node_modules/readable-stream/lib/internal/streams/duplex.js", "../node_modules/readable-stream/lib/internal/streams/transform.js", "../node_modules/readable-stream/lib/internal/streams/passthrough.js", "../node_modules/readable-stream/lib/internal/streams/pipeline.js", "../node_modules/readable-stream/lib/internal/streams/compose.js", "../node_modules/readable-stream/lib/internal/streams/operators.js", "../node_modules/readable-stream/lib/stream/promises.js", "../node_modules/readable-stream/lib/stream.js", "../node_modules/readable-stream/lib/ours/browser.js", "../src/index.ts", "../src/emulation/index.ts", "../src/emulation/path.ts", "../src/utils.ts", "../src/ApiError.ts", "../src/cred.ts", "../src/emulation/constants.ts", "../src/stats.ts", "../src/file.ts", "../src/filesystem.ts", "../src/inode.ts", "../src/backends/SyncStore.ts", "../src/backends/backend.ts", "../src/backends/InMemory.ts", "../src/emulation/shared.ts", "../src/emulation/promises.ts", "../src/emulation/sync.ts", "../src/emulation/dir.ts", "../src/emulation/callbacks.ts", "../src/emulation/streams.ts", "../src/emulation/fs.ts", "../src/backends/AsyncMirror.ts", "../src/backends/FolderAdapter.ts", "../src/mutex.ts", "../src/backends/Locked.ts", "../src/backends/OverlayFS.ts", "../src/backends/index.ts", "../src/backends/AsyncStore.ts", "../src/FileIndex.ts"],
"sourcesContent": ["'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n", "/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n", "/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <https://feross.org>\n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nconst base64 = require('base64-js')\nconst ieee754 = require('ieee754')\nconst customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nconst K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n const arr = new Uint8Array(1)\n const proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n const buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n const valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n const b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n const length = byteLength(string, encoding) | 0\n let buf = createBuffer(length)\n\n const actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n const length = array.length < 0 ? 0 : checked(array.length) | 0\n const buf = createBuffer(length)\n for (let i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n const copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n let buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n const len = checked(obj.length) | 0\n const buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n let x = a.length\n let y = b.length\n\n for (let i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n let i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n const buffer = Buffer.allocUnsafe(length)\n let pos = 0\n for (i = 0; i < list.length; ++i) {\n let buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)\n buf.copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n const len = string.length\n const mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n let loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n const i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n const len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (let i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n const len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (let i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n const len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (let i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n const length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n let str = ''\n const max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return '<Buffer ' + str + '>'\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n let x = thisEnd - thisStart\n let y = end - start\n const len = Math.min(x, y)\n\n const thisCopy = this.slice(thisStart, thisEnd)\n const targetCopy = target.slice(start, end)\n\n for (let i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n let indexSize = 1\n let arrLength = arr.length\n let valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n let i\n if (dir) {\n let foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n let found = true\n for (let j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n const remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n const strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n let i\n for (i = 0; i < length; ++i) {\n const parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n const remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n const res = []\n\n let i = start\n while (i < end) {\n const firstByte = buf[i]\n let codePoint = null\n let bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n let secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n const len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = ''\n let i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n const len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n let out = ''\n for (let i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n const bytes = buf.slice(start, end)\n let res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (let i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n const len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n const newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n let val = this[offset + --byteLength]\n let mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const lo = first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24\n\n const hi = this[++offset] +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n last * 2 ** 24\n\n return BigInt(lo) + (BigInt(hi) << BigInt(32))\n})\n\nBuffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const hi = first * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n const lo = this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last\n\n return (BigInt(hi) << BigInt(32)) + BigInt(lo)\n})\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let i = byteLength\n let mul = 1\n let val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = this[offset + 4] +\n this[offset + 5] * 2 ** 8 +\n this[offset + 6] * 2 ** 16 +\n (last << 24) // Overflow\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24)\n})\n\nBuffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = (first << 24) + // Overflow\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last)\n})\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let mul = 1\n let i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let i = byteLength - 1\n let mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction wrtBigUInt64LE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n return offset\n}\n\nfunction wrtBigUInt64BE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset + 7] = lo\n lo = lo >> 8\n buf[offset + 6] = lo\n lo = lo >> 8\n buf[offset + 5] = lo\n lo = lo >> 8\n buf[offset + 4] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset + 3] = hi\n hi = hi >> 8\n buf[offset + 2] = hi\n hi = hi >> 8\n buf[offset + 1] = hi\n hi = hi >> 8\n buf[offset] = hi\n return offset + 8\n}\n\nBuffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = 0\n let mul = 1\n let sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = byteLength - 1\n let mul = 1\n let sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nBuffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n const len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n const code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n let i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n const bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n const len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// CUSTOM ERRORS\n// =============\n\n// Simplified versions from Node, changed for Buffer-only usage\nconst errors = {}\nfunction E (sym, getMessage, Base) {\n errors[sym] = class NodeError extends Base {\n constructor () {\n super()\n\n Object.defineProperty(this, 'message', {\n value: getMessage.apply(this, arguments),\n writable: true,\n configurable: true\n })\n\n // Add the error code to the name to include it in the stack trace.\n this.name = `${this.name} [${sym}]`\n // Access the stack to generate the error message including the error code\n // from the name.\n this.stack // eslint-disable-line no-unused-expressions\n // Reset the name to the actual name.\n delete this.name\n }\n\n get code () {\n return sym\n }\n\n set code (value) {\n Object.defineProperty(this, 'code', {\n configurable: true,\n enumerable: true,\n value,\n writable: true\n })\n }\n\n toString () {\n return `${this.name} [${sym}]: ${this.message}`\n }\n }\n}\n\nE('ERR_BUFFER_OUT_OF_BOUNDS',\n function (name) {\n if (name) {\n return `${name} is outside of buffer bounds`\n }\n\n return 'Attempt to access memory outside buffer bounds'\n }, RangeError)\nE('ERR_INVALID_ARG_TYPE',\n function (name, actual) {\n return `The \"${name}\" argument must be of type number. Received type ${typeof actual}`\n }, TypeError)\nE('ERR_OUT_OF_RANGE',\n function (str, range, input) {\n let msg = `The value of \"${str}\" is out of range.`\n let received = input\n if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {\n received = addNumericalSeparator(String(input))\n } else if (typeof input === 'bigint') {\n received = String(input)\n if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {\n received = addNumericalSeparator(received)\n }\n received += 'n'\n }\n msg += ` It must be ${range}. Received ${received}`\n return msg\n }, RangeError)\n\nfunction addNumericalSeparator (val) {\n let res = ''\n let i = val.length\n const start = val[0] === '-' ? 1 : 0\n for (; i >= start + 4; i -= 3) {\n res = `_${val.slice(i - 3, i)}${res}`\n }\n return `${val.slice(0, i)}${res}`\n}\n\n// CHECK FUNCTIONS\n// ===============\n\nfunction checkBounds (buf, offset, byteLength) {\n validateNumber(offset, 'offset')\n if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {\n boundsError(offset, buf.length - (byteLength + 1))\n }\n}\n\nfunction checkIntBI (value, min, max, buf, offset, byteLength) {\n if (value > max || value < min) {\n const n = typeof min === 'bigint' ? 'n' : ''\n let range\n if (byteLength > 3) {\n if (min === 0 || min === BigInt(0)) {\n range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`\n } else {\n range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +\n `${(byteLength + 1) * 8 - 1}${n}`\n }\n } else {\n range = `>= ${min}${n} and <= ${max}${n}`\n }\n throw new errors.ERR_OUT_OF_RANGE('value', range, value)\n }\n checkBounds(buf, offset, byteLength)\n}\n\nfunction validateNumber (value, name) {\n if (typeof value !== 'number') {\n throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)\n }\n}\n\nfunction boundsError (value, length, type) {\n if (Math.floor(value) !== value) {\n validateNumber(value, type)\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)\n }\n\n if (length < 0) {\n throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()\n }\n\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset',\n `>= ${type ? 1 : 0} and <= ${length}`,\n value)\n}\n\n// HELPER FUNCTIONS\n// ================\n\nconst INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n let codePoint\n const length = string.length\n let leadSurrogate = null\n const bytes = []\n\n for (let i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n let c, hi, lo\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n let i\n for (i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nconst hexSliceLookupTable = (function () {\n const alphabet = '0123456789abcdef'\n const table = new Array(256)\n for (let i = 0; i < 16; ++i) {\n const i16 = i * 16\n for (let j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n\n// Return not function with Error if BigInt not supported\nfunction defineBigIntMethod (fn) {\n return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn\n}\n\nfunction BufferBigIntNotDefined () {\n throw new Error('BigInt not supported')\n}\n", "'use strict'\n\n/*\n This file is a reduced and adapted version of the main lib/internal/per_context/primordials.js file defined at\n\n https://github.com/nodejs/node/blob/master/lib/internal/per_context/primordials.js\n\n Don't try to replace with the original file and keep it up to date with the upstream file.\n*/\nmodule.exports = {\n ArrayIsArray(self) {\n return Array.isArray(self)\n },\n ArrayPrototypeIncludes(self, el) {\n return self.includes(el)\n },\n ArrayPrototypeIndexOf(self, el) {\n return self.indexOf(el)\n },\n ArrayPrototypeJoin(self, sep) {\n return self.join(sep)\n },\n ArrayPrototypeMap(self, fn) {\n return self.map(fn)\n },\n ArrayPrototypePop(self, el) {\n return self.pop(el)\n },\n ArrayPrototypePush(self, el) {\n return self.push(el)\n },\n ArrayPrototypeSlice(self, start, end) {\n return self.slice(start, end)\n },\n Error,\n FunctionPrototypeCall(fn, thisArgs, ...args) {\n return fn.call(thisArgs, ...args)\n },\n FunctionPrototypeSymbolHasInstance(self, instance) {\n return Function.prototype[Symbol.hasInstance].call(self, instance)\n },\n MathFloor: Math.floor,\n Number,\n NumberIsInteger: Number.isInteger,\n NumberIsNaN: Number.isNaN,\n NumberMAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER,\n NumberMIN_SAFE_INTEGER: Number.MIN_SAFE_INTEGER,\n NumberParseInt: Number.parseInt,\n ObjectDefineProperties(self, props) {\n return Object.defineProperties(self, props)\n },\n ObjectDefineProperty(self, name, prop) {\n return Object.defineProperty(self, name, prop)\n },\n ObjectGetOwnPropertyDescriptor(self, name) {\n return Object.getOwnPropertyDescriptor(self, name)\n },\n ObjectKeys(obj) {\n return Object.keys(obj)\n },\n ObjectSetPrototypeOf(target, proto) {\n return Object.setPrototypeOf(target, proto)\n },\n Promise,\n PromisePrototypeCatch(self, fn) {\n return self.catch(fn)\n },\n PromisePrototypeThen(self, thenFn, catchFn) {\n return self.then(thenFn, catchFn)\n },\n PromiseReject(err) {\n return Promise.reject(err)\n },\n PromiseResolve(val) {\n return Promise.resolve(val)\n },\n ReflectApply: Reflect.apply,\n RegExpPrototypeTest(self, value) {\n return self.test(value)\n },\n SafeSet: Set,\n String,\n StringPrototypeSlice(self, start, end) {\n return self.slice(start, end)\n },\n StringPrototypeToLowerCase(self) {\n return self.toLowerCase()\n },\n StringPrototypeToUpperCase(self) {\n return self.toUpperCase()\n },\n StringPrototypeTrim(self) {\n return self.trim()\n },\n Symbol,\n SymbolFor: Symbol.for,\n SymbolAsyncIterator: Symbol.asyncIterator,\n SymbolHasInstance: Symbol.hasInstance,\n SymbolIterator: Symbol.iterator,\n SymbolDispose: Symbol.dispose || Symbol('Symbol.dispose'),\n SymbolAsyncDispose: Symbol.asyncDispose || Symbol('Symbol.asyncDispose'),\n TypedArrayPrototypeSet(self, buf, len) {\n return self.set(buf, len)\n },\n Boolean: Boolean,\n Uint8Array\n}\n", "/*globals self, window */\n\"use strict\"\n\n/*eslint-disable @mysticatea/prettier */\nconst { AbortController, AbortSignal } =\n typeof self !== \"undefined\" ? self :\n typeof window !== \"undefined\" ? window :\n /* otherwise */ undefined\n/*eslint-enable @mysticatea/prettier */\n\nmodule.exports = AbortController\nmodule.exports.AbortSignal = AbortSignal\nmodule.exports.default = AbortController\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n", "'use strict'\n\nconst bufferModule = require('buffer')\nconst { kResistStopPropagation, SymbolDispose } = require('./primordials')\nconst AbortSignal = globalThis.AbortSignal || require('abort-controller').AbortSignal\nconst AbortController = globalThis.AbortController || require('abort-controller').AbortController\nconst AsyncFunction = Object.getPrototypeOf(async function () {}).constructor\nconst Blob = globalThis.Blob || bufferModule.Blob\n/* eslint-disable indent */\nconst isBlob =\n typeof Blob !== 'undefined'\n ? function isBlob(b) {\n // eslint-disable-next-line indent\n return b instanceof Blob\n }\n : function isBlob(b) {\n return false\n }\n/* eslint-enable indent */\n\nconst validateAbortSignal = (signal, name) => {\n if (signal !== undefined && (signal === null || typeof signal !== 'object' || !('aborted' in signal))) {\n throw new ERR_INVALID_ARG_TYPE(name, 'AbortSignal', signal)\n }\n}\nconst validateFunction = (value, name) => {\n if (typeof value !== 'function') throw new ERR_INVALID_ARG_TYPE(name, 'Function', value)\n}\n\n// This is a simplified version of AggregateError\nclass AggregateError extends Error {\n constructor(errors) {\n if (!Array.isArray(errors)) {\n throw new TypeError(`Expected input to be an Array, got ${typeof errors}`)\n }\n let message = ''\n for (let i = 0; i < errors.length; i++) {\n message += ` ${errors[i].stack}\\n`\n }\n super(message)\n this.name = 'AggregateError'\n this.errors = errors\n }\n}\nmodule.exports = {\n AggregateError,\n kEmptyObject: Object.freeze({}),\n once(callback) {\n let called = false\n return function (...args) {\n if (called) {\n return\n }\n called = true\n callback.apply(this, args)\n }\n },\n createDeferredPromise: function () {\n let resolve\n let reject\n\n // eslint-disable-next-line promise/param-names\n const promise = new Promise((res, rej) => {\n resolve = res\n reject = rej\n })\n return {\n promise,\n resolve,\n reject\n }\n },\n promisify(fn) {\n return new Promise((resolve, reject) => {\n fn((err, ...args) => {\n if (err) {\n return reject(err)\n }\n return resolve(...args)\n })\n })\n },\n debuglog() {\n return function () {}\n },\n format(format, ...args) {\n // Simplified version of https://nodejs.org/api/util.html#utilformatformat-args\n return format.replace(/%([sdifj])/g, function (...[_unused, type]) {\n const replacement = args.shift()\n if (type === 'f') {\n return replacement.toFixed(6)\n } else if (type === 'j') {\n return JSON.stringify(replacement)\n } else if (type === 's' && typeof replacement === 'object') {\n const ctor = replacement.constructor !== Object ? replacement.constructor.name : ''\n return `${ctor} {}`.trim()\n } else {\n return replacement.toString()\n }\n })\n },\n inspect(value) {\n // Vastly simplified version of https://nodejs.org/api/util.html#utilinspectobject-options\n switch (typeof value) {\n case 'string':\n if (value.includes(\"'\")) {\n if (!value.includes('\"')) {\n return `\"${value}\"`\n } else if (!value.includes('`') && !value.includes('${')) {\n return `\\`${value}\\``\n }\n }\n return `'${value}'`\n case 'number':\n if (isNaN(value)) {\n return 'NaN'\n } else if (Object.is(value, -0)) {\n return String(value)\n }\n return value\n case 'bigint':\n return `${String(value)}n`\n case 'boolean':\n case 'undefined':\n return String(value)\n case 'object':\n return '{}'\n }\n },\n types: {\n isAsyncFunction(fn) {\n return fn instanceof AsyncFunction\n },\n isArrayBufferView(arr) {\n return ArrayBuffer.isView(arr)\n }\n },\n isBlob,\n deprecate(fn, message) {\n return fn\n },\n addAbortListener:\n require('events').addAbortListener ||\n function addAbortListener(signal, listener) {\n if (signal === undefined) {\n throw new ERR_INVALID_ARG_TYPE('signal', 'AbortSignal', signal)\n }\n validateAbortSignal(signal, 'signal')\n validateFunction(listener, 'listener')\n let removeEventListener\n if (signal.aborted) {\n queueMicrotask(() => listener())\n } else {\n signal.addEventListener('abort', listener, {\n __proto__: null,\n once: true,\n [kResistStopPropagation]: true\n })\n removeEventListener = () => {\n signal.removeEventListener('abort', listener)\n }\n }\n return {\n __proto__: null,\n [SymbolDispose]() {\n var _removeEventListener\n ;(_removeEventListener = removeEventListener) === null || _removeEventListener === undefined\n ? undefined\n : _removeEventListener()\n }\n }\n },\n AbortSignalAny:\n AbortSignal.any ||\n function AbortSignalAny(signals) {\n // Fast path if there is only one signal.\n if (signals.length === 1) {\n return signals[0]\n }\n const ac = new AbortController()\n const abort = () => ac.abort()\n signals.forEach((signal) => {\n validateAbortSignal(signal, 'signals')\n signal.addEventListener('abort', abort, {\n once: true\n })\n })\n ac.signal.addEventListener(\n 'abort',\n () => {\n signals.forEach((signal) => signal.removeEventListener('abort', abort))\n },\n {\n once: true\n }\n )\n return ac.signal\n }\n}\nmodule.exports.promisify.custom = Symbol.for('nodejs.util.promisify.custom')\n", "'use strict'\n\nconst { format, inspect, AggregateError: CustomAggregateError } = require('./util')\n\n/*\n This file is a reduced and adapted version of the main lib/internal/errors.js file defined at\n\n https://github.com/nodejs/node/blob/master/lib/internal/errors.js\n\n Don't try to replace with the original file and keep it up to date (starting from E(...) definitions)\n with the upstream file.\n*/\n\nconst AggregateError = globalThis.AggregateError || CustomAggregateError\nconst kIsNodeError = Symbol('kIsNodeError')\nconst kTypes = [\n 'string',\n 'function',\n 'number',\n 'object',\n // Accept 'Function' and 'Object' as alternative to the lower cased version.\n 'Function',\n 'Object',\n 'boolean',\n 'bigint',\n 'symbol'\n]\nconst classRegExp = /^([A-Z][a-z0-9]*)+$/\nconst nodeInternalPrefix = '__node_internal_'\nconst codes = {}\nfunction assert(value, message) {\n if (!value) {\n throw new codes.ERR_INTERNAL_ASSERTION(message)\n }\n}\n\n// Only use this for integers! Decimal numbers do not work with this function.\nfunction addNumericalSeparator(val) {\n let res = ''\n let i = val.length\n const start = val[0] === '-' ? 1 : 0\n for (; i >= start + 4; i -= 3) {\n res = `_${val.slice(i - 3, i)}${res}`\n }\n return `${val.slice(0, i)}${res}`\n}\nfunction getMessage(key, msg, args) {\n if (typeof msg === 'function') {\n assert(\n msg.length <= args.length,\n // Default options do not count.\n `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${msg.length}).`\n )\n return msg(...args)\n }\n const expectedLength = (msg.match(/%[dfijoOs]/g) || []).length\n assert(\n expectedLength === args.length,\n `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`\n )\n if (args.length === 0) {\n return msg\n }\n return format(msg, ...args)\n}\nfunction E(code, message, Base) {\n if (!Base) {\n Base = Error\n }\n class NodeError extends Base {\n constructor(...args) {\n super(getMessage(code, message, args))\n }\n toString() {\n return `${this.name} [${code}]: ${this.message}`\n }\n }\n Object.defineProperties(NodeError.prototype, {\n name: {\n value: Base.name,\n writable: true,\n enumerable: false,\n configurable: true\n },\n toString: {\n value() {\n return `${this.name} [${code}]: ${this.message}`\n },\n writable: true,\n enumerable: false,\n configurable: true\n }\n })\n NodeError.prototype.code = code\n NodeError.prototype[kIsNodeError] = true\n codes[code] = NodeError\n}\nfunction hideStackFrames(fn) {\n // We rename the functions that will be hidden to cut off the stacktrace\n // at the outermost one\n const hidden = nodeInternalPrefix + fn.name\n Object.defineProperty(fn, 'name', {\n value: hidden\n })\n return fn\n}\nfunction aggregateTwoErrors(innerError, outerError) {\n if (innerError && outerError && innerError !== outerError) {\n if (Array.isArray(outerError.errors)) {\n // If `outerError` is already an `AggregateError`.\n outerError.errors.push(innerError)\n return outerError\n }\n const err = new AggregateError([outerError, innerError], outerError.message)\n err.code = outerError.code\n return err\n }\n return innerError || outerError\n}\nclass AbortError extends Error {\n constructor(message = 'The operation was aborted', options = undefined) {\n if (options !== undefined && typeof options !== 'object') {\n throw new codes.ERR_INVALID_ARG_TYPE('options', 'Object', options)\n }\n super(message, options)\n this.code = 'ABORT_ERR'\n this.name = 'AbortError'\n }\n}\nE('ERR_ASSERTION', '%s', Error)\nE(\n 'ERR_INVALID_ARG_TYPE',\n (name, expected, actual) => {\n assert(typeof name === 'string', \"'name' must be a string\")\n if (!Array.isArray(expected)) {\n expected = [expected]\n }\n let msg = 'The '\n if (name.endsWith(' argument')) {\n // For cases like 'first argument'\n msg += `${name} `\n } else {\n msg += `\"${name}\" ${name.includes('.') ? 'property' : 'argument'} `\n }\n msg += 'must be '\n const types = []\n const instances = []\n const other = []\n for (const value of expected) {\n assert(typeof value === 'string', 'All expected entries have to be of type string')\n if (kTypes.includes(value)) {\n types.push(value.toLowerCase())\n } else if (classRegExp.test(value)) {\n instances.push(value)\n } else {\n assert(value !== 'object', 'The value \"object\" should be written as \"Object\"')\n other.push(value)\n }\n }\n\n // Special handle `object` in case other instances are allowed to outline\n // the differences between each other.\n if (instances.length > 0) {\n const pos = types.indexOf('object')\n if (pos !== -1) {\n types.splice(types, pos, 1)\n instances.push('Object')\n }\n }\n if (types.length > 0) {\n switch (types.length) {\n case 1:\n msg += `of type ${types[0]}`\n break\n case 2:\n msg += `one of type ${types[0]} or ${types[1]}`\n break\n default: {\n const last = types.pop()\n msg += `one of type ${types.join(', ')}, or ${last}`\n }\n }\n if (instances.length > 0 || other.length > 0) {\n msg += ' or '\n }\n }\n if (instances.length > 0) {\n switch (instances.length) {\n case 1:\n msg += `an instance of ${instances[0]}`\n break\n case 2:\n msg += `an instance of ${instances[0]} or ${instances[1]}`\n break\n default: {\n const last = instances.pop()\n msg += `an instance of ${instances.join(', ')}, or ${last}`\n }\n }\n if (other.length > 0) {\n msg += ' or '\n }\n }\n switch (other.length) {\n case 0:\n break\n case 1:\n if (other[0].toLowerCase() !== other[0]) {\n msg += 'an '\n }\n msg += `${other[0]}`\n break\n case 2:\n msg += `one of ${other[0]} or ${other[1]}`\n break\n default: {\n const last = other.pop()\n msg += `one of ${other.join(', ')}, or ${last}`\n }\n }\n if (actual == null) {\n msg += `. Received ${actual}`\n } else if (typeof actual === 'function' && actual.name) {\n msg += `. Received function ${actual.name}`\n } else if (typeof actual === 'object') {\n var _actual$constructor\n if (\n (_actual$constructor = actual.constructor) !== null &&\n _actual$constructor !== undefined &&\n _actual$constructor.name\n ) {\n msg += `. Received an instance of ${actual.constructor.name}`\n } else {\n const inspected = inspect(actual, {\n depth: -1\n })\n msg += `. Received ${inspected}`\n }\n } else {\n let inspected = inspect(actual, {\n colors: false\n })\n if (inspected.length > 25) {\n inspected = `${inspected.slice(0, 25)}...`\n }\n msg += `. Received type ${typeof actual} (${inspected})`\n }\n return msg\n },\n TypeError\n)\nE(\n 'ERR_INVALID_ARG_VALUE',\n (name, value, reason = 'is invalid') => {\n let inspected = inspect(value)\n if (inspected.length > 128) {\n inspected = inspected.slice(0, 128) + '...'\n }\n const type = name.includes('.') ? 'property' : 'argument'\n return `The ${type} '${name}' ${reason}. Received ${inspected}`\n },\n TypeError\n)\nE(\n 'ERR_INVALID_RETURN_VALUE',\n (input, name, value) => {\n var _value$constructor\n const type =\n value !== null &&\n value !== undefined &&\n (_value$constructor = value.constructor) !== null &&\n _value$constructor !== undefined &&\n _value$constructor.name\n ? `instance of ${value.constructor.name}`\n : `type ${typeof value}`\n return `Expected ${input} to be returned from the \"${name}\"` + ` function but got ${type}.`\n },\n TypeError\n)\nE(\n 'ERR_MISSING_ARGS',\n (...args) => {\n assert(args.length > 0, 'At least one arg needs to be specified')\n let msg\n const len = args.length\n args = (Array.isArray(args) ? args : [args]).map((a) => `\"${a}\"`).join(' or ')\n switch (len) {\n case 1:\n msg += `The ${args[0]} argument`\n break\n case 2:\n msg += `The ${args[0]} and ${args[1]} arguments`\n break\n default:\n {\n const last = args.pop()\n msg += `The ${args.join(', ')}, and ${last} arguments`\n }\n break\n }\n return `${msg} must be specified`\n },\n TypeError\n)\nE(\n 'ERR_OUT_OF_RANGE',\n (str, range, input) => {\n assert(range, 'Missing \"range\" argument')\n let received\n if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {\n received = addNumericalSeparator(String(input))\n } else if (typeof input === 'bigint') {\n received = String(input)\n if (input > 2n ** 32n || input < -(2n ** 32n)) {\n received = addNumericalSeparator(received)\n }\n received += 'n'\n } else {\n received = inspect(input)\n }\n return `The value of \"${str}\" is out of range. It must be ${range}. Received ${received}`\n },\n RangeError\n)\nE('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times', Error)\nE('ERR_METHOD_NOT_IMPLEMENTED', 'The %s method is not implemented', Error)\nE('ERR_STREAM_ALREADY_FINISHED', 'Cannot call %s after a stream was finished', Error)\nE('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable', Error)\nE('ERR_STREAM_DESTROYED', 'Cannot call %s after a stream was destroyed', Error)\nE('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError)\nE('ERR_STREAM_PREMATURE_CLOSE', 'Premature close', Error)\nE('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF', Error)\nE('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event', Error)\nE('ERR_STREAM_WRITE_AFTER_END', 'write after end', Error)\nE('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s', TypeError)\nmodule.exports = {\n AbortError,\n aggregateTwoErrors: hideStackFrames(aggregateTwoErrors),\n hideStackFrames,\n codes\n}\n", "/* eslint jsdoc/require-jsdoc: \"error\" */\n\n'use strict'\n\nconst {\n ArrayIsArray,\n ArrayPrototypeIncludes,\n ArrayPrototypeJoin,\n ArrayPrototypeMap,\n NumberIsInteger,\n NumberIsNaN,\n NumberMAX_SAFE_INTEGER,\n NumberMIN_SAFE_INTEGER,\n NumberParseInt,\n ObjectPrototypeHasOwnProperty,\n RegExpPrototypeExec,\n String,\n StringPrototypeToUpperCase,\n StringPrototypeTrim\n} = require('../ours/primordials')\nconst {\n hideStackFrames,\n codes: { ERR_SOCKET_BAD_PORT, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_OUT_OF_RANGE, ERR_UNKNOWN_SIGNAL }\n} = require('../ours/errors')\nconst { normalizeEncoding } = require('../ours/util')\nconst { isAsyncFunction, isArrayBufferView } = require('../ours/util').types\nconst signals = {}\n\n/**\n * @param {*} value\n * @returns {boolean}\n */\nfunction isInt32(value) {\n return value === (value | 0)\n}\n\n/**\n * @param {*} value\n * @returns {boolean}\n */\nfunction isUint32(value) {\n return value === value >>> 0\n}\nconst octalReg = /^[0-7]+$/\nconst modeDesc = 'must be a 32-bit unsigned integer or an octal string'\n\n/**\n * Parse and validate values that will be converted into mode_t (the S_*\n * constants). Only valid numbers and octal strings are allowed. They could be\n * converted to 32-bit unsigned integers or non-negative signed integers in the\n * C++ land, but any value higher than 0o777 will result in platform-specific\n * behaviors.\n * @param {*} value Values to be validated\n * @param {string} name Name of the argument\n * @param {number} [def] If specified, will be returned for invalid values\n * @returns {number}\n */\nfunction parseFileMode(value, name, def) {\n if (typeof value === 'undefined') {\n value = def\n }\n if (typeof value === 'string') {\n if (RegExpPrototypeExec(octalReg, value) === null) {\n throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc)\n }\n value = NumberParseInt(value, 8)\n }\n validateUint32(value, name)\n return value\n}\n\n/**\n * @callback validateInteger\n * @param {*} value\n * @param {string} name\n * @param {number} [min]\n * @param {number} [max]\n * @returns {asserts value is number}\n */\n\n/** @type {validateInteger} */\nconst validateInteger = hideStackFrames((value, name, min = NumberMIN_SAFE_INTEGER, max = NumberMAX_SAFE_INTEGER) => {\n if (typeof value !== 'number') throw new ERR_INVALID_ARG_TYPE(name, 'number', value)\n if (!NumberIsInteger(value)) throw new ERR_OUT_OF_RANGE(name, 'an integer', value)\n if (value < min || value > max) throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value)\n})\n\n/**\n * @callback validateInt32\n * @param {*} value\n * @param {string} name\n * @param {number} [min]\n * @param {number} [max]\n * @returns {asserts value is number}\n */\n\n/** @type {validateInt32} */\nconst validateInt32 = hideStackFrames((value, name, min = -2147483648, max = 2147483647) => {\n // The defaults for min and max correspond to the limits of 32-bit integers.\n if (typeof value !== 'number') {\n throw new ERR_INVALID_ARG_TYPE(name, 'number', value)\n }\n if (!NumberIsInteger(value)) {\n throw new ERR_OUT_OF_RANGE(name, 'an integer', value)\n }\n if (value < min || value > max) {\n throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value)\n }\n})\n\n/**\n * @callback validateUint32\n * @param {*} value\n * @param {string} name\n * @param {number|boolean} [positive=false]\n * @returns {asserts value is number}\n */\n\n/** @type {validateUint32} */\nconst validateUint32 = hideStackFrames((value, name, positive = false) => {\n if (typeof value !== 'number') {\n throw new ERR_INVALID_ARG_TYPE(name, 'number', value)\n }\n if (!NumberIsInteger(value)) {\n throw new ERR_OUT_OF_RANGE(name, 'an integer', value)\n }\n const min = positive ? 1 : 0\n // 2 ** 32 === 4294967296\n const max = 4294967295\n if (value < min || value > max) {\n throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value)\n }\n})\n\n/**\n * @callback validateString\n * @param {*} value\n * @param {string} name\n * @returns {asserts value is string}\n */\n\n/** @type {validateString} */\nfunction validateString(value, name) {\n if (typeof value !== 'string') throw new ERR_INVALID_ARG_TYPE(name, 'string', value)\n}\n\n/**\n * @callback validateNumber\n * @param {*} value\n * @param {string} name\n * @param {number} [min]\n * @param {number} [max]\n * @returns {asserts value is number}\n */\n\n/** @type {validateNumber} */\nfunction validateNumber(value, name, min = undefined, max) {\n if (typeof value !== 'number') throw new ERR_INVALID_ARG_TYPE(name, 'number', value)\n if (\n (min != null && value < min) ||\n (max != null && value > max) ||\n ((min != null || max != null) && NumberIsNaN(value))\n ) {\n throw new ERR_OUT_OF_RANGE(\n name,\n `${min != null ? `>= ${min}` : ''}${min != null && max != null ? ' && ' : ''}${max != null ? `<= ${max}` : ''}`,\n value\n )\n }\n}\n\n/**\n * @callback validateOneOf\n * @template T\n * @param {T} value\n * @param {string} name\n * @param {T[]} oneOf\n */\n\n/** @type {validateOneOf} */\nconst validateOneOf = hideStackFrames((value, name, oneOf) => {\n if (!ArrayPrototypeIncludes(oneOf, value)) {\n const allowed = ArrayPrototypeJoin(\n ArrayPrototypeMap(oneOf, (v) => (typeof v === 'string' ? `'${v}'` : String(v))),\n ', '\n )\n const reason = 'must be one of: ' + allowed\n throw new ERR_INVALID_ARG_VALUE(name, value, reason)\n }\n})\n\n/**\n * @callback validateBoolean\n * @param {*} value\n * @param {string} name\n * @returns {asserts value is boolean}\n */\n\n/** @type {validateBoolean} */\nfunction validateBoolean(value, name) {\n if (typeof value !== 'boolean') throw new ERR_INVALID_ARG_TYPE(name, 'boolean', value)\n}\n\n/**\n * @param {any} options\n * @param {string} key\n * @param {boolean} defaultValue\n * @returns {boolean}\n */\nfunction getOwnPropertyValueOrDefault(options, key, defaultValue) {\n return options == null || !ObjectPrototypeHasOwnProperty(options, key) ? defaultValue : options[key]\n}\n\n/**\n * @callback validateObject\n * @param {*} value\n * @param {string} name\n * @param {{\n * allowArray?: boolean,\n * allowFunction?: boolean,\n * nullable?: boolean\n * }} [options]\n */\n\n/** @type {validateObject} */\nconst validateObject = hideStackFrames((value, name, options = null) => {\n const allowArray = getOwnPropertyValueOrDefault(options, 'allowArray', false)\n const allowFunction = getOwnPropertyValueOrDefault(options, 'allowFunction', false)\n const nullable = getOwnPropertyValueOrDefault(options, 'nullable', false)\n if (\n (!nullable && value === null) ||\n (!allowArray && ArrayIsArray(value)) ||\n (typeof value !== 'object' && (!allowFunction || typeof value !== 'function'))\n ) {\n throw new ERR_INVALID_ARG_TYPE(name, 'Object', value)\n }\n})\n\n/**\n * @callback validateDictionary - We are using the Web IDL Standard definition\n * of \"dictionary\" here, which means any value\n * whose Type is either Undefined, Null, or\n * Object (which includes functions).\n * @param {*} value\n * @param {string} name\n * @see https://webidl.spec.whatwg.org/#es-dictionary\n * @see https://tc39.es/ecma262/#table-typeof-operator-results\n */\n\n/** @type {validateDictionary} */\nconst validateDictionary = hideStackFrames((value, name) => {\n if (value != null && typeof value !== 'object' && typeof value !== 'function') {\n throw new ERR_INVALID_ARG_TYPE(name, 'a dictionary', value)\n }\n})\n\n/**\n * @callback validateArray\n * @param {*} value\n * @param {string} name\n * @param {number} [minLength]\n * @returns {asserts value is any[]}\n */\n\n/** @type {validateArray} */\nconst validateArray = hideStackFrames((value, name, minLength = 0) => {\n if (!ArrayIsArray(value)) {\n throw new ERR_INVALID_ARG_TYPE(name, 'Array', value)\n }\n if (value.length < minLength) {\n const reason = `must be longer than ${minLength}`\n throw new ERR_INVALID_ARG_VALUE(name, value, reason)\n }\n})\n\n/**\n * @callback validateStringArray\n * @param {*} value\n * @param {string} name\n * @returns {asserts value is string[]}\n */\n\n/** @type {validateStringArray} */\nfunction validateStringArray(value, name) {\n validateArray(value, name)\n for (let i = 0; i < value.length; i++) {\n validateString(value[i], `${name}[${i}]`)\n }\n}\n\n/**\n * @callback validateBooleanArray\n * @param {*} value\n * @param {string} name\n * @returns {asserts value is boolean[]}\n */\n\n/** @type {validateBooleanArray} */\nfunction validateBooleanArray(value, name) {\n validateArray(value, name)\n for (let i = 0; i < value.length; i++) {\n validateBoolean(value[i], `${name}[${i}]`)\n }\n}\n\n/**\n * @callback validateAbortSignalArray\n * @param {*} value\n * @param {string} name\n * @returns {asserts value is AbortSignal[]}\n */\n\n/** @type {validateAbortSignalArray} */\nfunction validateAbortSignalArray(value, name) {\n validateArray(value, name)\n for (let i = 0; i < value.length; i++) {\n const signal = value[i]\n const indexedName = `${name}[${i}]`\n if (signal == null) {\n throw new ERR_INVALID_ARG_TYPE(indexedName, 'AbortSignal', signal)\n }\n validateAbortSignal(signal, indexedName)\n }\n}\n\n/**\n * @param {*} signal\n * @param {string} [name='signal']\n * @returns {asserts signal is keyof signals}\n */\nfunction validateSignalName(signal, name = 'signal') {\n validateString(signal, name)\n if (signals[signal] === undefined) {\n if (signals[StringPrototypeToUpperCase(signal)] !== undefined) {\n throw new ERR_UNKNOWN_SIGNAL(signal + ' (signals must use all capital letters)')\n }\n throw new ERR_UNKNOWN_SIGNAL(signal)\n }\n}\n\n/**\n * @callback validateBuffer\n * @param {*} buffer\n * @param {string} [name='buffer']\n * @returns {asserts buffer is ArrayBufferView}\n */\n\n/** @type {validateBuffer} */\nconst validateBuffer = hideStackFrames((buffer, name = 'buffer') => {\n if (!isArrayBufferView(buffer)) {\n throw new ERR_INVALID_ARG_TYPE(name, ['Buffer', 'TypedArray', 'DataView'], buffer)\n }\n})\n\n/**\n * @param {string} data\n * @param {string} encoding\n */\nfunction validateEncoding(data, encoding) {\n const normalizedEncoding = normalizeEncoding(encoding)\n const length = data.length\n if (normalizedEncoding === 'hex' && length % 2 !== 0) {\n throw new ERR_INVALID_ARG_VALUE('encoding', encoding, `is invalid for data of length ${length}`)\n }\n}\n\n/**\n * Check that the port number is not NaN when coerced to a number,\n * is an integer and that it falls within the legal range of port numbers.\n * @param {*} port\n * @param {string} [name='Port']\n * @param {boolean} [allowZero=true]\n * @returns {number}\n */\nfunction validatePort(port, name = 'Port', allowZero = true) {\n if (\n (typeof port !== 'number' && typeof port !== 'string') ||\n (typeof port === 'string' && StringPrototypeTrim(port).length === 0) ||\n +port !== +port >>> 0 ||\n port > 0xffff ||\n (port === 0 && !allowZero)\n ) {\n throw new ERR_SOCKET_BAD_PORT(name, port, allowZero)\n }\n return port | 0\n}\n\n/**\n * @callback validateAbortSignal\n * @param {*} signal\n * @param {string} name\n */\n\n/** @type {validateAbortSignal} */\nconst validateAbortSignal = hideStackFrames((signal, name) => {\n if (signal !== undefined && (signal === null || typeof signal !== 'object' || !('aborted' in signal))) {\n throw new ERR_INVALID_ARG_TYPE(name, 'AbortSignal', signal)\n }\n})\n\n/**\n * @callback validateFunction\n * @param {*} value\n * @param {string} name\n * @returns {asserts value is Function}\n */\n\n/** @type {validateFunction} */\nconst validateFunction = hideStackFrames((value, name) => {\n if (typeof value !== 'function') throw new ERR_INVALID_ARG_TYPE(name, 'Function', value)\n})\n\n/**\n * @callback validatePlainFunction\n * @param {*} value\n * @param {string} name\n * @returns {asserts value is Function}\n */\n\n/** @type {validatePlainFunction} */\nconst validatePlainFunction = hideStackFrames((value, name) => {\n if (typeof value !== 'function' || isAsyncFunction(value)) throw new ERR_INVALID_ARG_TYPE(name, 'Function', value)\n})\n\n/**\n * @callback validateUndefined\n * @param {*} value\n * @param {string} name\n * @returns {asserts value is undefined}\n */\n\n/** @type {validateUndefined} */\nconst validateUndefined = hideStackFrames((value, name) => {\n if (value !== undefined) throw new ERR_INVALID_ARG_TYPE(name, 'undefined', value)\n})\n\n/**\n * @template T\n * @param {T} value\n * @param {string} name\n * @param {T[]} union\n */\nfunction validateUnion(value, name, union) {\n if (!ArrayPrototypeIncludes(union, value)) {\n throw new ERR_INVALID_ARG_TYPE(name, `('${ArrayPrototypeJoin(union, '|')}')`, value)\n }\n}\n\n/*\n The rules for the Link header field are described here:\n https://www.rfc-editor.org/rfc/rfc8288.html#section-3\n\n This regex validates any string surrounded by angle brackets\n (not necessarily a valid URI reference) followed by zero or more\n link-params separated by semicolons.\n*/\nconst linkValueRegExp = /^(?:<[^>]*>)(?:\\s*;\\s*[^;\"\\s]+(?:=(\")?[^;\"\\s]*\\1)?)*$/\n\n/**\n * @param {any} value\n * @param {string} name\n */\nfunction validateLinkHeaderFormat(value, name) {\n if (typeof value === 'undefined' || !RegExpPrototypeExec(linkValueRegExp, value)) {\n throw new ERR_INVALID_ARG_VALUE(\n name,\n value,\n 'must be an array or string of format \"</styles.css>; rel=preload; as=style\"'\n )\n }\n}\n\n/**\n * @param {any} hints\n * @return {string}\n */\nfunction validateLinkHeaderValue(hints) {\n if (typeof hints === 'string') {\n validateLinkHeaderFormat(hints, 'hints')\n return hints\n } else if (ArrayIsArray(hints)) {\n const hintsLength = hints.length\n let result = ''\n if (hintsLength === 0) {\n return result\n }\n for (let i = 0; i < hintsLength; i++) {\n const link = hints[i]\n validateLinkHeaderFormat(link, 'hints')\n result += link\n if (i !== hintsLength - 1) {\n result += ', '\n }\n }\n return result\n }\n throw new ERR_INVALID_ARG_VALUE(\n 'hints',\n hints,\n 'must be an array or string of format \"</styles.css>; rel=preload; as=style\"'\n )\n}\nmodule.exports = {\n isInt32,\n isUint32,\n parseFileMode,\n validateArray,\n validateStringArray,\n validateBooleanArray,\n validateAbortSignalArray,\n validateBoolean,\n validateBuffer,\n validateDictionary,\n validateEncoding,\n validateFunction,\n validateInt32,\n validateInteger,\n validateNumber,\n validateObject,\n validateOneOf,\n validatePlainFunction,\n validatePort,\n validateSignalName,\n validateString,\n validateUint32,\n validateUndefined,\n validateUnion,\n validateAbortSignal,\n validateLinkHeaderValue\n}\n", "// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n", "'use strict'\n\nconst { SymbolAsyncIterator, SymbolIterator, SymbolFor } = require('../../ours/primordials')\n\n// We need to use SymbolFor to make these globally available\n// for interopt with readable-stream, i.e. readable-stream\n// and node core needs to be able to read/write private state\n// from each other for proper interoperability.\nconst kIsDestroyed = SymbolFor('nodejs.stream.destroyed')\nconst kIsErrored = SymbolFor('nodejs.stream.errored')\nconst kIsReadable = SymbolFor('nodejs.stream.readable')\nconst kIsWritable = SymbolFor('nodejs.stream.writable')\nconst kIsDisturbed = SymbolFor('nodejs.stream.disturbed')\nconst kIsClosedPromise = SymbolFor('nodejs.webstream.isClosedPromise')\nconst kControllerErrorFunction = SymbolFor('nodejs.webstream.controllerErrorFunction')\nfunction isReadableNodeStream(obj, strict = false) {\n var _obj$_readableState\n return !!(\n (\n obj &&\n typeof obj.pipe === 'function' &&\n typeof obj.on === 'function' &&\n (!strict || (typeof obj.pause === 'function' && typeof obj.resume === 'function')) &&\n (!obj._writableState ||\n ((_obj$_readableState = obj._readableState) === null || _obj$_readableState === undefined\n ? undefined\n : _obj$_readableState.readable) !== false) &&\n // Duplex\n (!obj._writableState || obj._readableState)\n ) // Writable has .pipe.\n )\n}\n\nfunction isWritableNodeStream(obj) {\n var _obj$_writableState\n return !!(\n (\n obj &&\n typeof obj.write === 'function' &&\n typeof obj.on === 'function' &&\n (!obj._readableState ||\n ((_obj$_writableState = obj._writableState) === null || _obj$_writableState === undefined\n ? undefined\n : _obj$_writableState.writable) !== false)\n ) // Duplex\n )\n}\n\nfunction isDuplexNodeStream(obj) {\n return !!(\n obj &&\n typeof obj.pipe === 'function' &&\n obj._readableState &&\n typeof obj.on === 'function' &&\n typeof obj.write === 'function'\n )\n}\nfunction isNodeStream(obj) {\n return (\n obj &&\n (obj._readableState ||\n obj._writableState ||\n (typeof obj.write === 'function' && typeof obj.on === 'function') ||\n (typeof obj.pipe === 'function' && typeof obj.on === 'function'))\n )\n}\nfunction isReadableStream(obj) {\n return !!(\n obj &&\n !isNodeStream(obj) &&\n typeof obj.pipeThrough === 'function' &&\n typeof obj.getReader === 'function' &&\n typeof obj.cancel === 'function'\n )\n}\nfunction isWritableStream(obj) {\n return !!(obj && !isNodeStream(obj) && typeof obj.getWriter === 'function' && typeof obj.abort === 'function')\n}\nfunction isTransformStream(obj) {\n return !!(obj && !isNodeStream(obj) && typeof obj.readable === 'object' && typeof obj.writable === 'object')\n}\nfunction isWebStream(obj) {\n return isReadableStream(obj) || isWritableStream(obj) || isTransformStream(obj)\n}\nfunction isIterable(obj, isAsync) {\n if (obj == null) return false\n if (isAsync === true) return typeof obj[SymbolAsyncIterator] === 'function'\n if (isAsync === false) return typeof obj[SymbolIterator] === 'function'\n return typeof obj[SymbolAsyncIterator] === 'function' || typeof obj[SymbolIterator] === 'function'\n}\nfunction isDestroyed(stream) {\n if (!isNodeStream(stream)) return null\n const wState = stream._writableState\n const rState = stream._readableState\n const state = wState || rState\n return !!(stream.destroyed || stream[kIsDestroyed] || (state !== null && state !== undefined && state.destroyed))\n}\n\n// Have been end():d.\nfunction isWritableEnded(stream) {\n if (!isWritableNodeStream(stream)) return null\n if (stream.writableEnded === true) return true\n const wState = stream._writableState\n if (wState !== null && wState !== undefined && wState.errored) return false\n if (typeof (wState === null || wState === undefined ? undefined : wState.ended) !== 'boolean') return null\n return wState.ended\n}\n\n// Have emitted 'finish'.\nfunction isWritableFinished(stream, strict) {\n if (!isWritableNodeStream(stream)) return null\n if (stream.writableFinished === true) return true\n const wState = stream._writableState\n if (wState !== null && wState !== undefined && wState.errored) return false\n if (typeof (wState === null || wState === undefined ? undefined : wState.finished) !== 'boolean') return null\n return !!(wState.finished || (strict === false && wState.ended === true && wState.length === 0))\n}\n\n// Have been push(null):d.\nfunction isReadableEnded(stream) {\n if (!isReadableNodeStream(stream)) return null\n if (stream.readableEnded === true) return true\n const rState = stream._readableState\n if (!rState || rState.errored) return false\n if (typeof (rState === null || rState === undefined ? undefined : rState.ended) !== 'boolean') return null\n return rState.ended\n}\n\n// Have emitted 'end'.\nfunction isReadableFinished(stream, strict) {\n if (!isReadableNodeStream(stream)) return null\n const rState = stream._readableState\n if (rState !== null && rState !== undefined && rState.errored) return false\n if (typeof (rState === null || rState === undefined ? undefined : rState.endEmitted) !== 'boolean') return null\n return !!(rState.endEmitted || (strict === false && rState.ended === true && rState.length === 0))\n}\nfunction isReadable(stream) {\n if (stream && stream[kIsReadable] != null) return stream[kIsReadable]\n if (typeof (stream === null || stream === undefined ? undefined : stream.readable) !== 'boolean') return null\n if (isDestroyed(stream)) return false\n return isReadableNodeStream(stream) && stream.readable && !isReadableFinished(stream)\n}\nfunction isWritable(stream) {\n if (stream && stream[kIsWritable] != null) return stream[kIsWritable]\n if (typeof (stream === null || stream === undefined ? undefined : stream.writable) !== 'boolean') return null\n if (isDestroyed(stream)) return false\n return isWritableNodeStream(stream) && stream.writable && !isWritableEnded(stream)\n}\nfunction isFinished(stream, opts) {\n if (!isNodeStream(stream)) {\n return null\n }\n if (isDestroyed(stream)) {\n return true\n }\n if ((opts === null || opts === undefined ? undefined : opts.readable) !== false && isReadable(stream)) {\n return false\n }\n if ((opts === null || opts === undefined ? undefined : opts.writable) !== false && isWritable(stream)) {\n return false\n }\n return true\n}\nfunction isWritableErrored(stream) {\n var _stream$_writableStat, _stream$_writableStat2\n if (!isNodeStream(stream)) {\n return null\n }\n if (stream.writableErrored) {\n return stream.writableErrored\n }\n return (_stream$_writableStat =\n (_stream$_writableStat2 = stream._writableState) === null || _stream$_writableStat2 === undefined\n ? undefined\n : _stream$_writableStat2.errored) !== null && _stream$_writableStat !== undefined\n ? _stream$_writableStat\n : null\n}\nfunction isReadableErrored(stream) {\n var _stream$_readableStat, _stream$_readableStat2\n if (!isNodeStream(stream)) {\n return null\n }\n if (stream.readableErrored) {\n return stream.readableErrored\n }\n return (_stream$_readableStat =\n (_stream$_readableStat2 = stream._readableState) === null || _stream$_readableStat2 === undefined\n ? undefined\n : _stream$_readableStat2.errored) !== null && _stream$_readableStat !== undefined\n ? _stream$_readableStat\n : null\n}\nfunction isClosed(stream) {\n if (!isNodeStream(stream)) {\n return null\n }\n if (typeof stream.closed === 'boolean') {\n return stream.closed\n }\n const wState = stream._writableState\n const rState = stream._readableState\n if (\n typeof (wState === null || wState === undefined ? undefined : wState.closed) === 'boolean' ||\n typeof (rState === null || rState === undefined ? undefined : rState.closed) === 'boolean'\n ) {\n return (\n (wState === null || wState === undefined ? undefined : wState.closed) ||\n (rState === null || rState === undefined ? undefined : rState.closed)\n )\n }\n if (typeof stream._closed === 'boolean' && isOutgoingMessage(stream)) {\n return stream._closed\n }\n return null\n}\nfunction isOutgoingMessage(stream) {\n return (\n typeof stream._closed === 'boolean' &&\n typeof stream._defaultKeepAlive === 'boolean' &&\n typeof stream._removedConnection === 'boolean' &&\n typeof stream._removedContLen === 'boolean'\n )\n}\nfunction isServerResponse(stream) {\n return typeof stream._sent100 === 'boolean' && isOutgoingMessage(stream)\n}\nfunction isServerRequest(stream) {\n var _stream$req\n return (\n typeof stream._consuming === 'boolean' &&\n typeof stream._dumped === 'boolean' &&\n ((_stream$req = stream.req) === null || _stream$req === undefined ? undefined : _stream$req.upgradeOrConnect) ===\n undefined\n )\n}\nfunction willEmitClose(stream) {\n if (!isNodeStream(stream)) return null\n const wState = stream._writableState\n const rState = stream._readableState\n const state = wState || rState\n return (\n (!state && isServerResponse(stream)) || !!(state && state.autoDestroy && state.emitClose && state.closed === false)\n )\n}\nfunction isDisturbed(stream) {\n var _stream$kIsDisturbed\n return !!(\n stream &&\n ((_stream$kIsDisturbed = stream[kIsDisturbed]) !== null && _stream$kIsDisturbed !== undefined\n ? _stream$kIsDisturbed\n : stream.readableDidRead || stream.readableAborted)\n )\n}\nfunction isErrored(stream) {\n var _ref,\n _ref2,\n _ref3,\n _ref4,\n _ref5,\n _stream$kIsErrored,\n _stream$_readableStat3,\n _stream$_writableStat3,\n _stream$_readableStat4,\n _stream$_writableStat4\n return !!(\n stream &&\n ((_ref =\n (_ref2 =\n (_ref3 =\n (_ref4 =\n (_ref5 =\n (_stream$kIsErrored = stream[kIsErrored]) !== null && _stream$kIsErrored !== undefined\n ? _stream$kIsErrored\n : stream.readableErrored) !== null && _ref5 !== undefined\n ? _ref5\n : stream.writableErrored) !== null && _ref4 !== undefined\n ? _ref4\n : (_stream$_readableStat3 = stream._readableState) === null || _stream$_readableStat3 === undefined\n ? undefined\n : _stream$_readableStat3.errorEmitted) !== null && _ref3 !== undefined\n ? _ref3\n : (_stream$_writableStat3 = stream._writableState) === null || _stream$_writableStat3 === undefined\n ? undefined\n : _stream$_writableStat3.errorEmitted) !== null && _ref2 !== undefined\n ? _ref2\n : (_stream$_readableStat4 = stream._readableState) === null || _stream$_readableStat4 === undefined\n ? undefined\n : _stream$_readableStat4.errored) !== null && _ref !== undefined\n ? _ref\n : (_stream$_writableStat4 = stream._writableState) === null || _stream$_writableStat4 === undefined\n ? undefined\n : _stream$_writableStat4.errored)\n )\n}\nmodule.exports = {\n isDestroyed,\n kIsDestroyed,\n isDisturbed,\n kIsDisturbed,\n isErrored,\n kIsErrored,\n isReadable,\n kIsReadable,\n kIsClosedPromise,\n kControllerErrorFunction,\n kIsWritable,\n isClosed,\n isDuplexNodeStream,\n isFinished,\n isIterable,\n isReadableNodeStream,\n isReadableStream,\n isReadableEnded,\n isReadableFinished,\n isReadableErrored,\n isNodeStream,\n isWebStream,\n isWritable,\n isWritableNodeStream,\n isWritableStream,\n isWritableEnded,\n isWritableFinished,\n isWritableErrored,\n isServerRequest,\n isServerResponse,\n willEmitClose,\n isTransformStream\n}\n", "/* replacement start */\n\nconst process = require('process/')\n\n/* replacement end */\n// Ported from https://github.com/mafintosh/end-of-stream with\n// permission from the author, Mathias Buus (@mafintosh).\n\n;('use strict')\nconst { AbortError, codes } = require('../../ours/errors')\nconst { ERR_INVALID_ARG_TYPE, ERR_STREAM_PREMATURE_CLOSE } = codes\nconst { kEmptyObject, once } = require('../../ours/util')\nconst { validateAbortSignal, validateFunction, validateObject, validateBoolean } = require('../validators')\nconst { Promise, PromisePrototypeThen, SymbolDispose } = require('../../ours/primordials')\nconst {\n isClosed,\n isReadable,\n isReadableNodeStream,\n isReadableStream,\n isReadableFinished,\n isReadableErrored,\n isWritable,\n isWritableNodeStream,\n isWritableStream,\n isWritableFinished,\n isWritableErrored,\n isNodeStream,\n willEmitClose: _willEmitClose,\n kIsClosedPromise\n} = require('./utils')\nlet addAbortListener\nfunction isRequest(stream) {\n return stream.setHeader && typeof stream.abort === 'function'\n}\nconst nop = () => {}\nfunction eos(stream, options, callback) {\n var _options$readable, _options$writable\n if (arguments.length === 2) {\n callback = options\n options = kEmptyObject\n } else if (options == null) {\n options = kEmptyObject\n } else {\n validateObject(options, 'options')\n }\n validateFunction(callback, 'callback')\n validateAbortSignal(options.signal, 'options.signal')\n callback = once(callback)\n if (isReadableStream(stream) || isWritableStream(stream)) {\n return eosWeb(stream, options, callback)\n }\n if (!isNodeStream(stream)) {\n throw new ERR_INVALID_ARG_TYPE('stream', ['ReadableStream', 'WritableStream', 'Stream'], stream)\n }\n const readable =\n (_options$readable = options.readable) !== null && _options$readable !== undefined\n ? _options$readable\n : isReadableNodeStream(stream)\n const writable =\n (_options$writable = options.writable) !== null && _options$writable !== undefined\n ? _options$writable\n : isWritableNodeStream(stream)\n const wState = stream._writableState\n const rState = stream._readableState\n const onlegacyfinish = () => {\n if (!stream.writable) {\n onfinish()\n }\n }\n\n // TODO (ronag): Improve soft detection to include core modules and\n // common ecosystem modules that do properly emit 'close' but fail\n // this generic check.\n let willEmitClose =\n _willEmitClose(stream) && isReadableNodeStream(stream) === readable && isWritableNodeStream(stream) === writable\n let writableFinished = isWritableFinished(stream, false)\n const onfinish = () => {\n writableFinished = true\n // Stream should not be destroyed here. If it is that\n // means that user space is doing something differently and\n // we cannot trust willEmitClose.\n if (stream.destroyed) {\n willEmitClose = false\n }\n if (willEmitClose && (!stream.readable || readable)) {\n return\n }\n if (!readable || readableFinished) {\n callback.call(stream)\n }\n }\n let readableFinished = isReadableFinished(stream, false)\n const onend = () => {\n readableFinished = true\n // Stream should not be destroyed here. If it is that\n // means that user space is doing something differently and\n // we cannot trust willEmitClose.\n if (stream.destroyed) {\n willEmitClose = false\n }\n if (willEmitClose && (!stream.writable || writable)) {\n return\n }\n if (!writable || writableFinished) {\n callback.call(stream)\n }\n }\n const onerror = (err) => {\n callback.call(stream, err)\n }\n let closed = isClosed(stream)\n const onclose = () => {\n closed = true\n const errored = isWritableErrored(stream) || isReadableErrored(stream)\n if (errored && typeof errored !== 'boolean') {\n return callback.call(stream, errored)\n }\n if (readable && !readableFinished && isReadableNodeStream(stream, true)) {\n if (!isReadableFinished(stream, false)) return callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE())\n }\n if (writable && !writableFinished) {\n if (!isWritableFinished(stream, false)) return callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE())\n }\n callback.call(stream)\n }\n const onclosed = () => {\n closed = true\n const errored = isWritableErrored(stream) || isReadableErrored(stream)\n if (errored && typeof errored !== 'boolean') {\n return callback.call(stream, errored)\n }\n callback.call(stream)\n }\n const onrequest = () => {\n stream.req.on('finish', onfinish)\n }\n if (isRequest(stream)) {\n stream.on('complete', onfinish)\n if (!willEmitClose) {\n stream.on('abort', onclose)\n }\n if (stream.req) {\n onrequest()\n } else {\n stream.on('request', onrequest)\n }\n } else if (writable && !wState) {\n // legacy streams\n stream.on('end', onlegacyfinish)\n stream.on('close', onlegacyfinish)\n }\n\n // Not all streams will emit 'close' after 'aborted'.\n if (!willEmitClose && typeof stream.aborted === 'boolean') {\n stream.on('aborted', onclose)\n }\n stream.on('end', onend)\n stream.on('finish', onfinish)\n if (options.error !== false) {\n stream.on('error', onerror)\n }\n stream.on('close', onclose)\n if (closed) {\n process.nextTick(onclose)\n } else if (\n (wState !== null && wState !== undefined && wState.errorEmitted) ||\n (rState !== null && rState !== undefined && rState.errorEmitted)\n ) {\n if (!willEmitClose) {\n process.nextTick(onclosed)\n }\n } else if (\n !readable &&\n (!willEmitClose || isReadable(stream)) &&\n (writableFinished || isWritable(stream) === false)\n ) {\n process.nextTick(onclosed)\n } else if (\n !writable &&\n (!willEmitClose || isWritable(stream)) &&\n (readableFinished || isReadable(stream) === false)\n ) {\n process.nextTick(onclosed)\n } else if (rState && stream.req && stream.aborted) {\n process.nextTick(onclosed)\n }\n const cleanup = () => {\n callback = nop\n stream.removeListener('aborted', onclose)\n stream.removeListener('complete', onfinish)\n stream.removeListener('abort', onclose)\n stream.removeListener('request', onrequest)\n if (stream.req) stream.req.removeListener('finish', onfinish)\n stream.removeListener('end', onlegacyfinish)\n stream.removeListener('close', onlegacyfinish)\n stream.removeListener('finish', onfinish)\n stream.removeListener('end', onend)\n stream.removeListener('error', onerror)\n stream.removeListener('close', onclose)\n }\n if (options.signal && !closed) {\n const abort = () => {\n // Keep it because cleanup removes it.\n const endCallback = callback\n cleanup()\n endCallback.call(\n stream,\n new AbortError(undefined, {\n cause: options.signal.reason\n })\n )\n }\n if (options.signal.aborted) {\n process.nextTick(abort)\n } else {\n addAbortListener = addAbortListener || require('../../ours/util').addAbortListener\n const disposable = addAbortListener(options.signal, abort)\n const originalCallback = callback\n callback = once((...args) => {\n disposable[SymbolDispose]()\n originalCallback.apply(stream, args)\n })\n }\n }\n return cleanup\n}\nfunction eosWeb(stream, options, callback) {\n let isAborted = false\n let abort = nop\n if (options.signal) {\n abort = () => {\n isAborted = true\n callback.call(\n stream,\n new AbortError(undefined, {\n cause: options.signal.reason\n })\n )\n }\n if (options.signal.aborted) {\n process.nextTick(abort)\n } else {\n addAbortListener = addAbortListener || require('../../ours/util').addAbortListener\n const disposable = addAbortListener(options.signal, abort)\n const originalCallback = callback\n callback = once((...args) => {\n disposable[SymbolDispose]()\n originalCallback.apply(stream, args)\n })\n }\n }\n const resolverFn = (...args) => {\n if (!isAborted) {\n process.nextTick(() => callback.apply(stream, args))\n }\n }\n PromisePrototypeThen(stream[kIsClosedPromise].promise, resolverFn, resolverFn)\n return nop\n}\nfunction finished(stream, opts) {\n var _opts\n let autoCleanup = false\n if (opts === null) {\n opts = kEmptyObject\n }\n if ((_opts = opts) !== null && _opts !== undefined && _opts.cleanup) {\n validateBoolean(opts.cleanup, 'cleanup')\n autoCleanup = opts.cleanup\n }\n return new Promise((resolve, reject) => {\n const cleanup = eos(stream, opts, (err) => {\n if (autoCleanup) {\n cleanup()\n }\n if (err) {\n reject(err)\n } else {\n resolve()\n }\n })\n })\n}\nmodule.exports = eos\nmodule.exports.finished = finished\n", "'use strict'\n\n/* replacement start */\n\nconst process = require('process/')\n\n/* replacement end */\n\nconst {\n aggregateTwoErrors,\n codes: { ERR_MULTIPLE_CALLBACK },\n AbortError\n} = require('../../ours/errors')\nconst { Symbol } = require('../../ours/primordials')\nconst { kIsDestroyed, isDestroyed, isFinished, isServerRequest } = require('./utils')\nconst kDestroy = Symbol('kDestroy')\nconst kConstruct = Symbol('kConstruct')\nfunction checkError(err, w, r) {\n if (err) {\n // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364\n err.stack // eslint-disable-line no-unused-expressions\n\n if (w && !w.errored) {\n w.errored = err\n }\n if (r && !r.errored) {\n r.errored = err\n }\n }\n}\n\n// Backwards compat. cb() is undocumented and unused in core but\n// unfortunately might be used by modules.\nfunction destroy(err, cb) {\n const r = this._readableState\n const w = this._writableState\n // With duplex streams we use the writable side for state.\n const s = w || r\n if ((w !== null && w !== undefined && w.destroyed) || (r !== null && r !== undefined && r.destroyed)) {\n if (typeof cb === 'function') {\n cb()\n }\n return this\n }\n\n // We set destroyed to true before firing error callbacks in order\n // to make it re-entrance safe in case destroy() is called within callbacks\n checkError(err, w, r)\n if (w) {\n w.destroyed = true\n }\n if (r) {\n r.destroyed = true\n }\n\n // If still constructing then defer calling _destroy.\n if (!s.constructed) {\n this.once(kDestroy, function (er) {\n _destroy(this, aggregateTwoErrors(er, err), cb)\n })\n } else {\n _destroy(this, err, cb)\n }\n return this\n}\nfunction _destroy(self, err, cb) {\n let called = false\n function onDestroy(err) {\n if (called) {\n return\n }\n called = true\n const r = self._readableState\n const w = self._writableState\n checkError(err, w, r)\n if (w) {\n w.closed = true\n }\n if (r) {\n r.closed = true\n }\n if (typeof cb === 'function') {\n cb(err)\n }\n if (err) {\n process.nextTick(emitErrorCloseNT, self, err)\n } else {\n process.nextTick(emitCloseNT, self)\n }\n }\n try {\n self._destroy(err || null, onDestroy)\n } catch (err) {\n onDestroy(err)\n }\n}\nfunction emitErrorCloseNT(self, err) {\n emitErrorNT(self, err)\n emitCloseNT(self)\n}\nfunction emitCloseNT(self) {\n const r = self._readableState\n const w = self._writableState\n if (w) {\n w.closeEmitted = true\n }\n if (r) {\n r.closeEmitted = true\n }\n if ((w !== null && w !== undefined && w.emitClose) || (r !== null && r !== undefined && r.emitClose)) {\n self.emit('close')\n }\n}\nfunction emitErrorNT(self, err) {\n const r = self._readableState\n const w = self._writableState\n if ((w !== null && w !== undefined && w.errorEmitted) || (r !== null && r !== undefined && r.errorEmitted)) {\n return\n }\n if (w) {\n w.errorEmitted = true\n }\n if (r) {\n r.errorEmitted = true\n }\n self.emit('error', err)\n}\nfunction undestroy() {\n const r = this._readableState\n const w = this._writableState\n if (r) {\n r.constructed = true\n r.closed = false\n r.closeEmitted = false\n r.destroyed = false\n r.errored = null\n r.errorEmitted = false\n r.reading = false\n r.ended = r.readable === false\n r.endEmitted = r.readable === false\n }\n if (w) {\n w.constructed = true\n w.destroyed = false\n w.closed = false\n w.closeEmitted = false\n w.errored = null\n w.errorEmitted = false\n w.finalCalled = false\n w.prefinished = false\n w.ended = w.writable === false\n w.ending = w.writable === false\n w.finished = w.writable === false\n }\n}\nfunction errorOrDestroy(stream, err, sync) {\n // We have tests that rely on errors being emitted\n // in the same tick, so changing this is semver major.\n // For now when you opt-in to autoDestroy we allow\n // the error to be emitted nextTick. In a future\n // semver major update we should change the default to this.\n\n const r = stream._readableState\n const w = stream._writableState\n if ((w !== null && w !== undefined && w.destroyed) || (r !== null && r !== undefined && r.destroyed)) {\n return this\n }\n if ((r !== null && r !== undefined && r.autoDestroy) || (w !== null && w !== undefined && w.autoDestroy))\n stream.destroy(err)\n else if (err) {\n // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364\n err.stack // eslint-disable-line no-unused-expressions\n\n if (w && !w.errored) {\n w.errored = err\n }\n if (r && !r.errored) {\n r.errored = err\n }\n if (sync) {\n process.nextTick(emitErrorNT, stream, err)\n } else {\n emitErrorNT(stream, err)\n }\n }\n}\nfunction construct(stream, cb) {\n if (typeof stream._construct !== 'function') {\n return\n }\n const r = stream._readableState\n const w = stream._writableState\n if (r) {\n r.constructed = false\n }\n if (w) {\n w.constructed = false\n }\n stream.once(kConstruct, cb)\n if (stream.listenerCount(kConstruct) > 1) {\n // Duplex\n return\n }\n process.nextTick(constructNT, stream)\n}\nfunction constructNT(stream) {\n let called = false\n function onConstruct(err) {\n if (called) {\n errorOrDestroy(stream, err !== null && err !== undefined ? err : new ERR_MULTIPLE_CALLBACK())\n return\n }\n called = true\n const r = stream._readableState\n const w = stream._writableState\n const s = w || r\n if (r) {\n r.constructed = true\n }\n if (w) {\n w.constructed = true\n }\n if (s.destroyed) {\n stream.emit(kDestroy, err)\n } else if (err) {\n errorOrDestroy(stream, err, true)\n } else {\n process.nextTick(emitConstructNT, stream)\n }\n }\n try {\n stream._construct((err) => {\n process.nextTick(onConstruct, err)\n })\n } catch (err) {\n process.nextTick(onConstruct, err)\n }\n}\nfunction emitConstructNT(stream) {\n stream.emit(kConstruct)\n}\nfunction isRequest(stream) {\n return (stream === null || stream === undefined ? undefined : stream.setHeader) && typeof stream.abort === 'function'\n}\nfunction emitCloseLegacy(stream) {\n stream.emit('close')\n}\nfunction emitErrorCloseLegacy(stream, err) {\n stream.emit('error', err)\n process.nextTick(emitCloseLegacy, stream)\n}\n\n// Normalize destroy for legacy.\nfunction destroyer(stream, err) {\n if (!stream || isDestroyed(stream)) {\n return\n }\n if (!err && !isFinished(stream)) {\n err = new AbortError()\n }\n\n // TODO: Remove isRequest branches.\n if (isServerRequest(stream)) {\n stream.socket = null\n stream.destroy(err)\n } else if (isRequest(stream)) {\n stream.abort()\n } else if (isRequest(stream.req)) {\n stream.req.abort()\n } else if (typeof stream.destroy === 'function') {\n stream.destroy(err)\n } else if (typeof stream.close === 'function') {\n // TODO: Don't lose err?\n stream.close()\n } else if (err) {\n process.nextTick(emitErrorCloseLegacy, stream, err)\n } else {\n process.nextTick(emitCloseLegacy, stream)\n }\n if (!stream.destroyed) {\n stream[kIsDestroyed] = true\n }\n}\nmodule.exports = {\n construct,\n destroyer,\n destroy,\n undestroy,\n errorOrDestroy\n}\n", "'use strict'\n\nconst { ArrayIsArray, ObjectSetPrototypeOf } = require('../../ours/primordials')\nconst { EventEmitter: EE } = require('events')\nfunction Stream(opts) {\n EE.call(this, opts)\n}\nObjectSetPrototypeOf(Stream.prototype, EE.prototype)\nObjectSetPrototypeOf(Stream, EE)\nStream.prototype.pipe = function (dest, options) {\n const source = this\n function ondata(chunk) {\n if (dest.writable && dest.write(chunk) === false && source.pause) {\n source.pause()\n }\n }\n source.on('data', ondata)\n function ondrain() {\n if (source.readable && source.resume) {\n source.resume()\n }\n }\n dest.on('drain', ondrain)\n\n // If the 'end' option is not supplied, dest.end() will be called when\n // source gets the 'end' or 'close' events. Only dest.end() once.\n if (!dest._isStdio && (!options || options.end !== false)) {\n source.on('end', onend)\n source.on('close', onclose)\n }\n let didOnEnd = false\n function onend() {\n if (didOnEnd) return\n didOnEnd = true\n dest.end()\n }\n function onclose() {\n if (didOnEnd) return\n didOnEnd = true\n if (typeof dest.destroy === 'function') dest.destroy()\n }\n\n // Don't leave dangling pipes when there are errors.\n function onerror(er) {\n cleanup()\n if (EE.listenerCount(this, 'error') === 0) {\n this.emit('error', er)\n }\n }\n prependListener(source, 'error', onerror)\n prependListener(dest, 'error', onerror)\n\n // Remove all the event listeners that were added.\n function cleanup() {\n source.removeListener('data', ondata)\n dest.removeListener('drain', ondrain)\n source.removeListener('end', onend)\n source.removeListener('close', onclose)\n source.removeListener('error', onerror)\n dest.removeListener('error', onerror)\n source.removeListener('end', cleanup)\n source.removeListener('close', cleanup)\n dest.removeListener('close', cleanup)\n }\n source.on('end', cleanup)\n source.on('close', cleanup)\n dest.on('close', cleanup)\n dest.emit('pipe', source)\n\n // Allow for unix-like usage: A.pipe(B).pipe(C)\n return dest\n}\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn)\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event]) emitter.on(event, fn)\n else if (ArrayIsArray(emitter._events[event])) emitter._events[event].unshift(fn)\n else emitter._events[event] = [fn, emitter._events[event]]\n}\nmodule.exports = {\n Stream,\n prependListener\n}\n", "'use strict'\n\nconst { SymbolDispose } = require('../../ours/primordials')\nconst { AbortError, codes } = require('../../ours/errors')\nconst { isNodeStream, isWebStream, kControllerErrorFunction } = require('./utils')\nconst eos = require('./end-of-stream')\nconst { ERR_INVALID_ARG_TYPE } = codes\nlet addAbortListener\n\n// This method is inlined here for readable-stream\n// It also does not allow for signal to not exist on the stream\n// https://github.com/nodejs/node/pull/36061#discussion_r533718029\nconst validateAbortSignal = (signal, name) => {\n if (typeof signal !== 'object' || !('aborted' in signal)) {\n throw new ERR_INVALID_ARG_TYPE(name, 'AbortSignal', signal)\n }\n}\nmodule.exports.addAbortSignal = function addAbortSignal(signal, stream) {\n validateAbortSignal(signal, 'signal')\n if (!isNodeStream(stream) && !isWebStream(stream)) {\n throw new ERR_INVALID_ARG_TYPE('stream', ['ReadableStream', 'WritableStream', 'Stream'], stream)\n }\n return module.exports.addAbortSignalNoValidate(signal, stream)\n}\nmodule.exports.addAbortSignalNoValidate = function (signal, stream) {\n if (typeof signal !== 'object' || !('aborted' in signal)) {\n return stream\n }\n const onAbort = isNodeStream(stream)\n ? () => {\n stream.destroy(\n new AbortError(undefined, {\n cause: signal.reason\n })\n )\n }\n : () => {\n stream[kControllerErrorFunction](\n new AbortError(undefined, {\n cause: signal.reason\n })\n )\n }\n if (signal.aborted) {\n onAbort()\n } else {\n addAbortListener = addAbortListener || require('../../ours/util').addAbortListener\n const disposable = addAbortListener(signal, onAbort)\n eos(stream, disposable[SymbolDispose])\n }\n return stream\n}\n", "'use strict'\n\nconst { StringPrototypeSlice, SymbolIterator, TypedArrayPrototypeSet, Uint8Array } = require('../../ours/primordials')\nconst { Buffer } = require('buffer')\nconst { inspect } = require('../../ours/util')\nmodule.exports = class BufferList {\n constructor() {\n this.head = null\n this.tail = null\n this.length = 0\n }\n push(v) {\n const entry = {\n data: v,\n next: null\n }\n if (this.length > 0) this.tail.next = entry\n else this.head = entry\n this.tail = entry\n ++this.length\n }\n unshift(v) {\n const entry = {\n data: v,\n next: this.head\n }\n if (this.length === 0) this.tail = entry\n this.head = entry\n ++this.length\n }\n shift() {\n if (this.length === 0) return\n const ret = this.head.data\n if (this.length === 1) this.head = this.tail = null\n else this.head = this.head.next\n --this.length\n return ret\n }\n clear() {\n this.head = this.tail = null\n this.length = 0\n }\n join(s) {\n if (this.length === 0) return ''\n let p = this.head\n let ret = '' + p.data\n while ((p = p.next) !== null) ret += s + p.data\n return ret\n }\n concat(n) {\n if (this.length === 0) return Buffer.alloc(0)\n const ret = Buffer.allocUnsafe(n >>> 0)\n let p = this.head\n let i = 0\n while (p) {\n TypedArrayPrototypeSet(ret, p.data, i)\n i += p.data.length\n p = p.next\n }\n return ret\n }\n\n // Consumes a specified amount of bytes or characters from the buffered data.\n consume(n, hasStrings) {\n const data = this.head.data\n if (n < data.length) {\n // `slice` is the same for buffers and strings.\n const slice = data.slice(0, n)\n this.head.data = data.slice(n)\n return slice\n }\n if (n === data.length) {\n // First chunk is a perfect match.\n return this.shift()\n }\n // Result spans more than one buffer.\n return hasStrings ? this._getString(n) : this._getBuffer(n)\n }\n first() {\n return this.head.data\n }\n *[SymbolIterator]() {\n for (let p = this.head; p; p = p.next) {\n yield p.data\n }\n }\n\n // Consumes a specified amount of characters from the buffered data.\n _getString(n) {\n let ret = ''\n let p = this.head\n let c = 0\n do {\n const str = p.data\n if (n > str.length) {\n ret += str\n n -= str.length\n } else {\n if (n === str.length) {\n ret += str\n ++c\n if (p.next) this.head = p.next\n else this.head = this.tail = null\n } else {\n ret += StringPrototypeSlice(str, 0, n)\n this.head = p\n p.data = StringPrototypeSlice(str, n)\n }\n break\n }\n ++c\n } while ((p = p.next) !== null)\n this.length -= c\n return ret\n }\n\n // Consumes a specified amount of bytes from the buffered data.\n _getBuffer(n) {\n const ret = Buffer.allocUnsafe(n)\n const retLen = n\n let p = this.head\n let c = 0\n do {\n const buf = p.data\n if (n > buf.length) {\n TypedArrayPrototypeSet(ret, buf, retLen - n)\n n -= buf.length\n } else {\n if (n === buf.length) {\n TypedArrayPrototypeSet(ret, buf, retLen - n)\n ++c\n if (p.next) this.head = p.next\n else this.head = this.tail = null\n } else {\n TypedArrayPrototypeSet(ret, new Uint8Array(buf.buffer, buf.byteOffset, n), retLen - n)\n this.head = p\n p.data = buf.slice(n)\n }\n break\n }\n ++c\n } while ((p = p.next) !== null)\n this.length -= c\n return ret\n }\n\n // Make sure the linked list only shows the minimal necessary information.\n [Symbol.for('nodejs.util.inspect.custom')](_, options) {\n return inspect(this, {\n ...options,\n // Only inspect one level.\n depth: 0,\n // It should not recurse.\n customInspect: false\n })\n }\n}\n", "'use strict'\n\nconst { MathFloor, NumberIsInteger } = require('../../ours/primordials')\nconst { validateInteger } = require('../validators')\nconst { ERR_INVALID_ARG_VALUE } = require('../../ours/errors').codes\nlet defaultHighWaterMarkBytes = 16 * 1024\nlet defaultHighWaterMarkObjectMode = 16\nfunction highWaterMarkFrom(options, isDuplex, duplexKey) {\n return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null\n}\nfunction getDefaultHighWaterMark(objectMode) {\n return objectMode ? defaultHighWaterMarkObjectMode : defaultHighWaterMarkBytes\n}\nfunction setDefaultHighWaterMark(objectMode, value) {\n validateInteger(value, 'value', 0)\n if (objectMode) {\n defaultHighWaterMarkObjectMode = value\n } else {\n defaultHighWaterMarkBytes = value\n }\n}\nfunction getHighWaterMark(state, options, duplexKey, isDuplex) {\n const hwm = highWaterMarkFrom(options, isDuplex, duplexKey)\n if (hwm != null) {\n if (!NumberIsInteger(hwm) || hwm < 0) {\n const name = isDuplex ? `options.${duplexKey}` : 'options.highWaterMark'\n throw new ERR_INVALID_ARG_VALUE(name, hwm)\n }\n return MathFloor(hwm)\n }\n\n // Default value\n return getDefaultHighWaterMark(state.objectMode)\n}\nmodule.exports = {\n getHighWaterMark,\n getDefaultHighWaterMark,\n setDefaultHighWaterMark\n}\n", "/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */\n/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.prototype = Object.create(Buffer.prototype)\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n/*<replacement>*/\n\nvar Buffer = require('safe-buffer').Buffer;\n/*</replacement>*/\n\nvar isEncoding = Buffer.isEncoding || function (encoding) {\n encoding = '' + encoding;\n switch (encoding && encoding.toLowerCase()) {\n case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':\n return true;\n default:\n return false;\n }\n};\n\nfunction _normalizeEncoding(enc) {\n if (!enc) return 'utf8';\n var retried;\n while (true) {\n switch (enc) {\n case 'utf8':\n case 'utf-8':\n return 'utf8';\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return 'utf16le';\n case 'latin1':\n case 'binary':\n return 'latin1';\n case 'base64':\n case 'ascii':\n case 'hex':\n return enc;\n default:\n if (retried) return; // undefined\n enc = ('' + enc).toLowerCase();\n retried = true;\n }\n }\n};\n\n// Do not cache `Buffer.isEncoding` when checking encoding names as some\n// modules monkey-patch it to support additional encodings\nfunction normalizeEncoding(enc) {\n var nenc = _normalizeEncoding(enc);\n if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);\n return nenc || enc;\n}\n\n// StringDecoder provides an interface for efficiently splitting a series of\n// buffers into a series of JS strings without breaking apart multi-byte\n// characters.\nexports.StringDecoder = StringDecoder;\nfunction StringDecoder(encoding) {\n this.encoding = normalizeEncoding(encoding);\n var nb;\n switch (this.encoding) {\n case 'utf16le':\n this.text = utf16Text;\n this.end = utf16End;\n nb = 4;\n break;\n case 'utf8':\n this.fillLast = utf8FillLast;\n nb = 4;\n break;\n case 'base64':\n this.text = base64Text;\n this.end = base64End;\n nb = 3;\n break;\n default:\n this.write = simpleWrite;\n this.end = simpleEnd;\n return;\n }\n this.lastNeed = 0;\n this.lastTotal = 0;\n this.lastChar = Buffer.allocUnsafe(nb);\n}\n\nStringDecoder.prototype.write = function (buf) {\n if (buf.length === 0) return '';\n var r;\n var i;\n if (this.lastNeed) {\n r = this.fillLast(buf);\n if (r === undefined) return '';\n i = this.lastNeed;\n this.lastNeed = 0;\n } else {\n i = 0;\n }\n if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);\n return r || '';\n};\n\nStringDecoder.prototype.end = utf8End;\n\n// Returns only complete characters in a Buffer\nStringDecoder.prototype.text = utf8Text;\n\n// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer\nStringDecoder.prototype.fillLast = function (buf) {\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);\n this.lastNeed -= buf.length;\n};\n\n// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a\n// continuation byte. If an invalid byte is detected, -2 is returned.\nfunction utf8CheckByte(byte) {\n if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;\n return byte >> 6 === 0x02 ? -1 : -2;\n}\n\n// Checks at most 3 bytes at the end of a Buffer in order to detect an\n// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)\n// needed to complete the UTF-8 character (if applicable) are returned.\nfunction utf8CheckIncomplete(self, buf, i) {\n var j = buf.length - 1;\n if (j < i) return 0;\n var nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 1;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) self.lastNeed = nb - 2;\n return nb;\n }\n if (--j < i || nb === -2) return 0;\n nb = utf8CheckByte(buf[j]);\n if (nb >= 0) {\n if (nb > 0) {\n if (nb === 2) nb = 0;else self.lastNeed = nb - 3;\n }\n return nb;\n }\n return 0;\n}\n\n// Validates as many continuation bytes for a multi-byte UTF-8 character as\n// needed or are available. If we see a non-continuation byte where we expect\n// one, we \"replace\" the validated continuation bytes we've seen so far with\n// a single UTF-8 replacement character ('\\ufffd'), to match v8's UTF-8 decoding\n// behavior. The continuation byte check is included three times in the case\n// where all of the continuation bytes for a character exist in the same buffer.\n// It is also done this way as a slight performance increase instead of using a\n// loop.\nfunction utf8CheckExtraBytes(self, buf, p) {\n if ((buf[0] & 0xC0) !== 0x80) {\n self.lastNeed = 0;\n return '\\ufffd';\n }\n if (self.lastNeed > 1 && buf.length > 1) {\n if ((buf[1] & 0xC0) !== 0x80) {\n self.lastNeed = 1;\n return '\\ufffd';\n }\n if (self.lastNeed > 2 && buf.length > 2) {\n if ((buf[2] & 0xC0) !== 0x80) {\n self.lastNeed = 2;\n return '\\ufffd';\n }\n }\n }\n}\n\n// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.\nfunction utf8FillLast(buf) {\n var p = this.lastTotal - this.lastNeed;\n var r = utf8CheckExtraBytes(this, buf, p);\n if (r !== undefined) return r;\n if (this.lastNeed <= buf.length) {\n buf.copy(this.lastChar, p, 0, this.lastNeed);\n return this.lastChar.toString(this.encoding, 0, this.lastTotal);\n }\n buf.copy(this.lastChar, p, 0, buf.length);\n this.lastNeed -= buf.length;\n}\n\n// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a\n// partial character, the character's bytes are buffered until the required\n// number of bytes are available.\nfunction utf8Text(buf, i) {\n var total = utf8CheckIncomplete(this, buf, i);\n if (!this.lastNeed) return buf.toString('utf8', i);\n this.lastTotal = total;\n var end = buf.length - (total - this.lastNeed);\n buf.copy(this.lastChar, 0, end);\n return buf.toString('utf8', i, end);\n}\n\n// For UTF-8, a replacement character is added when ending on a partial\n// character.\nfunction utf8End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + '\\ufffd';\n return r;\n}\n\n// UTF-16LE typically needs two bytes per character, but even if we have an even\n// number of bytes available, we need to check if we end on a leading/high\n// surrogate. In that case, we need to wait for the next two bytes in order to\n// decode the last character properly.\nfunction utf16Text(buf, i) {\n if ((buf.length - i) % 2 === 0) {\n var r = buf.toString('utf16le', i);\n if (r) {\n var c = r.charCodeAt(r.length - 1);\n if (c >= 0xD800 && c <= 0xDBFF) {\n this.lastNeed = 2;\n this.lastTotal = 4;\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n return r.slice(0, -1);\n }\n }\n return r;\n }\n this.lastNeed = 1;\n this.lastTotal = 2;\n this.lastChar[0] = buf[buf.length - 1];\n return buf.toString('utf16le', i, buf.length - 1);\n}\n\n// For UTF-16LE we do not explicitly append special replacement characters if we\n// end on a partial character, we simply let v8 handle that.\nfunction utf16End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) {\n var end = this.lastTotal - this.lastNeed;\n return r + this.lastChar.toString('utf16le', 0, end);\n }\n return r;\n}\n\nfunction base64Text(buf, i) {\n var n = (buf.length - i) % 3;\n if (n === 0) return buf.toString('base64', i);\n this.lastNeed = 3 - n;\n this.lastTotal = 3;\n if (n === 1) {\n this.lastChar[0] = buf[buf.length - 1];\n } else {\n this.lastChar[0] = buf[buf.length - 2];\n this.lastChar[1] = buf[buf.length - 1];\n }\n return buf.toString('base64', i, buf.length - n);\n}\n\nfunction base64End(buf) {\n var r = buf && buf.length ? this.write(buf) : '';\n if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);\n return r;\n}\n\n// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)\nfunction simpleWrite(buf) {\n return buf.toString(this.encoding);\n}\n\nfunction simpleEnd(buf) {\n return buf && buf.length ? this.write(buf) : '';\n}", "'use strict'\n\n/* replacement start */\n\nconst process = require('process/')\n\n/* replacement end */\n\nconst { PromisePrototypeThen, SymbolAsyncIterator, SymbolIterator } = require('../../ours/primordials')\nconst { Buffer } = require('buffer')\nconst { ERR_INVALID_ARG_TYPE, ERR_STREAM_NULL_VALUES } = require('../../ours/errors').codes\nfunction from(Readable, iterable, opts) {\n let iterator\n if (typeof iterable === 'string' || iterable instanceof Buffer) {\n return new Readable({\n objectMode: true,\n ...opts,\n read() {\n this.push(iterable)\n this.push(null)\n }\n })\n }\n let isAsync\n if (iterable && iterable[SymbolAsyncIterator]) {\n isAsync = true\n iterator = iterable[SymbolAsyncIterator]()\n } else if (iterable && iterable[SymbolIterator]) {\n isAsync = false\n iterator = iterable[SymbolIterator]()\n } else {\n throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable)\n }\n const readable = new Readable({\n objectMode: true,\n highWaterMark: 1,\n // TODO(ronag): What options should be allowed?\n ...opts\n })\n\n // Flag to protect against _read\n // being called before last iteration completion.\n let reading = false\n readable._read = function () {\n if (!reading) {\n reading = true\n next()\n }\n }\n readable._destroy = function (error, cb) {\n PromisePrototypeThen(\n close(error),\n () => process.nextTick(cb, error),\n // nextTick is here in case cb throws\n (e) => process.nextTick(cb, e || error)\n )\n }\n async function close(error) {\n const hadError = error !== undefined && error !== null\n const hasThrow = typeof iterator.throw === 'function'\n if (hadError && hasThrow) {\n const { value, done } = await iterator.throw(error)\n await value\n if (done) {\n return\n }\n }\n if (typeof iterator.return === 'function') {\n const { value } = await iterator.return()\n await value\n }\n }\n async function next() {\n for (;;) {\n try {\n const { value, done } = isAsync ? await iterator.next() : iterator.next()\n if (done) {\n readable.push(null)\n } else {\n const res = value && typeof value.then === 'function' ? await value : value\n if (res === null) {\n reading = false\n throw new ERR_STREAM_NULL_VALUES()\n } else if (readable.push(res)) {\n continue\n } else {\n reading = false\n }\n }\n } catch (err) {\n readable.destroy(err)\n }\n break\n }\n }\n return readable\n}\nmodule.exports = from\n", "/* replacement start */\n\nconst process = require('process/')\n\n/* replacement end */\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n;('use strict')\nconst {\n ArrayPrototypeIndexOf,\n NumberIsInteger,\n NumberIsNaN,\n NumberParseInt,\n ObjectDefineProperties,\n ObjectKeys,\n ObjectSetPrototypeOf,\n Promise,\n SafeSet,\n SymbolAsyncDispose,\n SymbolAsyncIterator,\n Symbol\n} = require('../../ours/primordials')\nmodule.exports = Readable\nReadable.ReadableState = ReadableState\nconst { EventEmitter: EE } = require('events')\nconst { Stream, prependListener } = require('./legacy')\nconst { Buffer } = require('buffer')\nconst { addAbortSignal } = require('./add-abort-signal')\nconst eos = require('./end-of-stream')\nlet debug = require('../../ours/util').debuglog('stream', (fn) => {\n debug = fn\n})\nconst BufferList = require('./buffer_list')\nconst destroyImpl = require('./destroy')\nconst { getHighWaterMark, getDefaultHighWaterMark } = require('./state')\nconst {\n aggregateTwoErrors,\n codes: {\n ERR_INVALID_ARG_TYPE,\n ERR_METHOD_NOT_IMPLEMENTED,\n ERR_OUT_OF_RANGE,\n ERR_STREAM_PUSH_AFTER_EOF,\n ERR_STREAM_UNSHIFT_AFTER_END_EVENT\n },\n AbortError\n} = require('../../ours/errors')\nconst { validateObject } = require('../validators')\nconst kPaused = Symbol('kPaused')\nconst { StringDecoder } = require('string_decoder')\nconst from = require('./from')\nObjectSetPrototypeOf(Readable.prototype, Stream.prototype)\nObjectSetPrototypeOf(Readable, Stream)\nconst nop = () => {}\nconst { errorOrDestroy } = destroyImpl\nconst kObjectMode = 1 << 0\nconst kEnded = 1 << 1\nconst kEndEmitted = 1 << 2\nconst kReading = 1 << 3\nconst kConstructed = 1 << 4\nconst kSync = 1 << 5\nconst kNeedReadable = 1 << 6\nconst kEmittedReadable = 1 << 7\nconst kReadableListening = 1 << 8\nconst kResumeScheduled = 1 << 9\nconst kErrorEmitted = 1 << 10\nconst kEmitClose = 1 << 11\nconst kAutoDestroy = 1 << 12\nconst kDestroyed = 1 << 13\nconst kClosed = 1 << 14\nconst kCloseEmitted = 1 << 15\nconst kMultiAwaitDrain = 1 << 16\nconst kReadingMore = 1 << 17\nconst kDataEmitted = 1 << 18\n\n// TODO(benjamingr) it is likely slower to do it this way than with free functions\nfunction makeBitMapDescriptor(bit) {\n return {\n enumerable: false,\n get() {\n return (this.state & bit) !== 0\n },\n set(value) {\n if (value) this.state |= bit\n else this.state &= ~bit\n }\n }\n}\nObjectDefineProperties(ReadableState.prototype, {\n objectMode: makeBitMapDescriptor(kObjectMode),\n ended: makeBitMapDescriptor(kEnded),\n endEmitted: makeBitMapDescriptor(kEndEmitted),\n reading: makeBitMapDescriptor(kReading),\n // Stream is still being constructed and cannot be\n // destroyed until construction finished or failed.\n // Async construction is opt in, therefore we start as\n // constructed.\n constructed: makeBitMapDescriptor(kConstructed),\n // A flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n sync: makeBitMapDescriptor(kSync),\n // Whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n needReadable: makeBitMapDescriptor(kNeedReadable),\n emittedReadable: makeBitMapDescriptor(kEmittedReadable),\n readableListening: makeBitMapDescriptor(kReadableListening),\n resumeScheduled: makeBitMapDescriptor(kResumeScheduled),\n // True if the error was already emitted and should not be thrown again.\n errorEmitted: makeBitMapDescriptor(kErrorEmitted),\n emitClose: makeBitMapDescriptor(kEmitClose),\n autoDestroy: makeBitMapDescriptor(kAutoDestroy),\n // Has it been destroyed.\n destroyed: makeBitMapDescriptor(kDestroyed),\n // Indicates whether the stream has finished destroying.\n closed: makeBitMapDescriptor(kClosed),\n // True if close has been emitted or would have been emitted\n // depending on emitClose.\n closeEmitted: makeBitMapDescriptor(kCloseEmitted),\n multiAwaitDrain: makeBitMapDescriptor(kMultiAwaitDrain),\n // If true, a maybeReadMore has been scheduled.\n readingMore: makeBitMapDescriptor(kReadingMore),\n dataEmitted: makeBitMapDescriptor(kDataEmitted)\n})\nfunction ReadableState(options, stream, isDuplex) {\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof require('./duplex')\n\n // Bit map field to store ReadableState more effciently with 1 bit per field\n // instead of a V8 slot per field.\n this.state = kEmitClose | kAutoDestroy | kConstructed | kSync\n // Object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away.\n if (options && options.objectMode) this.state |= kObjectMode\n if (isDuplex && options && options.readableObjectMode) this.state |= kObjectMode\n\n // The point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n this.highWaterMark = options\n ? getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex)\n : getDefaultHighWaterMark(false)\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift().\n this.buffer = new BufferList()\n this.length = 0\n this.pipes = []\n this.flowing = null\n this[kPaused] = null\n\n // Should close be emitted on destroy. Defaults to true.\n if (options && options.emitClose === false) this.state &= ~kEmitClose\n\n // Should .destroy() be called after 'end' (and potentially 'finish').\n if (options && options.autoDestroy === false) this.state &= ~kAutoDestroy\n\n // Indicates whether the stream has errored. When true no further\n // _read calls, 'data' or 'readable' events should occur. This is needed\n // since when autoDestroy is disabled we need a way to tell whether the\n // stream has failed.\n this.errored = null\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = (options && options.defaultEncoding) || 'utf8'\n\n // Ref the piped dest which we need a drain event on it\n // type: null | Writable | Set<Writable>.\n this.awaitDrainWriters = null\n this.decoder = null\n this.encoding = null\n if (options && options.encoding) {\n this.decoder = new StringDecoder(options.encoding)\n this.encoding = options.encoding\n }\n}\nfunction Readable(options) {\n if (!(this instanceof Readable)) return new Readable(options)\n\n // Checking for a Stream.Duplex instance is faster here instead of inside\n // the ReadableState constructor, at least with V8 6.5.\n const isDuplex = this instanceof require('./duplex')\n this._readableState = new ReadableState(options, this, isDuplex)\n if (options) {\n if (typeof options.read === 'function') this._read = options.read\n if (typeof options.destroy === 'function') this._destroy = options.destroy\n if (typeof options.construct === 'function') this._construct = options.construct\n if (options.signal && !isDuplex) addAbortSignal(options.signal, this)\n }\n Stream.call(this, options)\n destroyImpl.construct(this, () => {\n if (this._readableState.needReadable) {\n maybeReadMore(this, this._readableState)\n }\n })\n}\nReadable.prototype.destroy = destroyImpl.destroy\nReadable.prototype._undestroy = destroyImpl.undestroy\nReadable.prototype._destroy = function (err, cb) {\n cb(err)\n}\nReadable.prototype[EE.captureRejectionSymbol] = function (err) {\n this.destroy(err)\n}\nReadable.prototype[SymbolAsyncDispose] = function () {\n let error\n if (!this.destroyed) {\n error = this.readableEnded ? null : new AbortError()\n this.destroy(error)\n }\n return new Promise((resolve, reject) => eos(this, (err) => (err && err !== error ? reject(err) : resolve(null))))\n}\n\n// Manually shove something into the read() buffer.\n// This returns true if the highWaterMark has not been hit yet,\n// similar to how Writable.write() returns true if you should\n// write() some more.\nReadable.prototype.push = function (chunk, encoding) {\n return readableAddChunk(this, chunk, encoding, false)\n}\n\n// Unshift should *always* be something directly out of read().\nReadable.prototype.unshift = function (chunk, encoding) {\n return readableAddChunk(this, chunk, encoding, true)\n}\nfunction readableAddChunk(stream, chunk, encoding, addToFront) {\n debug('readableAddChunk', chunk)\n const state = stream._readableState\n let err\n if ((state.state & kObjectMode) === 0) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding\n if (state.encoding !== encoding) {\n if (addToFront && state.encoding) {\n // When unshifting, if state.encoding is set, we have to save\n // the string in the BufferList with the state encoding.\n chunk = Buffer.from(chunk, encoding).toString(state.encoding)\n } else {\n chunk = Buffer.from(chunk, encoding)\n encoding = ''\n }\n }\n } else if (chunk instanceof Buffer) {\n encoding = ''\n } else if (Stream._isUint8Array(chunk)) {\n chunk = Stream._uint8ArrayToBuffer(chunk)\n encoding = ''\n } else if (chunk != null) {\n err = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk)\n }\n }\n if (err) {\n errorOrDestroy(stream, err)\n } else if (chunk === null) {\n state.state &= ~kReading\n onEofChunk(stream, state)\n } else if ((state.state & kObjectMode) !== 0 || (chunk && chunk.length > 0)) {\n if (addToFront) {\n if ((state.state & kEndEmitted) !== 0) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT())\n else if (state.destroyed || state.errored) return false\n else addChunk(stream, state, chunk, true)\n } else if (state.ended) {\n errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF())\n } else if (state.destroyed || state.errored) {\n return false\n } else {\n state.state &= ~kReading\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk)\n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false)\n else maybeReadMore(stream, state)\n } else {\n addChunk(stream, state, chunk, false)\n }\n }\n } else if (!addToFront) {\n state.state &= ~kReading\n maybeReadMore(stream, state)\n }\n\n // We can push more data if we are below the highWaterMark.\n // Also, if we have no data yet, we can stand some more bytes.\n // This is to work around cases where hwm=0, such as the repl.\n return !state.ended && (state.length < state.highWaterMark || state.length === 0)\n}\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync && stream.listenerCount('data') > 0) {\n // Use the guard to avoid creating `Set()` repeatedly\n // when we have multiple pipes.\n if ((state.state & kMultiAwaitDrain) !== 0) {\n state.awaitDrainWriters.clear()\n } else {\n state.awaitDrainWriters = null\n }\n state.dataEmitted = true\n stream.emit('data', chunk)\n } else {\n // Update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length\n if (addToFront) state.buffer.unshift(chunk)\n else state.buffer.push(chunk)\n if ((state.state & kNeedReadable) !== 0) emitReadable(stream)\n }\n maybeReadMore(stream, state)\n}\nReadable.prototype.isPaused = function () {\n const state = this._readableState\n return state[kPaused] === true || state.flowing === false\n}\n\n// Backwards compatibility.\nReadable.prototype.setEncoding = function (enc) {\n const decoder = new StringDecoder(enc)\n this._readableState.decoder = decoder\n // If setEncoding(null), decoder.encoding equals utf8.\n this._readableState.encoding = this._readableState.decoder.encoding\n const buffer = this._readableState.buffer\n // Iterate over current buffer to convert already stored Buffers:\n let content = ''\n for (const data of buffer) {\n content += decoder.write(data)\n }\n buffer.clear()\n if (content !== '') buffer.push(content)\n this._readableState.length = content.length\n return this\n}\n\n// Don't raise the hwm > 1GB.\nconst MAX_HWM = 0x40000000\nfunction computeNewHighWaterMark(n) {\n if (n > MAX_HWM) {\n throw new ERR_OUT_OF_RANGE('size', '<= 1GiB', n)\n } else {\n // Get the next highest power of 2 to prevent increasing hwm excessively in\n // tiny amounts.\n n--\n n |= n >>> 1\n n |= n >>> 2\n n |= n >>> 4\n n |= n >>> 8\n n |= n >>> 16\n n++\n }\n return n\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || (state.length === 0 && state.ended)) return 0\n if ((state.state & kObjectMode) !== 0) return 1\n if (NumberIsNaN(n)) {\n // Only flow one buffer at a time.\n if (state.flowing && state.length) return state.buffer.first().length\n return state.length\n }\n if (n <= state.length) return n\n return state.ended ? state.length : 0\n}\n\n// You can override either this method, or the async _read(n) below.\nReadable.prototype.read = function (n) {\n debug('read', n)\n // Same as parseInt(undefined, 10), however V8 7.3 performance regressed\n // in this scenario, so we are doing it manually.\n if (n === undefined) {\n n = NaN\n } else if (!NumberIsInteger(n)) {\n n = NumberParseInt(n, 10)\n }\n const state = this._readableState\n const nOrig = n\n\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n)\n if (n !== 0) state.state &= ~kEmittedReadable\n\n // If we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (\n n === 0 &&\n state.needReadable &&\n ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)\n ) {\n debug('read: emitReadable', state.length, state.ended)\n if (state.length === 0 && state.ended) endReadable(this)\n else emitReadable(this)\n return null\n }\n n = howMuchToRead(n, state)\n\n // If we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0) endReadable(this)\n return null\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n let doRead = (state.state & kNeedReadable) !== 0\n debug('need readable', doRead)\n\n // If we currently have less than the highWaterMark, then also read some.\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true\n debug('length less than watermark', doRead)\n }\n\n // However, if we've ended, then there's no point, if we're already\n // reading, then it's unnecessary, if we're constructing we have to wait,\n // and if we're destroyed or errored, then it's not allowed,\n if (state.ended || state.reading || state.destroyed || state.errored || !state.constructed) {\n doRead = false\n debug('reading, ended or constructing', doRead)\n } else if (doRead) {\n debug('do read')\n state.state |= kReading | kSync\n // If the length is currently zero, then we *need* a readable event.\n if (state.length === 0) state.state |= kNeedReadable\n\n // Call internal read method\n try {\n this._read(state.highWaterMark)\n } catch (err) {\n errorOrDestroy(this, err)\n }\n state.state &= ~kSync\n\n // If _read pushed data synchronously, then `reading` will be false,\n // and we need to re-evaluate how much data we can return to the user.\n if (!state.reading) n = howMuchToRead(nOrig, state)\n }\n let ret\n if (n > 0) ret = fromList(n, state)\n else ret = null\n if (ret === null) {\n state.needReadable = state.length <= state.highWaterMark\n n = 0\n } else {\n state.length -= n\n if (state.multiAwaitDrain) {\n state.awaitDrainWriters.clear()\n } else {\n state.awaitDrainWriters = null\n }\n }\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended) state.needReadable = true\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended) endReadable(this)\n }\n if (ret !== null && !state.errorEmitted && !state.closeEmitted) {\n state.dataEmitted = true\n this.emit('data', ret)\n }\n return ret\n}\nfunction onEofChunk(stream, state) {\n debug('onEofChunk')\n if (state.ended) return\n if (state.decoder) {\n const chunk = state.decoder.end()\n if (chunk && chunk.length) {\n state.buffer.push(chunk)\n state.length += state.objectMode ? 1 : chunk.length\n }\n }\n state.ended = true\n if (state.sync) {\n // If we are sync, wait until next tick to emit the data.\n // Otherwise we risk emitting data in the flow()\n // the readable code triggers during a read() call.\n emitReadable(stream)\n } else {\n // Emit 'readable' now to make sure it gets picked up.\n state.needReadable = false\n state.emittedReadable = true\n // We have to emit readable now that we are EOF. Modules\n // in the ecosystem (e.g. dicer) rely on this event being sync.\n emitReadable_(stream)\n }\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n const state = stream._readableState\n debug('emitReadable', state.needReadable, state.emittedReadable)\n state.needReadable = false\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing)\n state.emittedReadable = true\n process.nextTick(emitReadable_, stream)\n }\n}\nfunction emitReadable_(stream) {\n const state = stream._readableState\n debug('emitReadable_', state.destroyed, state.length, state.ended)\n if (!state.destroyed && !state.errored && (state.length || state.ended)) {\n stream.emit('readable')\n state.emittedReadable = false\n }\n\n // The stream needs another readable event if:\n // 1. It is not flowing, as the flow mechanism will take\n // care of it.\n // 2. It is not ended.\n // 3. It is below the highWaterMark, so we can schedule\n // another readable later.\n state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark\n flow(stream)\n}\n\n// At this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// it's in progress.\n// However, if we're not ended, or reading, and the length < hwm,\n// then go ahead and try to read some more preemptively.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore && state.constructed) {\n state.readingMore = true\n process.nextTick(maybeReadMore_, stream, state)\n }\n}\nfunction maybeReadMore_(stream, state) {\n // Attempt to read more data if we should.\n //\n // The conditions for reading more data are (one of):\n // - Not enough data buffered (state.length < state.highWaterMark). The loop\n // is responsible for filling the buffer with enough data if such data\n // is available. If highWaterMark is 0 and we are not in the flowing mode\n // we should _not_ attempt to buffer any extra data. We'll get more data\n // when the stream consumer calls read() instead.\n // - No data in the buffer, and the stream is in flowing mode. In this mode\n // the loop below is responsible for ensuring read() is called. Failing to\n // call read here would abort the flow and there's no other mechanism for\n // continuing the flow if the stream consumer has just subscribed to the\n // 'data' event.\n //\n // In addition to the above conditions to keep reading data, the following\n // conditions prevent the data from being read:\n // - The stream has ended (state.ended).\n // - There is already a pending 'read' operation (state.reading). This is a\n // case where the stream has called the implementation defined _read()\n // method, but they are processing the call asynchronously and have _not_\n // called push() with new data. In this case we skip performing more\n // read()s. The execution ends in this method again after the _read() ends\n // up calling push() with more data.\n while (\n !state.reading &&\n !state.ended &&\n (state.length < state.highWaterMark || (state.flowing && state.length === 0))\n ) {\n const len = state.length\n debug('maybeReadMore read 0')\n stream.read(0)\n if (len === state.length)\n // Didn't get any data, stop spinning.\n break\n }\n state.readingMore = false\n}\n\n// Abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function (n) {\n throw new ERR_METHOD_NOT_IMPLEMENTED('_read()')\n}\nReadable.prototype.pipe = function (dest, pipeOpts) {\n const src = this\n const state = this._readableState\n if (state.pipes.length === 1) {\n if (!state.multiAwaitDrain) {\n state.multiAwaitDrain = true\n state.awaitDrainWriters = new SafeSet(state.awaitDrainWriters ? [state.awaitDrainWriters] : [])\n }\n }\n state.pipes.push(dest)\n debug('pipe count=%d opts=%j', state.pipes.length, pipeOpts)\n const doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr\n const endFn = doEnd ? onend : unpipe\n if (state.endEmitted) process.nextTick(endFn)\n else src.once('end', endFn)\n dest.on('unpipe', onunpipe)\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe')\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true\n cleanup()\n }\n }\n }\n function onend() {\n debug('onend')\n dest.end()\n }\n let ondrain\n let cleanedUp = false\n function cleanup() {\n debug('cleanup')\n // Cleanup event handlers once the pipe is broken.\n dest.removeListener('close', onclose)\n dest.removeListener('finish', onfinish)\n if (ondrain) {\n dest.removeListener('drain', ondrain)\n }\n dest.removeListener('error', onerror)\n dest.removeListener('unpipe', onunpipe)\n src.removeListener('end', onend)\n src.removeListener('end', unpipe)\n src.removeListener('data', ondata)\n cleanedUp = true\n\n // If the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // flowing again.\n // So, if this is awaiting a drain, then we just call it now.\n // If we don't know, then assume that we are waiting for one.\n if (ondrain && state.awaitDrainWriters && (!dest._writableState || dest._writableState.needDrain)) ondrain()\n }\n function pause() {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if (!cleanedUp) {\n if (state.pipes.length === 1 && state.pipes[0] === dest) {\n debug('false write response, pause', 0)\n state.awaitDrainWriters = dest\n state.multiAwaitDrain = false\n } else if (state.pipes.length > 1 && state.pipes.includes(dest)) {\n debug('false write response, pause', state.awaitDrainWriters.size)\n state.awaitDrainWriters.add(dest)\n }\n src.pause()\n }\n if (!ondrain) {\n // When the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n ondrain = pipeOnDrain(src, dest)\n dest.on('drain', ondrain)\n }\n }\n src.on('data', ondata)\n function ondata(chunk) {\n debug('ondata')\n const ret = dest.write(chunk)\n debug('dest.write', ret)\n if (ret === false) {\n pause()\n }\n }\n\n // If the dest has an error, then stop piping into it.\n // However, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er)\n unpipe()\n dest.removeListener('error', onerror)\n if (dest.listenerCount('error') === 0) {\n const s = dest._writableState || dest._readableState\n if (s && !s.errorEmitted) {\n // User incorrectly emitted 'error' directly on the stream.\n errorOrDestroy(dest, er)\n } else {\n dest.emit('error', er)\n }\n }\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror)\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish)\n unpipe()\n }\n dest.once('close', onclose)\n function onfinish() {\n debug('onfinish')\n dest.removeListener('close', onclose)\n unpipe()\n }\n dest.once('finish', onfinish)\n function unpipe() {\n debug('unpipe')\n src.unpipe(dest)\n }\n\n // Tell the dest that it's being piped to.\n dest.emit('pipe', src)\n\n // Start the flow if it hasn't been started already.\n\n if (dest.writableNeedDrain === true) {\n pause()\n } else if (!state.flowing) {\n debug('pipe resume')\n src.resume()\n }\n return dest\n}\nfunction pipeOnDrain(src, dest) {\n return function pipeOnDrainFunctionResult() {\n const state = src._readableState\n\n // `ondrain` will call directly,\n // `this` maybe not a reference to dest,\n // so we use the real dest here.\n if (state.awaitDrainWriters === dest) {\n debug('pipeOnDrain', 1)\n state.awaitDrainWriters = null\n } else if (state.multiAwaitDrain) {\n debug('pipeOnDrain', state.awaitDrainWriters.size)\n state.awaitDrainWriters.delete(dest)\n }\n if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) && src.listenerCount('data')) {\n src.resume()\n }\n }\n}\nReadable.prototype.unpipe = function (dest) {\n const state = this._readableState\n const unpipeInfo = {\n hasUnpiped: false\n }\n\n // If we're not piping anywhere, then do nothing.\n if (state.pipes.length === 0) return this\n if (!dest) {\n // remove all.\n const dests = state.pipes\n state.pipes = []\n this.pause()\n for (let i = 0; i < dests.length; i++)\n dests[i].emit('unpipe', this, {\n hasUnpiped: false\n })\n return this\n }\n\n // Try to find the right one.\n const index = ArrayPrototypeIndexOf(state.pipes, dest)\n if (index === -1) return this\n state.pipes.splice(index, 1)\n if (state.pipes.length === 0) this.pause()\n dest.emit('unpipe', this, unpipeInfo)\n return this\n}\n\n// Set up data events if they are asked for\n// Ensure readable listeners eventually get something.\nReadable.prototype.on = function (ev, fn) {\n const res = Stream.prototype.on.call(this, ev, fn)\n const state = this._readableState\n if (ev === 'data') {\n // Update readableListening so that resume() may be a no-op\n // a few lines down. This is needed to support once('readable').\n state.readableListening = this.listenerCount('readable') > 0\n\n // Try start flowing on next tick if stream isn't explicitly paused.\n if (state.flowing !== false) this.resume()\n } else if (ev === 'readable') {\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true\n state.flowing = false\n state.emittedReadable = false\n debug('on readable', state.length, state.reading)\n if (state.length) {\n emitReadable(this)\n } else if (!state.reading) {\n process.nextTick(nReadingNextTick, this)\n }\n }\n }\n return res\n}\nReadable.prototype.addListener = Readable.prototype.on\nReadable.prototype.removeListener = function (ev, fn) {\n const res = Stream.prototype.removeListener.call(this, ev, fn)\n if (ev === 'readable') {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this)\n }\n return res\n}\nReadable.prototype.off = Readable.prototype.removeListener\nReadable.prototype.removeAllListeners = function (ev) {\n const res = Stream.prototype.removeAllListeners.apply(this, arguments)\n if (ev === 'readable' || ev === undefined) {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this)\n }\n return res\n}\nfunction updateReadableListening(self) {\n const state = self._readableState\n state.readableListening = self.listenerCount('readable') > 0\n if (state.resumeScheduled && state[kPaused] === false) {\n // Flowing needs to be set to true now, otherwise\n // the upcoming resume will not flow.\n state.flowing = true\n\n // Crude way to check if we should resume.\n } else if (self.listenerCount('data') > 0) {\n self.resume()\n } else if (!state.readableListening) {\n state.flowing = null\n }\n}\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0')\n self.read(0)\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function () {\n const state = this._readableState\n if (!state.flowing) {\n debug('resume')\n // We flow only if there is no one listening\n // for readable, but we still have to call\n // resume().\n state.flowing = !state.readableListening\n resume(this, state)\n }\n state[kPaused] = false\n return this\n}\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true\n process.nextTick(resume_, stream, state)\n }\n}\nfunction resume_(stream, state) {\n debug('resume', state.reading)\n if (!state.reading) {\n stream.read(0)\n }\n state.resumeScheduled = false\n stream.emit('resume')\n flow(stream)\n if (state.flowing && !state.reading) stream.read(0)\n}\nReadable.prototype.pause = function () {\n debug('call pause flowing=%j', this._readableState.flowing)\n if (this._readableState.flowing !== false) {\n debug('pause')\n this._readableState.flowing = false\n this.emit('pause')\n }\n this._readableState[kPaused] = true\n return this\n}\nfunction flow(stream) {\n const state = stream._readableState\n debug('flow', state.flowing)\n while (state.flowing && stream.read() !== null);\n}\n\n// Wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function (stream) {\n let paused = false\n\n // TODO (ronag): Should this.destroy(err) emit\n // 'error' on the wrapped stream? Would require\n // a static factory method, e.g. Readable.wrap(stream).\n\n stream.on('data', (chunk) => {\n if (!this.push(chunk) && stream.pause) {\n paused = true\n stream.pause()\n }\n })\n stream.on('end', () => {\n this.push(null)\n })\n stream.on('error', (err) => {\n errorOrDestroy(this, err)\n })\n stream.on('close', () => {\n this.destroy()\n })\n stream.on('destroy', () => {\n this.destroy()\n })\n this._read = () => {\n if (paused && stream.resume) {\n paused = false\n stream.resume()\n }\n }\n\n // Proxy all the other methods. Important when wrapping filters and duplexes.\n const streamKeys = ObjectKeys(stream)\n for (let j = 1; j < streamKeys.length; j++) {\n const i = streamKeys[j]\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = stream[i].bind(stream)\n }\n }\n return this\n}\nReadable.prototype[SymbolAsyncIterator] = function () {\n return streamToAsyncIterator(this)\n}\nReadable.prototype.iterator = function (options) {\n if (options !== undefined) {\n validateObject(options, 'options')\n }\n return streamToAsyncIterator(this, options)\n}\nfunction streamToAsyncIterator(stream, options) {\n if (typeof stream.read !== 'function') {\n stream = Readable.wrap(stream, {\n objectMode: true\n })\n }\n const iter = createAsyncIterator(stream, options)\n iter.stream = stream\n return iter\n}\nasync function* createAsyncIterator(stream, options) {\n let callback = nop\n function next(resolve) {\n if (this === stream) {\n callback()\n callback = nop\n } else {\n callback = resolve\n }\n }\n stream.on('readable', next)\n let error\n const cleanup = eos(\n stream,\n {\n writable: false\n },\n (err) => {\n error = err ? aggregateTwoErrors(error, err) : null\n callback()\n callback = nop\n }\n )\n try {\n while (true) {\n const chunk = stream.destroyed ? null : stream.read()\n if (chunk !== null) {\n yield chunk\n } else if (error) {\n throw error\n } else if (error === null) {\n return\n } else {\n await new Promise(next)\n }\n }\n } catch (err) {\n error = aggregateTwoErrors(error, err)\n throw error\n } finally {\n if (\n (error || (options === null || options === undefined ? undefined : options.destroyOnReturn) !== false) &&\n (error === undefined || stream._readableState.autoDestroy)\n ) {\n destroyImpl.destroyer(stream, null)\n } else {\n stream.off('readable', next)\n cleanup()\n }\n }\n}\n\n// Making it explicit these properties are not enumerable\n// because otherwise some prototype manipulation in\n// userland will fail.\nObjectDefineProperties(Readable.prototype, {\n readable: {\n __proto__: null,\n get() {\n const r = this._readableState\n // r.readable === false means that this is part of a Duplex stream\n // where the readable side was disabled upon construction.\n // Compat. The user might manually disable readable side through\n // deprecated setter.\n return !!r && r.readable !== false && !r.destroyed && !r.errorEmitted && !r.endEmitted\n },\n set(val) {\n // Backwards compat.\n if (this._readableState) {\n this._readableState.readable = !!val\n }\n }\n },\n readableDidRead: {\n __proto__: null,\n enumerable: false,\n get: function () {\n return this._readableState.dataEmitted\n }\n },\n readableAborted: {\n __proto__: null,\n enumerable: false,\n get: function () {\n return !!(\n this._readableState.readable !== false &&\n (this._readableState.destroyed || this._readableState.errored) &&\n !this._readableState.endEmitted\n )\n }\n },\n readableHighWaterMark: {\n __proto__: null,\n enumerable: false,\n get: function () {\n return this._readableState.highWaterMark\n }\n },\n readableBuffer: {\n __proto__: null,\n enumerable: false,\n get: function () {\n return this._readableState && this._readableState.buffer\n }\n },\n readableFlowing: {\n __proto__: null,\n enumerable: false,\n get: function () {\n return this._readableState.flowing\n },\n set: function (state) {\n if (this._readableState) {\n this._readableState.flowing = state\n }\n }\n },\n readableLength: {\n __proto__: null,\n enumerable: false,\n get() {\n return this._readableState.length\n }\n },\n readableObjectMode: {\n __proto__: null,\n enumerable: false,\n get() {\n return this._readableState ? this._readableState.objectMode : false\n }\n },\n readableEncoding: {\n __proto__: null,\n enumerable: false,\n get() {\n return this._readableState ? this._readableState.encoding : null\n }\n },\n errored: {\n __proto__: null,\n enumerable: false,\n get() {\n return this._readableState ? this._readableState.errored : null\n }\n },\n closed: {\n __proto__: null,\n get() {\n return this._readableState ? this._readableState.closed : false\n }\n },\n destroyed: {\n __proto__: null,\n enumerable: false,\n get() {\n return this._readableState ? this._readableState.destroyed : false\n },\n set(value) {\n // We ignore the value if the stream\n // has not been initialized yet.\n if (!this._readableState) {\n return\n }\n\n // Backward compatibility, the user is explicitly\n // managing destroyed.\n this._readableState.destroyed = value\n }\n },\n readableEnded: {\n __proto__: null,\n enumerable: false,\n get() {\n return this._readableState ? this._readableState.endEmitted : false\n }\n }\n})\nObjectDefineProperties(ReadableState.prototype, {\n // Legacy getter for `pipesCount`.\n pipesCount: {\n __proto__: null,\n get() {\n return this.pipes.length\n }\n },\n // Legacy property for `paused`.\n paused: {\n __proto__: null,\n get() {\n return this[kPaused] !== false\n },\n set(value) {\n this[kPaused] = !!value\n }\n }\n})\n\n// Exposed for testing purposes only.\nReadable._fromList = fromList\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered.\n if (state.length === 0) return null\n let ret\n if (state.objectMode) ret = state.buffer.shift()\n else if (!n || n >= state.length) {\n // Read it all, truncate the list.\n if (state.decoder) ret = state.buffer.join('')\n else if (state.buffer.length === 1) ret = state.buffer.first()\n else ret = state.buffer.concat(state.length)\n state.buffer.clear()\n } else {\n // read part of list.\n ret = state.buffer.consume(n, state.decoder)\n }\n return ret\n}\nfunction endReadable(stream) {\n const state = stream._readableState\n debug('endReadable', state.endEmitted)\n if (!state.endEmitted) {\n state.ended = true\n process.nextTick(endReadableNT, state, stream)\n }\n}\nfunction endReadableNT(state, stream) {\n debug('endReadableNT', state.endEmitted, state.length)\n\n // Check that we didn't get one last unshift.\n if (!state.errored && !state.closeEmitted && !state.endEmitted && state.length === 0) {\n state.endEmitted = true\n stream.emit('end')\n if (stream.writable && stream.allowHalfOpen === false) {\n process.nextTick(endWritableNT, stream)\n } else if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the writable side is ready for autoDestroy as well.\n const wState = stream._writableState\n const autoDestroy =\n !wState ||\n (wState.autoDestroy &&\n // We don't expect the writable to ever 'finish'\n // if writable is explicitly set to false.\n (wState.finished || wState.writable === false))\n if (autoDestroy) {\n stream.destroy()\n }\n }\n }\n}\nfunction endWritableNT(stream) {\n const writable = stream.writable && !stream.writableEnded && !stream.destroyed\n if (writable) {\n stream.end()\n }\n}\nReadable.from = function (iterable, opts) {\n return from(Readable, iterable, opts)\n}\nlet webStreamsAdapters\n\n// Lazy to avoid circular references\nfunction lazyWebStreams() {\n if (webStreamsAdapters === undefined) webStreamsAdapters = {}\n return webStreamsAdapters\n}\nReadable.fromWeb = function (readableStream, options) {\n return lazyWebStreams().newStreamReadableFromReadableStream(readableStream, options)\n}\nReadable.toWeb = function (streamReadable, options) {\n return lazyWebStreams().newReadableStreamFromStreamReadable(streamReadable, options)\n}\nReadable.wrap = function (src, options) {\n var _ref, _src$readableObjectMo\n return new Readable({\n objectMode:\n (_ref =\n (_src$readableObjectMo = src.readableObjectMode) !== null && _src$readableObjectMo !== undefined\n ? _src$readableObjectMo\n : src.objectMode) !== null && _ref !== undefined\n ? _ref\n : true,\n ...options,\n destroy(err, callback) {\n destroyImpl.destroyer(src, err)\n callback(err)\n }\n }).wrap(src)\n}\n", "/* replacement start */\n\nconst process = require('process/')\n\n/* replacement end */\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n;('use strict')\nconst {\n ArrayPrototypeSlice,\n Error,\n FunctionPrototypeSymbolHasInstance,\n ObjectDefineProperty,\n ObjectDefineProperties,\n ObjectSetPrototypeOf,\n StringPrototypeToLowerCase,\n Symbol,\n SymbolHasInstance\n} = require('../../ours/primordials')\nmodule.exports = Writable\nWritable.WritableState = WritableState\nconst { EventEmitter: EE } = require('events')\nconst Stream = require('./legacy').Stream\nconst { Buffer } = require('buffer')\nconst destroyImpl = require('./destroy')\nconst { addAbortSignal } = require('./add-abort-signal')\nconst { getHighWaterMark, getDefaultHighWaterMark } = require('./state')\nconst {\n ERR_INVALID_ARG_TYPE,\n ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK,\n ERR_STREAM_CANNOT_PIPE,\n ERR_STREAM_DESTROYED,\n ERR_STREAM_ALREADY_FINISHED,\n ERR_STREAM_NULL_VALUES,\n ERR_STREAM_WRITE_AFTER_END,\n ERR_UNKNOWN_ENCODING\n} = require('../../ours/errors').codes\nconst { errorOrDestroy } = destroyImpl\nObjectSetPrototypeOf(Writable.prototype, Stream.prototype)\nObjectSetPrototypeOf(Writable, Stream)\nfunction nop() {}\nconst kOnFinished = Symbol('kOnFinished')\nfunction WritableState(options, stream, isDuplex) {\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream,\n // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.\n if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof require('./duplex')\n\n // Object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!(options && options.objectMode)\n if (isDuplex) this.objectMode = this.objectMode || !!(options && options.writableObjectMode)\n\n // The point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write().\n this.highWaterMark = options\n ? getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex)\n : getDefaultHighWaterMark(false)\n\n // if _final has been called.\n this.finalCalled = false\n\n // drain event flag.\n this.needDrain = false\n // At the start of calling end()\n this.ending = false\n // When end() has been called, and returned.\n this.ended = false\n // When 'finish' is emitted.\n this.finished = false\n\n // Has it been destroyed\n this.destroyed = false\n\n // Should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n const noDecode = !!(options && options.decodeStrings === false)\n this.decodeStrings = !noDecode\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = (options && options.defaultEncoding) || 'utf8'\n\n // Not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0\n\n // A flag to see when we're in the middle of a write.\n this.writing = false\n\n // When true all writes will be buffered until .uncork() call.\n this.corked = 0\n\n // A flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true\n\n // A flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false\n\n // The callback that's passed to _write(chunk, cb).\n this.onwrite = onwrite.bind(undefined, stream)\n\n // The callback that the user supplies to write(chunk, encoding, cb).\n this.writecb = null\n\n // The amount that is being written when _write is called.\n this.writelen = 0\n\n // Storage for data passed to the afterWrite() callback in case of\n // synchronous _write() completion.\n this.afterWriteTickInfo = null\n resetBuffer(this)\n\n // Number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted.\n this.pendingcb = 0\n\n // Stream is still being constructed and cannot be\n // destroyed until construction finished or failed.\n // Async construction is opt in, therefore we start as\n // constructed.\n this.constructed = true\n\n // Emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams.\n this.prefinished = false\n\n // True if the error was already emitted and should not be thrown again.\n this.errorEmitted = false\n\n // Should close be emitted on destroy. Defaults to true.\n this.emitClose = !options || options.emitClose !== false\n\n // Should .destroy() be called after 'finish' (and potentially 'end').\n this.autoDestroy = !options || options.autoDestroy !== false\n\n // Indicates whether the stream has errored. When true all write() calls\n // should return false. This is needed since when autoDestroy\n // is disabled we need a way to tell whether the stream has failed.\n this.errored = null\n\n // Indicates whether the stream has finished destroying.\n this.closed = false\n\n // True if close has been emitted or would have been emitted\n // depending on emitClose.\n this.closeEmitted = false\n this[kOnFinished] = []\n}\nfunction resetBuffer(state) {\n state.buffered = []\n state.bufferedIndex = 0\n state.allBuffers = true\n state.allNoop = true\n}\nWritableState.prototype.getBuffer = function getBuffer() {\n return ArrayPrototypeSlice(this.buffered, this.bufferedIndex)\n}\nObjectDefineProperty(WritableState.prototype, 'bufferedRequestCount', {\n __proto__: null,\n get() {\n return this.buffered.length - this.bufferedIndex\n }\n})\nfunction Writable(options) {\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n\n // Checking for a Stream.Duplex instance is faster here instead of inside\n // the WritableState constructor, at least with V8 6.5.\n const isDuplex = this instanceof require('./duplex')\n if (!isDuplex && !FunctionPrototypeSymbolHasInstance(Writable, this)) return new Writable(options)\n this._writableState = new WritableState(options, this, isDuplex)\n if (options) {\n if (typeof options.write === 'function') this._write = options.write\n if (typeof options.writev === 'function') this._writev = options.writev\n if (typeof options.destroy === 'function') this._destroy = options.destroy\n if (typeof options.final === 'function') this._final = options.final\n if (typeof options.construct === 'function') this._construct = options.construct\n if (options.signal) addAbortSignal(options.signal, this)\n }\n Stream.call(this, options)\n destroyImpl.construct(this, () => {\n const state = this._writableState\n if (!state.writing) {\n clearBuffer(this, state)\n }\n finishMaybe(this, state)\n })\n}\nObjectDefineProperty(Writable, SymbolHasInstance, {\n __proto__: null,\n value: function (object) {\n if (FunctionPrototypeSymbolHasInstance(this, object)) return true\n if (this !== Writable) return false\n return object && object._writableState instanceof WritableState\n }\n})\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function () {\n errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE())\n}\nfunction _write(stream, chunk, encoding, cb) {\n const state = stream._writableState\n if (typeof encoding === 'function') {\n cb = encoding\n encoding = state.defaultEncoding\n } else {\n if (!encoding) encoding = state.defaultEncoding\n else if (encoding !== 'buffer' && !Buffer.isEncoding(encoding)) throw new ERR_UNKNOWN_ENCODING(encoding)\n if (typeof cb !== 'function') cb = nop\n }\n if (chunk === null) {\n throw new ERR_STREAM_NULL_VALUES()\n } else if (!state.objectMode) {\n if (typeof chunk === 'string') {\n if (state.decodeStrings !== false) {\n chunk = Buffer.from(chunk, encoding)\n encoding = 'buffer'\n }\n } else if (chunk instanceof Buffer) {\n encoding = 'buffer'\n } else if (Stream._isUint8Array(chunk)) {\n chunk = Stream._uint8ArrayToBuffer(chunk)\n encoding = 'buffer'\n } else {\n throw new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk)\n }\n }\n let err\n if (state.ending) {\n err = new ERR_STREAM_WRITE_AFTER_END()\n } else if (state.destroyed) {\n err = new ERR_STREAM_DESTROYED('write')\n }\n if (err) {\n process.nextTick(cb, err)\n errorOrDestroy(stream, err, true)\n return err\n }\n state.pendingcb++\n return writeOrBuffer(stream, state, chunk, encoding, cb)\n}\nWritable.prototype.write = function (chunk, encoding, cb) {\n return _write(this, chunk, encoding, cb) === true\n}\nWritable.prototype.cork = function () {\n this._writableState.corked++\n}\nWritable.prototype.uncork = function () {\n const state = this._writableState\n if (state.corked) {\n state.corked--\n if (!state.writing) clearBuffer(this, state)\n }\n}\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string') encoding = StringPrototypeToLowerCase(encoding)\n if (!Buffer.isEncoding(encoding)) throw new ERR_UNKNOWN_ENCODING(encoding)\n this._writableState.defaultEncoding = encoding\n return this\n}\n\n// If we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, chunk, encoding, callback) {\n const len = state.objectMode ? 1 : chunk.length\n state.length += len\n\n // stream._write resets state.length\n const ret = state.length < state.highWaterMark\n // We must ensure that previous needDrain will not be reset to false.\n if (!ret) state.needDrain = true\n if (state.writing || state.corked || state.errored || !state.constructed) {\n state.buffered.push({\n chunk,\n encoding,\n callback\n })\n if (state.allBuffers && encoding !== 'buffer') {\n state.allBuffers = false\n }\n if (state.allNoop && callback !== nop) {\n state.allNoop = false\n }\n } else {\n state.writelen = len\n state.writecb = callback\n state.writing = true\n state.sync = true\n stream._write(chunk, encoding, state.onwrite)\n state.sync = false\n }\n\n // Return false if errored or destroyed in order to break\n // any synchronous while(stream.write(data)) loops.\n return ret && !state.errored && !state.destroyed\n}\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len\n state.writecb = cb\n state.writing = true\n state.sync = true\n if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'))\n else if (writev) stream._writev(chunk, state.onwrite)\n else stream._write(chunk, encoding, state.onwrite)\n state.sync = false\n}\nfunction onwriteError(stream, state, er, cb) {\n --state.pendingcb\n cb(er)\n // Ensure callbacks are invoked even when autoDestroy is\n // not enabled. Passing `er` here doesn't make sense since\n // it's related to one specific write, not to the buffered\n // writes.\n errorBuffer(state)\n // This can emit error, but error must always follow cb.\n errorOrDestroy(stream, er)\n}\nfunction onwrite(stream, er) {\n const state = stream._writableState\n const sync = state.sync\n const cb = state.writecb\n if (typeof cb !== 'function') {\n errorOrDestroy(stream, new ERR_MULTIPLE_CALLBACK())\n return\n }\n state.writing = false\n state.writecb = null\n state.length -= state.writelen\n state.writelen = 0\n if (er) {\n // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364\n er.stack // eslint-disable-line no-unused-expressions\n\n if (!state.errored) {\n state.errored = er\n }\n\n // In case of duplex streams we need to notify the readable side of the\n // error.\n if (stream._readableState && !stream._readableState.errored) {\n stream._readableState.errored = er\n }\n if (sync) {\n process.nextTick(onwriteError, stream, state, er, cb)\n } else {\n onwriteError(stream, state, er, cb)\n }\n } else {\n if (state.buffered.length > state.bufferedIndex) {\n clearBuffer(stream, state)\n }\n if (sync) {\n // It is a common case that the callback passed to .write() is always\n // the same. In that case, we do not schedule a new nextTick(), but\n // rather just increase a counter, to improve performance and avoid\n // memory allocations.\n if (state.afterWriteTickInfo !== null && state.afterWriteTickInfo.cb === cb) {\n state.afterWriteTickInfo.count++\n } else {\n state.afterWriteTickInfo = {\n count: 1,\n cb,\n stream,\n state\n }\n process.nextTick(afterWriteTick, state.afterWriteTickInfo)\n }\n } else {\n afterWrite(stream, state, 1, cb)\n }\n }\n}\nfunction afterWriteTick({ stream, state, count, cb }) {\n state.afterWriteTickInfo = null\n return afterWrite(stream, state, count, cb)\n}\nfunction afterWrite(stream, state, count, cb) {\n const needDrain = !state.ending && !stream.destroyed && state.length === 0 && state.needDrain\n if (needDrain) {\n state.needDrain = false\n stream.emit('drain')\n }\n while (count-- > 0) {\n state.pendingcb--\n cb()\n }\n if (state.destroyed) {\n errorBuffer(state)\n }\n finishMaybe(stream, state)\n}\n\n// If there's something in the buffer waiting, then invoke callbacks.\nfunction errorBuffer(state) {\n if (state.writing) {\n return\n }\n for (let n = state.bufferedIndex; n < state.buffered.length; ++n) {\n var _state$errored\n const { chunk, callback } = state.buffered[n]\n const len = state.objectMode ? 1 : chunk.length\n state.length -= len\n callback(\n (_state$errored = state.errored) !== null && _state$errored !== undefined\n ? _state$errored\n : new ERR_STREAM_DESTROYED('write')\n )\n }\n const onfinishCallbacks = state[kOnFinished].splice(0)\n for (let i = 0; i < onfinishCallbacks.length; i++) {\n var _state$errored2\n onfinishCallbacks[i](\n (_state$errored2 = state.errored) !== null && _state$errored2 !== undefined\n ? _state$errored2\n : new ERR_STREAM_DESTROYED('end')\n )\n }\n resetBuffer(state)\n}\n\n// If there's something in the buffer waiting, then process it.\nfunction clearBuffer(stream, state) {\n if (state.corked || state.bufferProcessing || state.destroyed || !state.constructed) {\n return\n }\n const { buffered, bufferedIndex, objectMode } = state\n const bufferedLength = buffered.length - bufferedIndex\n if (!bufferedLength) {\n return\n }\n let i = bufferedIndex\n state.bufferProcessing = true\n if (bufferedLength > 1 && stream._writev) {\n state.pendingcb -= bufferedLength - 1\n const callback = state.allNoop\n ? nop\n : (err) => {\n for (let n = i; n < buffered.length; ++n) {\n buffered[n].callback(err)\n }\n }\n // Make a copy of `buffered` if it's going to be used by `callback` above,\n // since `doWrite` will mutate the array.\n const chunks = state.allNoop && i === 0 ? buffered : ArrayPrototypeSlice(buffered, i)\n chunks.allBuffers = state.allBuffers\n doWrite(stream, state, true, state.length, chunks, '', callback)\n resetBuffer(state)\n } else {\n do {\n const { chunk, encoding, callback } = buffered[i]\n buffered[i++] = null\n const len = objectMode ? 1 : chunk.length\n doWrite(stream, state, false, len, chunk, encoding, callback)\n } while (i < buffered.length && !state.writing)\n if (i === buffered.length) {\n resetBuffer(state)\n } else if (i > 256) {\n buffered.splice(0, i)\n state.bufferedIndex = 0\n } else {\n state.bufferedIndex = i\n }\n }\n state.bufferProcessing = false\n}\nWritable.prototype._write = function (chunk, encoding, cb) {\n if (this._writev) {\n this._writev(\n [\n {\n chunk,\n encoding\n }\n ],\n cb\n )\n } else {\n throw new ERR_METHOD_NOT_IMPLEMENTED('_write()')\n }\n}\nWritable.prototype._writev = null\nWritable.prototype.end = function (chunk, encoding, cb) {\n const state = this._writableState\n if (typeof chunk === 'function') {\n cb = chunk\n chunk = null\n encoding = null\n } else if (typeof encoding === 'function') {\n cb = encoding\n encoding = null\n }\n let err\n if (chunk !== null && chunk !== undefined) {\n const ret = _write(this, chunk, encoding)\n if (ret instanceof Error) {\n err = ret\n }\n }\n\n // .end() fully uncorks.\n if (state.corked) {\n state.corked = 1\n this.uncork()\n }\n if (err) {\n // Do nothing...\n } else if (!state.errored && !state.ending) {\n // This is forgiving in terms of unnecessary calls to end() and can hide\n // logic errors. However, usually such errors are harmless and causing a\n // hard error can be disproportionately destructive. It is not always\n // trivial for the user to determine whether end() needs to be called\n // or not.\n\n state.ending = true\n finishMaybe(this, state, true)\n state.ended = true\n } else if (state.finished) {\n err = new ERR_STREAM_ALREADY_FINISHED('end')\n } else if (state.destroyed) {\n err = new ERR_STREAM_DESTROYED('end')\n }\n if (typeof cb === 'function') {\n if (err || state.finished) {\n process.nextTick(cb, err)\n } else {\n state[kOnFinished].push(cb)\n }\n }\n return this\n}\nfunction needFinish(state) {\n return (\n state.ending &&\n !state.destroyed &&\n state.constructed &&\n state.length === 0 &&\n !state.errored &&\n state.buffered.length === 0 &&\n !state.finished &&\n !state.writing &&\n !state.errorEmitted &&\n !state.closeEmitted\n )\n}\nfunction callFinal(stream, state) {\n let called = false\n function onFinish(err) {\n if (called) {\n errorOrDestroy(stream, err !== null && err !== undefined ? err : ERR_MULTIPLE_CALLBACK())\n return\n }\n called = true\n state.pendingcb--\n if (err) {\n const onfinishCallbacks = state[kOnFinished].splice(0)\n for (let i = 0; i < onfinishCallbacks.length; i++) {\n onfinishCallbacks[i](err)\n }\n errorOrDestroy(stream, err, state.sync)\n } else if (needFinish(state)) {\n state.prefinished = true\n stream.emit('prefinish')\n // Backwards compat. Don't check state.sync here.\n // Some streams assume 'finish' will be emitted\n // asynchronously relative to _final callback.\n state.pendingcb++\n process.nextTick(finish, stream, state)\n }\n }\n state.sync = true\n state.pendingcb++\n try {\n stream._final(onFinish)\n } catch (err) {\n onFinish(err)\n }\n state.sync = false\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function' && !state.destroyed) {\n state.finalCalled = true\n callFinal(stream, state)\n } else {\n state.prefinished = true\n stream.emit('prefinish')\n }\n }\n}\nfunction finishMaybe(stream, state, sync) {\n if (needFinish(state)) {\n prefinish(stream, state)\n if (state.pendingcb === 0) {\n if (sync) {\n state.pendingcb++\n process.nextTick(\n (stream, state) => {\n if (needFinish(state)) {\n finish(stream, state)\n } else {\n state.pendingcb--\n }\n },\n stream,\n state\n )\n } else if (needFinish(state)) {\n state.pendingcb++\n finish(stream, state)\n }\n }\n }\n}\nfunction finish(stream, state) {\n state.pendingcb--\n state.finished = true\n const onfinishCallbacks = state[kOnFinished].splice(0)\n for (let i = 0; i < onfinishCallbacks.length; i++) {\n onfinishCallbacks[i]()\n }\n stream.emit('finish')\n if (state.autoDestroy) {\n // In case of duplex streams we need a way to detect\n // if the readable side is ready for autoDestroy as well.\n const rState = stream._readableState\n const autoDestroy =\n !rState ||\n (rState.autoDestroy &&\n // We don't expect the readable to ever 'end'\n // if readable is explicitly set to false.\n (rState.endEmitted || rState.readable === false))\n if (autoDestroy) {\n stream.destroy()\n }\n }\n}\nObjectDefineProperties(Writable.prototype, {\n closed: {\n __proto__: null,\n get() {\n return this._writableState ? this._writableState.closed : false\n }\n },\n destroyed: {\n __proto__: null,\n get() {\n return this._writableState ? this._writableState.destroyed : false\n },\n set(value) {\n // Backward compatibility, the user is explicitly managing destroyed.\n if (this._writableState) {\n this._writableState.destroyed = value\n }\n }\n },\n writable: {\n __proto__: null,\n get() {\n const w = this._writableState\n // w.writable === false means that this is part of a Duplex stream\n // where the writable side was disabled upon construction.\n // Compat. The user might manually disable writable side through\n // deprecated setter.\n return !!w && w.writable !== false && !w.destroyed && !w.errored && !w.ending && !w.ended\n },\n set(val) {\n // Backwards compatible.\n if (this._writableState) {\n this._writableState.writable = !!val\n }\n }\n },\n writableFinished: {\n __proto__: null,\n get() {\n return this._writableState ? this._writableState.finished : false\n }\n },\n writableObjectMode: {\n __proto__: null,\n get() {\n return this._writableState ? this._writableState.objectMode : false\n }\n },\n writableBuffer: {\n __proto__: null,\n get() {\n return this._writableState && this._writableState.getBuffer()\n }\n },\n writableEnded: {\n __proto__: null,\n get() {\n return this._writableState ? this._writableState.ending : false\n }\n },\n writableNeedDrain: {\n __proto__: null,\n get() {\n const wState = this._writableState\n if (!wState) return false\n return !wState.destroyed && !wState.ending && wState.needDrain\n }\n },\n writableHighWaterMark: {\n __proto__: null,\n get() {\n return this._writableState && this._writableState.highWaterMark\n }\n },\n writableCorked: {\n __proto__: null,\n get() {\n return this._writableState ? this._writableState.corked : 0\n }\n },\n writableLength: {\n __proto__: null,\n get() {\n return this._writableState && this._writableState.length\n }\n },\n errored: {\n __proto__: null,\n enumerable: false,\n get() {\n return this._writableState ? this._writableState.errored : null\n }\n },\n writableAborted: {\n __proto__: null,\n enumerable: false,\n get: function () {\n return !!(\n this._writableState.writable !== false &&\n (this._writableState.destroyed || this._writableState.errored) &&\n !this._writableState.finished\n )\n }\n }\n})\nconst destroy = destroyImpl.destroy\nWritable.prototype.destroy = function (err, cb) {\n const state = this._writableState\n\n // Invoke pending callbacks.\n if (!state.destroyed && (state.bufferedIndex < state.buffered.length || state[kOnFinished].length)) {\n process.nextTick(errorBuffer, state)\n }\n destroy.call(this, err, cb)\n return this\n}\nWritable.prototype._undestroy = destroyImpl.undestroy\nWritable.prototype._destroy = function (err, cb) {\n cb(err)\n}\nWritable.prototype[EE.captureRejectionSymbol] = function (err) {\n this.destroy(err)\n}\nlet webStreamsAdapters\n\n// Lazy to avoid circular references\nfunction lazyWebStreams() {\n if (webStreamsAdapters === undefined) webStreamsAdapters = {}\n return webStreamsAdapters\n}\nWritable.fromWeb = function (writableStream, options) {\n return lazyWebStreams().newStreamWritableFromWritableStream(writableStream, options)\n}\nWritable.toWeb = function (streamWritable) {\n return lazyWebStreams().newWritableStreamFromStreamWritable(streamWritable)\n}\n", "/* replacement start */\n\nconst process = require('process/')\n\n/* replacement end */\n\n;('use strict')\nconst bufferModule = require('buffer')\nconst {\n isReadable,\n isWritable,\n isIterable,\n isNodeStream,\n isReadableNodeStream,\n isWritableNodeStream,\n isDuplexNodeStream,\n isReadableStream,\n isWritableStream\n} = require('./utils')\nconst eos = require('./end-of-stream')\nconst {\n AbortError,\n codes: { ERR_INVALID_ARG_TYPE, ERR_INVALID_RETURN_VALUE }\n} = require('../../ours/errors')\nconst { destroyer } = require('./destroy')\nconst Duplex = require('./duplex')\nconst Readable = require('./readable')\nconst Writable = require('./writable')\nconst { createDeferredPromise } = require('../../ours/util')\nconst from = require('./from')\nconst Blob = globalThis.Blob || bufferModule.Blob\nconst isBlob =\n typeof Blob !== 'undefined'\n ? function isBlob(b) {\n return b instanceof Blob\n }\n : function isBlob(b) {\n return false\n }\nconst AbortController = globalThis.AbortController || require('abort-controller').AbortController\nconst { FunctionPrototypeCall } = require('../../ours/primordials')\n\n// This is needed for pre node 17.\nclass Duplexify extends Duplex {\n constructor(options) {\n super(options)\n\n // https://github.com/nodejs/node/pull/34385\n\n if ((options === null || options === undefined ? undefined : options.readable) === false) {\n this._readableState.readable = false\n this._readableState.ended = true\n this._readableState.endEmitted = true\n }\n if ((options === null || options === undefined ? undefined : options.writable) === false) {\n this._writableState.writable = false\n this._writableState.ending = true\n this._writableState.ended = true\n this._writableState.finished = true\n }\n }\n}\nmodule.exports = function duplexify(body, name) {\n if (isDuplexNodeStream(body)) {\n return body\n }\n if (isReadableNodeStream(body)) {\n return _duplexify({\n readable: body\n })\n }\n if (isWritableNodeStream(body)) {\n return _duplexify({\n writable: body\n })\n }\n if (isNodeStream(body)) {\n return _duplexify({\n writable: false,\n readable: false\n })\n }\n if (isReadableStream(body)) {\n return _duplexify({\n readable: Readable.fromWeb(body)\n })\n }\n if (isWritableStream(body)) {\n return _duplexify({\n writable: Writable.fromWeb(body)\n })\n }\n if (typeof body === 'function') {\n const { value, write, final, destroy } = fromAsyncGen(body)\n if (isIterable(value)) {\n return from(Duplexify, value, {\n // TODO (ronag): highWaterMark?\n objectMode: true,\n write,\n final,\n destroy\n })\n }\n const then = value === null || value === undefined ? undefined : value.then\n if (typeof then === 'function') {\n let d\n const promise = FunctionPrototypeCall(\n then,\n value,\n (val) => {\n if (val != null) {\n throw new ERR_INVALID_RETURN_VALUE('nully', 'body', val)\n }\n },\n (err) => {\n destroyer(d, err)\n }\n )\n return (d = new Duplexify({\n // TODO (ronag): highWaterMark?\n objectMode: true,\n readable: false,\n write,\n final(cb) {\n final(async () => {\n try {\n await promise\n process.nextTick(cb, null)\n } catch (err) {\n process.nextTick(cb, err)\n }\n })\n },\n destroy\n }))\n }\n throw new ERR_INVALID_RETURN_VALUE('Iterable, AsyncIterable or AsyncFunction', name, value)\n }\n if (isBlob(body)) {\n return duplexify(body.arrayBuffer())\n }\n if (isIterable(body)) {\n return from(Duplexify, body, {\n // TODO (ronag): highWaterMark?\n objectMode: true,\n writable: false\n })\n }\n if (\n isReadableStream(body === null || body === undefined ? undefined : body.readable) &&\n isWritableStream(body === null || body === undefined ? undefined : body.writable)\n ) {\n return Duplexify.fromWeb(body)\n }\n if (\n typeof (body === null || body === undefined ? undefined : body.writable) === 'object' ||\n typeof (body === null || body === undefined ? undefined : body.readable) === 'object'\n ) {\n const readable =\n body !== null && body !== undefined && body.readable\n ? isReadableNodeStream(body === null || body === undefined ? undefined : body.readable)\n ? body === null || body === undefined\n ? undefined\n : body.readable\n : duplexify(body.readable)\n : undefined\n const writable =\n body !== null && body !== undefined && body.writable\n ? isWritableNodeStream(body === null || body === undefined ? undefined : body.writable)\n ? body === null || body === undefined\n ? undefined\n : body.writable\n : duplexify(body.writable)\n : undefined\n return _duplexify({\n readable,\n writable\n })\n }\n const then = body === null || body === undefined ? undefined : body.then\n if (typeof then === 'function') {\n let d\n FunctionPrototypeCall(\n then,\n body,\n (val) => {\n if (val != null) {\n d.push(val)\n }\n d.push(null)\n },\n (err) => {\n destroyer(d, err)\n }\n )\n return (d = new Duplexify({\n objectMode: true,\n writable: false,\n read() {}\n }))\n }\n throw new ERR_INVALID_ARG_TYPE(\n name,\n [\n 'Blob',\n 'ReadableStream',\n 'WritableStream',\n 'Stream',\n 'Iterable',\n 'AsyncIterable',\n 'Function',\n '{ readable, writable } pair',\n 'Promise'\n ],\n body\n )\n}\nfunction fromAsyncGen(fn) {\n let { promise, resolve } = createDeferredPromise()\n const ac = new AbortController()\n const signal = ac.signal\n const value = fn(\n (async function* () {\n while (true) {\n const _promise = promise\n promise = null\n const { chunk, done, cb } = await _promise\n process.nextTick(cb)\n if (done) return\n if (signal.aborted)\n throw new AbortError(undefined, {\n cause: signal.reason\n })\n ;({ promise, resolve } = createDeferredPromise())\n yield chunk\n }\n })(),\n {\n signal\n }\n )\n return {\n value,\n write(chunk, encoding, cb) {\n const _resolve = resolve\n resolve = null\n _resolve({\n chunk,\n done: false,\n cb\n })\n },\n final(cb) {\n const _resolve = resolve\n resolve = null\n _resolve({\n done: true,\n cb\n })\n },\n destroy(err, cb) {\n ac.abort()\n cb(err)\n }\n }\n}\nfunction _duplexify(pair) {\n const r = pair.readable && typeof pair.readable.read !== 'function' ? Readable.wrap(pair.readable) : pair.readable\n const w = pair.writable\n let readable = !!isReadable(r)\n let writable = !!isWritable(w)\n let ondrain\n let onfinish\n let onreadable\n let onclose\n let d\n function onfinished(err) {\n const cb = onclose\n onclose = null\n if (cb) {\n cb(err)\n } else if (err) {\n d.destroy(err)\n }\n }\n\n // TODO(ronag): Avoid double buffering.\n // Implement Writable/Readable/Duplex traits.\n // See, https://github.com/nodejs/node/pull/33515.\n d = new Duplexify({\n // TODO (ronag): highWaterMark?\n readableObjectMode: !!(r !== null && r !== undefined && r.readableObjectMode),\n writableObjectMode: !!(w !== null && w !== undefined && w.writableObjectMode),\n readable,\n writable\n })\n if (writable) {\n eos(w, (err) => {\n writable = false\n if (err) {\n destroyer(r, err)\n }\n onfinished(err)\n })\n d._write = function (chunk, encoding, callback) {\n if (w.write(chunk, encoding)) {\n callback()\n } else {\n ondrain = callback\n }\n }\n d._final = function (callback) {\n w.end()\n onfinish = callback\n }\n w.on('drain', function () {\n if (ondrain) {\n const cb = ondrain\n ondrain = null\n cb()\n }\n })\n w.on('finish', function () {\n if (onfinish) {\n const cb = onfinish\n onfinish = null\n cb()\n }\n })\n }\n if (readable) {\n eos(r, (err) => {\n readable = false\n if (err) {\n destroyer(r, err)\n }\n onfinished(err)\n })\n r.on('readable', function () {\n if (onreadable) {\n const cb = onreadable\n onreadable = null\n cb()\n }\n })\n r.on('end', function () {\n d.push(null)\n })\n d._read = function () {\n while (true) {\n const buf = r.read()\n if (buf === null) {\n onreadable = d._read\n return\n }\n if (!d.push(buf)) {\n return\n }\n }\n }\n }\n d._destroy = function (err, callback) {\n if (!err && onclose !== null) {\n err = new AbortError()\n }\n onreadable = null\n ondrain = null\n onfinish = null\n if (onclose === null) {\n callback(err)\n } else {\n onclose = callback\n destroyer(w, err)\n destroyer(r, err)\n }\n }\n return d\n}\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototype inheritance, this class\n// prototypically inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict'\n\nconst {\n ObjectDefineProperties,\n ObjectGetOwnPropertyDescriptor,\n ObjectKeys,\n ObjectSetPrototypeOf\n} = require('../../ours/primordials')\nmodule.exports = Duplex\nconst Readable = require('./readable')\nconst Writable = require('./writable')\nObjectSetPrototypeOf(Duplex.prototype, Readable.prototype)\nObjectSetPrototypeOf(Duplex, Readable)\n{\n const keys = ObjectKeys(Writable.prototype)\n // Allow the keys array to be GC'ed.\n for (let i = 0; i < keys.length; i++) {\n const method = keys[i]\n if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]\n }\n}\nfunction Duplex(options) {\n if (!(this instanceof Duplex)) return new Duplex(options)\n Readable.call(this, options)\n Writable.call(this, options)\n if (options) {\n this.allowHalfOpen = options.allowHalfOpen !== false\n if (options.readable === false) {\n this._readableState.readable = false\n this._readableState.ended = true\n this._readableState.endEmitted = true\n }\n if (options.writable === false) {\n this._writableState.writable = false\n this._writableState.ending = true\n this._writableState.ended = true\n this._writableState.finished = true\n }\n } else {\n this.allowHalfOpen = true\n }\n}\nObjectDefineProperties(Duplex.prototype, {\n writable: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable')\n },\n writableHighWaterMark: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableHighWaterMark')\n },\n writableObjectMode: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableObjectMode')\n },\n writableBuffer: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableBuffer')\n },\n writableLength: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableLength')\n },\n writableFinished: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableFinished')\n },\n writableCorked: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableCorked')\n },\n writableEnded: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableEnded')\n },\n writableNeedDrain: {\n __proto__: null,\n ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableNeedDrain')\n },\n destroyed: {\n __proto__: null,\n get() {\n if (this._readableState === undefined || this._writableState === undefined) {\n return false\n }\n return this._readableState.destroyed && this._writableState.destroyed\n },\n set(value) {\n // Backward compatibility, the user is explicitly\n // managing destroyed.\n if (this._readableState && this._writableState) {\n this._readableState.destroyed = value\n this._writableState.destroyed = value\n }\n }\n }\n})\nlet webStreamsAdapters\n\n// Lazy to avoid circular references\nfunction lazyWebStreams() {\n if (webStreamsAdapters === undefined) webStreamsAdapters = {}\n return webStreamsAdapters\n}\nDuplex.fromWeb = function (pair, options) {\n return lazyWebStreams().newStreamDuplexFromReadableWritablePair(pair, options)\n}\nDuplex.toWeb = function (duplex) {\n return lazyWebStreams().newReadableWritablePairFromDuplex(duplex)\n}\nlet duplexify\nDuplex.from = function (body) {\n if (!duplexify) {\n duplexify = require('./duplexify')\n }\n return duplexify(body, 'body')\n}\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict'\n\nconst { ObjectSetPrototypeOf, Symbol } = require('../../ours/primordials')\nmodule.exports = Transform\nconst { ERR_METHOD_NOT_IMPLEMENTED } = require('../../ours/errors').codes\nconst Duplex = require('./duplex')\nconst { getHighWaterMark } = require('./state')\nObjectSetPrototypeOf(Transform.prototype, Duplex.prototype)\nObjectSetPrototypeOf(Transform, Duplex)\nconst kCallback = Symbol('kCallback')\nfunction Transform(options) {\n if (!(this instanceof Transform)) return new Transform(options)\n\n // TODO (ronag): This should preferably always be\n // applied but would be semver-major. Or even better;\n // make Transform a Readable with the Writable interface.\n const readableHighWaterMark = options ? getHighWaterMark(this, options, 'readableHighWaterMark', true) : null\n if (readableHighWaterMark === 0) {\n // A Duplex will buffer both on the writable and readable side while\n // a Transform just wants to buffer hwm number of elements. To avoid\n // buffering twice we disable buffering on the writable side.\n options = {\n ...options,\n highWaterMark: null,\n readableHighWaterMark,\n // TODO (ronag): 0 is not optimal since we have\n // a \"bug\" where we check needDrain before calling _write and not after.\n // Refs: https://github.com/nodejs/node/pull/32887\n // Refs: https://github.com/nodejs/node/pull/35941\n writableHighWaterMark: options.writableHighWaterMark || 0\n }\n }\n Duplex.call(this, options)\n\n // We have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false\n this[kCallback] = null\n if (options) {\n if (typeof options.transform === 'function') this._transform = options.transform\n if (typeof options.flush === 'function') this._flush = options.flush\n }\n\n // When the writable side finishes, then flush out anything remaining.\n // Backwards compat. Some Transform streams incorrectly implement _final\n // instead of or in addition to _flush. By using 'prefinish' instead of\n // implementing _final we continue supporting this unfortunate use case.\n this.on('prefinish', prefinish)\n}\nfunction final(cb) {\n if (typeof this._flush === 'function' && !this.destroyed) {\n this._flush((er, data) => {\n if (er) {\n if (cb) {\n cb(er)\n } else {\n this.destroy(er)\n }\n return\n }\n if (data != null) {\n this.push(data)\n }\n this.push(null)\n if (cb) {\n cb()\n }\n })\n } else {\n this.push(null)\n if (cb) {\n cb()\n }\n }\n}\nfunction prefinish() {\n if (this._final !== final) {\n final.call(this)\n }\n}\nTransform.prototype._final = final\nTransform.prototype._transform = function (chunk, encoding, callback) {\n throw new ERR_METHOD_NOT_IMPLEMENTED('_transform()')\n}\nTransform.prototype._write = function (chunk, encoding, callback) {\n const rState = this._readableState\n const wState = this._writableState\n const length = rState.length\n this._transform(chunk, encoding, (err, val) => {\n if (err) {\n callback(err)\n return\n }\n if (val != null) {\n this.push(val)\n }\n if (\n wState.ended ||\n // Backwards compat.\n length === rState.length ||\n // Backwards compat.\n rState.length < rState.highWaterMark\n ) {\n callback()\n } else {\n this[kCallback] = callback\n }\n })\n}\nTransform.prototype._read = function () {\n if (this[kCallback]) {\n const callback = this[kCallback]\n this[kCallback] = null\n callback()\n }\n}\n", "// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict'\n\nconst { ObjectSetPrototypeOf } = require('../../ours/primordials')\nmodule.exports = PassThrough\nconst Transform = require('./transform')\nObjectSetPrototypeOf(PassThrough.prototype, Transform.prototype)\nObjectSetPrototypeOf(PassThrough, Transform)\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough)) return new PassThrough(options)\n Transform.call(this, options)\n}\nPassThrough.prototype._transform = function (chunk, encoding, cb) {\n cb(null, chunk)\n}\n", "/* replacement start */\n\nconst process = require('process/')\n\n/* replacement end */\n// Ported from https://github.com/mafintosh/pump with\n// permission from the author, Mathias Buus (@mafintosh).\n\n;('use strict')\nconst { ArrayIsArray, Promise, SymbolAsyncIterator, SymbolDispose } = require('../../ours/primordials')\nconst eos = require('./end-of-stream')\nconst { once } = require('../../ours/util')\nconst destroyImpl = require('./destroy')\nconst Duplex = require('./duplex')\nconst {\n aggregateTwoErrors,\n codes: {\n ERR_INVALID_ARG_TYPE,\n ERR_INVALID_RETURN_VALUE,\n ERR_MISSING_ARGS,\n ERR_STREAM_DESTROYED,\n ERR_STREAM_PREMATURE_CLOSE\n },\n AbortError\n} = require('../../ours/errors')\nconst { validateFunction, validateAbortSignal } = require('../validators')\nconst {\n isIterable,\n isReadable,\n isReadableNodeStream,\n isNodeStream,\n isTransformStream,\n isWebStream,\n isReadableStream,\n isReadableFinished\n} = require('./utils')\nconst AbortController = globalThis.AbortController || require('abort-controller').AbortController\nlet PassThrough\nlet Readable\nlet addAbortListener\nfunction destroyer(stream, reading, writing) {\n let finished = false\n stream.on('close', () => {\n finished = true\n })\n const cleanup = eos(\n stream,\n {\n readable: reading,\n writable: writing\n },\n (err) => {\n finished = !err\n }\n )\n return {\n destroy: (err) => {\n if (finished) return\n finished = true\n destroyImpl.destroyer(stream, err || new ERR_STREAM_DESTROYED('pipe'))\n },\n cleanup\n }\n}\nfunction popCallback(streams) {\n // Streams should never be an empty array. It should always contain at least\n // a single stream. Therefore optimize for the average case instead of\n // checking for length === 0 as well.\n validateFunction(streams[streams.length - 1], 'streams[stream.length - 1]')\n return streams.pop()\n}\nfunction makeAsyncIterable(val) {\n if (isIterable(val)) {\n return val\n } else if (isReadableNodeStream(val)) {\n // Legacy streams are not Iterable.\n return fromReadable(val)\n }\n throw new ERR_INVALID_ARG_TYPE('val', ['Readable', 'Iterable', 'AsyncIterable'], val)\n}\nasync function* fromReadable(val) {\n if (!Readable) {\n Readable = require('./readable')\n }\n yield* Readable.prototype[SymbolAsyncIterator].call(val)\n}\nasync function pumpToNode(iterable, writable, finish, { end }) {\n let error\n let onresolve = null\n const resume = (err) => {\n if (err) {\n error = err\n }\n if (onresolve) {\n const callback = onresolve\n onresolve = null\n callback()\n }\n }\n const wait = () =>\n new Promise((resolve, reject) => {\n if (error) {\n reject(error)\n } else {\n onresolve = () => {\n if (error) {\n reject(error)\n } else {\n resolve()\n }\n }\n }\n })\n writable.on('drain', resume)\n const cleanup = eos(\n writable,\n {\n readable: false\n },\n resume\n )\n try {\n if (writable.writableNeedDrain) {\n await wait()\n }\n for await (const chunk of iterable) {\n if (!writable.write(chunk)) {\n await wait()\n }\n }\n if (end) {\n writable.end()\n await wait()\n }\n finish()\n } catch (err) {\n finish(error !== err ? aggregateTwoErrors(error, err) : err)\n } finally {\n cleanup()\n writable.off('drain', resume)\n }\n}\nasync function pumpToWeb(readable, writable, finish, { end }) {\n if (isTransformStream(writable)) {\n writable = writable.writable\n }\n // https://streams.spec.whatwg.org/#example-manual-write-with-backpressure\n const writer = writable.getWriter()\n try {\n for await (const chunk of readable) {\n await writer.ready\n writer.write(chunk).catch(() => {})\n }\n await writer.ready\n if (end) {\n await writer.close()\n }\n finish()\n } catch (err) {\n try {\n await writer.abort(err)\n finish(err)\n } catch (err) {\n finish(err)\n }\n }\n}\nfunction pipeline(...streams) {\n return pipelineImpl(streams, once(popCallback(streams)))\n}\nfunction pipelineImpl(streams, callback, opts) {\n if (streams.length === 1 && ArrayIsArray(streams[0])) {\n streams = streams[0]\n }\n if (streams.length < 2) {\n throw new ERR_MISSING_ARGS('streams')\n }\n const ac = new AbortController()\n const signal = ac.signal\n const outerSignal = opts === null || opts === undefined ? undefined : opts.signal\n\n // Need to cleanup event listeners if last stream is readable\n // https://github.com/nodejs/node/issues/35452\n const lastStreamCleanup = []\n validateAbortSignal(outerSignal, 'options.signal')\n function abort() {\n finishImpl(new AbortError())\n }\n addAbortListener = addAbortListener || require('../../ours/util').addAbortListener\n let disposable\n if (outerSignal) {\n disposable = addAbortListener(outerSignal, abort)\n }\n let error\n let value\n const destroys = []\n let finishCount = 0\n function finish(err) {\n finishImpl(err, --finishCount === 0)\n }\n function finishImpl(err, final) {\n var _disposable\n if (err && (!error || error.code === 'ERR_STREAM_PREMATURE_CLOSE')) {\n error = err\n }\n if (!error && !final) {\n return\n }\n while (destroys.length) {\n destroys.shift()(error)\n }\n ;(_disposable = disposable) === null || _disposable === undefined ? undefined : _disposable[SymbolDispose]()\n ac.abort()\n if (final) {\n if (!error) {\n lastStreamCleanup.forEach((fn) => fn())\n }\n process.nextTick(callback, error, value)\n }\n }\n let ret\n for (let i = 0; i < streams.length; i++) {\n const stream = streams[i]\n const reading = i < streams.length - 1\n const writing = i > 0\n const end = reading || (opts === null || opts === undefined ? undefined : opts.end) !== false\n const isLastStream = i === streams.length - 1\n if (isNodeStream(stream)) {\n if (end) {\n const { destroy, cleanup } = destroyer(stream, reading, writing)\n destroys.push(destroy)\n if (isReadable(stream) && isLastStream) {\n lastStreamCleanup.push(cleanup)\n }\n }\n\n // Catch stream errors that occur after pipe/pump has completed.\n function onError(err) {\n if (err && err.name !== 'AbortError' && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {\n finish(err)\n }\n }\n stream.on('error', onError)\n if (isReadable(stream) && isLastStream) {\n lastStreamCleanup.push(() => {\n stream.removeListener('error', onError)\n })\n }\n }\n if (i === 0) {\n if (typeof stream === 'function') {\n ret = stream({\n signal\n })\n if (!isIterable(ret)) {\n throw new ERR_INVALID_RETURN_VALUE('Iterable, AsyncIterable or Stream', 'source', ret)\n }\n } else if (isIterable(stream) || isReadableNodeStream(stream) || isTransformStream(stream)) {\n ret = stream\n } else {\n ret = Duplex.from(stream)\n }\n } else if (typeof stream === 'function') {\n if (isTransformStream(ret)) {\n var _ret\n ret = makeAsyncIterable((_ret = ret) === null || _ret === undefined ? undefined : _ret.readable)\n } else {\n ret = makeAsyncIterable(ret)\n }\n ret = stream(ret, {\n signal\n })\n if (reading) {\n if (!isIterable(ret, true)) {\n throw new ERR_INVALID_RETURN_VALUE('AsyncIterable', `transform[${i - 1}]`, ret)\n }\n } else {\n var _ret2\n if (!PassThrough) {\n PassThrough = require('./passthrough')\n }\n\n // If the last argument to pipeline is not a stream\n // we must create a proxy stream so that pipeline(...)\n // always returns a stream which can be further\n // composed through `.pipe(stream)`.\n\n const pt = new PassThrough({\n objectMode: true\n })\n\n // Handle Promises/A+ spec, `then` could be a getter that throws on\n // second use.\n const then = (_ret2 = ret) === null || _ret2 === undefined ? undefined : _ret2.then\n if (typeof then === 'function') {\n finishCount++\n then.call(\n ret,\n (val) => {\n value = val\n if (val != null) {\n pt.write(val)\n }\n if (end) {\n pt.end()\n }\n process.nextTick(finish)\n },\n (err) => {\n pt.destroy(err)\n process.nextTick(finish, err)\n }\n )\n } else if (isIterable(ret, true)) {\n finishCount++\n pumpToNode(ret, pt, finish, {\n end\n })\n } else if (isReadableStream(ret) || isTransformStream(ret)) {\n const toRead = ret.readable || ret\n finishCount++\n pumpToNode(toRead, pt, finish, {\n end\n })\n } else {\n throw new ERR_INVALID_RETURN_VALUE('AsyncIterable or Promise', 'destination', ret)\n }\n ret = pt\n const { destroy, cleanup } = destroyer(ret, false, true)\n destroys.push(destroy)\n if (isLastStream) {\n lastStreamCleanup.push(cleanup)\n }\n }\n } else if (isNodeStream(stream)) {\n if (isReadableNodeStream(ret)) {\n finishCount += 2\n const cleanup = pipe(ret, stream, finish, {\n end\n })\n if (isReadable(stream) && isLastStream) {\n lastStreamCleanup.push(cleanup)\n }\n } else if (isTransformStream(ret) || isReadableStream(ret)) {\n const toRead = ret.readable || ret\n finishCount++\n pumpToNode(toRead, stream, finish, {\n end\n })\n } else if (isIterable(ret)) {\n finishCount++\n pumpToNode(ret, stream, finish, {\n end\n })\n } else {\n throw new ERR_INVALID_ARG_TYPE(\n 'val',\n ['Readable', 'Iterable', 'AsyncIterable', 'ReadableStream', 'TransformStream'],\n ret\n )\n }\n ret = stream\n } else if (isWebStream(stream)) {\n if (isReadableNodeStream(ret)) {\n finishCount++\n pumpToWeb(makeAsyncIterable(ret), stream, finish, {\n end\n })\n } else if (isReadableStream(ret) || isIterable(ret)) {\n finishCount++\n pumpToWeb(ret, stream, finish, {\n end\n })\n } else if (isTransformStream(ret)) {\n finishCount++\n pumpToWeb(ret.readable, stream, finish, {\n end\n })\n } else {\n throw new ERR_INVALID_ARG_TYPE(\n 'val',\n ['Readable', 'Iterable', 'AsyncIterable', 'ReadableStream', 'TransformStream'],\n ret\n )\n }\n ret = stream\n } else {\n ret = Duplex.from(stream)\n }\n }\n if (\n (signal !== null && signal !== undefined && signal.aborted) ||\n (outerSignal !== null && outerSignal !== undefined && outerSignal.aborted)\n ) {\n process.nextTick(abort)\n }\n return ret\n}\nfunction pipe(src, dst, finish, { end }) {\n let ended = false\n dst.on('close', () => {\n if (!ended) {\n // Finish if the destination closes before the source has completed.\n finish(new ERR_STREAM_PREMATURE_CLOSE())\n }\n })\n src.pipe(dst, {\n end: false\n }) // If end is true we already will have a listener to end dst.\n\n if (end) {\n // Compat. Before node v10.12.0 stdio used to throw an error so\n // pipe() did/does not end() stdio destinations.\n // Now they allow it but \"secretly\" don't close the underlying fd.\n\n function endFn() {\n ended = true\n dst.end()\n }\n if (isReadableFinished(src)) {\n // End the destination if the source has already ended.\n process.nextTick(endFn)\n } else {\n src.once('end', endFn)\n }\n } else {\n finish()\n }\n eos(\n src,\n {\n readable: true,\n writable: false\n },\n (err) => {\n const rState = src._readableState\n if (\n err &&\n err.code === 'ERR_STREAM_PREMATURE_CLOSE' &&\n rState &&\n rState.ended &&\n !rState.errored &&\n !rState.errorEmitted\n ) {\n // Some readable streams will emit 'close' before 'end'. However, since\n // this is on the readable side 'end' should still be emitted if the\n // stream has been ended and no error emitted. This should be allowed in\n // favor of backwards compatibility. Since the stream is piped to a\n // destination this should not result in any observable difference.\n // We don't need to check if this is a writable premature close since\n // eos will only fail with premature close on the reading side for\n // duplex streams.\n src.once('end', finish).once('error', finish)\n } else {\n finish(err)\n }\n }\n )\n return eos(\n dst,\n {\n readable: false,\n writable: true\n },\n finish\n )\n}\nmodule.exports = {\n pipelineImpl,\n pipeline\n}\n", "'use strict'\n\nconst { pipeline } = require('./pipeline')\nconst Duplex = require('./duplex')\nconst { destroyer } = require('./destroy')\nconst {\n isNodeStream,\n isReadable,\n isWritable,\n isWebStream,\n isTransformStream,\n isWritableStream,\n isReadableStream\n} = require('./utils')\nconst {\n AbortError,\n codes: { ERR_INVALID_ARG_VALUE, ERR_MISSING_ARGS }\n} = require('../../ours/errors')\nconst eos = require('./end-of-stream')\nmodule.exports = function compose(...streams) {\n if (streams.length === 0) {\n throw new ERR_MISSING_ARGS('streams')\n }\n if (streams.length === 1) {\n return Duplex.from(streams[0])\n }\n const orgStreams = [...streams]\n if (typeof streams[0] === 'function') {\n streams[0] = Duplex.from(streams[0])\n }\n if (typeof streams[streams.length - 1] === 'function') {\n const idx = streams.length - 1\n streams[idx] = Duplex.from(streams[idx])\n }\n for (let n = 0; n < streams.length; ++n) {\n if (!isNodeStream(streams[n]) && !isWebStream(streams[n])) {\n // TODO(ronag): Add checks for non streams.\n continue\n }\n if (\n n < streams.length - 1 &&\n !(isReadable(streams[n]) || isReadableStream(streams[n]) || isTransformStream(streams[n]))\n ) {\n throw new ERR_INVALID_ARG_VALUE(`streams[${n}]`, orgStreams[n], 'must be readable')\n }\n if (n > 0 && !(isWritable(streams[n]) || isWritableStream(streams[n]) || isTransformStream(streams[n]))) {\n throw new ERR_INVALID_ARG_VALUE(`streams[${n}]`, orgStreams[n], 'must be writable')\n }\n }\n let ondrain\n let onfinish\n let onreadable\n let onclose\n let d\n function onfinished(err) {\n const cb = onclose\n onclose = null\n if (cb) {\n cb(err)\n } else if (err) {\n d.destroy(err)\n } else if (!readable && !writable) {\n d.destroy()\n }\n }\n const head = streams[0]\n const tail = pipeline(streams, onfinished)\n const writable = !!(isWritable(head) || isWritableStream(head) || isTransformStream(head))\n const readable = !!(isReadable(tail) || isReadableStream(tail) || isTransformStream(tail))\n\n // TODO(ronag): Avoid double buffering.\n // Implement Writable/Readable/Duplex traits.\n // See, https://github.com/nodejs/node/pull/33515.\n d = new Duplex({\n // TODO (ronag): highWaterMark?\n writableObjectMode: !!(head !== null && head !== undefined && head.writableObjectMode),\n readableObjectMode: !!(tail !== null && tail !== undefined && tail.readableObjectMode),\n writable,\n readable\n })\n if (writable) {\n if (isNodeStream(head)) {\n d._write = function (chunk, encoding, callback) {\n if (head.write(chunk, encoding)) {\n callback()\n } else {\n ondrain = callback\n }\n }\n d._final = function (callback) {\n head.end()\n onfinish = callback\n }\n head.on('drain', function () {\n if (ondrain) {\n const cb = ondrain\n ondrain = null\n cb()\n }\n })\n } else if (isWebStream(head)) {\n const writable = isTransformStream(head) ? head.writable : head\n const writer = writable.getWriter()\n d._write = async function (chunk, encoding, callback) {\n try {\n await writer.ready\n writer.write(chunk).catch(() => {})\n callback()\n } catch (err) {\n callback(err)\n }\n }\n d._final = async function (callback) {\n try {\n await writer.ready\n writer.close().catch(() => {})\n onfinish = callback\n } catch (err) {\n callback(err)\n }\n }\n }\n const toRead = isTransformStream(tail) ? tail.readable : tail\n eos(toRead, () => {\n if (onfinish) {\n const cb = onfinish\n onfinish = null\n cb()\n }\n })\n }\n if (readable) {\n if (isNodeStream(tail)) {\n tail.on('readable', function () {\n if (onreadable) {\n const cb = onreadable\n onreadable = null\n cb()\n }\n })\n tail.on('end', function () {\n d.push(null)\n })\n d._read = function () {\n while (true) {\n const buf = tail.read()\n if (buf === null) {\n onreadable = d._read\n return\n }\n if (!d.push(buf)) {\n return\n }\n }\n }\n } else if (isWebStream(tail)) {\n const readable = isTransformStream(tail) ? tail.readable : tail\n const reader = readable.getReader()\n d._read = async function () {\n while (true) {\n try {\n const { value, done } = await reader.read()\n if (!d.push(value)) {\n return\n }\n if (done) {\n d.push(null)\n return\n }\n } catch {\n return\n }\n }\n }\n }\n }\n d._destroy = function (err, callback) {\n if (!err && onclose !== null) {\n err = new AbortError()\n }\n onreadable = null\n ondrain = null\n onfinish = null\n if (onclose === null) {\n callback(err)\n } else {\n onclose = callback\n if (isNodeStream(tail)) {\n destroyer(tail, err)\n }\n }\n }\n return d\n}\n", "'use strict'\n\nconst AbortController = globalThis.AbortController || require('abort-controller').AbortController\nconst {\n codes: { ERR_INVALID_ARG_VALUE, ERR_INVALID_ARG_TYPE, ERR_MISSING_ARGS, ERR_OUT_OF_RANGE },\n AbortError\n} = require('../../ours/errors')\nconst { validateAbortSignal, validateInteger, validateObject } = require('../validators')\nconst kWeakHandler = require('../../ours/primordials').Symbol('kWeak')\nconst kResistStopPropagation = require('../../ours/primordials').Symbol('kResistStopPropagation')\nconst { finished } = require('./end-of-stream')\nconst staticCompose = require('./compose')\nconst { addAbortSignalNoValidate } = require('./add-abort-signal')\nconst { isWritable, isNodeStream } = require('./utils')\nconst { deprecate } = require('../../ours/util')\nconst {\n ArrayPrototypePush,\n Boolean,\n MathFloor,\n Number,\n NumberIsNaN,\n Promise,\n PromiseReject,\n PromiseResolve,\n PromisePrototypeThen,\n Symbol\n} = require('../../ours/primordials')\nconst kEmpty = Symbol('kEmpty')\nconst kEof = Symbol('kEof')\nfunction compose(stream, options) {\n if (options != null) {\n validateObject(options, 'options')\n }\n if ((options === null || options === undefined ? undefined : options.signal) != null) {\n validateAbortSignal(options.signal, 'options.signal')\n }\n if (isNodeStream(stream) && !isWritable(stream)) {\n throw new ERR_INVALID_ARG_VALUE('stream', stream, 'must be writable')\n }\n const composedStream = staticCompose(this, stream)\n if (options !== null && options !== undefined && options.signal) {\n // Not validating as we already validated before\n addAbortSignalNoValidate(options.signal, composedStream)\n }\n return composedStream\n}\nfunction map(fn, options) {\n if (typeof fn !== 'function') {\n throw new ERR_INVALID_ARG_TYPE('fn', ['Function', 'AsyncFunction'], fn)\n }\n if (options != null) {\n validateObject(options, 'options')\n }\n if ((options === null || options === undefined ? undefined : options.signal) != null) {\n validateAbortSignal(options.signal, 'options.signal')\n }\n let concurrency = 1\n if ((options === null || options === undefined ? undefined : options.concurrency) != null) {\n concurrency = MathFloor(options.concurrency)\n }\n let highWaterMark = concurrency - 1\n if ((options === null || options === undefined ? undefined : options.highWaterMark) != null) {\n highWaterMark = MathFloor(options.highWaterMark)\n }\n validateInteger(concurrency, 'options.concurrency', 1)\n validateInteger(highWaterMark, 'options.highWaterMark', 0)\n highWaterMark += concurrency\n return async function* map() {\n const signal = require('../../ours/util').AbortSignalAny(\n [options === null || options === undefined ? undefined : options.signal].filter(Boolean)\n )\n const stream = this\n const queue = []\n const signalOpt = {\n signal\n }\n let next\n let resume\n let done = false\n let cnt = 0\n function onCatch() {\n done = true\n afterItemProcessed()\n }\n function afterItemProcessed() {\n cnt -= 1\n maybeResume()\n }\n function maybeResume() {\n if (resume && !done && cnt < concurrency && queue.length < highWaterMark) {\n resume()\n resume = null\n }\n }\n async function pump() {\n try {\n for await (let val of stream) {\n if (done) {\n return\n }\n if (signal.aborted) {\n throw new AbortError()\n }\n try {\n val = fn(val, signalOpt)\n if (val === kEmpty) {\n continue\n }\n val = PromiseResolve(val)\n } catch (err) {\n val = PromiseReject(err)\n }\n cnt += 1\n PromisePrototypeThen(val, afterItemProcessed, onCatch)\n queue.push(val)\n if (next) {\n next()\n next = null\n }\n if (!done && (queue.length >= highWaterMark || cnt >= concurrency)) {\n await new Promise((resolve) => {\n resume = resolve\n })\n }\n }\n queue.push(kEof)\n } catch (err) {\n const val = PromiseReject(err)\n PromisePrototypeThen(val, afterItemProcessed, onCatch)\n queue.push(val)\n } finally {\n done = true\n if (next) {\n next()\n next = null\n }\n }\n }\n pump()\n try {\n while (true) {\n while (queue.length > 0) {\n const val = await queue[0]\n if (val === kEof) {\n return\n }\n if (signal.aborted) {\n throw new AbortError()\n }\n if (val !== kEmpty) {\n yield val\n }\n queue.shift()\n maybeResume()\n }\n await new Promise((resolve) => {\n next = resolve\n })\n }\n } finally {\n done = true\n if (resume) {\n resume()\n resume = null\n }\n }\n }.call(this)\n}\nfunction asIndexedPairs(options = undefined) {\n if (options != null) {\n validateObject(options, 'options')\n }\n if ((options === null || options === undefined ? undefined : options.signal) != null) {\n validateAbortSignal(options.signal, 'options.signal')\n }\n return async function* asIndexedPairs() {\n let index = 0\n for await (const val of this) {\n var _options$signal\n if (\n options !== null &&\n options !== undefined &&\n (_options$signal = options.signal) !== null &&\n _options$signal !== undefined &&\n _options$signal.aborted\n ) {\n throw new AbortError({\n cause: options.signal.reason\n })\n }\n yield [index++, val]\n }\n }.call(this)\n}\nasync function some(fn, options = undefined) {\n for await (const unused of filter.call(this, fn, options)) {\n return true\n }\n return false\n}\nasync function every(fn, options = undefined) {\n if (typeof fn !== 'function') {\n throw new ERR_INVALID_ARG_TYPE('fn', ['Function', 'AsyncFunction'], fn)\n }\n // https://en.wikipedia.org/wiki/De_Morgan%27s_laws\n return !(await some.call(\n this,\n async (...args) => {\n return !(await fn(...args))\n },\n options\n ))\n}\nasync function find(fn, options) {\n for await (const result of filter.call(this, fn, options)) {\n return result\n }\n return undefined\n}\nasync function forEach(fn, options) {\n if (typeof fn !== 'function') {\n throw new ERR_INVALID_ARG_TYPE('fn', ['Function', 'AsyncFunction'], fn)\n }\n async function forEachFn(value, options) {\n await fn(value, options)\n return kEmpty\n }\n // eslint-disable-next-line no-unused-vars\n for await (const unused of map.call(this, forEachFn, options));\n}\nfunction filter(fn, options) {\n if (typeof fn !== 'function') {\n throw new ERR_INVALID_ARG_TYPE('fn', ['Function', 'AsyncFunction'], fn)\n }\n async function filterFn(value, options) {\n if (await fn(value, options)) {\n return value\n }\n return kEmpty\n }\n return map.call(this, filterFn, options)\n}\n\n// Specific to provide better error to reduce since the argument is only\n// missing if the stream has no items in it - but the code is still appropriate\nclass ReduceAwareErrMissingArgs extends ERR_MISSING_ARGS {\n constructor() {\n super('reduce')\n this.message = 'Reduce of an empty stream requires an initial value'\n }\n}\nasync function reduce(reducer, initialValue, options) {\n var _options$signal2\n if (typeof reducer !== 'function') {\n throw new ERR_INVALID_ARG_TYPE('reducer', ['Function', 'AsyncFunction'], reducer)\n }\n if (options != null) {\n validateObject(options, 'options')\n }\n if ((options === null || options === undefined ? undefined : options.signal) != null) {\n validateAbortSignal(options.signal, 'options.signal')\n }\n let hasInitialValue = arguments.length > 1\n if (\n options !== null &&\n options !== undefined &&\n (_options$signal2 = options.signal) !== null &&\n _options$signal2 !== undefined &&\n _options$signal2.aborted\n ) {\n const err = new AbortError(undefined, {\n cause: options.signal.reason\n })\n this.once('error', () => {}) // The error is already propagated\n await finished(this.destroy(err))\n throw err\n }\n const ac = new AbortController()\n const signal = ac.signal\n if (options !== null && options !== undefined && options.signal) {\n const opts = {\n once: true,\n [kWeakHandler]: this,\n [kResistStopPropagation]: true\n }\n options.signal.addEventListener('abort', () => ac.abort(), opts)\n }\n let gotAnyItemFromStream = false\n try {\n for await (const value of this) {\n var _options$signal3\n gotAnyItemFromStream = true\n if (\n options !== null &&\n options !== undefined &&\n (_options$signal3 = options.signal) !== null &&\n _options$signal3 !== undefined &&\n _options$signal3.aborted\n ) {\n throw new AbortError()\n }\n if (!hasInitialValue) {\n initialValue = value\n hasInitialValue = true\n } else {\n initialValue = await reducer(initialValue, value, {\n signal\n })\n }\n }\n if (!gotAnyItemFromStream && !hasInitialValue) {\n throw new ReduceAwareErrMissingArgs()\n }\n } finally {\n ac.abort()\n }\n return initialValue\n}\nasync function toArray(options) {\n if (options != null) {\n validateObject(options, 'options')\n }\n if ((options === null || options === undefined ? undefined : options.signal) != null) {\n validateAbortSignal(options.signal, 'options.signal')\n }\n const result = []\n for await (const val of this) {\n var _options$signal4\n if (\n options !== null &&\n options !== undefined &&\n (_options$signal4 = options.signal) !== null &&\n _options$signal4 !== undefined &&\n _options$signal4.aborted\n ) {\n throw new AbortError(undefined, {\n cause: options.signal.reason\n })\n }\n ArrayPrototypePush(result, val)\n }\n return result\n}\nfunction flatMap(fn, options) {\n const values = map.call(this, fn, options)\n return async function* flatMap() {\n for await (const val of values) {\n yield* val\n }\n }.call(this)\n}\nfunction toIntegerOrInfinity(number) {\n // We coerce here to align with the spec\n // https://github.com/tc39/proposal-iterator-helpers/issues/169\n number = Number(number)\n if (NumberIsNaN(number)) {\n return 0\n }\n if (number < 0) {\n throw new ERR_OUT_OF_RANGE('number', '>= 0', number)\n }\n return number\n}\nfunction drop(number, options = undefined) {\n if (options != null) {\n validateObject(options, 'options')\n }\n if ((options === null || options === undefined ? undefined : options.signal) != null) {\n validateAbortSignal(options.signal, 'options.signal')\n }\n number = toIntegerOrInfinity(number)\n return async function* drop() {\n var _options$signal5\n if (\n options !== null &&\n options !== undefined &&\n (_options$signal5 = options.signal) !== null &&\n _options$signal5 !== undefined &&\n _options$signal5.aborted\n ) {\n throw new AbortError()\n }\n for await (const val of this) {\n var _options$signal6\n if (\n options !== null &&\n options !== undefined &&\n (_options$signal6 = options.signal) !== null &&\n _options$signal6 !== undefined &&\n _options$signal6.aborted\n ) {\n throw new AbortError()\n }\n if (number-- <= 0) {\n yield val\n }\n }\n }.call(this)\n}\nfunction take(number, options = undefined) {\n if (options != null) {\n validateObject(options, 'options')\n }\n if ((options === null || options === undefined ? undefined : options.signal) != null) {\n validateAbortSignal(options.signal, 'options.signal')\n }\n number = toIntegerOrInfinity(number)\n return async function* take() {\n var _options$signal7\n if (\n options !== null &&\n options !== undefined &&\n (_options$signal7 = options.signal) !== null &&\n _options$signal7 !== undefined &&\n _options$signal7.aborted\n ) {\n throw new AbortError()\n }\n for await (const val of this) {\n var _options$signal8\n if (\n options !== null &&\n options !== undefined &&\n (_options$signal8 = options.signal) !== null &&\n _options$signal8 !== undefined &&\n _options$signal8.aborted\n ) {\n throw new AbortError()\n }\n if (number-- > 0) {\n yield val\n }\n\n // Don't get another item from iterator in case we reached the end\n if (number <= 0) {\n return\n }\n }\n }.call(this)\n}\nmodule.exports.streamReturningOperators = {\n asIndexedPairs: deprecate(asIndexedPairs, 'readable.asIndexedPairs will be removed in a future version.'),\n drop,\n filter,\n flatMap,\n map,\n take,\n compose\n}\nmodule.exports.promiseReturningOperators = {\n every,\n forEach,\n reduce,\n toArray,\n some,\n find\n}\n", "'use strict'\n\nconst { ArrayPrototypePop, Promise } = require('../ours/primordials')\nconst { isIterable, isNodeStream, isWebStream } = require('../internal/streams/utils')\nconst { pipelineImpl: pl } = require('../internal/streams/pipeline')\nconst { finished } = require('../internal/streams/end-of-stream')\nrequire('../../lib/stream.js')\nfunction pipeline(...streams) {\n return new Promise((resolve, reject) => {\n let signal\n let end\n const lastArg = streams[streams.length - 1]\n if (\n lastArg &&\n typeof lastArg === 'object' &&\n !isNodeStream(lastArg) &&\n !isIterable(lastArg) &&\n !isWebStream(lastArg)\n ) {\n const options = ArrayPrototypePop(streams)\n signal = options.signal\n end = options.end\n }\n pl(\n streams,\n (err, value) => {\n if (err) {\n reject(err)\n } else {\n resolve(value)\n }\n },\n {\n signal,\n end\n }\n )\n })\n}\nmodule.exports = {\n finished,\n pipeline\n}\n", "/* replacement start */\n\nconst { Buffer } = require('buffer')\n\n/* replacement end */\n// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n;('use strict')\nconst { ObjectDefineProperty, ObjectKeys, ReflectApply } = require('./ours/primordials')\nconst {\n promisify: { custom: customPromisify }\n} = require('./ours/util')\nconst { streamReturningOperators, promiseReturningOperators } = require('./internal/streams/operators')\nconst {\n codes: { ERR_ILLEGAL_CONSTRUCTOR }\n} = require('./ours/errors')\nconst compose = require('./internal/streams/compose')\nconst { setDefaultHighWaterMark, getDefaultHighWaterMark } = require('./internal/streams/state')\nconst { pipeline } = require('./internal/streams/pipeline')\nconst { destroyer } = require('./internal/streams/destroy')\nconst eos = require('./internal/streams/end-of-stream')\nconst internalBuffer = {}\nconst promises = require('./stream/promises')\nconst utils = require('./internal/streams/utils')\nconst Stream = (module.exports = require('./internal/streams/legacy').Stream)\nStream.isDestroyed = utils.isDestroyed\nStream.isDisturbed = utils.isDisturbed\nStream.isErrored = utils.isErrored\nStream.isReadable = utils.isReadable\nStream.isWritable = utils.isWritable\nStream.Readable = require('./internal/streams/readable')\nfor (const key of ObjectKeys(streamReturningOperators)) {\n const op = streamReturningOperators[key]\n function fn(...args) {\n if (new.target) {\n throw ERR_ILLEGAL_CONSTRUCTOR()\n }\n return Stream.Readable.from(ReflectApply(op, this, args))\n }\n ObjectDefineProperty(fn, 'name', {\n __proto__: null,\n value: op.name\n })\n ObjectDefineProperty(fn, 'length', {\n __proto__: null,\n value: op.length\n })\n ObjectDefineProperty(Stream.Readable.prototype, key, {\n __proto__: null,\n value: fn,\n enumerable: false,\n configurable: true,\n writable: true\n })\n}\nfor (const key of ObjectKeys(promiseReturningOperators)) {\n const op = promiseReturningOperators[key]\n function fn(...args) {\n if (new.target) {\n throw ERR_ILLEGAL_CONSTRUCTOR()\n }\n return ReflectApply(op, this, args)\n }\n ObjectDefineProperty(fn, 'name', {\n __proto__: null,\n value: op.name\n })\n ObjectDefineProperty(fn, 'length', {\n __proto__: null,\n value: op.length\n })\n ObjectDefineProperty(Stream.Readable.prototype, key, {\n __proto__: null,\n value: fn,\n enumerable: false,\n configurable: true,\n writable: true\n })\n}\nStream.Writable = require('./internal/streams/writable')\nStream.Duplex = require('./internal/streams/duplex')\nStream.Transform = require('./internal/streams/transform')\nStream.PassThrough = require('./internal/streams/passthrough')\nStream.pipeline = pipeline\nconst { addAbortSignal } = require('./internal/streams/add-abort-signal')\nStream.addAbortSignal = addAbortSignal\nStream.finished = eos\nStream.destroy = destroyer\nStream.compose = compose\nStream.setDefaultHighWaterMark = setDefaultHighWaterMark\nStream.getDefaultHighWaterMark = getDefaultHighWaterMark\nObjectDefineProperty(Stream, 'promises', {\n __proto__: null,\n configurable: true,\n enumerable: true,\n get() {\n return promises\n }\n})\nObjectDefineProperty(pipeline, customPromisify, {\n __proto__: null,\n enumerable: true,\n get() {\n return promises.pipeline\n }\n})\nObjectDefineProperty(eos, customPromisify, {\n __proto__: null,\n enumerable: true,\n get() {\n return promises.finished\n }\n})\n\n// Backwards-compat with node 0.4.x\nStream.Stream = Stream\nStream._isUint8Array = function isUint8Array(value) {\n return value instanceof Uint8Array\n}\nStream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) {\n return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength)\n}\n", "'use strict'\n\nconst CustomStream = require('../stream')\nconst promises = require('../stream/promises')\nconst originalDestroy = CustomStream.Readable.destroy\nmodule.exports = CustomStream.Readable\n\n// Explicit export naming is needed for ESM\nmodule.exports._uint8ArrayToBuffer = CustomStream._uint8ArrayToBuffer\nmodule.exports._isUint8Array = CustomStream._isUint8Array\nmodule.exports.isDisturbed = CustomStream.isDisturbed\nmodule.exports.isErrored = CustomStream.isErrored\nmodule.exports.isReadable = CustomStream.isReadable\nmodule.exports.Readable = CustomStream.Readable\nmodule.exports.Writable = CustomStream.Writable\nmodule.exports.Duplex = CustomStream.Duplex\nmodule.exports.Transform = CustomStream.Transform\nmodule.exports.PassThrough = CustomStream.PassThrough\nmodule.exports.addAbortSignal = CustomStream.addAbortSignal\nmodule.exports.finished = CustomStream.finished\nmodule.exports.destroy = CustomStream.destroy\nmodule.exports.destroy = originalDestroy\nmodule.exports.pipeline = CustomStream.pipeline\nmodule.exports.compose = CustomStream.compose\nObject.defineProperty(CustomStream, 'promises', {\n configurable: true,\n enumerable: true,\n get() {\n return promises\n }\n})\nmodule.exports.Stream = CustomStream.Stream\n\n// Allow default importing\nmodule.exports.default = module.exports\n", "/**\n * BrowserFS's main module. This is exposed in the browser via the BrowserFS global.\n */\n\nimport fs from './emulation/fs.js';\nimport { FileSystem, type NoArgCallback, type TwoArgCallback } from './filesystem.js';\nimport { backends } from './backends/index.js';\nimport { ErrorCode, ApiError } from './ApiError.js';\nimport { Cred } from './cred.js';\nimport type { BackendConstructor } from './backends/backend.js';\nimport { type MountMapping, setCred } from './emulation/shared.js';\n\n/**\n * Initializes BrowserFS with the given file systems.\n */\nexport function initialize(mounts: { [point: string]: FileSystem }, uid: number = 0, gid: number = 0) {\n\tsetCred(new Cred(uid, gid, uid, gid, uid, gid));\n\treturn fs.initialize(mounts);\n}\n\n/**\n * Defines a mapping of mount points to their configurations\n */\nexport interface ConfigMapping {\n\t[mountPoint: string]: FileSystem | FileSystemConfiguration | keyof typeof backends;\n}\n\n/**\n * A configuration for BrowserFS\n */\nexport type Configuration = FileSystem | FileSystemConfiguration | ConfigMapping;\n\nasync function _configure(config: Configuration): Promise<void> {\n\tif ('fs' in config || config instanceof FileSystem) {\n\t\t// single FS\n\t\tconfig = { '/': config } as ConfigMapping;\n\t}\n\tfor (let [point, value] of Object.entries(config)) {\n\t\tif (typeof value == 'number') {\n\t\t\t//should never happen\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (value instanceof FileSystem) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof value == 'string') {\n\t\t\tvalue = { fs: value };\n\t\t}\n\n\t\tconfig[point] = await getFileSystem(value);\n\t}\n\treturn initialize(config as MountMapping);\n}\n\n/**\n * Creates a file system with the given configuration, and initializes BrowserFS with it.\n * See the FileSystemConfiguration type for more info on the configuration object.\n */\nexport function configure(config: Configuration): Promise<void>;\nexport function configure(config: Configuration, cb: NoArgCallback): void;\nexport function configure(config: Configuration, cb?: NoArgCallback): Promise<void> | void {\n\t// Promise version\n\tif (typeof cb != 'function') {\n\t\treturn _configure(config);\n\t}\n\n\t// Callback version\n\t_configure(config)\n\t\t.then(() => cb())\n\t\t.catch(err => cb(err));\n\treturn;\n}\n\n/**\n * Asynchronously creates a file system with the given configuration, and initializes BrowserFS with it.\n * See the FileSystemConfiguration type for more info on the configuration object.\n * Note: unlike configure, the .then is provided with the file system\n */\n\n/**\n * Specifies a file system backend type and its options.\n *\n * Individual options can recursively contain FileSystemConfiguration objects for\n * option values that require file systems.\n *\n * For example, to mirror Dropbox to Storage with AsyncMirror, use the following\n * object:\n *\n * ```javascript\n * var config = {\n * fs: \"AsyncMirror\",\n * options: {\n * sync: {fs: \"Storage\"},\n * async: {fs: \"Dropbox\", options: {client: anAuthenticatedDropboxSDKClient }}\n * }\n * };\n * ```\n *\n * The option object for each file system corresponds to that file system's option object passed to its `Create()` method.\n */\nexport interface FileSystemConfiguration {\n\tfs: string;\n\toptions?: object;\n}\n\nasync function _getFileSystem({ fs: fsName, options = {} }: FileSystemConfiguration): Promise<FileSystem> {\n\tif (!fsName) {\n\t\tthrow new ApiError(ErrorCode.EPERM, 'Missing \"fs\" property on configuration object.');\n\t}\n\n\tif (typeof options !== 'object' || options === null) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid \"options\" property on configuration object.');\n\t}\n\n\tconst props = Object.keys(options).filter(k => k != 'fs');\n\n\tfor (const prop of props) {\n\t\tconst opt = options[prop];\n\t\tif (opt === null || typeof opt !== 'object' || !('fs' in opt)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst fs = await _getFileSystem(opt);\n\t\toptions[prop] = fs;\n\t}\n\n\tconst fsc = <BackendConstructor | undefined>(<any>backends)[fsName];\n\tif (!fsc) {\n\t\tthrow new ApiError(ErrorCode.EPERM, `File system ${fsName} is not available in BrowserFS.`);\n\t} else {\n\t\treturn fsc.Create(options);\n\t}\n}\n\n/**\n * Retrieve a file system with the given configuration. Will return a promise if invoked without a callback\n * @param config A FileSystemConfiguration object. See FileSystemConfiguration for details.\n * @param cb Called when the file system is constructed, or when an error occurs.\n */\nexport function getFileSystem(config: FileSystemConfiguration): Promise<FileSystem>;\nexport function getFileSystem(config: FileSystemConfiguration, cb: TwoArgCallback<FileSystem>): void;\nexport function getFileSystem(config: FileSystemConfiguration, cb?: TwoArgCallback<FileSystem>): Promise<FileSystem> | void {\n\t// Promise version\n\tif (typeof cb != 'function') {\n\t\treturn _getFileSystem(config);\n\t}\n\n\t// Callback version\n\t_getFileSystem(config)\n\t\t.then(fs => cb(null, fs))\n\t\t.catch(err => cb(err));\n\treturn;\n}\n\nexport * from './backends/index.js';\nexport * from './backends/AsyncStore.js';\nexport * from './backends/SyncStore.js';\nexport * from './ApiError.js';\nexport * from './cred.js';\nexport * from './FileIndex.js';\nexport * from './file.js';\nexport * from './filesystem.js';\nexport * from './inode.js';\nexport * from './mutex.js';\nexport * from './stats.js';\nexport * from './utils.js';\nexport { fs };\nexport default fs;\n", "export * from './callbacks.js';\nexport * from './sync.js';\nexport * as promises from './promises.js';\nexport * as constants from './constants.js';\nexport * from './streams.js';\nexport * from './dir.js';\nexport { initialize, getMount, getMounts, mount, umount, _toUnixTimestamp } from './shared.js';\nexport { Stats, BigIntStats } from '../stats.js';\n", "/*\nCopyright Joyent, Inc. and other Node contributors.\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the\nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\nNO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\nDAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n/*\nThis is the POSIX path code of NodeJS\nhttps://raw.githubusercontent.com/nodejs/node/3907bd1/lib/path.js \n*/\n\nimport type { ParsedPath } from 'node:path';\n\nexport const cwd = '/';\n\nexport const sep = '/';\n\nfunction validateString(str: unknown, name: string): void {\n\tif (typeof str != 'string') {\n\t\tthrow new TypeError(`\"${name}\" is not a string`);\n\t}\n}\n\nfunction validateObject(str: unknown, name: string): void {\n\tif (typeof str != 'object') {\n\t\tthrow new TypeError(`\"${name}\" is not an object`);\n\t}\n}\n\n// Resolves . and .. elements in a path with directory names\nexport function normalizeString(path: string, allowAboveRoot: boolean): string {\n\tlet res = '';\n\tlet lastSegmentLength = 0;\n\tlet lastSlash = -1;\n\tlet dots = 0;\n\tlet char = '\\x00';\n\tfor (let i = 0; i <= path.length; ++i) {\n\t\tif (i < path.length) {\n\t\t\tchar = path[i];\n\t\t} else if (char == '/') {\n\t\t\tbreak;\n\t\t} else {\n\t\t\tchar = '/';\n\t\t}\n\n\t\tif (char == '/') {\n\t\t\tif (lastSlash === i - 1 || dots === 1) {\n\t\t\t\t// NOOP\n\t\t\t} else if (dots === 2) {\n\t\t\t\tif (res.length < 2 || lastSegmentLength !== 2 || res.at(-1) !== '.' || res.at(-2) !== '.') {\n\t\t\t\t\tif (res.length > 2) {\n\t\t\t\t\t\tconst lastSlashIndex = res.lastIndexOf('/');\n\t\t\t\t\t\tif (lastSlashIndex === -1) {\n\t\t\t\t\t\t\tres = '';\n\t\t\t\t\t\t\tlastSegmentLength = 0;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tres = res.slice(0, lastSlashIndex);\n\t\t\t\t\t\t\tlastSegmentLength = res.length - 1 - res.lastIndexOf('/');\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlastSlash = i;\n\t\t\t\t\t\tdots = 0;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (res.length !== 0) {\n\t\t\t\t\t\tres = '';\n\t\t\t\t\t\tlastSegmentLength = 0;\n\t\t\t\t\t\tlastSlash = i;\n\t\t\t\t\t\tdots = 0;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (allowAboveRoot) {\n\t\t\t\t\tres += res.length > 0 ? '/..' : '..';\n\t\t\t\t\tlastSegmentLength = 2;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (res.length > 0) res += '/' + path.slice(lastSlash + 1, i);\n\t\t\t\telse res = path.slice(lastSlash + 1, i);\n\t\t\t\tlastSegmentLength = i - lastSlash - 1;\n\t\t\t}\n\t\t\tlastSlash = i;\n\t\t\tdots = 0;\n\t\t} else if (char === '.' && dots !== -1) {\n\t\t\t++dots;\n\t\t} else {\n\t\t\tdots = -1;\n\t\t}\n\t}\n\treturn res;\n}\n\nexport function formatExt(ext: string): string {\n\treturn ext ? `${ext[0] === '.' ? '' : '.'}${ext}` : '';\n}\n\nexport function resolve(...args: string[]): string {\n\tlet resolvedPath = '';\n\tlet resolvedAbsolute = false;\n\n\tfor (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n\t\tconst path = i >= 0 ? args[i] : cwd;\n\t\tvalidateString(path, `paths[${i}]`);\n\n\t\t// Skip empty entries\n\t\tif (path.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tresolvedPath = `${path}/${resolvedPath}`;\n\t\tresolvedAbsolute = path[0] === '/';\n\t}\n\n\t// At this point the path should be resolved to a full absolute path, but\n\t// handle relative paths to be safe (might happen when process.cwd() fails)\n\n\t// Normalize the path\n\tresolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);\n\n\tif (resolvedAbsolute) {\n\t\treturn `/${resolvedPath}`;\n\t}\n\treturn resolvedPath.length > 0 ? resolvedPath : '.';\n}\n\nexport function normalize(path: string): string {\n\tvalidateString(path, 'path');\n\n\tif (path.length === 0) return '.';\n\n\tconst isAbsolute = path[0] === '/';\n\tconst trailingSeparator = path.at(-1) === '/';\n\n\t// Normalize the path\n\tpath = normalizeString(path, !isAbsolute);\n\n\tif (path.length === 0) {\n\t\tif (isAbsolute) return '/';\n\t\treturn trailingSeparator ? './' : '.';\n\t}\n\tif (trailingSeparator) path += '/';\n\n\treturn isAbsolute ? `/${path}` : path;\n}\n\nexport function isAbsolute(path: string): boolean {\n\tvalidateString(path, 'path');\n\treturn path.length > 0 && path[0] === '/';\n}\n\nexport function join(...args: string[]): string {\n\tif (args.length === 0) return '.';\n\tlet joined;\n\tfor (let i = 0; i < args.length; ++i) {\n\t\tconst arg = args[i];\n\t\tvalidateString(arg, 'path');\n\t\tif (arg.length > 0) {\n\t\t\tif (joined === undefined) joined = arg;\n\t\t\telse joined += `/${arg}`;\n\t\t}\n\t}\n\tif (joined === undefined) return '.';\n\treturn normalize(joined);\n}\n\nexport function relative(from: string, to: string) {\n\tvalidateString(from, 'from');\n\tvalidateString(to, 'to');\n\n\tif (from === to) return '';\n\n\t// Trim leading forward slashes.\n\tfrom = resolve(from);\n\tto = resolve(to);\n\n\tif (from === to) return '';\n\n\tconst fromStart = 1;\n\tconst fromEnd = from.length;\n\tconst fromLen = fromEnd - fromStart;\n\tconst toStart = 1;\n\tconst toLen = to.length - toStart;\n\n\t// Compare paths to find the longest common path from root\n\tconst length = fromLen < toLen ? fromLen : toLen;\n\tlet lastCommonSep = -1;\n\tlet i = 0;\n\tfor (; i < length; i++) {\n\t\tconst fromCode = from[fromStart + i];\n\t\tif (fromCode !== to[toStart + i]) break;\n\t\telse if (fromCode === '/') lastCommonSep = i;\n\t}\n\tif (i === length) {\n\t\tif (toLen > length) {\n\t\t\tif (to[toStart + i] === '/') {\n\t\t\t\t// We get here if `from` is the exact base path for `to`.\n\t\t\t\t// For example: from='/foo/bar'; to='/foo/bar/baz'\n\t\t\t\treturn to.slice(toStart + i + 1);\n\t\t\t}\n\t\t\tif (i === 0) {\n\t\t\t\t// We get here if `from` is the root\n\t\t\t\t// For example: from='/'; to='/foo'\n\t\t\t\treturn to.slice(toStart + i);\n\t\t\t}\n\t\t} else if (fromLen > length) {\n\t\t\tif (from[fromStart + i] === '/') {\n\t\t\t\t// We get here if `to` is the exact base path for `from`.\n\t\t\t\t// For example: from='/foo/bar/baz'; to='/foo/bar'\n\t\t\t\tlastCommonSep = i;\n\t\t\t} else if (i === 0) {\n\t\t\t\t// We get here if `to` is the root.\n\t\t\t\t// For example: from='/foo/bar'; to='/'\n\t\t\t\tlastCommonSep = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tlet out = '';\n\t// Generate the relative path based on the path difference between `to`\n\t// and `from`.\n\tfor (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {\n\t\tif (i === fromEnd || from[i] === '/') {\n\t\t\tout += out.length === 0 ? '..' : '/..';\n\t\t}\n\t}\n\n\t// Lastly, append the rest of the destination (`to`) path that comes after\n\t// the common path parts.\n\treturn `${out}${to.slice(toStart + lastCommonSep)}`;\n}\n\nexport function dirname(path: string): string {\n\tvalidateString(path, 'path');\n\tif (path.length === 0) return '.';\n\tconst hasRoot = path[0] === '/';\n\tlet end = -1;\n\tlet matchedSlash = true;\n\tfor (let i = path.length - 1; i >= 1; --i) {\n\t\tif (path[i] === '/') {\n\t\t\tif (!matchedSlash) {\n\t\t\t\tend = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\t// We saw the first non-path separator\n\t\t\tmatchedSlash = false;\n\t\t}\n\t}\n\n\tif (end === -1) return hasRoot ? '/' : '.';\n\tif (hasRoot && end === 1) return '//';\n\treturn path.slice(0, end);\n}\n\nexport function basename(path: string, suffix?: string): string {\n\tif (suffix !== undefined) validateString(suffix, 'ext');\n\tvalidateString(path, 'path');\n\n\tlet start = 0;\n\tlet end = -1;\n\tlet matchedSlash = true;\n\n\tif (suffix !== undefined && suffix.length > 0 && suffix.length <= path.length) {\n\t\tif (suffix === path) return '';\n\t\tlet extIdx = suffix.length - 1;\n\t\tlet firstNonSlashEnd = -1;\n\t\tfor (let i = path.length - 1; i >= 0; --i) {\n\t\t\tif (path[i] === '/') {\n\t\t\t\t// If we reached a path separator that was not part of a set of path\n\t\t\t\t// separators at the end of the string, stop now\n\t\t\t\tif (!matchedSlash) {\n\t\t\t\t\tstart = i + 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (firstNonSlashEnd === -1) {\n\t\t\t\t\t// We saw the first non-path separator, remember this index in case\n\t\t\t\t\t// we need it if the extension ends up not matching\n\t\t\t\t\tmatchedSlash = false;\n\t\t\t\t\tfirstNonSlashEnd = i + 1;\n\t\t\t\t}\n\t\t\t\tif (extIdx >= 0) {\n\t\t\t\t\t// Try to match the explicit extension\n\t\t\t\t\tif (path[i] === suffix[extIdx]) {\n\t\t\t\t\t\tif (--extIdx === -1) {\n\t\t\t\t\t\t\t// We matched the extension, so mark this as the end of our path\n\t\t\t\t\t\t\t// component\n\t\t\t\t\t\t\tend = i;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Extension does not match, so our result is the entire path\n\t\t\t\t\t\t// component\n\t\t\t\t\t\textIdx = -1;\n\t\t\t\t\t\tend = firstNonSlashEnd;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (start === end) end = firstNonSlashEnd;\n\t\telse if (end === -1) end = path.length;\n\t\treturn path.slice(start, end);\n\t}\n\tfor (let i = path.length - 1; i >= 0; --i) {\n\t\tif (path[i] === '/') {\n\t\t\t// If we reached a path separator that was not part of a set of path\n\t\t\t// separators at the end of the string, stop now\n\t\t\tif (!matchedSlash) {\n\t\t\t\tstart = i + 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else if (end === -1) {\n\t\t\t// We saw the first non-path separator, mark this as the end of our\n\t\t\t// path component\n\t\t\tmatchedSlash = false;\n\t\t\tend = i + 1;\n\t\t}\n\t}\n\n\tif (end === -1) return '';\n\treturn path.slice(start, end);\n}\n\nexport function extname(path: string): string {\n\tvalidateString(path, 'path');\n\tlet startDot = -1;\n\tlet startPart = 0;\n\tlet end = -1;\n\tlet matchedSlash = true;\n\t// Track the state of characters (if any) we see before our first dot and\n\t// after any path separator we find\n\tlet preDotState = 0;\n\tfor (let i = path.length - 1; i >= 0; --i) {\n\t\tif (path[i] === '/') {\n\t\t\t// If we reached a path separator that was not part of a set of path\n\t\t\t// separators at the end of the string, stop now\n\t\t\tif (!matchedSlash) {\n\t\t\t\tstartPart = i + 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (end === -1) {\n\t\t\t// We saw the first non-path separator, mark this as the end of our\n\t\t\t// extension\n\t\t\tmatchedSlash = false;\n\t\t\tend = i + 1;\n\t\t}\n\t\tif (path[i] === '.') {\n\t\t\t// If this is our first dot, mark it as the start of our extension\n\t\t\tif (startDot === -1) startDot = i;\n\t\t\telse if (preDotState !== 1) preDotState = 1;\n\t\t} else if (startDot !== -1) {\n\t\t\t// We saw a non-dot and non-path separator before our dot, so we should\n\t\t\t// have a good chance at having a non-empty extension\n\t\t\tpreDotState = -1;\n\t\t}\n\t}\n\n\tif (\n\t\tstartDot === -1 ||\n\t\tend === -1 ||\n\t\t// We saw a non-dot character immediately before the dot\n\t\tpreDotState === 0 ||\n\t\t// The (right-most) trimmed path component is exactly '..'\n\t\t(preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)\n\t) {\n\t\treturn '';\n\t}\n\treturn path.slice(startDot, end);\n}\n\nexport function format(pathObject: ParsedPath): string {\n\tvalidateObject(pathObject, 'pathObject');\n\tconst dir = pathObject.dir || pathObject.root;\n\tconst base = pathObject.base || `${pathObject.name || ''}${formatExt(pathObject.ext)}`;\n\tif (!dir) {\n\t\treturn base;\n\t}\n\treturn dir === pathObject.root ? `${dir}${base}` : `${dir}/${base}`;\n}\n\nexport function parse(path: string): ParsedPath {\n\tvalidateString(path, 'path');\n\tconst isAbsolute = path[0] === '/';\n\tconst ret = { root: isAbsolute ? '/' : '', dir: '', base: '', ext: '', name: '' };\n\tif (path.length === 0) return ret;\n\n\tconst start = isAbsolute ? 1 : 0;\n\tlet startDot = -1;\n\tlet startPart = 0;\n\tlet end = -1;\n\tlet matchedSlash = true;\n\tlet i = path.length - 1;\n\n\t// Track the state of characters (if any) we see before our first dot and\n\t// after any path separator we find\n\tlet preDotState = 0;\n\n\t// Get non-dir info\n\tfor (; i >= start; --i) {\n\t\tif (path[i] === '/') {\n\t\t\t// If we reached a path separator that was not part of a set of path\n\t\t\t// separators at the end of the string, stop now\n\t\t\tif (!matchedSlash) {\n\t\t\t\tstartPart = i + 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (end === -1) {\n\t\t\t// We saw the first non-path separator, mark this as the end of our\n\t\t\t// extension\n\t\t\tmatchedSlash = false;\n\t\t\tend = i + 1;\n\t\t}\n\t\tif (path[i] === '.') {\n\t\t\t// If this is our first dot, mark it as the start of our extension\n\t\t\tif (startDot === -1) startDot = i;\n\t\t\telse if (preDotState !== 1) preDotState = 1;\n\t\t} else if (startDot !== -1) {\n\t\t\t// We saw a non-dot and non-path separator before our dot, so we should\n\t\t\t// have a good chance at having a non-empty extension\n\t\t\tpreDotState = -1;\n\t\t}\n\t}\n\n\tif (end !== -1) {\n\t\tconst start = startPart === 0 && isAbsolute ? 1 : startPart;\n\t\tif (\n\t\t\tstartDot === -1 ||\n\t\t\t// We saw a non-dot character immediately before the dot\n\t\t\tpreDotState === 0 ||\n\t\t\t// The (right-most) trimmed path component is exactly '..'\n\t\t\t(preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)\n\t\t) {\n\t\t\tret.base = ret.name = path.slice(start, end);\n\t\t} else {\n\t\t\tret.name = path.slice(start, startDot);\n\t\t\tret.base = path.slice(start, end);\n\t\t\tret.ext = path.slice(startDot, end);\n\t\t}\n\t}\n\n\tif (startPart > 0) ret.dir = path.slice(0, startPart - 1);\n\telse if (isAbsolute) ret.dir = '/';\n\n\treturn ret;\n}\n", "/**\n * Grab bag of utility functions used across the code.\n */\nimport { FileSystem } from './filesystem.js';\nimport { ErrorCode, ApiError } from './ApiError.js';\nimport * as path from './emulation/path.js';\nimport { Cred } from './cred.js';\nimport type { BaseBackendConstructor } from './backends/backend.js';\n\ndeclare const globalThis: {\n\tsetImmediate?: (callback: () => unknown) => void;\n};\ndeclare global {\n\texport const { TextEncoder, TextDecoder }: typeof import('node:util');\n\texport const { atob, btoa }: typeof import('b2a');\n}\n\n/**\n * Synchronous recursive makedir.\n * @internal\n */\nexport function mkdirpSync(p: string, mode: number, cred: Cred, fs: FileSystem): void {\n\tif (!fs.existsSync(p, cred)) {\n\t\tmkdirpSync(path.dirname(p), mode, cred, fs);\n\t\tfs.mkdirSync(p, mode, cred);\n\t}\n}\n\n/*\n * Levenshtein distance, from the `js-levenshtein` NPM module.\n * Copied here to avoid complexity of adding another CommonJS module dependency.\n */\n\nfunction _min(d0: number, d1: number, d2: number, bx: number, ay: number): number {\n\treturn Math.min(d0 + 1, d1 + 1, d2 + 1, bx === ay ? d1 : d1 + 1);\n}\n\n/**\n * Calculates levenshtein distance.\n * @param a\n * @param b\n */\nfunction levenshtein(a: string, b: string): number {\n\tif (a === b) {\n\t\treturn 0;\n\t}\n\n\tif (a.length > b.length) {\n\t\t[a, b] = [b, a]; // Swap a and b\n\t}\n\n\tlet la = a.length;\n\tlet lb = b.length;\n\n\t// Trim common suffix\n\twhile (la > 0 && a.charCodeAt(la - 1) === b.charCodeAt(lb - 1)) {\n\t\tla--;\n\t\tlb--;\n\t}\n\n\tlet offset = 0;\n\n\t// Trim common prefix\n\twhile (offset < la && a.charCodeAt(offset) === b.charCodeAt(offset)) {\n\t\toffset++;\n\t}\n\n\tla -= offset;\n\tlb -= offset;\n\n\tif (la === 0 || lb === 1) {\n\t\treturn lb;\n\t}\n\n\tconst vector = new Array<number>(la << 1);\n\n\tfor (let y = 0; y < la; ) {\n\t\tvector[la + y] = a.charCodeAt(offset + y);\n\t\tvector[y] = ++y;\n\t}\n\n\tlet x: number;\n\tlet d0: number;\n\tlet d1: number;\n\tlet d2: number;\n\tlet d3: number;\n\tfor (x = 0; x + 3 < lb; ) {\n\t\tconst bx0 = b.charCodeAt(offset + (d0 = x));\n\t\tconst bx1 = b.charCodeAt(offset + (d1 = x + 1));\n\t\tconst bx2 = b.charCodeAt(offset + (d2 = x + 2));\n\t\tconst bx3 = b.charCodeAt(offset + (d3 = x + 3));\n\t\tlet dd = (x += 4);\n\t\tfor (let y = 0; y < la; ) {\n\t\t\tconst ay = vector[la + y];\n\t\t\tconst dy = vector[y];\n\t\t\td0 = _min(dy, d0, d1, bx0, ay);\n\t\t\td1 = _min(d0, d1, d2, bx1, ay);\n\t\t\td2 = _min(d1, d2, d3, bx2, ay);\n\t\t\tdd = _min(d2, d3, dd, bx3, ay);\n\t\t\tvector[y++] = dd;\n\t\t\td3 = d2;\n\t\t\td2 = d1;\n\t\t\td1 = d0;\n\t\t\td0 = dy;\n\t\t}\n\t}\n\n\tlet dd: number = 0;\n\tfor (; x < lb; ) {\n\t\tconst bx0 = b.charCodeAt(offset + (d0 = x));\n\t\tdd = ++x;\n\t\tfor (let y = 0; y < la; y++) {\n\t\t\tconst dy = vector[y];\n\t\t\tvector[y] = dd = dy < d0 || dd < d0 ? (dy > dd ? dd + 1 : dy + 1) : bx0 === vector[la + y] ? d0 : d0 + 1;\n\t\t\td0 = dy;\n\t\t}\n\t}\n\n\treturn dd;\n}\n\n/**\n * Checks that the given options object is valid for the file system options.\n * @internal\n */\nexport async function checkOptions(backend: BaseBackendConstructor, opts: object): Promise<void> {\n\tconst optsInfo = backend.Options;\n\tconst fsName = backend.Name;\n\n\tlet pendingValidators = 0;\n\tlet callbackCalled = false;\n\tlet loopEnded = false;\n\n\t// Check for required options.\n\tfor (const optName in optsInfo) {\n\t\tif (Object.prototype.hasOwnProperty.call(optsInfo, optName)) {\n\t\t\tconst opt = optsInfo[optName];\n\t\t\tconst providedValue = opts && opts[optName];\n\n\t\t\tif (providedValue === undefined || providedValue === null) {\n\t\t\t\tif (!opt.optional) {\n\t\t\t\t\t// Required option, not provided.\n\t\t\t\t\t// Any incorrect options provided? Which ones are close to the provided one?\n\t\t\t\t\t// (edit distance 5 === close)\n\t\t\t\t\tconst incorrectOptions = Object.keys(opts)\n\t\t\t\t\t\t.filter(o => !(o in optsInfo))\n\t\t\t\t\t\t.map((a: string) => {\n\t\t\t\t\t\t\treturn { str: a, distance: levenshtein(optName, a) };\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter(o => o.distance < 5)\n\t\t\t\t\t\t.sort((a, b) => a.distance - b.distance);\n\t\t\t\t\t// Validators may be synchronous.\n\t\t\t\t\tif (callbackCalled) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcallbackCalled = true;\n\t\t\t\t\tthrow new ApiError(\n\t\t\t\t\t\tErrorCode.EINVAL,\n\t\t\t\t\t\t`[${fsName}] Required option '${optName}' not provided.${\n\t\t\t\t\t\t\tincorrectOptions.length > 0 ? ` You provided unrecognized option '${incorrectOptions[0].str}'; perhaps you meant to type '${optName}'.` : ''\n\t\t\t\t\t\t}\\nOption description: ${opt.description}`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// Else: Optional option, not provided. That is OK.\n\t\t\t} else {\n\t\t\t\t// Option provided! Check type.\n\t\t\t\tlet typeMatches = false;\n\t\t\t\tif (Array.isArray(opt.type)) {\n\t\t\t\t\ttypeMatches = opt.type.indexOf(typeof providedValue) !== -1;\n\t\t\t\t} else {\n\t\t\t\t\ttypeMatches = typeof providedValue === opt.type;\n\t\t\t\t}\n\t\t\t\tif (!typeMatches) {\n\t\t\t\t\t// Validators may be synchronous.\n\t\t\t\t\tif (callbackCalled) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcallbackCalled = true;\n\t\t\t\t\tthrow new ApiError(\n\t\t\t\t\t\tErrorCode.EINVAL,\n\t\t\t\t\t\t`[${fsName}] Value provided for option ${optName} is not the proper type. Expected ${\n\t\t\t\t\t\t\tArray.isArray(opt.type) ? `one of {${opt.type.join(', ')}}` : opt.type\n\t\t\t\t\t\t}, but received ${typeof providedValue}\\nOption description: ${opt.description}`\n\t\t\t\t\t);\n\t\t\t\t} else if (opt.validator) {\n\t\t\t\t\tpendingValidators++;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait opt.validator(providedValue);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tif (!callbackCalled) {\n\t\t\t\t\t\t\tif (e) {\n\t\t\t\t\t\t\t\tcallbackCalled = true;\n\t\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tpendingValidators--;\n\t\t\t\t\t\t\tif (pendingValidators === 0 && loopEnded) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Otherwise: All good!\n\t\t\t}\n\t\t}\n\t}\n\tloopEnded = true;\n\tif (pendingValidators === 0 && !callbackCalled) {\n\t\treturn;\n\t}\n}\n\n/** Waits n ms. */\nexport function wait(ms: number): Promise<void> {\n\treturn new Promise(resolve => {\n\t\tsetTimeout(resolve, ms);\n\t});\n}\n\n/**\n * Converts a callback into a promise. Assumes last parameter is the callback\n * @todo Look at changing resolve value from cbArgs[0] to include other callback arguments?\n */\nexport function toPromise(fn: (...fnArgs: unknown[]) => unknown) {\n\treturn function (...args: unknown[]): Promise<unknown> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\targs.push((e: ApiError, ...cbArgs: unknown[]) => {\n\t\t\t\tif (e) {\n\t\t\t\t\treject(e);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(cbArgs[0]);\n\t\t\t\t}\n\t\t\t});\n\t\t\tfn(...args);\n\t\t});\n\t};\n}\n\n/**\n * @internal\n */\nexport const setImmediate = typeof globalThis.setImmediate == 'function' ? globalThis.setImmediate : cb => setTimeout(cb, 0);\n\n/**\n * @internal\n */\nexport const ROOT_NODE_ID: string = '/';\n\n// prettier-ignore\nexport function encode(\n string?: string,\n encoding: BufferEncoding|'utf-16le' = 'utf8'\n): Uint8Array\n{\n\tlet input = string || '';\n\tswitch (encoding) {\n\t\tdefault:\n\t\tcase 'utf8':\n\t\tcase 'utf-8':\n\t\t\treturn new TextEncoder().encode(input);\n\n\t\tcase 'utf16le':\n\t\tcase 'utf-16le':\n\t\tcase 'ucs2':\n\t\tcase 'ucs-2':\n return new Uint8Array(Uint16Array.from(\n input.split(''), (c: string) => c.charCodeAt(0)\n ).buffer);\n\n\t\tcase 'ascii':\n\t\tcase 'latin1':\n\t\tcase 'binary':\n return Uint8Array.from(\n input.split(''), (c: string) => c.charCodeAt(0)\n );\n\n\t\tcase 'hex':\n return Uint8Array.from(\n input.match(/../g), (s: string)=> parseInt(s, 16)\n );\n\n\t\tcase 'base64':\n\t\tcase 'base64url':\n\t\t\tinput = input.replaceAll('-', '+').replaceAll('_', '/');\n return Uint8Array.from(\n atob(input).split(''), (c: string) => c.charCodeAt(0)\n );\n\t}\n}\n\n// prettier-ignore\nexport function decode(\n data?: ArrayBufferView | ArrayBuffer,\n encoding: BufferEncoding|'utf-16le' = 'utf8'\n): string\n{\n\tif (!data || !data.byteLength) return '';\n\tconst input = new Uint8Array('buffer' in data ? data.buffer : data);\n\tswitch (encoding) {\n\t\tdefault:\n\t\tcase 'utf8':\n\t\tcase 'utf-8':\n\t\t\treturn new TextDecoder('utf-8').decode(input);\n\n\t\tcase 'utf16le':\n\t\tcase 'utf-16le':\n\t\tcase 'ucs2':\n\t\tcase 'ucs-2':\n\t\t\treturn new TextDecoder('utf-16le').decode(input);\n\n\t\tcase 'ascii':\n return new TextDecoder('utf-8').decode(\n input.map(i => i & 127)\n );\n\n\t\tcase 'latin1':\n\t\tcase 'binary':\n return new TextDecoder('utf-16').decode(\n new Uint8Array(Uint16Array.from(input).buffer)\n );\n\n\t\tcase 'hex':\n return Array.from(input,\n i => i.toString(16).padStart(2,'0')\n ).join('');\n\n\t\tcase 'base64':\n return btoa(new TextDecoder('utf-16').decode(\n new Uint8Array(Uint16Array.from(input).buffer)\n ));\n\t\tcase 'base64url':\n return btoa(new TextDecoder('utf-16').decode(\n new Uint8Array(Uint16Array.from(input).buffer)\n )).replaceAll('+','-').replaceAll('/','_').replaceAll('=','');\n \n\t}\n}\n\n/**\n * Generates a random ID.\n * @internal\n */\nexport function randomUUID(): string {\n\t// From http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript\n\treturn 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n\t\tconst r = (Math.random() * 16) | 0;\n\t\tconst v = c === 'x' ? r : (r & 0x3) | 0x8;\n\t\treturn v.toString(16);\n\t});\n}\n", "import { decode, encode } from './utils.js';\n\n/**\n * Standard libc error codes. More will be added to this enum and ErrorStrings as they are\n * needed.\n * @url http://www.gnu.org/software/libc/manual/html_node/Error-Codes.html\n */\nexport enum ErrorCode {\n\tEPERM = 1,\n\tENOENT = 2,\n\tEIO = 5,\n\tEBADF = 9,\n\tEACCES = 13,\n\tEBUSY = 16,\n\tEEXIST = 17,\n\tENOTDIR = 20,\n\tEISDIR = 21,\n\tEINVAL = 22,\n\tEFBIG = 27,\n\tENOSPC = 28,\n\tEROFS = 30,\n\tENOTEMPTY = 39,\n\tENOTSUP = 95,\n}\n\n/**\n * Strings associated with each error code.\n * @internal\n */\nexport const ErrorStrings: { [code in ErrorCode]: string } = {\n\t[ErrorCode.EPERM]: 'Operation not permitted.',\n\t[ErrorCode.ENOENT]: 'No such file or directory.',\n\t[ErrorCode.EIO]: 'Input/output error.',\n\t[ErrorCode.EBADF]: 'Bad file descriptor.',\n\t[ErrorCode.EACCES]: 'Permission denied.',\n\t[ErrorCode.EBUSY]: 'Resource busy or locked.',\n\t[ErrorCode.EEXIST]: 'File exists.',\n\t[ErrorCode.ENOTDIR]: 'File is not a directory.',\n\t[ErrorCode.EISDIR]: 'File is a directory.',\n\t[ErrorCode.EINVAL]: 'Invalid argument.',\n\t[ErrorCode.EFBIG]: 'File is too big.',\n\t[ErrorCode.ENOSPC]: 'No space left on disk.',\n\t[ErrorCode.EROFS]: 'Cannot modify a read-only file system.',\n\t[ErrorCode.ENOTEMPTY]: 'Directory is not empty.',\n\t[ErrorCode.ENOTSUP]: 'Operation is not supported.',\n};\n\ninterface ApiErrorJSON {\n\terrno: ErrorCode;\n\tmessage: string;\n\tpath: string;\n\tcode: string;\n\tstack: string;\n}\n\n/**\n * Represents a BrowserFS error. Passed back to applications after a failed\n * call to the BrowserFS API.\n */\nexport class ApiError extends Error implements NodeJS.ErrnoException {\n\tpublic static fromJSON(json: ApiErrorJSON): ApiError {\n\t\tconst err = new ApiError(json.errno, json.message, json.path);\n\t\terr.code = json.code;\n\t\terr.stack = json.stack;\n\t\treturn err;\n\t}\n\n\t/**\n\t * Creates an ApiError object from a buffer.\n\t */\n\tpublic static Derserialize(data: ArrayBufferLike | ArrayBufferView, i: number = 0): ApiError {\n\t\tconst view = new DataView('buffer' in data ? data.buffer : data);\n\t\tconst dataText = decode(view.buffer.slice(i + 4, i + 4 + view.getUint32(i, true)));\n\t\treturn ApiError.fromJSON(JSON.parse(dataText));\n\t}\n\n\tpublic static FileError(code: ErrorCode, p: string): ApiError {\n\t\treturn new ApiError(code, ErrorStrings[code], p);\n\t}\n\n\tpublic static EACCES(path: string): ApiError {\n\t\treturn this.FileError(ErrorCode.EACCES, path);\n\t}\n\n\tpublic static ENOENT(path: string): ApiError {\n\t\treturn this.FileError(ErrorCode.ENOENT, path);\n\t}\n\n\tpublic static EEXIST(path: string): ApiError {\n\t\treturn this.FileError(ErrorCode.EEXIST, path);\n\t}\n\n\tpublic static EISDIR(path: string): ApiError {\n\t\treturn this.FileError(ErrorCode.EISDIR, path);\n\t}\n\n\tpublic static ENOTDIR(path: string): ApiError {\n\t\treturn this.FileError(ErrorCode.ENOTDIR, path);\n\t}\n\n\tpublic static EPERM(path: string): ApiError {\n\t\treturn this.FileError(ErrorCode.EPERM, path);\n\t}\n\n\tpublic static ENOTEMPTY(path: string): ApiError {\n\t\treturn this.FileError(ErrorCode.ENOTEMPTY, path);\n\t}\n\n\tpublic errno: ErrorCode;\n\tpublic code: string;\n\tpublic path?: string;\n\t// Unsupported.\n\tpublic syscall: string = '';\n\tpublic stack?: string;\n\n\t/**\n\t * Represents a BrowserFS error. Passed back to applications after a failed\n\t * call to the BrowserFS API.\n\t *\n\t * Error codes mirror those returned by regular Unix file operations, which is\n\t * what Node returns.\n\t * @constructor ApiError\n\t * @param type The type of the error.\n\t * @param [message] A descriptive error message.\n\t */\n\tconstructor(type: ErrorCode, message: string = ErrorStrings[type], path?: string) {\n\t\tsuper(message);\n\t\tthis.errno = type;\n\t\tthis.code = ErrorCode[type];\n\t\tthis.path = path;\n\t\tthis.message = `Error: ${this.code}: ${message}${this.path ? `, '${this.path}'` : ''}`;\n\t}\n\n\t/**\n\t * @return A friendly error message.\n\t */\n\tpublic toString(): string {\n\t\treturn this.message;\n\t}\n\n\tpublic toJSON(): any {\n\t\treturn {\n\t\t\terrno: this.errno,\n\t\t\tcode: this.code,\n\t\t\tpath: this.path,\n\t\t\tstack: this.stack,\n\t\t\tmessage: this.message,\n\t\t};\n\t}\n\n\t/**\n\t * Writes the API error into a buffer.\n\t */\n\tpublic serialize(data: ArrayBufferLike | ArrayBufferView = new Uint8Array(this.bufferSize()), i: number = 0): Uint8Array {\n\t\tconst view = new DataView('buffer' in data ? data.buffer : data),\n\t\t\tbuffer = new Uint8Array(view.buffer);\n\t\tconst newData = encode(JSON.stringify(this.toJSON()));\n\t\tbuffer.set(newData);\n\t\tview.setUint32(i, newData.byteLength, true);\n\t\treturn buffer;\n\t}\n\n\t/**\n\t * The size of the API error in buffer-form in bytes.\n\t */\n\tpublic bufferSize(): number {\n\t\t// 4 bytes for string length.\n\t\treturn 4 + JSON.stringify(this.toJSON()).length;\n\t}\n}\n", "/**\n * Credentials used for FS ops.\n * Similar to Linux's cred struct. See https://github.com/torvalds/linux/blob/master/include/linux/cred.h\n */\nexport class Cred {\n\tconstructor(public uid: number, public gid: number, public suid: number, public sgid: number, public euid: number, public egid: number) {}\n\n\tpublic static Root = new Cred(0, 0, 0, 0, 0, 0);\n}\n", "/*\nFS Constants\nSee https://nodejs.org/api/fs.html#file-access-constants\n*/\n\n// File Access Constants\n\n/** Constant for fs.access(). File is visible to the calling process. */\nexport const F_OK = 0;\n\n/** Constant for fs.access(). File can be read by the calling process. */\nexport const R_OK = 4;\n\n/** Constant for fs.access(). File can be written by the calling process. */\nexport const W_OK = 2;\n\n/** Constant for fs.access(). File can be executed by the calling process. */\nexport const X_OK = 1;\n\n// File Copy Constants\n\n/** Constant for fs.copyFile. Flag indicating the destination file should not be overwritten if it already exists. */\nexport const COPYFILE_EXCL = 1;\n\n/**\n * Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.\n * If the underlying platform does not support copy-on-write, then a fallback copy mechanism is used.\n */\nexport const COPYFILE_FICLONE = 2;\n\n/**\n * Constant for fs.copyFile. Copy operation will attempt to create a copy-on-write reflink.\n * If the underlying platform does not support copy-on-write, then the operation will fail with an error.\n */\nexport const COPYFILE_FICLONE_FORCE = 4;\n\n// File Open Constants\n\n/** Constant for fs.open(). Flag indicating to open a file for read-only access. */\nexport const O_RDONLY = 0;\n\n/** Constant for fs.open(). Flag indicating to open a file for write-only access. */\nexport const O_WRONLY = 1;\n\n/** Constant for fs.open(). Flag indicating to open a file for read-write access. */\nexport const O_RDWR = 2;\n\n/** Constant for fs.open(). Flag indicating to create the file if it does not already exist. */\nexport const O_CREAT = 0o100; // Node internal is\n\n/** Constant for fs.open(). Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists. */\nexport const O_EXCL = 0o200;\n\n/**\n * Constant for fs.open(). Flag indicating that if path identifies a terminal device,\n * opening the path shall not cause that terminal to become the controlling terminal for the process\n * (if the process does not already have one).\n */\nexport const O_NOCTTY = 0o400;\n\n/** Constant for fs.open(). Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero. */\nexport const O_TRUNC = 0o1000;\n\n/** Constant for fs.open(). Flag indicating that data will be appended to the end of the file. */\nexport const O_APPEND = 0o2000;\n\n/** Constant for fs.open(). Flag indicating that the open should fail if the path is not a directory. */\nexport const O_DIRECTORY = 0o200000;\n\n/**\n * constant for fs.open().\n * Flag indicating reading accesses to the file system will no longer result in\n * an update to the atime information associated with the file.\n * This flag is available on Linux operating systems only.\n */\nexport const O_NOATIME = 0o1000000;\n\n/** Constant for fs.open(). Flag indicating that the open should fail if the path is a symbolic link. */\nexport const O_NOFOLLOW = 0o400000;\n\n/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O. */\nexport const O_SYNC = 0o4010000;\n\n/** Constant for fs.open(). Flag indicating that the file is opened for synchronous I/O with write operations waiting for data integrity. */\nexport const O_DSYNC = 0o10000;\n\n/** Constant for fs.open(). Flag indicating to open the symbolic link itself rather than the resource it is pointing to. */\nexport const O_SYMLINK = 0o100000;\n\n/** Constant for fs.open(). When set, an attempt will be made to minimize caching effects of file I/O. */\nexport const O_DIRECT = 0o40000;\n\n/** Constant for fs.open(). Flag indicating to open the file in nonblocking mode when possible. */\nexport const O_NONBLOCK = 0o4000;\n\n// File Type Constants\n\n/** Constant for fs.Stats mode property for determining a file's type. Bit mask used to extract the file type code. */\nexport const S_IFMT = 0o170000;\n\n/** Constant for fs.Stats mode property for determining a file's type. File type constant for a regular file. */\nexport const S_IFREG = 0o100000;\n\n/** Constant for fs.Stats mode property for determining a file's type. File type constant for a directory. */\nexport const S_IFDIR = 0o40000;\n\n/** Constant for fs.Stats mode property for determining a file's type. File type constant for a character-oriented device file. */\nexport const S_IFCHR = 0o20000;\n\n/** Constant for fs.Stats mode property for determining a file's type. File type constant for a block-oriented device file. */\nexport const S_IFBLK = 0o60000;\n\n/** Constant for fs.Stats mode property for determining a file's type. File type constant for a FIFO/pipe. */\nexport const S_IFIFO = 0o10000;\n\n/** Constant for fs.Stats mode property for determining a file's type. File type constant for a symbolic link. */\nexport const S_IFLNK = 0o120000;\n\n/** Constant for fs.Stats mode property for determining a file's type. File type constant for a socket. */\nexport const S_IFSOCK = 0o140000;\n\n// File Mode Constants\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by owner. */\nexport const S_IRWXU = 0o700;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by owner. */\nexport const S_IRUSR = 0o400;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by owner. */\nexport const S_IWUSR = 0o200;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by owner. */\nexport const S_IXUSR = 0o100;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by group. */\nexport const S_IRWXG = 0o70;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by group. */\nexport const S_IRGRP = 0o40;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by group. */\nexport const S_IWGRP = 0o20;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by group. */\nexport const S_IXGRP = 0o10;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable, writable and executable by others. */\nexport const S_IRWXO = 7;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating readable by others. */\nexport const S_IROTH = 4;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating writable by others. */\nexport const S_IWOTH = 2;\n\n/** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */\nexport const S_IXOTH = 1;\n", "import type * as Node from 'fs';\nimport { Cred } from './cred.js';\n\nimport { S_IFDIR, S_IFLNK, S_IFMT, S_IFREG } from './emulation/constants.js';\n\n/**\n * Indicates the type of the given file. Applied to 'mode'.\n */\nexport enum FileType {\n\tFILE = S_IFREG,\n\tDIRECTORY = S_IFDIR,\n\tSYMLINK = S_IFLNK,\n}\n\n/**\n * Common code used by both Stats and BigIntStats\n */\nexport abstract class StatsCommon<T extends number | bigint> implements Node.StatsBase<T> {\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpublic static Deserialize(data: ArrayBufferLike | ArrayBufferView): StatsCommon<number> | StatsCommon<bigint> {\n\t\tthrow new ReferenceError('Called static abstract method: StatsCommon.Deserialize()');\n\t}\n\n\tprotected abstract _isBigint: boolean;\n\n\tprotected get _typename(): string {\n\t\treturn this._isBigint ? 'bigint' : 'number';\n\t}\n\n\tprotected get _typename_inverse(): string {\n\t\treturn this._isBigint ? 'number' : 'bigint';\n\t}\n\n\tprotected _convert(arg: number | bigint | string | boolean): T {\n\t\treturn (this._isBigint ? BigInt(arg) : Number(arg)) as T;\n\t}\n\n\tpublic blocks: T;\n\tpublic mode: T;\n\n\t/**\n\t * ID of device containing file\n\t */\n\tpublic dev: T = this._convert(0);\n\t/**\n\t * inode number\n\t */\n\tpublic ino: T = this._convert(0);\n\t/**\n\t * device ID (if special file)\n\t */\n\tpublic rdev: T = this._convert(0);\n\t/**\n\t * number of hard links\n\t */\n\tpublic nlink: T = this._convert(1);\n\t/**\n\t * blocksize for file system I/O\n\t */\n\tpublic blksize: T = this._convert(4096);\n\t/**\n\t * user ID of owner\n\t */\n\tpublic uid: T = this._convert(0);\n\t/**\n\t * group ID of owner\n\t */\n\tpublic gid: T = this._convert(0);\n\t/**\n\t * Some file systems stash data on stats objects.\n\t */\n\tpublic fileData: Uint8Array | null = null;\n\tpublic atimeMs: T;\n\tpublic mtimeMs: T;\n\tpublic ctimeMs: T;\n\tpublic birthtimeMs: T;\n\tpublic size: T;\n\n\tpublic get atime(): Date {\n\t\treturn new Date(Number(this.atimeMs));\n\t}\n\n\tpublic get mtime(): Date {\n\t\treturn new Date(Number(this.mtimeMs));\n\t}\n\n\tpublic get ctime(): Date {\n\t\treturn new Date(Number(this.ctimeMs));\n\t}\n\n\tpublic get birthtime(): Date {\n\t\treturn new Date(Number(this.birthtimeMs));\n\t}\n\n\t/**\n\t * Provides information about a particular entry in the file system.\n\t * @param itemType Type of the item (FILE, DIRECTORY, SYMLINK, or SOCKET)\n\t * @param size Size of the item in bytes. For directories/symlinks,\n\t * this is normally the size of the struct that represents the item.\n\t * @param mode Unix-style file mode (e.g. 0o644)\n\t * @param atimeMs time of last access, in milliseconds since epoch\n\t * @param mtimeMs time of last modification, in milliseconds since epoch\n\t * @param ctimeMs time of last time file status was changed, in milliseconds since epoch\n\t * @param uid the id of the user that owns the file\n\t * @param gid the id of the group that owns the file\n\t * @param birthtimeMs time of file creation, in milliseconds since epoch\n\t */\n\tconstructor(\n\t\titemType: FileType = FileType.FILE,\n\t\tsize: number | bigint = -1,\n\t\tmode?: number | bigint,\n\t\tatimeMs?: number | bigint,\n\t\tmtimeMs?: number | bigint,\n\t\tctimeMs?: number | bigint,\n\t\tuid?: number | bigint,\n\t\tgid?: number | bigint,\n\t\tbirthtimeMs?: number | bigint\n\t) {\n\t\tconst currentTime = Date.now();\n\t\tconst resolveT = (v: number | bigint, def: number) => (typeof v == this._typename ? v : this._convert(typeof v == this._typename_inverse ? v : def)) as T;\n\t\tthis.atimeMs = resolveT(atimeMs, currentTime);\n\t\tthis.mtimeMs = resolveT(mtimeMs, currentTime);\n\t\tthis.ctimeMs = resolveT(ctimeMs, currentTime);\n\t\tthis.birthtimeMs = resolveT(birthtimeMs, currentTime);\n\t\tthis.uid = resolveT(uid, 0);\n\t\tthis.gid = resolveT(gid, 0);\n\t\tthis.size = this._convert(size);\n\n\t\tif (mode) {\n\t\t\tthis.mode = this._convert(mode);\n\t\t} else {\n\t\t\tswitch (itemType) {\n\t\t\t\tcase FileType.FILE:\n\t\t\t\t\tthis.mode = this._convert(0o644);\n\t\t\t\t\tbreak;\n\t\t\t\tcase FileType.DIRECTORY:\n\t\t\t\tdefault:\n\t\t\t\t\tthis.mode = this._convert(0o777);\n\t\t\t}\n\t\t}\n\t\t// number of 512B blocks allocated\n\t\tthis.blocks = this._convert(Math.ceil(Number(size) / 512));\n\t\t// Check if mode also includes top-most bits, which indicate the file's\n\t\t// type.\n\t\tif ((this.mode & S_IFMT) == 0) {\n\t\t\tthis.mode = (this.mode | this._convert(itemType)) as T;\n\t\t}\n\t}\n\n\tpublic abstract serialize(): Uint8Array;\n\n\t/**\n\t * @return [Boolean] True if this item is a file.\n\t */\n\tpublic isFile(): boolean {\n\t\treturn (this.mode & S_IFMT) === S_IFREG;\n\t}\n\n\t/**\n\t * @return [Boolean] True if this item is a directory.\n\t */\n\tpublic isDirectory(): boolean {\n\t\treturn (this.mode & S_IFMT) === S_IFDIR;\n\t}\n\n\t/**\n\t * @return [Boolean] True if this item is a symbolic link (only valid through lstat)\n\t */\n\tpublic isSymbolicLink(): boolean {\n\t\treturn (this.mode & S_IFMT) === S_IFLNK;\n\t}\n\n\t/**\n\t * Checks if a given user/group has access to this item\n\t * @param mode The request access as 4 bits (unused, read, write, execute)\n\t * @param uid The requesting UID\n\t * @param gid The requesting GID\n\t * @returns [Boolean] True if the request has access, false if the request does not\n\t */\n\tpublic hasAccess(mode: number, cred: Cred): boolean {\n\t\tif (cred.euid === 0 || cred.egid === 0) {\n\t\t\t//Running as root\n\t\t\treturn true;\n\t\t}\n\t\tconst perms = this.mode & ~S_IFMT;\n\t\tlet uMode = 0xf,\n\t\t\tgMode = 0xf,\n\t\t\twMode = 0xf;\n\n\t\tif (cred.euid == this.uid) {\n\t\t\tconst uPerms = (0xf00 & perms) >> 8;\n\t\t\tuMode = (mode ^ uPerms) & mode;\n\t\t}\n\t\tif (cred.egid == this.gid) {\n\t\t\tconst gPerms = (0xf0 & perms) >> 4;\n\t\t\tgMode = (mode ^ gPerms) & mode;\n\t\t}\n\t\tconst wPerms = 0xf & perms;\n\t\twMode = (mode ^ wPerms) & mode;\n\t\t/*\n Result = 0b0xxx (read, write, execute)\n If any bits are set that means the request does not have that permission.\n */\n\t\tconst result = uMode & gMode & wMode;\n\t\treturn !result;\n\t}\n\n\t/**\n\t * Convert the current stats object into a cred object\n\t */\n\tpublic getCred(uid: number = Number(this.uid), gid: number = Number(this.gid)): Cred {\n\t\treturn new Cred(uid, gid, Number(this.uid), Number(this.gid), uid, gid);\n\t}\n\n\t/**\n\t * Change the mode of the file. We use this helper function to prevent messing\n\t * up the type of the file, which is encoded in mode.\n\t */\n\tpublic chmod(mode: number): void {\n\t\tthis.mode = this._convert((this.mode & S_IFMT) | mode);\n\t}\n\n\t/**\n\t * Change the owner user/group of the file.\n\t * This function makes sure it is a valid UID/GID (that is, a 32 unsigned int)\n\t */\n\tpublic chown(uid: number | bigint, gid: number | bigint): void {\n\t\tuid = Number(uid);\n\t\tgid = Number(gid);\n\t\tif (!isNaN(uid) && 0 <= uid && uid < 2 ** 32) {\n\t\t\tthis.uid = this._convert(uid);\n\t\t}\n\t\tif (!isNaN(gid) && 0 <= gid && gid < 2 ** 32) {\n\t\t\tthis.gid = this._convert(gid);\n\t\t}\n\t}\n\n\t// We don't support the following types of files.\n\n\tpublic isSocket(): boolean {\n\t\treturn false;\n\t}\n\n\tpublic isBlockDevice(): boolean {\n\t\treturn false;\n\t}\n\n\tpublic isCharacterDevice(): boolean {\n\t\treturn false;\n\t}\n\n\tpublic isFIFO(): boolean {\n\t\treturn false;\n\t}\n}\n\n/**\n * Implementation of Node's `Stats`.\n *\n * Attribute descriptions are from `man 2 stat'\n * @see http://nodejs.org/api/fs.html#fs_class_fs_stats\n * @see http://man7.org/linux/man-pages/man2/stat.2.html\n */\nexport class Stats extends StatsCommon<number> implements Node.Stats {\n\tprotected _isBigint = false;\n\n\t/**\n\t * Clones the stats object.\n\t */\n\tpublic static clone(s: Stats): Stats {\n\t\treturn new Stats(s.mode & S_IFMT, s.size, s.mode & ~S_IFMT, s.atimeMs, s.mtimeMs, s.ctimeMs, s.uid, s.gid, s.birthtimeMs);\n\t}\n\n\tpublic static Deserialize(data: ArrayBufferLike | ArrayBufferView): Stats {\n\t\tconst view = new DataView('buffer' in data ? data.buffer : data);\n\t\tconst size = view.getUint32(0, true),\n\t\t\tmode = view.getUint32(4, true),\n\t\t\tatime = view.getFloat64(8, true),\n\t\t\tmtime = view.getFloat64(16, true),\n\t\t\tctime = view.getFloat64(24, true),\n\t\t\tuid = view.getUint32(32, true),\n\t\t\tgid = view.getUint32(36, true);\n\n\t\treturn new Stats(mode & S_IFMT, size, mode & ~S_IFMT, atime, mtime, ctime, uid, gid);\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst data = new Uint8Array(32),\n\t\t\tview = new DataView(data.buffer);\n\t\tview.setUint32(0, this.size, true);\n\t\tview.setUint32(4, this.mode, true);\n\t\tview.setFloat64(8, this.atime.getTime(), true);\n\t\tview.setFloat64(16, this.mtime.getTime(), true);\n\t\tview.setFloat64(24, this.ctime.getTime(), true);\n\t\tview.setUint32(32, this.uid, true);\n\t\tview.setUint32(36, this.gid, true);\n\t\treturn data;\n\t}\n}\nStats satisfies typeof Node.Stats;\n\n/**\n * Stats with bigint\n * @todo Implement with bigint instead of wrapping Stats\n */\nexport class BigIntStats extends StatsCommon<bigint> implements Node.BigIntStats {\n\tprotected _isBigint = true;\n\n\tpublic atimeNs: bigint;\n\tpublic mtimeNs: bigint;\n\tpublic ctimeNs: bigint;\n\tpublic birthtimeNs: bigint;\n\n\t/**\n\t * Clone a stats object.\n\t */\n\tpublic static clone(s: BigIntStats | Stats): BigIntStats {\n\t\treturn new BigIntStats(\n\t\t\tNumber(s.mode) & S_IFMT,\n\t\t\tBigInt(s.size),\n\t\t\tBigInt(s.mode) & BigInt(~S_IFMT),\n\t\t\tBigInt(s.atimeMs),\n\t\t\tBigInt(s.mtimeMs),\n\t\t\tBigInt(s.ctimeMs),\n\t\t\tBigInt(s.uid),\n\t\t\tBigInt(s.gid),\n\t\t\tBigInt(s.birthtimeMs)\n\t\t);\n\t}\n\n\tpublic static Deserialize(data: ArrayBufferLike | ArrayBufferView): Stats {\n\t\tconst view = new DataView('buffer' in data ? data.buffer : data);\n\t\tconst size = view.getBigUint64(0, true),\n\t\t\tmode = view.getBigUint64(4, true),\n\t\t\tatime = view.getFloat64(8, true),\n\t\t\tmtime = view.getFloat64(16, true),\n\t\t\tctime = view.getFloat64(24, true),\n\t\t\tuid = view.getBigUint64(32, true),\n\t\t\tgid = view.getBigUint64(36, true);\n\n\t\treturn new Stats(Number(mode) & S_IFMT, size, mode & BigInt(~S_IFMT), atime, mtime, ctime, uid, gid);\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst data = new Uint8Array(32),\n\t\t\tview = new DataView(data.buffer);\n\t\tview.setBigUint64(0, this.size, true);\n\t\tview.setBigUint64(4, this.mode, true);\n\t\tview.setFloat64(8, this.atime.getTime(), true);\n\t\tview.setFloat64(16, this.mtime.getTime(), true);\n\t\tview.setFloat64(24, this.ctime.getTime(), true);\n\t\tview.setBigUint64(32, this.uid, true);\n\t\tview.setBigUint64(36, this.gid, true);\n\t\treturn data;\n\t}\n}\nBigIntStats satisfies typeof Node.BigIntStats;\n", "import { ApiError, ErrorCode } from './ApiError.js';\nimport { Stats } from './stats.js';\nimport { FileSystem } from './filesystem.js';\nimport { O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_TRUNC, O_APPEND, O_SYNC } from './emulation/constants.js';\n\nexport enum ActionType {\n\t// Indicates that the code should not do anything.\n\tNOP = 0,\n\t// Indicates that the code should throw an exception.\n\tTHROW_EXCEPTION = 1,\n\t// Indicates that the code should truncate the file, but only if it is a file.\n\tTRUNCATE_FILE = 2,\n\t// Indicates that the code should create the file.\n\tCREATE_FILE = 3,\n}\n\n/**\n * Represents one of the following file flags. A convenience object.\n *\n * * `'r'` - Open file for reading. An exception occurs if the file does not exist.\n * * `'r+'` - Open file for reading and writing. An exception occurs if the file does not exist.\n * * `'rs'` - Open file for reading in synchronous mode. Instructs the filesystem to not cache writes.\n * * `'rs+'` - Open file for reading and writing, and opens the file in synchronous mode.\n * * `'w'` - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).\n * * `'wx'` - Like 'w' but opens the file in exclusive mode.\n * * `'w+'` - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).\n * * `'wx+'` - Like 'w+' but opens the file in exclusive mode.\n * * `'a'` - Open file for appending. The file is created if it does not exist.\n * * `'ax'` - Like 'a' but opens the file in exclusive mode.\n * * `'a+'` - Open file for reading and appending. The file is created if it does not exist.\n * * `'ax+'` - Like 'a+' but opens the file in exclusive mode.\n *\n * Exclusive mode ensures that the file path is newly created.\n */\nexport class FileFlag {\n\t// Contains cached FileMode instances.\n\tprivate static flagCache: Map<string | number, FileFlag> = new Map();\n\t// Array of valid mode strings.\n\tprivate static validFlagStrs = ['r', 'r+', 'rs', 'rs+', 'w', 'wx', 'w+', 'wx+', 'a', 'ax', 'a+', 'ax+'];\n\n\t/**\n\t * Get an object representing the given file flag.\n\t * @param flag The string or number representing the flag\n\t * @return The FileFlag object representing the flag\n\t * @throw when the flag string is invalid\n\t */\n\tpublic static getFileFlag(flag: string | number): FileFlag {\n\t\t// Check cache first.\n\t\tif (!FileFlag.flagCache.has(flag)) {\n\t\t\tFileFlag.flagCache.set(flag, new FileFlag(flag));\n\t\t}\n\t\treturn FileFlag.flagCache.get(flag);\n\t}\n\n\tprivate flagStr: string;\n\t/**\n\t * This should never be called directly.\n\t * @param flag The string or number representing the flag\n\t * @throw when the flag is invalid\n\t */\n\tconstructor(flag: string | number) {\n\t\tif (typeof flag === 'number') {\n\t\t\tflag = FileFlag.StringFromNumber(flag);\n\t\t}\n\t\tif (FileFlag.validFlagStrs.indexOf(flag) < 0) {\n\t\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid flag string: ' + flag);\n\t\t}\n\t\tthis.flagStr = flag;\n\t}\n\n\t/**\n\t * @param flag The number representing the flag\n\t * @return The string representing the flag\n\t * @throw when the flag number is invalid\n\t */\n\tpublic static StringFromNumber(flag: number): string {\n\t\t// based on https://github.com/nodejs/node/blob/abbdc3efaa455e6c907ebef5409ac8b0f222f969/lib/internal/fs/utils.js#L619\n\t\tswitch (flag) {\n\t\t\tcase O_RDONLY:\n\t\t\t\treturn 'r';\n\t\t\tcase O_RDONLY | O_SYNC:\n\t\t\t\treturn 'rs';\n\t\t\tcase O_RDWR:\n\t\t\t\treturn 'r+';\n\t\t\tcase O_RDWR | O_SYNC:\n\t\t\t\treturn 'rs+';\n\n\t\t\tcase O_TRUNC | O_CREAT | O_WRONLY:\n\t\t\t\treturn 'w';\n\t\t\tcase O_TRUNC | O_CREAT | O_WRONLY | O_EXCL:\n\t\t\t\treturn 'wx';\n\n\t\t\tcase O_TRUNC | O_CREAT | O_RDWR:\n\t\t\t\treturn 'w+';\n\t\t\tcase O_TRUNC | O_CREAT | O_RDWR | O_EXCL:\n\t\t\t\treturn 'wx+';\n\n\t\t\tcase O_APPEND | O_CREAT | O_WRONLY:\n\t\t\t\treturn 'a';\n\t\t\tcase O_APPEND | O_CREAT | O_WRONLY | O_EXCL:\n\t\t\t\treturn 'ax';\n\n\t\t\tcase O_APPEND | O_CREAT | O_RDWR:\n\t\t\t\treturn 'a+';\n\t\t\tcase O_APPEND | O_CREAT | O_RDWR | O_EXCL:\n\t\t\t\treturn 'ax+';\n\n\t\t\tdefault:\n\t\t\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid flag number: ' + flag);\n\t\t}\n\t}\n\n\t/**\n\t * Get the underlying flag string for this flag.\n\t */\n\tpublic getFlagString(): string {\n\t\treturn this.flagStr;\n\t}\n\n\t/**\n\t * Get the equivalent mode (0b0xxx: read, write, execute)\n\t * Note: Execute will always be 0\n\t */\n\tpublic getMode(): number {\n\t\tlet mode = 0;\n\t\tmode <<= 1;\n\t\tmode += +this.isReadable();\n\t\tmode <<= 1;\n\t\tmode += +this.isWriteable();\n\t\tmode <<= 1;\n\t\treturn mode;\n\t}\n\n\t/**\n\t * Returns true if the file is readable.\n\t */\n\tpublic isReadable(): boolean {\n\t\treturn this.flagStr.indexOf('r') !== -1 || this.flagStr.indexOf('+') !== -1;\n\t}\n\t/**\n\t * Returns true if the file is writeable.\n\t */\n\tpublic isWriteable(): boolean {\n\t\treturn this.flagStr.indexOf('w') !== -1 || this.flagStr.indexOf('a') !== -1 || this.flagStr.indexOf('+') !== -1;\n\t}\n\t/**\n\t * Returns true if the file mode should truncate.\n\t */\n\tpublic isTruncating(): boolean {\n\t\treturn this.flagStr.indexOf('w') !== -1;\n\t}\n\t/**\n\t * Returns true if the file is appendable.\n\t */\n\tpublic isAppendable(): boolean {\n\t\treturn this.flagStr.indexOf('a') !== -1;\n\t}\n\t/**\n\t * Returns true if the file is open in synchronous mode.\n\t */\n\tpublic isSynchronous(): boolean {\n\t\treturn this.flagStr.indexOf('s') !== -1;\n\t}\n\t/**\n\t * Returns true if the file is open in exclusive mode.\n\t */\n\tpublic isExclusive(): boolean {\n\t\treturn this.flagStr.indexOf('x') !== -1;\n\t}\n\t/**\n\t * Returns one of the static fields on this object that indicates the\n\t * appropriate response to the path existing.\n\t */\n\tpublic pathExistsAction(): ActionType {\n\t\tif (this.isExclusive()) {\n\t\t\treturn ActionType.THROW_EXCEPTION;\n\t\t} else if (this.isTruncating()) {\n\t\t\treturn ActionType.TRUNCATE_FILE;\n\t\t} else {\n\t\t\treturn ActionType.NOP;\n\t\t}\n\t}\n\t/**\n\t * Returns one of the static fields on this object that indicates the\n\t * appropriate response to the path not existing.\n\t */\n\tpublic pathNotExistsAction(): ActionType {\n\t\tif ((this.isWriteable() || this.isAppendable()) && this.flagStr !== 'r+') {\n\t\t\treturn ActionType.CREATE_FILE;\n\t\t} else {\n\t\t\treturn ActionType.THROW_EXCEPTION;\n\t\t}\n\t}\n}\n\nexport interface File {\n\t/**\n\t * **Core**: Get the current file position.\n\t */\n\tgetPos(): number | undefined;\n\t/**\n\t * **Core**: Asynchronous `stat`.\n\t */\n\tstat(): Promise<Stats>;\n\t/**\n\t * **Core**: Synchronous `stat`.\n\t */\n\tstatSync(): Stats;\n\t/**\n\t * **Core**: Asynchronous close.\n\t */\n\tclose(): Promise<void>;\n\t/**\n\t * **Core**: Synchronous close.\n\t */\n\tcloseSync(): void;\n\t/**\n\t * **Core**: Asynchronous truncate.\n\t */\n\ttruncate(len: number): Promise<void>;\n\t/**\n\t * **Core**: Synchronous truncate.\n\t */\n\ttruncateSync(len: number): void;\n\t/**\n\t * **Core**: Asynchronous sync.\n\t */\n\tsync(): Promise<void>;\n\t/**\n\t * **Core**: Synchronous sync.\n\t */\n\tsyncSync(): void;\n\t/**\n\t * **Core**: Write buffer to the file.\n\t * Note that it is unsafe to use fs.write multiple times on the same file\n\t * without waiting for the callback.\n\t * @param buffer Uint8Array containing the data to write to\n\t * the file.\n\t * @param offset Offset in the buffer to start reading data from.\n\t * @param length The amount of bytes to write to the file.\n\t * @param position Offset from the beginning of the file where this\n\t * data should be written. If position is null, the data will be written at\n\t * the current position.\n\t * @returns Promise resolving to the new length of the buffer\n\t */\n\twrite(buffer: Uint8Array, offset: number, length: number, position: number | null): Promise<number>;\n\t/**\n\t * **Core**: Write buffer to the file.\n\t * Note that it is unsafe to use fs.writeSync multiple times on the same file\n\t * without waiting for it to return.\n\t * @param buffer Uint8Array containing the data to write to\n\t * the file.\n\t * @param offset Offset in the buffer to start reading data from.\n\t * @param length The amount of bytes to write to the file.\n\t * @param position Offset from the beginning of the file where this\n\t * data should be written. If position is null, the data will be written at\n\t * the current position.\n\t */\n\twriteSync(buffer: Uint8Array, offset: number, length: number, position: number | null): number;\n\t/**\n\t * **Core**: Read data from the file.\n\t * @param buffer The buffer that the data will be\n\t * written to.\n\t * @param offset The offset within the buffer where writing will\n\t * start.\n\t * @param length An integer specifying the number of bytes to read.\n\t * @param position An integer specifying where to begin reading from\n\t * in the file. If position is null, data will be read from the current file\n\t * position.\n\t * @returns Promise resolving to the new length of the buffer\n\t */\n\tread(buffer: Uint8Array, offset: number, length: number, position: number | null): Promise<{ bytesRead: number; buffer: Uint8Array }>;\n\t/**\n\t * **Core**: Read data from the file.\n\t * @param buffer The buffer that the data will be written to.\n\t * @param offset The offset within the buffer where writing will start.\n\t * @param length An integer specifying the number of bytes to read.\n\t * @param position An integer specifying where to begin reading from\n\t * in the file. If position is null, data will be read from the current file\n\t * position.\n\t */\n\treadSync(buffer: Uint8Array, offset: number, length: number, position: number): number;\n\t/**\n\t * **Supplementary**: Asynchronous `datasync`.\n\t *\n\t * Default implementation maps to `sync`.\n\t */\n\tdatasync(): Promise<void>;\n\t/**\n\t * **Supplementary**: Synchronous `datasync`.\n\t *\n\t * Default implementation maps to `syncSync`.\n\t */\n\tdatasyncSync(): void;\n\t/**\n\t * **Optional**: Asynchronous `chown`.\n\t */\n\tchown(uid: number, gid: number): Promise<void>;\n\t/**\n\t * **Optional**: Synchronous `chown`.\n\t */\n\tchownSync(uid: number, gid: number): void;\n\t/**\n\t * **Optional**: Asynchronous `fchmod`.\n\t */\n\tchmod(mode: number): Promise<void>;\n\t/**\n\t * **Optional**: Synchronous `fchmod`.\n\t */\n\tchmodSync(mode: number): void;\n\t/**\n\t * **Optional**: Change the file timestamps of the file.\n\t */\n\tutimes(atime: Date, mtime: Date): Promise<void>;\n\t/**\n\t * **Optional**: Change the file timestamps of the file.\n\t */\n\tutimesSync(atime: Date, mtime: Date): void;\n}\n\n/**\n * Base class that contains shared implementations of functions for the file\n * object.\n */\nexport class BaseFile {\n\tpublic async sync(): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic syncSync(): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async datasync(): Promise<void> {\n\t\treturn this.sync();\n\t}\n\tpublic datasyncSync(): void {\n\t\treturn this.syncSync();\n\t}\n\tpublic async chown(uid: number, gid: number): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic chownSync(uid: number, gid: number): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async chmod(mode: number): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic chmodSync(mode: number): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async utimes(atime: Date, mtime: Date): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic utimesSync(atime: Date, mtime: Date): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n}\n\n/**\n * An implementation of the File interface that operates on a file that is\n * completely in-memory. PreloadFiles are backed by a Uint8Array.\n *\n * This is also an abstract class, as it lacks an implementation of 'sync' and\n * 'close'. Each filesystem that wishes to use this file representation must\n * extend this class and implement those two methods.\n * @todo 'close' lever that disables functionality once closed.\n */\nexport class PreloadFile<T extends FileSystem> extends BaseFile {\n\tprotected _fs: T;\n\tprotected _pos: number = 0;\n\tprotected _path: string;\n\tprotected _stat: Stats;\n\tprotected _flag: FileFlag;\n\tprotected _buffer: Uint8Array;\n\tprotected _dirty: boolean = false;\n\t/**\n\t * Creates a file with the given path and, optionally, the given contents. Note\n\t * that, if contents is specified, it will be mutated by the file!\n\t * @param _fs The file system that created the file.\n\t * @param _path\n\t * @param _mode The mode that the file was opened using.\n\t * Dictates permissions and where the file pointer starts.\n\t * @param _stat The stats object for the given file.\n\t * PreloadFile will mutate this object. Note that this object must contain\n\t * the appropriate mode that the file was opened as.\n\t * @param contents A buffer containing the entire\n\t * contents of the file. PreloadFile will mutate this buffer. If not\n\t * specified, we assume it is a new file.\n\t */\n\tconstructor(_fs: T, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array) {\n\t\tsuper();\n\t\tthis._fs = _fs;\n\t\tthis._path = _path;\n\t\tthis._flag = _flag;\n\t\tthis._stat = _stat;\n\t\tthis._buffer = contents ? contents : new Uint8Array(0);\n\t\t// Note: This invariant is *not* maintained once the file starts getting\n\t\t// modified.\n\t\t// Note: Only actually matters if file is readable, as writeable modes may\n\t\t// truncate/append to file.\n\t\tif (this._stat.size !== this._buffer.length && this._flag.isReadable()) {\n\t\t\tthrow new Error(`Invalid buffer: Uint8Array is ${this._buffer.length} long, yet Stats object specifies that file is ${this._stat.size} long.`);\n\t\t}\n\t}\n\n\t/**\n\t * NONSTANDARD: Get the underlying buffer for this file. !!DO NOT MUTATE!! Will mess up dirty tracking.\n\t */\n\tpublic getBuffer(): Uint8Array {\n\t\treturn this._buffer;\n\t}\n\n\t/**\n\t * NONSTANDARD: Get underlying stats for this file. !!DO NOT MUTATE!!\n\t */\n\tpublic getStats(): Stats {\n\t\treturn this._stat;\n\t}\n\n\tpublic getFlag(): FileFlag {\n\t\treturn this._flag;\n\t}\n\n\t/**\n\t * Get the path to this file.\n\t * @return [String] The path to the file.\n\t */\n\tpublic getPath(): string {\n\t\treturn this._path;\n\t}\n\n\t/**\n\t * Get the current file position.\n\t *\n\t * We emulate the following bug mentioned in the Node documentation:\n\t * > On Linux, positional writes don't work when the file is opened in append\n\t * mode. The kernel ignores the position argument and always appends the data\n\t * to the end of the file.\n\t * @return [Number] The current file position.\n\t */\n\tpublic getPos(): number {\n\t\tif (this._flag.isAppendable()) {\n\t\t\treturn this._stat.size;\n\t\t}\n\t\treturn this._pos;\n\t}\n\n\t/**\n\t * Advance the current file position by the indicated number of positions.\n\t * @param [Number] delta\n\t */\n\tpublic advancePos(delta: number): number {\n\t\treturn (this._pos += delta);\n\t}\n\n\t/**\n\t * Set the file position.\n\t * @param [Number] newPos\n\t */\n\tpublic setPos(newPos: number): number {\n\t\treturn (this._pos = newPos);\n\t}\n\n\t/**\n\t * **Core**: Asynchronous sync. Must be implemented by subclasses of this\n\t * class.\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\tpublic async sync(): Promise<void> {\n\t\tthis.syncSync();\n\t}\n\n\t/**\n\t * **Core**: Synchronous sync.\n\t */\n\tpublic syncSync(): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\n\t/**\n\t * **Core**: Asynchronous close. Must be implemented by subclasses of this\n\t * class.\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\tpublic async close(): Promise<void> {\n\t\tthis.closeSync();\n\t}\n\n\t/**\n\t * **Core**: Synchronous close.\n\t */\n\tpublic closeSync(): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\n\t/**\n\t * Asynchronous `stat`.\n\t * @param [Function(BrowserFS.ApiError, BrowserFS.node.fs.Stats)] cb\n\t */\n\tpublic async stat(): Promise<Stats> {\n\t\treturn Stats.clone(this._stat);\n\t}\n\n\t/**\n\t * Synchronous `stat`.\n\t */\n\tpublic statSync(): Stats {\n\t\treturn Stats.clone(this._stat);\n\t}\n\n\t/**\n\t * Asynchronous truncate.\n\t * @param [Number] len\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\tpublic truncate(len: number): Promise<void> {\n\t\tthis.truncateSync(len);\n\t\tif (this._flag.isSynchronous() && !this._fs.metadata.synchronous) {\n\t\t\treturn this.sync();\n\t\t}\n\t}\n\n\t/**\n\t * Synchronous truncate.\n\t * @param [Number] len\n\t */\n\tpublic truncateSync(len: number): void {\n\t\tthis._dirty = true;\n\t\tif (!this._flag.isWriteable()) {\n\t\t\tthrow new ApiError(ErrorCode.EPERM, 'File not opened with a writeable mode.');\n\t\t}\n\t\tthis._stat.mtimeMs = Date.now();\n\t\tif (len > this._buffer.length) {\n\t\t\tconst buf = new Uint8Array(len - this._buffer.length);\n\t\t\t// Write will set @_stat.size for us.\n\t\t\tthis.writeSync(buf, 0, buf.length, this._buffer.length);\n\t\t\tif (this._flag.isSynchronous() && this._fs.metadata.synchronous) {\n\t\t\t\tthis.syncSync();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis._stat.size = len;\n\t\t// Truncate buffer to 'len'.\n\t\tthis._buffer = this._buffer.subarray(0, len);\n\t\tif (this._flag.isSynchronous() && this._fs.metadata.synchronous) {\n\t\t\tthis.syncSync();\n\t\t}\n\t}\n\n\t/**\n\t * Write buffer to the file.\n\t * Note that it is unsafe to use fs.write multiple times on the same file\n\t * without waiting for the callback.\n\t * @param [BrowserFS.node.Uint8Array] buffer Uint8Array containing the data to write to\n\t * the file.\n\t * @param [Number] offset Offset in the buffer to start reading data from.\n\t * @param [Number] length The amount of bytes to write to the file.\n\t * @param [Number] position Offset from the beginning of the file where this\n\t * data should be written. If position is null, the data will be written at\n\t * the current position.\n\t * @param [Function(BrowserFS.ApiError, Number, BrowserFS.node.Uint8Array)]\n\t * cb The number specifies the number of bytes written into the file.\n\t */\n\tpublic async write(buffer: Uint8Array, offset: number, length: number, position: number): Promise<number> {\n\t\treturn this.writeSync(buffer, offset, length, position);\n\t}\n\n\t/**\n\t * Write buffer to the file.\n\t * Note that it is unsafe to use fs.writeSync multiple times on the same file\n\t * without waiting for the callback.\n\t * @param [BrowserFS.node.Uint8Array] buffer Uint8Array containing the data to write to\n\t * the file.\n\t * @param [Number] offset Offset in the buffer to start reading data from.\n\t * @param [Number] length The amount of bytes to write to the file.\n\t * @param [Number] position Offset from the beginning of the file where this\n\t * data should be written. If position is null, the data will be written at\n\t * the current position.\n\t * @return [Number]\n\t */\n\tpublic writeSync(buffer: Uint8Array, offset: number, length: number, position: number): number {\n\t\tthis._dirty = true;\n\t\tif (position === undefined || position === null) {\n\t\t\tposition = this.getPos();\n\t\t}\n\t\tif (!this._flag.isWriteable()) {\n\t\t\tthrow new ApiError(ErrorCode.EPERM, 'File not opened with a writeable mode.');\n\t\t}\n\t\tconst endFp = position + length;\n\t\tif (endFp > this._stat.size) {\n\t\t\tthis._stat.size = endFp;\n\t\t\tif (endFp > this._buffer.length) {\n\t\t\t\t// Extend the buffer!\n\t\t\t\tconst newBuffer = new Uint8Array(endFp);\n\t\t\t\tnewBuffer.set(this._buffer);\n\t\t\t\tthis._buffer = newBuffer;\n\t\t\t}\n\t\t}\n\t\tthis._buffer.set(buffer.slice(offset, offset + length), position);\n\t\tconst len = this._buffer.length;\n\t\tthis._stat.mtimeMs = Date.now();\n\t\tif (this._flag.isSynchronous()) {\n\t\t\tthis.syncSync();\n\t\t\treturn len;\n\t\t}\n\t\tthis.setPos(position + len);\n\t\treturn length;\n\t}\n\n\t/**\n\t * Read data from the file.\n\t * @param [BrowserFS.node.Uint8Array] buffer The buffer that the data will be\n\t * written to.\n\t * @param [Number] offset The offset within the buffer where writing will\n\t * start.\n\t * @param [Number] length An integer specifying the number of bytes to read.\n\t * @param [Number] position An integer specifying where to begin reading from\n\t * in the file. If position is null, data will be read from the current file\n\t * position.\n\t * @param [Function(BrowserFS.ApiError, Number, BrowserFS.node.Uint8Array)] cb The\n\t * number is the number of bytes read\n\t */\n\tpublic async read(buffer: Uint8Array, offset: number, length: number, position: number): Promise<{ bytesRead: number; buffer: Uint8Array }> {\n\t\treturn { bytesRead: this.readSync(buffer, offset, length, position), buffer };\n\t}\n\n\t/**\n\t * Read data from the file.\n\t * @param [BrowserFS.node.Uint8Array] buffer The buffer that the data will be\n\t * written to.\n\t * @param [Number] offset The offset within the buffer where writing will\n\t * start.\n\t * @param [Number] length An integer specifying the number of bytes to read.\n\t * @param [Number] position An integer specifying where to begin reading from\n\t * in the file. If position is null, data will be read from the current file\n\t * position.\n\t * @return [Number]\n\t */\n\tpublic readSync(buffer: Uint8Array, offset: number, length: number, position: number): number {\n\t\tif (!this._flag.isReadable()) {\n\t\t\tthrow new ApiError(ErrorCode.EPERM, 'File not opened with a readable mode.');\n\t\t}\n\t\tif (position === undefined || position === null) {\n\t\t\tposition = this.getPos();\n\t\t}\n\t\tconst endRead = position + length;\n\t\tif (endRead > this._stat.size) {\n\t\t\tlength = this._stat.size - position;\n\t\t}\n\t\tbuffer.set(this._buffer.slice(offset, offset + length), position);\n\t\tthis._stat.atimeMs = Date.now();\n\t\tthis._pos = position + length;\n\t\treturn length;\n\t}\n\n\t/**\n\t * Asynchronous `fchmod`.\n\t * @param [Number|String] mode\n\t */\n\tpublic async chmod(mode: number): Promise<void> {\n\t\tthis.chmodSync(mode);\n\t}\n\n\t/**\n\t * Synchronous `fchmod`.\n\t * @param [Number] mode\n\t */\n\tpublic chmodSync(mode: number): void {\n\t\tif (!this._fs.metadata.supportsProperties) {\n\t\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t\t}\n\t\tthis._dirty = true;\n\t\tthis._stat.chmod(mode);\n\t\tthis.syncSync();\n\t}\n\n\t/**\n\t * Asynchronous `fchown`.\n\t * @param [Number] uid\n\t * @param [Number] gid\n\t */\n\tpublic async chown(uid: number, gid: number): Promise<void> {\n\t\tthis.chownSync(uid, gid);\n\t}\n\n\t/**\n\t * Synchronous `fchown`.\n\t * @param [Number] uid\n\t * @param [Number] gid\n\t */\n\tpublic chownSync(uid: number, gid: number): void {\n\t\tif (!this._fs.metadata.supportsProperties) {\n\t\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t\t}\n\t\tthis._dirty = true;\n\t\tthis._stat.chown(uid, gid);\n\t\tthis.syncSync();\n\t}\n\n\tprotected isDirty(): boolean {\n\t\treturn this._dirty;\n\t}\n\n\t/**\n\t * Resets the dirty bit. Should only be called after a sync has completed successfully.\n\t */\n\tprotected resetDirty() {\n\t\tthis._dirty = false;\n\t}\n}\n\n/**\n * File class for the InMemory and XHR file systems.\n * Doesn't sync to anything, so it works nicely for memory-only files.\n */\nexport class NoSyncFile<T extends FileSystem> extends PreloadFile<T> implements File {\n\tconstructor(_fs: T, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array) {\n\t\tsuper(_fs, _path, _flag, _stat, contents);\n\t}\n\t/**\n\t * Asynchronous sync. Doesn't do anything, simply calls the cb.\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\tpublic async sync(): Promise<void> {\n\t\treturn;\n\t}\n\t/**\n\t * Synchronous sync. Doesn't do anything.\n\t */\n\tpublic syncSync(): void {\n\t\t// NOP.\n\t}\n\t/**\n\t * Asynchronous close. Doesn't do anything, simply calls the cb.\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\tpublic async close(): Promise<void> {\n\t\treturn;\n\t}\n\t/**\n\t * Synchronous close. Doesn't do anything.\n\t */\n\tpublic closeSync(): void {\n\t\t// NOP.\n\t}\n}\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\n// disable no-unused-vars since BaseFileSystem uses them a lot\n\nimport { ApiError, ErrorCode } from './ApiError.js';\nimport { Stats } from './stats.js';\nimport { File, FileFlag, ActionType } from './file.js';\nimport * as path from './emulation/path.js';\nimport { Cred } from './cred.js';\nimport { encode } from './utils.js';\n\nexport type NoArgCallback = (e?: ApiError) => unknown;\nexport type TwoArgCallback<T> = (e?: ApiError, rv?: T) => unknown;\nexport type ThreeArgCallback<T, U> = (e?: ApiError, arg1?: T, arg2?: U) => unknown;\n\nexport type FileContents = Uint8Array | string;\n\n/**\n * Metadata about a FileSystem\n */\nexport interface FileSystemMetadata {\n\t/**\n\t * The name of the FS\n\t */\n\tname: string;\n\n\t/**\n\t * Wheter the FS is readonly or not\n\t */\n\treadonly: boolean;\n\n\t/**\n\t * Does the FS support synchronous operations\n\t */\n\tsynchronous: boolean;\n\n\t/**\n\t * Does the FS support properties\n\t */\n\tsupportsProperties: boolean;\n\n\t/**\n\t * Does the FS support links\n\t */\n\tsupportsLinks: boolean;\n\n\t/**\n\t * The total space\n\t */\n\ttotalSpace: number;\n\n\t/**\n\t * The available space\n\t */\n\tfreeSpace: number;\n}\n\n/**\n * Structure for a filesystem. **All** BrowserFS FileSystems must implement\n * this.\n *\n * ### Argument Assumptions\n *\n * You can assume the following about arguments passed to each API method:\n *\n * - Every path is an absolute path. `.`, `..`, and other items\n * are resolved into an absolute form.\n * - All arguments are present. Any optional arguments at the Node API level\n * have been passed in with their default values.\n */\nexport abstract class FileSystem {\n\tstatic readonly Name: string;\n\n\tabstract readonly metadata: FileSystemMetadata;\n\n\tconstructor(options?: object) {\n\t\t// unused\n\t}\n\n\tabstract whenReady(): Promise<this>;\n\n\t// File or directory operations\n\t/**\n\t * Asynchronous access.\n\t */\n\tabstract access(p: string, mode: number, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous access.\n\t */\n\tabstract accessSync(p: string, mode: number, cred: Cred): void;\n\t/**\n\t * Asynchronous rename. No arguments other than a possible exception\n\t * are given to the completion callback.\n\t */\n\tabstract rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous rename.\n\t */\n\tabstract renameSync(oldPath: string, newPath: string, cred: Cred): void;\n\t/**\n\t * Asynchronous `stat`.\n\t */\n\tabstract stat(p: string, cred: Cred): Promise<Stats>;\n\t/**\n\t * Synchronous `stat`.\n\t */\n\tabstract statSync(p: string, cred: Cred): Stats;\n\t// File operations\n\t/**\n\t * Asynchronous file open.\n\t * @see http://www.manpagez.com/man/2/open/\n\t * @param flags Handles the complexity of the various file\n\t * modes. See its API for more details.\n\t * @param mode Mode to use to open the file. Can be ignored if the\n\t * filesystem doesn't support permissions.\n\t */\n\tabstract open(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;\n\t/**\n\t * Synchronous file open.\n\t * @see http://www.manpagez.com/man/2/open/\n\t * @param flags Handles the complexity of the various file\n\t * modes. See its API for more details.\n\t * @param mode Mode to use to open the file. Can be ignored if the\n\t * filesystem doesn't support permissions.\n\t */\n\tabstract openSync(p: string, flag: FileFlag, mode: number, cred: Cred): File;\n\t/**\n\t * Asynchronous `unlink`.\n\t */\n\tabstract unlink(p: string, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous `unlink`.\n\t */\n\tabstract unlinkSync(p: string, cred: Cred): void;\n\t// Directory operations\n\t/**\n\t * Asynchronous `rmdir`.\n\t */\n\tabstract rmdir(p: string, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous `rmdir`.\n\t */\n\tabstract rmdirSync(p: string, cred: Cred): void;\n\t/**\n\t * Asynchronous `mkdir`.\n\t * @param mode Mode to make the directory using. Can be ignored if\n\t * the filesystem doesn't support permissions.\n\t */\n\tabstract mkdir(p: string, mode: number, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous `mkdir`.\n\t * @param mode Mode to make the directory using. Can be ignored if\n\t * the filesystem doesn't support permissions.\n\t */\n\tabstract mkdirSync(p: string, mode: number, cred: Cred): void;\n\t/**\n\t * Asynchronous `readdir`. Reads the contents of a directory.\n\t *\n\t * The callback gets two arguments `(err, files)` where `files` is an array of\n\t * the names of the files in the directory excluding `'.'` and `'..'`.\n\t */\n\tabstract readdir(p: string, cred: Cred): Promise<string[]>;\n\t/**\n\t * Synchronous `readdir`. Reads the contents of a directory.\n\t */\n\tabstract readdirSync(p: string, cred: Cred): string[];\n\t// **SUPPLEMENTAL INTERFACE METHODS**\n\t// File or directory operations\n\t/**\n\t * Test whether or not the given path exists by checking with\n\t * the file system. Then call the callback argument with either true or false.\n\t */\n\tabstract exists(p: string, cred: Cred): Promise<boolean>;\n\t/**\n\t * Test whether or not the given path exists by checking with\n\t * the file system.\n\t */\n\tabstract existsSync(p: string, cred: Cred): boolean;\n\t/**\n\t * Asynchronous `realpath`. The callback gets two arguments\n\t * `(err, resolvedPath)`.\n\t *\n\t * Note that the Node API will resolve `path` to an absolute path.\n\t * @param cache An object literal of mapped paths that can be used to\n\t * force a specific path resolution or avoid additional `fs.stat` calls for\n\t * known real paths. If not supplied by the user, it'll be an empty object.\n\t */\n\tabstract realpath(p: string, cred: Cred): Promise<string>;\n\t/**\n\t * Synchronous `realpath`.\n\t *\n\t * Note that the Node API will resolve `path` to an absolute path.\n\t * @param cache An object literal of mapped paths that can be used to\n\t * force a specific path resolution or avoid additional `fs.stat` calls for\n\t * known real paths. If not supplied by the user, it'll be an empty object.\n\t */\n\tabstract realpathSync(p: string, cred: Cred): string;\n\t// File operations\n\t/**\n\t * Asynchronous `truncate`.\n\t */\n\tabstract truncate(p: string, len: number, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous `truncate`.\n\t */\n\tabstract truncateSync(p: string, len: number, cred: Cred): void;\n\t/**\n\t * Asynchronously reads the entire contents of a file.\n\t */\n\tabstract readFile(fname: string, flag: FileFlag, cred: Cred): Promise<Uint8Array>;\n\t/**\n\t * Synchronously reads the entire contents of a file.\n\t */\n\tabstract readFileSync(fname: string, flag: FileFlag, cred: Cred): Uint8Array;\n\t/**\n\t * Asynchronously writes data to a file, replacing the file\n\t * if it already exists.\n\t *\n\t * The encoding option is ignored if data is a buffer.\n\t */\n\tabstract writeFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronously writes data to a file, replacing the file\n\t * if it already exists.\n\t *\n\t * The encoding option is ignored if data is a buffer.\n\t */\n\tabstract writeFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void;\n\t/**\n\t * Asynchronously append data to a file, creating the file if\n\t * it not yet exists.\n\t */\n\tabstract appendFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronously append data to a file, creating the file if\n\t * it not yet exists.\n\t */\n\tabstract appendFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void;\n\t// **OPTIONAL INTERFACE METHODS**\n\t// Property operations\n\t// This isn't always possible on some filesystem types (e.g. Dropbox).\n\t/**\n\t * Asynchronous `chmod`.\n\t */\n\tabstract chmod(p: string, mode: number, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous `chmod`.\n\t */\n\tabstract chmodSync(p: string, mode: number, cred: Cred): void;\n\t/**\n\t * Asynchronous `chown`.\n\t */\n\tabstract chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous `chown`.\n\t */\n\tabstract chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void;\n\t/**\n\t * Change file timestamps of the file referenced by the supplied\n\t * path.\n\t */\n\tabstract utimes(p: string, atime: Date, mtime: Date, cred: Cred): Promise<void>;\n\t/**\n\t * Change file timestamps of the file referenced by the supplied\n\t * path.\n\t */\n\tabstract utimesSync(p: string, atime: Date, mtime: Date, cred: Cred): void;\n\t// Symlink operations\n\t// Symlinks aren't always supported.\n\t/**\n\t * Asynchronous `link`.\n\t */\n\tabstract link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous `link`.\n\t */\n\tabstract linkSync(srcpath: string, dstpath: string, cred: Cred): void;\n\t/**\n\t * Asynchronous `symlink`.\n\t * @param type can be either `'dir'` or `'file'`\n\t */\n\tabstract symlink(srcpath: string, dstpath: string, type: string, cred: Cred): Promise<void>;\n\t/**\n\t * Synchronous `symlink`.\n\t * @param type can be either `'dir'` or `'file'`\n\t */\n\tabstract symlinkSync(srcpath: string, dstpath: string, type: string, cred: Cred): void;\n\t/**\n\t * Asynchronous readlink.\n\t */\n\tabstract readlink(p: string, cred: Cred): Promise<string>;\n\t/**\n\t * Synchronous readlink.\n\t */\n\tabstract readlinkSync(p: string, cred: Cred): string;\n}\n\n/**\n * Basic filesystem class. Most filesystems should extend this class, as it\n * provides default implementations for a handful of methods.\n */\nexport class BaseFileSystem extends FileSystem {\n\tstatic readonly Name: string = this.name;\n\n\tprotected _ready: Promise<this> = Promise.resolve(this);\n\n\tpublic constructor(options?: { [key: string]: unknown }) {\n\t\tsuper();\n\t}\n\n\tpublic get metadata(): FileSystemMetadata {\n\t\treturn {\n\t\t\tname: this.constructor.name,\n\t\t\treadonly: false,\n\t\t\tsynchronous: false,\n\t\t\tsupportsProperties: false,\n\t\t\tsupportsLinks: false,\n\t\t\ttotalSpace: 0,\n\t\t\tfreeSpace: 0,\n\t\t};\n\t}\n\n\tpublic whenReady(): Promise<this> {\n\t\treturn this._ready;\n\t}\n\n\t/**\n\t * Opens the file at path p with the given flag. The file must exist.\n\t * @param p The path to open.\n\t * @param flag The flag to use when opening the file.\n\t */\n\tpublic async openFile(p: string, flag: FileFlag, cred: Cred): Promise<File> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\t/**\n\t * Create the file at path p with the given mode. Then, open it with the given\n\t * flag.\n\t */\n\tpublic async createFile(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async open(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File> {\n\t\ttry {\n\t\t\tconst stats = await this.stat(p, cred);\n\t\t\tswitch (flag.pathExistsAction()) {\n\t\t\t\tcase ActionType.THROW_EXCEPTION:\n\t\t\t\t\tthrow ApiError.EEXIST(p);\n\t\t\t\tcase ActionType.TRUNCATE_FILE:\n\t\t\t\t\t// NOTE: In a previous implementation, we deleted the file and\n\t\t\t\t\t// re-created it. However, this created a race condition if another\n\t\t\t\t\t// asynchronous request was trying to read the file, as the file\n\t\t\t\t\t// would not exist for a small period of time.\n\t\t\t\t\tconst fd = await this.openFile(p, flag, cred);\n\t\t\t\t\tif (!fd) throw new Error('BFS has reached an impossible code path; please file a bug.');\n\n\t\t\t\t\tawait fd.truncate(0);\n\t\t\t\t\tawait fd.sync();\n\t\t\t\t\treturn fd;\n\t\t\t\tcase ActionType.NOP:\n\t\t\t\t\treturn this.openFile(p, flag, cred);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');\n\t\t\t}\n\t\t\t// File exists.\n\t\t} catch (e) {\n\t\t\t// File does not exist.\n\t\t\tswitch (flag.pathNotExistsAction()) {\n\t\t\t\tcase ActionType.CREATE_FILE:\n\t\t\t\t\t// Ensure parent exists.\n\t\t\t\t\tconst parentStats = await this.stat(path.dirname(p), cred);\n\t\t\t\t\tif (parentStats && !parentStats.isDirectory()) {\n\t\t\t\t\t\tthrow ApiError.ENOTDIR(path.dirname(p));\n\t\t\t\t\t}\n\t\t\t\t\treturn this.createFile(p, flag, mode, cred);\n\t\t\t\tcase ActionType.THROW_EXCEPTION:\n\t\t\t\t\tthrow ApiError.ENOENT(p);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');\n\t\t\t}\n\t\t}\n\t}\n\tpublic async access(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic accessSync(p: string, mode: number, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async rename(oldPath: string, newPath: string, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic renameSync(oldPath: string, newPath: string, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async stat(p: string, cred: Cred): Promise<Stats> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic statSync(p: string, cred: Cred): Stats {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\t/**\n\t * Opens the file at path p with the given flag. The file must exist.\n\t * @param p The path to open.\n\t * @param flag The flag to use when opening the file.\n\t * @return A File object corresponding to the opened file.\n\t */\n\tpublic openFileSync(p: string, flag: FileFlag, cred: Cred): File {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\t/**\n\t * Create the file at path p with the given mode. Then, open it with the given\n\t * flag.\n\t */\n\tpublic createFileSync(p: string, flag: FileFlag, mode: number, cred: Cred): File {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic openSync(p: string, flag: FileFlag, mode: number, cred: Cred): File {\n\t\t// Check if the path exists, and is a file.\n\t\tlet stats: Stats;\n\t\ttry {\n\t\t\tstats = this.statSync(p, cred);\n\t\t} catch (e) {\n\t\t\t// File does not exist.\n\t\t\tswitch (flag.pathNotExistsAction()) {\n\t\t\t\tcase ActionType.CREATE_FILE:\n\t\t\t\t\t// Ensure parent exists.\n\t\t\t\t\tconst parentStats = this.statSync(path.dirname(p), cred);\n\t\t\t\t\tif (!parentStats.isDirectory()) {\n\t\t\t\t\t\tthrow ApiError.ENOTDIR(path.dirname(p));\n\t\t\t\t\t}\n\t\t\t\t\treturn this.createFileSync(p, flag, mode, cred);\n\t\t\t\tcase ActionType.THROW_EXCEPTION:\n\t\t\t\t\tthrow ApiError.ENOENT(p);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');\n\t\t\t}\n\t\t}\n\t\tif (!stats.hasAccess(mode, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\n\t\t// File exists.\n\t\tswitch (flag.pathExistsAction()) {\n\t\t\tcase ActionType.THROW_EXCEPTION:\n\t\t\t\tthrow ApiError.EEXIST(p);\n\t\t\tcase ActionType.TRUNCATE_FILE:\n\t\t\t\t// Delete file.\n\t\t\t\tthis.unlinkSync(p, cred);\n\t\t\t\t// Create file. Use the same mode as the old file.\n\t\t\t\t// Node itself modifies the ctime when this occurs, so this action\n\t\t\t\t// will preserve that behavior if the underlying file system\n\t\t\t\t// supports those properties.\n\t\t\t\treturn this.createFileSync(p, flag, stats.mode, cred);\n\t\t\tcase ActionType.NOP:\n\t\t\t\treturn this.openFileSync(p, flag, cred);\n\t\t\tdefault:\n\t\t\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');\n\t\t}\n\t}\n\tpublic async unlink(p: string, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic unlinkSync(p: string, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async rmdir(p: string, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic rmdirSync(p: string, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async mkdir(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic mkdirSync(p: string, mode: number, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async readdir(p: string, cred: Cred): Promise<string[]> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic readdirSync(p: string, cred: Cred): string[] {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async exists(p: string, cred: Cred): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.stat(p, cred);\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tpublic existsSync(p: string, cred: Cred): boolean {\n\t\ttry {\n\t\t\tthis.statSync(p, cred);\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tpublic async realpath(p: string, cred: Cred): Promise<string> {\n\t\tif (this.metadata.supportsLinks) {\n\t\t\t// The path could contain symlinks. Split up the path,\n\t\t\t// resolve any symlinks, return the resolved string.\n\t\t\tconst splitPath = p.split(path.sep);\n\t\t\t// TODO: Simpler to just pass through file, find sep and such.\n\t\t\tfor (let i = 0; i < splitPath.length; i++) {\n\t\t\t\tconst addPaths = splitPath.slice(0, i + 1);\n\t\t\t\tsplitPath[i] = path.join(...addPaths);\n\t\t\t}\n\t\t\treturn splitPath.join(path.sep);\n\t\t} else {\n\t\t\t// No symlinks. We just need to verify that it exists.\n\t\t\tif (!(await this.exists(p, cred))) {\n\t\t\t\tthrow ApiError.ENOENT(p);\n\t\t\t}\n\t\t\treturn p;\n\t\t}\n\t}\n\tpublic realpathSync(p: string, cred: Cred): string {\n\t\tif (this.metadata.supportsLinks) {\n\t\t\t// The path could contain symlinks. Split up the path,\n\t\t\t// resolve any symlinks, return the resolved string.\n\t\t\tconst splitPath = p.split(path.sep);\n\t\t\t// TODO: Simpler to just pass through file, find sep and such.\n\t\t\tfor (let i = 0; i < splitPath.length; i++) {\n\t\t\t\tconst addPaths = splitPath.slice(0, i + 1);\n\t\t\t\tsplitPath[i] = path.join(...addPaths);\n\t\t\t}\n\t\t\treturn splitPath.join(path.sep);\n\t\t} else {\n\t\t\t// No symlinks. We just need to verify that it exists.\n\t\t\tif (this.existsSync(p, cred)) {\n\t\t\t\treturn p;\n\t\t\t} else {\n\t\t\t\tthrow ApiError.ENOENT(p);\n\t\t\t}\n\t\t}\n\t}\n\tpublic async truncate(p: string, len: number, cred: Cred): Promise<void> {\n\t\tconst fd = await this.open(p, FileFlag.getFileFlag('r+'), 0o644, cred);\n\t\ttry {\n\t\t\tawait fd.truncate(len);\n\t\t} finally {\n\t\t\tawait fd.close();\n\t\t}\n\t}\n\tpublic truncateSync(p: string, len: number, cred: Cred): void {\n\t\tconst fd = this.openSync(p, FileFlag.getFileFlag('r+'), 0o644, cred);\n\t\t// Need to safely close FD, regardless of whether or not truncate succeeds.\n\t\ttry {\n\t\t\tfd.truncateSync(len);\n\t\t} finally {\n\t\t\tfd.closeSync();\n\t\t}\n\t}\n\tpublic async readFile(fname: string, flag: FileFlag, cred: Cred): Promise<Uint8Array> {\n\t\t// Get file.\n\t\tconst fd = await this.open(fname, flag, 0o644, cred);\n\t\ttry {\n\t\t\tconst stat = await fd.stat();\n\t\t\t// Allocate buffer.\n\t\t\tconst buf = new Uint8Array(stat.size);\n\t\t\tawait fd.read(buf, 0, stat.size, 0);\n\t\t\tawait fd.close();\n\t\t\treturn buf;\n\t\t} finally {\n\t\t\tawait fd.close();\n\t\t}\n\t}\n\tpublic readFileSync(fname: string, flag: FileFlag, cred: Cred): Uint8Array {\n\t\t// Get file.\n\t\tconst fd = this.openSync(fname, flag, 0o644, cred);\n\t\ttry {\n\t\t\tconst stat = fd.statSync();\n\t\t\t// Allocate buffer.\n\t\t\tconst buf = new Uint8Array(stat.size);\n\t\t\tfd.readSync(buf, 0, stat.size, 0);\n\t\t\tfd.closeSync();\n\t\t\treturn buf;\n\t\t} finally {\n\t\t\tfd.closeSync();\n\t\t}\n\t}\n\tpublic async writeFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void> {\n\t\t// Get file.\n\t\tconst fd = await this.open(fname, flag, mode, cred);\n\t\ttry {\n\t\t\tif (typeof data === 'string') {\n\t\t\t\tdata = encode(data);\n\t\t\t}\n\t\t\t// Write into file.\n\t\t\tawait fd.write(data, 0, data.length, 0);\n\t\t} finally {\n\t\t\tawait fd.close();\n\t\t}\n\t}\n\tpublic writeFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void {\n\t\t// Get file.\n\t\tconst fd = this.openSync(fname, flag, mode, cred);\n\t\ttry {\n\t\t\tif (typeof data === 'string') {\n\t\t\t\tdata = encode(data);\n\t\t\t}\n\t\t\t// Write into file.\n\t\t\tfd.writeSync(data, 0, data.length, 0);\n\t\t} finally {\n\t\t\tfd.closeSync();\n\t\t}\n\t}\n\tpublic async appendFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void> {\n\t\tconst fd = await this.open(fname, flag, mode, cred);\n\t\ttry {\n\t\t\tif (typeof data === 'string') {\n\t\t\t\tdata = encode(data);\n\t\t\t}\n\t\t\tawait fd.write(data, 0, data.length, null);\n\t\t} finally {\n\t\t\tawait fd.close();\n\t\t}\n\t}\n\tpublic appendFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void {\n\t\tconst fd = this.openSync(fname, flag, mode, cred);\n\t\ttry {\n\t\t\tif (typeof data === 'string') {\n\t\t\t\tdata = encode(data);\n\t\t\t}\n\t\t\tfd.writeSync(data, 0, data.length, null);\n\t\t} finally {\n\t\t\tfd.closeSync();\n\t\t}\n\t}\n\tpublic async chmod(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic chmodSync(p: string, mode: number, cred: Cred) {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async utimes(p: string, atime: Date, mtime: Date, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic utimesSync(p: string, atime: Date, mtime: Date, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async link(srcpath: string, dstpath: string, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic linkSync(srcpath: string, dstpath: string, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async symlink(srcpath: string, dstpath: string, type: string, cred: Cred): Promise<void> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic symlinkSync(srcpath: string, dstpath: string, type: string, cred: Cred): void {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic async readlink(p: string, cred: Cred): Promise<string> {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n\tpublic readlinkSync(p: string, cred: Cred): string {\n\t\tthrow new ApiError(ErrorCode.ENOTSUP);\n\t}\n}\n\n/**\n * Implements the asynchronous API in terms of the synchronous API.\n */\nexport class SynchronousFileSystem extends BaseFileSystem {\n\tpublic get metadata(): FileSystemMetadata {\n\t\treturn { ...super.metadata, synchronous: true };\n\t}\n\n\tpublic async access(p: string, mode: number, cred: Cred): Promise<void> {\n\t\treturn this.accessSync(p, mode, cred);\n\t}\n\n\tpublic async rename(oldPath: string, newPath: string, cred: Cred): Promise<void> {\n\t\treturn this.renameSync(oldPath, newPath, cred);\n\t}\n\n\tpublic async stat(p: string | null, cred: Cred): Promise<Stats> {\n\t\treturn this.statSync(p, cred);\n\t}\n\n\tpublic async open(p: string, flags: FileFlag, mode: number, cred: Cred): Promise<File> {\n\t\treturn this.openSync(p, flags, mode, cred);\n\t}\n\n\tpublic async unlink(p: string, cred: Cred): Promise<void> {\n\t\treturn this.unlinkSync(p, cred);\n\t}\n\n\tpublic async rmdir(p: string, cred: Cred): Promise<void> {\n\t\treturn this.rmdirSync(p, cred);\n\t}\n\n\tpublic async mkdir(p: string, mode: number, cred: Cred): Promise<void> {\n\t\treturn this.mkdirSync(p, mode, cred);\n\t}\n\n\tpublic async readdir(p: string, cred: Cred): Promise<string[]> {\n\t\treturn this.readdirSync(p, cred);\n\t}\n\n\tpublic async chmod(p: string, mode: number, cred: Cred): Promise<void> {\n\t\treturn this.chmodSync(p, mode, cred);\n\t}\n\n\tpublic async chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void> {\n\t\treturn this.chownSync(p, new_uid, new_gid, cred);\n\t}\n\n\tpublic async utimes(p: string, atime: Date, mtime: Date, cred: Cred): Promise<void> {\n\t\treturn this.utimesSync(p, atime, mtime, cred);\n\t}\n\n\tpublic async link(srcpath: string, dstpath: string, cred: Cred): Promise<void> {\n\t\treturn this.linkSync(srcpath, dstpath, cred);\n\t}\n\n\tpublic async symlink(srcpath: string, dstpath: string, type: string, cred: Cred): Promise<void> {\n\t\treturn this.symlinkSync(srcpath, dstpath, type, cred);\n\t}\n\n\tpublic async readlink(p: string, cred: Cred): Promise<string> {\n\t\treturn this.readlinkSync(p, cred);\n\t}\n}\n", "import { Stats, FileType } from './stats.js';\nimport { decode, encode } from './utils.js';\n\n/**\n * Generic inode definition that can easily be serialized.\n */\nexport default class Inode {\n\t/**\n\t * Converts the buffer into an Inode.\n\t */\n\tpublic static Deserialize(data: ArrayBufferLike | ArrayBufferView): Inode {\n\t\tconst view = new DataView('buffer' in data ? data.buffer : data);\n\t\treturn new Inode(\n\t\t\tdecode(view.buffer.slice(38)),\n\t\t\tview.getUint32(0, true),\n\t\t\tview.getUint16(4, true),\n\t\t\tview.getFloat64(6, true),\n\t\t\tview.getFloat64(14, true),\n\t\t\tview.getFloat64(22, true),\n\t\t\tview.getUint32(30, true),\n\t\t\tview.getUint32(34, true)\n\t\t);\n\t}\n\n\tconstructor(\n\t\tpublic id: string,\n\t\tpublic size: number,\n\t\tpublic mode: number,\n\t\tpublic atime: number,\n\t\tpublic mtime: number,\n\t\tpublic ctime: number,\n\t\tpublic uid: number,\n\t\tpublic gid: number\n\t) {}\n\n\t/**\n\t * Handy function that converts the Inode to a Node Stats object.\n\t */\n\tpublic toStats(): Stats {\n\t\treturn new Stats(\n\t\t\t(this.mode & 0xf000) === FileType.DIRECTORY ? FileType.DIRECTORY : FileType.FILE,\n\t\t\tthis.size,\n\t\t\tthis.mode,\n\t\t\tthis.atime,\n\t\t\tthis.mtime,\n\t\t\tthis.ctime,\n\t\t\tthis.uid,\n\t\t\tthis.gid\n\t\t);\n\t}\n\n\t/**\n\t * Get the size of this Inode, in bytes.\n\t */\n\tpublic getSize(): number {\n\t\t// ASSUMPTION: ID is 1 byte per char.\n\t\treturn 38 + this.id.length;\n\t}\n\n\t/**\n\t * Writes the inode into the start of the buffer.\n\t */\n\tpublic serialize(data: ArrayBufferLike | ArrayBufferView = new Uint8Array(this.getSize())): Uint8Array {\n\t\tconst view = new DataView('buffer' in data ? data.buffer : data);\n\t\tview.setUint32(0, this.size, true);\n\t\tview.setUint16(4, this.mode, true);\n\t\tview.setFloat64(6, this.atime, true);\n\t\tview.setFloat64(14, this.mtime, true);\n\t\tview.setFloat64(22, this.ctime, true);\n\t\tview.setUint32(30, this.uid, true);\n\t\tview.setUint32(34, this.gid, true);\n\t\tconst buffer = new Uint8Array(view.buffer);\n\t\tbuffer.set(encode(this.id), 38);\n\t\treturn buffer;\n\t}\n\n\t/**\n\t * Updates the Inode using information from the stats object. Used by file\n\t * systems at sync time, e.g.:\n\t * - Program opens file and gets a File object.\n\t * - Program mutates file. File object is responsible for maintaining\n\t * metadata changes locally -- typically in a Stats object.\n\t * - Program closes file. File object's metadata changes are synced with the\n\t * file system.\n\t * @return True if any changes have occurred.\n\t */\n\tpublic update(stats: Stats): boolean {\n\t\tlet hasChanged = false;\n\t\tif (this.size !== stats.size) {\n\t\t\tthis.size = stats.size;\n\t\t\thasChanged = true;\n\t\t}\n\n\t\tif (this.mode !== stats.mode) {\n\t\t\tthis.mode = stats.mode;\n\t\t\thasChanged = true;\n\t\t}\n\n\t\tconst atimeMs = stats.atime.getTime();\n\t\tif (this.atime !== atimeMs) {\n\t\t\tthis.atime = atimeMs;\n\t\t\thasChanged = true;\n\t\t}\n\n\t\tconst mtimeMs = stats.mtime.getTime();\n\t\tif (this.mtime !== mtimeMs) {\n\t\t\tthis.mtime = mtimeMs;\n\t\t\thasChanged = true;\n\t\t}\n\n\t\tconst ctimeMs = stats.ctime.getTime();\n\t\tif (this.ctime !== ctimeMs) {\n\t\t\tthis.ctime = ctimeMs;\n\t\t\thasChanged = true;\n\t\t}\n\n\t\tif (this.uid !== stats.uid) {\n\t\t\tthis.uid = stats.uid;\n\t\t\thasChanged = true;\n\t\t}\n\n\t\tif (this.uid !== stats.uid) {\n\t\t\tthis.uid = stats.uid;\n\t\t\thasChanged = true;\n\t\t}\n\n\t\treturn hasChanged;\n\t}\n\n\t// XXX: Copied from Stats. Should reconcile these two into something more\n\t// compact.\n\n\t/**\n\t * @return [Boolean] True if this item is a file.\n\t */\n\tpublic isFile(): boolean {\n\t\treturn (this.mode & 0xf000) === FileType.FILE;\n\t}\n\n\t/**\n\t * @return [Boolean] True if this item is a directory.\n\t */\n\tpublic isDirectory(): boolean {\n\t\treturn (this.mode & 0xf000) === FileType.DIRECTORY;\n\t}\n}\n", "import { dirname, basename, join, resolve, sep } from '../emulation/path.js';\nimport { ApiError, ErrorCode } from '../ApiError.js';\nimport { Cred } from '../cred.js';\nimport { W_OK, R_OK } from '../emulation/constants.js';\nimport { FileFlag, PreloadFile } from '../file.js';\nimport { SynchronousFileSystem } from '../filesystem.js';\nimport Inode from '../inode.js';\nimport { Stats, FileType } from '../stats.js';\nimport { decode, encode, randomUUID, ROOT_NODE_ID } from '../utils.js';\n\n/**\n * Represents a *synchronous* key-value store.\n */\nexport interface SyncKeyValueStore {\n\t/**\n\t * The name of the key-value store.\n\t */\n\tname(): string;\n\t/**\n\t * Empties the key-value store completely.\n\t */\n\tclear(): void;\n\t/**\n\t * Begins a new read-only transaction.\n\t */\n\tbeginTransaction(type: 'readonly'): SyncKeyValueROTransaction;\n\t/**\n\t * Begins a new read-write transaction.\n\t */\n\tbeginTransaction(type: 'readwrite'): SyncKeyValueRWTransaction;\n\tbeginTransaction(type: string): SyncKeyValueROTransaction;\n}\n\n/**\n * A read-only transaction for a synchronous key value store.\n */\nexport interface SyncKeyValueROTransaction {\n\t/**\n\t * Retrieves the data at the given key. Throws an ApiError if an error occurs\n\t * or if the key does not exist.\n\t * @param key The key to look under for data.\n\t * @return The data stored under the key, or undefined if not present.\n\t */\n\tget(key: string): Uint8Array | undefined;\n}\n\n/**\n * A read-write transaction for a synchronous key value store.\n */\nexport interface SyncKeyValueRWTransaction extends SyncKeyValueROTransaction {\n\t/**\n\t * Adds the data to the store under the given key.\n\t * @param key The key to add the data under.\n\t * @param data The data to add to the store.\n\t * @param overwrite If 'true', overwrite any existing data. If 'false',\n\t * avoids storing the data if the key exists.\n\t * @return True if storage succeeded, false otherwise.\n\t */\n\tput(key: string, data: Uint8Array, overwrite: boolean): boolean;\n\t/**\n\t * Deletes the data at the given key.\n\t * @param key The key to delete from the store.\n\t */\n\tdel(key: string): void;\n\t/**\n\t * Commits the transaction.\n\t */\n\tcommit(): void;\n\t/**\n\t * Aborts and rolls back the transaction.\n\t */\n\tabort(): void;\n}\n\n/**\n * An interface for simple synchronous key-value stores that don't have special\n * support for transactions and such.\n */\nexport interface SimpleSyncStore {\n\tget(key: string): Uint8Array | undefined;\n\tput(key: string, data: Uint8Array, overwrite: boolean): boolean;\n\tdel(key: string): void;\n}\n\n/**\n * A simple RW transaction for simple synchronous key-value stores.\n */\nexport class SimpleSyncRWTransaction implements SyncKeyValueRWTransaction {\n\t/**\n\t * Stores data in the keys we modify prior to modifying them.\n\t * Allows us to roll back commits.\n\t */\n\tprivate originalData: { [key: string]: Uint8Array | undefined } = {};\n\t/**\n\t * List of keys modified in this transaction, if any.\n\t */\n\tprivate modifiedKeys: string[] = [];\n\n\tconstructor(private store: SimpleSyncStore) {}\n\n\tpublic get(key: string): Uint8Array | undefined {\n\t\tconst val = this.store.get(key);\n\t\tthis.stashOldValue(key, val);\n\t\treturn val;\n\t}\n\n\tpublic put(key: string, data: Uint8Array, overwrite: boolean): boolean {\n\t\tthis.markModified(key);\n\t\treturn this.store.put(key, data, overwrite);\n\t}\n\n\tpublic del(key: string): void {\n\t\tthis.markModified(key);\n\t\tthis.store.del(key);\n\t}\n\n\tpublic commit(): void {\n\t\t/* NOP */\n\t}\n\n\tpublic abort(): void {\n\t\t// Rollback old values.\n\t\tfor (const key of this.modifiedKeys) {\n\t\t\tconst value = this.originalData[key];\n\t\t\tif (!value) {\n\t\t\t\t// Key didn't exist.\n\t\t\t\tthis.store.del(key);\n\t\t\t} else {\n\t\t\t\t// Key existed. Store old value.\n\t\t\t\tthis.store.put(key, value, true);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _has(key: string) {\n\t\treturn Object.prototype.hasOwnProperty.call(this.originalData, key);\n\t}\n\n\t/**\n\t * Stashes given key value pair into `originalData` if it doesn't already\n\t * exist. Allows us to stash values the program is requesting anyway to\n\t * prevent needless `get` requests if the program modifies the data later\n\t * on during the transaction.\n\t */\n\tprivate stashOldValue(key: string, value: Uint8Array | undefined) {\n\t\t// Keep only the earliest value in the transaction.\n\t\tif (!this._has(key)) {\n\t\t\tthis.originalData[key] = value;\n\t\t}\n\t}\n\n\t/**\n\t * Marks the given key as modified, and stashes its value if it has not been\n\t * stashed already.\n\t */\n\tprivate markModified(key: string) {\n\t\tif (this.modifiedKeys.indexOf(key) === -1) {\n\t\t\tthis.modifiedKeys.push(key);\n\t\t\tif (!this._has(key)) {\n\t\t\t\tthis.originalData[key] = this.store.get(key);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport interface SyncKeyValueFileSystemOptions {\n\t/**\n\t * The actual key-value store to read from/write to.\n\t */\n\tstore: SyncKeyValueStore;\n\t/**\n\t * Should the file system support properties (mtime/atime/ctime/chmod/etc)?\n\t * Enabling this slightly increases the storage space per file, and adds\n\t * atime updates every time a file is accessed, mtime updates every time\n\t * a file is modified, and permission checks on every operation.\n\t *\n\t * Defaults to *false*.\n\t */\n\tsupportProps?: boolean;\n\t/**\n\t * Should the file system support links?\n\t */\n\tsupportLinks?: boolean;\n}\n\nexport class SyncKeyValueFile extends PreloadFile<SyncKeyValueFileSystem> {\n\tconstructor(_fs: SyncKeyValueFileSystem, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array) {\n\t\tsuper(_fs, _path, _flag, _stat, contents);\n\t}\n\n\tpublic syncSync(): void {\n\t\tif (this.isDirty()) {\n\t\t\tthis._fs._syncSync(this.getPath(), this.getBuffer(), this.getStats());\n\t\t\tthis.resetDirty();\n\t\t}\n\t}\n\n\tpublic closeSync(): void {\n\t\tthis.syncSync();\n\t}\n}\n\n/**\n * A \"Synchronous key-value file system\". Stores data to/retrieves data from an\n * underlying key-value store.\n *\n * We use a unique ID for each node in the file system. The root node has a\n * fixed ID.\n * @todo Introduce Node ID caching.\n * @todo Check modes.\n */\nexport class SyncKeyValueFileSystem extends SynchronousFileSystem {\n\tpublic static isAvailable(): boolean {\n\t\treturn true;\n\t}\n\n\tprivate store: SyncKeyValueStore;\n\n\tconstructor(options: SyncKeyValueFileSystemOptions) {\n\t\tsuper();\n\t\tthis.store = options.store;\n\t\t// INVARIANT: Ensure that the root exists.\n\t\tthis.makeRootDirectory();\n\t}\n\n\tpublic getName(): string {\n\t\treturn this.store.name();\n\t}\n\tpublic isReadOnly(): boolean {\n\t\treturn false;\n\t}\n\tpublic supportsSymlinks(): boolean {\n\t\treturn false;\n\t}\n\tpublic supportsProps(): boolean {\n\t\treturn true;\n\t}\n\tpublic supportsSynch(): boolean {\n\t\treturn true;\n\t}\n\n\t/**\n\t * Delete all contents stored in the file system.\n\t */\n\tpublic empty(): void {\n\t\tthis.store.clear();\n\t\t// INVARIANT: Root always exists.\n\t\tthis.makeRootDirectory();\n\t}\n\n\tpublic accessSync(p: string, mode: number, cred: Cred): void {\n\t\tconst tx = this.store.beginTransaction('readonly'),\n\t\t\tnode = this.findINode(tx, p);\n\t\tif (!node.toStats().hasAccess(mode, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\t}\n\n\tpublic renameSync(oldPath: string, newPath: string, cred: Cred): void {\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\toldParent = dirname(oldPath),\n\t\t\toldName = basename(oldPath),\n\t\t\tnewParent = dirname(newPath),\n\t\t\tnewName = basename(newPath),\n\t\t\t// Remove oldPath from parent's directory listing.\n\t\t\toldDirNode = this.findINode(tx, oldParent),\n\t\t\toldDirList = this.getDirListing(tx, oldParent, oldDirNode);\n\n\t\tif (!oldDirNode.toStats().hasAccess(W_OK, cred)) {\n\t\t\tthrow ApiError.EACCES(oldPath);\n\t\t}\n\n\t\tif (!oldDirList[oldName]) {\n\t\t\tthrow ApiError.ENOENT(oldPath);\n\t\t}\n\t\tconst nodeId: string = oldDirList[oldName];\n\t\tdelete oldDirList[oldName];\n\n\t\t// Invariant: Can't move a folder inside itself.\n\t\t// This funny little hack ensures that the check passes only if oldPath\n\t\t// is a subpath of newParent. We append '/' to avoid matching folders that\n\t\t// are a substring of the bottom-most folder in the path.\n\t\tif ((newParent + '/').indexOf(oldPath + '/') === 0) {\n\t\t\tthrow new ApiError(ErrorCode.EBUSY, oldParent);\n\t\t}\n\n\t\t// Add newPath to parent's directory listing.\n\t\tlet newDirNode: Inode, newDirList: typeof oldDirList;\n\t\tif (newParent === oldParent) {\n\t\t\t// Prevent us from re-grabbing the same directory listing, which still\n\t\t\t// contains oldName.\n\t\t\tnewDirNode = oldDirNode;\n\t\t\tnewDirList = oldDirList;\n\t\t} else {\n\t\t\tnewDirNode = this.findINode(tx, newParent);\n\t\t\tnewDirList = this.getDirListing(tx, newParent, newDirNode);\n\t\t}\n\n\t\tif (newDirList[newName]) {\n\t\t\t// If it's a file, delete it.\n\t\t\tconst newNameNode = this.getINode(tx, newPath, newDirList[newName]);\n\t\t\tif (newNameNode.isFile()) {\n\t\t\t\ttry {\n\t\t\t\t\ttx.del(newNameNode.id);\n\t\t\t\t\ttx.del(newDirList[newName]);\n\t\t\t\t} catch (e) {\n\t\t\t\t\ttx.abort();\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// If it's a directory, throw a permissions error.\n\t\t\t\tthrow ApiError.EPERM(newPath);\n\t\t\t}\n\t\t}\n\t\tnewDirList[newName] = nodeId;\n\n\t\t// Commit the two changed directory listings.\n\t\ttry {\n\t\t\ttx.put(oldDirNode.id, encode(JSON.stringify(oldDirList)), true);\n\t\t\ttx.put(newDirNode.id, encode(JSON.stringify(newDirList)), true);\n\t\t} catch (e) {\n\t\t\ttx.abort();\n\t\t\tthrow e;\n\t\t}\n\n\t\ttx.commit();\n\t}\n\n\tpublic statSync(p: string, cred: Cred): Stats {\n\t\t// Get the inode to the item, convert it into a Stats object.\n\t\tconst stats = this.findINode(this.store.beginTransaction('readonly'), p).toStats();\n\t\tif (!stats.hasAccess(R_OK, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\t\treturn stats;\n\t}\n\n\tpublic createFileSync(p: string, flag: FileFlag, mode: number, cred: Cred): SyncKeyValueFile {\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\tdata = new Uint8Array(0),\n\t\t\tnewFile = this.commitNewFile(tx, p, FileType.FILE, mode, cred, data);\n\t\t// Open the file.\n\t\treturn new SyncKeyValueFile(this, p, flag, newFile.toStats(), data);\n\t}\n\n\tpublic openFileSync(p: string, flag: FileFlag, cred: Cred): SyncKeyValueFile {\n\t\tconst tx = this.store.beginTransaction('readonly'),\n\t\t\tnode = this.findINode(tx, p),\n\t\t\tdata = tx.get(node.id);\n\t\tif (!node.toStats().hasAccess(flag.getMode(), cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\t\tif (data === undefined) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t\treturn new SyncKeyValueFile(this, p, flag, node.toStats(), data);\n\t}\n\n\tpublic unlinkSync(p: string, cred: Cred): void {\n\t\tthis.removeEntry(p, false, cred);\n\t}\n\n\tpublic rmdirSync(p: string, cred: Cred): void {\n\t\t// Check first if directory is empty.\n\t\tif (this.readdirSync(p, cred).length > 0) {\n\t\t\tthrow ApiError.ENOTEMPTY(p);\n\t\t} else {\n\t\t\tthis.removeEntry(p, true, cred);\n\t\t}\n\t}\n\n\tpublic mkdirSync(p: string, mode: number, cred: Cred): void {\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\tdata = encode('{}');\n\t\tthis.commitNewFile(tx, p, FileType.DIRECTORY, mode, cred, data);\n\t}\n\n\tpublic readdirSync(p: string, cred: Cred): string[] {\n\t\tconst tx = this.store.beginTransaction('readonly');\n\t\tconst node = this.findINode(tx, p);\n\t\tif (!node.toStats().hasAccess(R_OK, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\t\treturn Object.keys(this.getDirListing(tx, p, node));\n\t}\n\n\tpublic chmodSync(p: string, mode: number, cred: Cred): void {\n\t\tconst fd = this.openFileSync(p, FileFlag.getFileFlag('r+'), cred);\n\t\tfd.chmodSync(mode);\n\t}\n\n\tpublic chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void {\n\t\tconst fd = this.openFileSync(p, FileFlag.getFileFlag('r+'), cred);\n\t\tfd.chownSync(new_uid, new_gid);\n\t}\n\n\tpublic _syncSync(p: string, data: Uint8Array, stats: Stats): void {\n\t\t// @todo Ensure mtime updates properly, and use that to determine if a data\n\t\t// update is required.\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\t// We use the _findInode helper because we actually need the INode id.\n\t\t\tfileInodeId = this._findINode(tx, dirname(p), basename(p)),\n\t\t\tfileInode = this.getINode(tx, p, fileInodeId),\n\t\t\tinodeChanged = fileInode.update(stats);\n\n\t\ttry {\n\t\t\t// Sync data.\n\t\t\ttx.put(fileInode.id, data, true);\n\t\t\t// Sync metadata.\n\t\t\tif (inodeChanged) {\n\t\t\t\ttx.put(fileInodeId, fileInode.serialize(), true);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\ttx.abort();\n\t\t\tthrow e;\n\t\t}\n\t\ttx.commit();\n\t}\n\n\t/**\n\t * Checks if the root directory exists. Creates it if it doesn't.\n\t */\n\tprivate makeRootDirectory() {\n\t\tconst tx = this.store.beginTransaction('readwrite');\n\t\tif (tx.get(ROOT_NODE_ID) === undefined) {\n\t\t\t// Create new inode.\n\t\t\tconst currTime = new Date().getTime(),\n\t\t\t\t// Mode 0666, owned by root:root\n\t\t\t\tdirInode = new Inode(randomUUID(), 4096, 511 | FileType.DIRECTORY, currTime, currTime, currTime, 0, 0);\n\t\t\t// If the root doesn't exist, the first random ID shouldn't exist,\n\t\t\t// either.\n\t\t\ttx.put(dirInode.id, encode('{}'), false);\n\t\t\ttx.put(ROOT_NODE_ID, dirInode.serialize(), false);\n\t\t\ttx.commit();\n\t\t}\n\t}\n\n\t/**\n\t * Helper function for findINode.\n\t * @param parent The parent directory of the file we are attempting to find.\n\t * @param filename The filename of the inode we are attempting to find, minus\n\t * the parent.\n\t * @return string The ID of the file's inode in the file system.\n\t */\n\tprivate _findINode(tx: SyncKeyValueROTransaction, parent: string, filename: string, visited: Set<string> = new Set<string>()): string {\n\t\tconst currentPath = join(parent, filename);\n\t\tif (visited.has(currentPath)) {\n\t\t\tthrow new ApiError(ErrorCode.EIO, 'Infinite loop detected while finding inode', currentPath);\n\t\t}\n\n\t\tvisited.add(currentPath);\n\t\tconst readDirectory = (inode: Inode): string => {\n\t\t\t// Get the root's directory listing.\n\t\t\tconst dirList = this.getDirListing(tx, parent, inode);\n\t\t\t// Get the file's ID.\n\t\t\tif (dirList[filename]) {\n\t\t\t\treturn dirList[filename];\n\t\t\t} else {\n\t\t\t\tthrow ApiError.ENOENT(resolve(parent, filename));\n\t\t\t}\n\t\t};\n\t\tif (parent === '/') {\n\t\t\tif (filename === '') {\n\t\t\t\t// Return the root's ID.\n\t\t\t\treturn ROOT_NODE_ID;\n\t\t\t} else {\n\t\t\t\t// Find the item in the root node.\n\t\t\t\treturn readDirectory(this.getINode(tx, parent, ROOT_NODE_ID));\n\t\t\t}\n\t\t} else {\n\t\t\treturn readDirectory(this.getINode(tx, parent + sep + filename, this._findINode(tx, dirname(parent), basename(parent), visited)));\n\t\t}\n\t}\n\n\t/**\n\t * Finds the Inode of the given path.\n\t * @param p The path to look up.\n\t * @return The Inode of the path p.\n\t * @todo memoize/cache\n\t */\n\tprivate findINode(tx: SyncKeyValueROTransaction, p: string): Inode {\n\t\treturn this.getINode(tx, p, this._findINode(tx, dirname(p), basename(p)));\n\t}\n\n\t/**\n\t * Given the ID of a node, retrieves the corresponding Inode.\n\t * @param tx The transaction to use.\n\t * @param p The corresponding path to the file (used for error messages).\n\t * @param id The ID to look up.\n\t */\n\tprivate getINode(tx: SyncKeyValueROTransaction, p: string, id: string): Inode {\n\t\tconst inode = tx.get(id);\n\t\tif (inode === undefined) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t\treturn Inode.Deserialize(inode);\n\t}\n\n\t/**\n\t * Given the Inode of a directory, retrieves the corresponding directory\n\t * listing.\n\t */\n\tprivate getDirListing(tx: SyncKeyValueROTransaction, p: string, inode: Inode): { [fileName: string]: string } {\n\t\tif (!inode.isDirectory()) {\n\t\t\tthrow ApiError.ENOTDIR(p);\n\t\t}\n\t\tconst data = tx.get(inode.id);\n\t\tif (data === undefined) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t\treturn JSON.parse(decode(data));\n\t}\n\n\t/**\n\t * Creates a new node under a random ID. Retries 5 times before giving up in\n\t * the exceedingly unlikely chance that we try to reuse a random GUID.\n\t * @return The GUID that the data was stored under.\n\t */\n\tprivate addNewNode(tx: SyncKeyValueRWTransaction, data: Uint8Array): string {\n\t\tconst retries = 0;\n\t\tlet currId: string;\n\t\twhile (retries < 5) {\n\t\t\ttry {\n\t\t\t\tcurrId = randomUUID();\n\t\t\t\ttx.put(currId, data, false);\n\t\t\t\treturn currId;\n\t\t\t} catch (e) {\n\t\t\t\t// Ignore and reroll.\n\t\t\t}\n\t\t}\n\t\tthrow new ApiError(ErrorCode.EIO, 'Unable to commit data to key-value store.');\n\t}\n\n\t/**\n\t * Commits a new file (well, a FILE or a DIRECTORY) to the file system with\n\t * the given mode.\n\t * Note: This will commit the transaction.\n\t * @param p The path to the new file.\n\t * @param type The type of the new file.\n\t * @param mode The mode to create the new file with.\n\t * @param data The data to store at the file's data node.\n\t * @return The Inode for the new file.\n\t */\n\tprivate commitNewFile(tx: SyncKeyValueRWTransaction, p: string, type: FileType, mode: number, cred: Cred, data: Uint8Array): Inode {\n\t\tconst parentDir = dirname(p),\n\t\t\tfname = basename(p),\n\t\t\tparentNode = this.findINode(tx, parentDir),\n\t\t\tdirListing = this.getDirListing(tx, parentDir, parentNode),\n\t\t\tcurrTime = new Date().getTime();\n\n\t\t//Check that the creater has correct access\n\t\tif (!parentNode.toStats().hasAccess(0b0100 /* Write */, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\n\t\t// Invariant: The root always exists.\n\t\t// If we don't check this prior to taking steps below, we will create a\n\t\t// file with name '' in root should p == '/'.\n\t\tif (p === '/') {\n\t\t\tthrow ApiError.EEXIST(p);\n\t\t}\n\n\t\t// Check if file already exists.\n\t\tif (dirListing[fname]) {\n\t\t\tthrow ApiError.EEXIST(p);\n\t\t}\n\n\t\tlet fileNode: Inode;\n\t\ttry {\n\t\t\t// Commit data.\n\t\t\tconst dataId = this.addNewNode(tx, data);\n\t\t\tfileNode = new Inode(dataId, data.length, mode | type, currTime, currTime, currTime, cred.uid, cred.gid);\n\t\t\t// Commit file node.\n\t\t\tconst fileNodeId = this.addNewNode(tx, fileNode.serialize());\n\t\t\t// Update and commit parent directory listing.\n\t\t\tdirListing[fname] = fileNodeId;\n\t\t\ttx.put(parentNode.id, encode(JSON.stringify(dirListing)), true);\n\t\t} catch (e) {\n\t\t\ttx.abort();\n\t\t\tthrow e;\n\t\t}\n\t\ttx.commit();\n\t\treturn fileNode;\n\t}\n\n\t/**\n\t * Remove all traces of the given path from the file system.\n\t * @param p The path to remove from the file system.\n\t * @param isDir Does the path belong to a directory, or a file?\n\t * @todo Update mtime.\n\t */\n\tprivate removeEntry(p: string, isDir: boolean, cred: Cred): void {\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\tparent: string = dirname(p),\n\t\t\tparentNode = this.findINode(tx, parent),\n\t\t\tparentListing = this.getDirListing(tx, parent, parentNode),\n\t\t\tfileName: string = basename(p);\n\n\t\tif (!parentListing[fileName]) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\n\t\tconst fileNodeId = parentListing[fileName];\n\n\t\t// Get file inode.\n\t\tconst fileNode = this.getINode(tx, p, fileNodeId);\n\n\t\tif (!fileNode.toStats().hasAccess(W_OK, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\n\t\t// Remove from directory listing of parent.\n\t\tdelete parentListing[fileName];\n\n\t\tif (!isDir && fileNode.isDirectory()) {\n\t\t\tthrow ApiError.EISDIR(p);\n\t\t} else if (isDir && !fileNode.isDirectory()) {\n\t\t\tthrow ApiError.ENOTDIR(p);\n\t\t}\n\n\t\ttry {\n\t\t\t// Delete data.\n\t\t\ttx.del(fileNode.id);\n\t\t\t// Delete node.\n\t\t\ttx.del(fileNodeId);\n\t\t\t// Update directory listing.\n\t\t\ttx.put(parentNode.id, encode(JSON.stringify(parentListing)), true);\n\t\t} catch (e) {\n\t\t\ttx.abort();\n\t\t\tthrow e;\n\t\t}\n\t\t// Success.\n\t\ttx.commit();\n\t}\n}\n", "import type { TwoArgCallback, FileSystem } from '../filesystem.js';\nimport { checkOptions } from '../utils.js';\n\n/**\n * Describes a file system option.\n */\nexport interface BackendOption<T> {\n\t/**\n\t * The basic JavaScript type(s) for this option.\n\t */\n\ttype: string | string[];\n\n\t/**\n\t * Whether or not the option is optional (e.g., can be set to null or undefined).\n\t * Defaults to `false`.\n\t */\n\toptional?: boolean;\n\n\t/**\n\t * Description of the option. Used in error messages and documentation.\n\t */\n\tdescription: string;\n\n\t/**\n\t * A custom validation function to check if the option is valid.\n\t * When async, resolves if valid and rejects if not.\n\t * When sync, it will throw an error if not valid.\n\t */\n\tvalidator?(opt: T): void | Promise<void>;\n}\n\n/**\n * Describes all of the options available in a file system.\n */\nexport interface BackendOptions {\n\t[name: string]: BackendOption<unknown>;\n}\n\n/**\n * Contains types for static functions on a backend.\n */\nexport interface BaseBackendConstructor<FS extends typeof FileSystem = typeof FileSystem> {\n\tnew (...params: ConstructorParameters<FS>): InstanceType<FS>;\n\n\t/**\n\t * A name to identify the backend.\n\t */\n\tName: string;\n\n\t/**\n\t * Describes all of the options available for this backend.\n\t */\n\tOptions: BackendOptions;\n\n\t/**\n\t * Whether the backend is available in the current environment.\n\t * It supports checking synchronously and asynchronously\n\t * Sync:\n\t * Returns 'true' if this backend is available in the current\n\t * environment. For example, a `localStorage`-backed filesystem will return\n\t * 'false' if the browser does not support that API.\n\t *\n\t * Defaults to 'false', as the FileSystem base class isn't usable alone.\n\t */\n\tisAvailable(): boolean;\n}\n\n/**\n * Contains types for static functions on a backend.\n */\nexport interface BackendConstructor<FS extends typeof FileSystem = typeof FileSystem> extends BaseBackendConstructor<FS> {\n\t/**\n\t * Creates backend of this given type with the given\n\t * options, and either returns the result in a promise or callback.\n\t */\n\tCreate(): Promise<InstanceType<FS>>;\n\tCreate(options: object): Promise<InstanceType<FS>>;\n\tCreate(cb: TwoArgCallback<InstanceType<FS>>): void;\n\tCreate(options: object, cb: TwoArgCallback<InstanceType<FS>>): void;\n\tCreate(options: object, cb?: TwoArgCallback<InstanceType<FS>>): Promise<InstanceType<FS>> | void;\n}\n\nexport function CreateBackend<FS extends BaseBackendConstructor>(this: FS): Promise<InstanceType<FS>>;\nexport function CreateBackend<FS extends BaseBackendConstructor>(this: FS, options: BackendOptions): Promise<InstanceType<FS>>;\nexport function CreateBackend<FS extends BaseBackendConstructor>(this: FS, cb: TwoArgCallback<InstanceType<FS>>): void;\nexport function CreateBackend<FS extends BaseBackendConstructor>(this: FS, options: BackendOptions, cb: TwoArgCallback<InstanceType<FS>>): void;\nexport function CreateBackend<FS extends BaseBackendConstructor>(\n\tthis: FS,\n\toptions?: BackendOptions | TwoArgCallback<InstanceType<FS>>,\n\tcb?: TwoArgCallback<InstanceType<FS>>\n): Promise<InstanceType<FS>> | void {\n\tcb = typeof options === 'function' ? options : cb;\n\n\tcheckOptions(this, options);\n\n\tconst fs = new this(typeof options === 'function' ? {} : options) as InstanceType<FS>;\n\n\t// Promise\n\tif (typeof cb != 'function') {\n\t\treturn fs.whenReady();\n\t}\n\n\t// Callback\n\tfs.whenReady()\n\t\t.then(fs => cb(null, fs))\n\t\t.catch(err => cb(err));\n}\n", "import { SyncKeyValueStore, SimpleSyncStore, SimpleSyncRWTransaction, SyncKeyValueRWTransaction, SyncKeyValueFileSystem } from './SyncStore.js';\nimport { CreateBackend, type BackendOptions } from './backend.js';\n\n/**\n * A simple in-memory key-value store backed by a JavaScript object.\n */\nexport class InMemoryStore implements SyncKeyValueStore, SimpleSyncStore {\n\tprivate store: Map<string, Uint8Array> = new Map<string, Uint8Array>();\n\n\tpublic name() {\n\t\treturn InMemoryFileSystem.Name;\n\t}\n\tpublic clear() {\n\t\tthis.store.clear();\n\t}\n\n\tpublic beginTransaction(type: string): SyncKeyValueRWTransaction {\n\t\treturn new SimpleSyncRWTransaction(this);\n\t}\n\n\tpublic get(key: string): Uint8Array {\n\t\treturn this.store.get(key);\n\t}\n\n\tpublic put(key: string, data: Uint8Array, overwrite: boolean): boolean {\n\t\tif (!overwrite && this.store.has(key)) {\n\t\t\treturn false;\n\t\t}\n\t\tthis.store.set(key, data);\n\t\treturn true;\n\t}\n\n\tpublic del(key: string): void {\n\t\tthis.store.delete(key);\n\t}\n}\n\n/**\n * A simple in-memory file system backed by an InMemoryStore.\n * Files are not persisted across page loads.\n */\nexport class InMemoryFileSystem extends SyncKeyValueFileSystem {\n\tpublic static readonly Name = 'InMemory';\n\n\tpublic static Create = CreateBackend.bind(this);\n\n\tpublic static readonly Options: BackendOptions = {};\n\n\tpublic constructor() {\n\t\tsuper({ store: new InMemoryStore() });\n\t}\n}\n", "// Utilities and shared data\n\nimport { resolve } from './path.js';\nimport { ApiError, ErrorCode } from '../ApiError.js';\nimport { Cred } from '../cred.js';\nimport { FileSystem } from '../filesystem.js';\nimport { File } from '../file.js';\nimport { InMemoryFileSystem } from '../backends/InMemory.js';\nimport { BackendConstructor } from '../backends/backend.js';\n\n/**\n * converts Date or number to a fractional UNIX timestamp\n * Grabbed from NodeJS sources (lib/fs.js)\n */\nexport function _toUnixTimestamp(time: Date | number): number {\n\tif (typeof time === 'number') {\n\t\treturn time;\n\t} else if (time instanceof Date) {\n\t\treturn time.getTime() / 1000;\n\t}\n\tthrow new Error('Cannot parse time: ' + time);\n}\n\nexport function normalizeMode(mode: unknown, def: number): number {\n\tswitch (typeof mode) {\n\t\tcase 'number':\n\t\t\t// (path, flag, mode, cb?)\n\t\t\treturn mode;\n\t\tcase 'string':\n\t\t\t// (path, flag, modeString, cb?)\n\t\t\tconst trueMode = parseInt(mode, 8);\n\t\t\tif (!isNaN(trueMode)) {\n\t\t\t\treturn trueMode;\n\t\t\t}\n\t\t\t// Invalid string.\n\t\t\treturn def;\n\t\tdefault:\n\t\t\treturn def;\n\t}\n}\n\nexport function normalizeTime(time: number | Date): Date {\n\tif (time instanceof Date) {\n\t\treturn time;\n\t}\n\n\tif (typeof time === 'number') {\n\t\treturn new Date(time * 1000);\n\t}\n\n\tthrow new ApiError(ErrorCode.EINVAL, `Invalid time.`);\n}\n\nexport function normalizePath(p: string): string {\n\t// Node doesn't allow null characters in paths.\n\tif (p.indexOf('\\u0000') >= 0) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Path must be a string without null bytes.');\n\t}\n\tif (p === '') {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Path must not be empty.');\n\t}\n\tp = p.replaceAll(/\\/+/g, '/');\n\treturn resolve(p);\n}\n\nexport function normalizeOptions(options: any, defEnc: string | null, defFlag: string, defMode: number | null): { encoding: BufferEncoding; flag: string; mode: number } {\n\t// typeof null === 'object' so special-case handing is needed.\n\tswitch (options === null ? 'null' : typeof options) {\n\t\tcase 'object':\n\t\t\treturn {\n\t\t\t\tencoding: typeof options['encoding'] !== 'undefined' ? options['encoding'] : defEnc,\n\t\t\t\tflag: typeof options['flag'] !== 'undefined' ? options['flag'] : defFlag,\n\t\t\t\tmode: normalizeMode(options['mode'], defMode!),\n\t\t\t};\n\t\tcase 'string':\n\t\t\treturn {\n\t\t\t\tencoding: options,\n\t\t\t\tflag: defFlag,\n\t\t\t\tmode: defMode!,\n\t\t\t};\n\t\tcase 'null':\n\t\tcase 'undefined':\n\t\tcase 'function':\n\t\t\treturn {\n\t\t\t\tencoding: defEnc! as BufferEncoding,\n\t\t\t\tflag: defFlag,\n\t\t\t\tmode: defMode!,\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new TypeError(`\"options\" must be a string or an object, got ${typeof options} instead.`);\n\t}\n}\n\nexport function nop() {\n\t// do nothing\n}\n\n// credentials\nexport let cred: Cred = Cred.Root;\nexport function setCred(val: Cred): void {\n\tcred = val;\n}\n\n// descriptors\nexport const fdMap: Map<number, File> = new Map();\nlet nextFd = 100;\nexport function getFdForFile(file: File): number {\n\tconst fd = nextFd++;\n\tfdMap.set(fd, file);\n\treturn fd;\n}\nexport function fd2file(fd: number): File {\n\tif (!fdMap.has(fd)) {\n\t\tthrow new ApiError(ErrorCode.EBADF, 'Invalid file descriptor.');\n\t}\n\treturn fdMap.get(fd);\n}\n\n// mounting\nexport interface MountMapping {\n\t[point: string]: InstanceType<BackendConstructor>;\n}\n\nexport const mounts: Map<string, FileSystem> = new Map();\n\n/*\nSet a default root.\nThere is a very small but not 0 change that initialize() will try to unmount the default before it is mounted.\nThis can be fixed by using a top-level await, which is not done to maintain ES6 compatibility.\n*/\nInMemoryFileSystem.Create().then(fs => mount('/', fs));\n\n/**\n * Gets the file system mounted at `mountPoint`\n */\nexport function getMount(mountPoint: string): FileSystem {\n\treturn mounts.get(mountPoint);\n}\n\n/**\n * Gets an object of mount points (keys) and filesystems (values)\n */\nexport function getMounts(): MountMapping {\n\treturn Object.fromEntries(mounts.entries());\n}\n\n/**\n * Mounts the file system at the given mount point.\n */\nexport function mount(mountPoint: string, fs: FileSystem): void {\n\tif (mountPoint[0] !== '/') {\n\t\tmountPoint = '/' + mountPoint;\n\t}\n\tmountPoint = resolve(mountPoint);\n\tif (mounts.has(mountPoint)) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Mount point ' + mountPoint + ' is already in use.');\n\t}\n\tmounts.set(mountPoint, fs);\n}\n\n/**\n * Unmounts the file system at the given mount point.\n */\nexport function umount(mountPoint: string): void {\n\tif (mountPoint[0] !== '/') {\n\t\tmountPoint = `/${mountPoint}`;\n\t}\n\tmountPoint = resolve(mountPoint);\n\tif (!mounts.has(mountPoint)) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Mount point ' + mountPoint + ' is already unmounted.');\n\t}\n\tmounts.delete(mountPoint);\n}\n\n/**\n * Gets the internal FileSystem for the path, then returns it along with the path relative to the FS' root\n */\nexport function resolveFS(path: string): { fs: FileSystem; path: string; mountPoint: string } {\n\tconst sortedMounts = [...mounts].sort((a, b) => (a[0].length > b[0].length ? -1 : 1)); // decending order of the string length\n\tfor (const [mountPoint, fs] of sortedMounts) {\n\t\t// We know path is normalized, so it would be a substring of the mount point.\n\t\tif (mountPoint.length <= path.length && path.startsWith(mountPoint)) {\n\t\t\tpath = path.slice(mountPoint.length > 1 ? mountPoint.length : 0); // Resolve the path relative to the mount point\n\t\t\tif (path === '') {\n\t\t\t\tpath = '/';\n\t\t\t}\n\t\t\treturn { fs, path, mountPoint };\n\t\t}\n\t}\n\n\tthrow new ApiError(ErrorCode.EIO, 'BrowserFS not initialized with a file system');\n}\n\n/**\n * Reverse maps the paths in text from the mounted FileSystem to the global path\n */\nexport function fixPaths(text: string, paths: { [from: string]: string }): string {\n\tfor (const [from, to] of Object.entries(paths)) {\n\t\ttext = text?.replaceAll(from, to);\n\t}\n\treturn text;\n}\n\nexport function fixError<E extends Error>(e: E, paths: { [from: string]: string }): E {\n\tif (typeof e.stack == 'string') {\n\t\te.stack = fixPaths(e.stack, paths);\n\t}\n\te.message = fixPaths(e.message, paths);\n\treturn e;\n}\n\nexport function initialize(mountMapping: MountMapping): void {\n\tif (mountMapping['/']) {\n\t\tumount('/');\n\t}\n\tfor (const [point, fs] of Object.entries(mountMapping)) {\n\t\tconst FS = fs.constructor as unknown as BackendConstructor;\n\t\tif (!FS.isAvailable()) {\n\t\t\tthrow new ApiError(ErrorCode.EINVAL, `Can not mount \"${point}\" since the filesystem is unavailable.`);\n\t\t}\n\n\t\tmount(point, fs);\n\t}\n}\n\n/**\n * Types supports as path parameters.\n *\n * In the future, maybe support URL?\n */\nexport type PathLike = string;\n\n/**\n * @internal\n *\n * Converts any Buffer in T to Uint8Array\n */\nexport type BufferToUint8Array<T> = T extends Buffer\n\t? Uint8Array\n\t: T extends (...args) => unknown\n\t? (...args: Parameters<T>) => BufferToUint8Array<ReturnType<T>>\n\t: T extends object\n\t? { [K in keyof T]: BufferToUint8Array<T[K]> }\n\t: T;\n", "import type { ReadStream, WriteStream, FSWatcher, symlink as _symlink, BaseEncodingOptions, BufferEncodingOption, BigIntOptions, StatOptions } from 'node:fs';\nimport { ApiError, ErrorCode } from '../ApiError.js';\n\nimport * as constants from './constants.js';\nexport { constants };\n\nimport { File, FileFlag } from '../file.js';\nimport { normalizePath, normalizeMode, getFdForFile, normalizeOptions, fd2file, fdMap, normalizeTime, cred, nop, resolveFS, fixError, mounts, PathLike } from './shared.js';\nimport { FileContents, FileSystem } from '../filesystem.js';\nimport { BigIntStats, Stats } from '../stats.js';\nimport { decode, encode } from '../utils.js';\nimport { Dirent } from './dir.js';\nimport { join } from './path.js';\n\ntype FileSystemMethod = {\n\t[K in keyof FileSystem]: FileSystem[K] extends (...args) => unknown\n\t\t? (name: K, resolveSymlinks: boolean, ...args: Parameters<FileSystem[K]>) => ReturnType<FileSystem[K]>\n\t\t: never;\n}[keyof FileSystem]; // https://stackoverflow.com/a/76335220/17637456\n\n/**\n * Utility for FS ops. It handles\n * - path normalization (for the first parameter to the FS op)\n * - path translation for errors\n * - FS/mount point resolution\n *\n * It can't be used for functions which may operate on multiple mounted FSs or paths (e.g. `rename`)\n * @param name the function name\n * @param resolveSymlinks whether to resolve symlinks\n * @param args the rest of the parameters are passed to the FS function. Note that the first parameter is required to be a path\n * @returns\n */\nasync function doOp<M extends FileSystemMethod, RT extends ReturnType<M> = ReturnType<M>>(...[name, resolveSymlinks, path, ...args]: Parameters<M>): Promise<RT> {\n\tpath = normalizePath(path);\n\tconst { fs, path: resolvedPath } = resolveFS(resolveSymlinks && (await exists(path)) ? await realpath(path) : path);\n\ttry {\n\t\t// @ts-expect-error 2556 (since ...args is not correctly picked up as being a tuple)\n\t\treturn fs[name](resolvedPath, ...args) as Promise<RT>;\n\t} catch (e) {\n\t\tthrow fixError(e, { [resolvedPath]: path });\n\t}\n}\n\n// fs.promises\n\n/**\n * Renames a file\n * @param oldPath\n * @param newPath\n */\nexport async function rename(oldPath: PathLike, newPath: PathLike): Promise<void> {\n\toldPath = normalizePath(oldPath);\n\tnewPath = normalizePath(newPath);\n\tconst _old = resolveFS(oldPath);\n\tconst _new = resolveFS(newPath);\n\tconst paths = { [_old.path]: oldPath, [_new.path]: newPath };\n\ttry {\n\t\tif (_old === _new) {\n\t\t\treturn _old.fs.rename(_old.path, _new.path, cred);\n\t\t}\n\n\t\tconst data = await readFile(oldPath);\n\t\tawait writeFile(newPath, data);\n\t\tawait unlink(oldPath);\n\t} catch (e) {\n\t\tthrow fixError(e, paths);\n\t}\n}\n\n/**\n * Test whether or not the given path exists by checking with the file system.\n * @param path\n */\nexport async function exists(path: PathLike): Promise<boolean> {\n\tpath = normalizePath(path);\n\ttry {\n\t\tconst { fs, path: resolvedPath } = resolveFS(path);\n\t\treturn fs.exists(resolvedPath, cred);\n\t} catch (e) {\n\t\tif ((e as ApiError).errno == ErrorCode.ENOENT) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthrow e;\n\t}\n}\n\n/**\n * `stat`.\n * @param path\n * @returns Stats\n */\nexport async function stat(path: PathLike, options: BigIntOptions): Promise<BigIntStats>;\nexport async function stat(path: PathLike, options?: { bigint?: false }): Promise<Stats>;\nexport async function stat(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats> {\n\tconst stats: Stats = await doOp('stat', true, path, cred);\n\treturn options?.bigint ? BigIntStats.clone(stats) : stats;\n}\n\n/**\n * `lstat`.\n * `lstat()` is identical to `stat()`, except that if path is a symbolic link,\n * then the link itself is stat-ed, not the file that it refers to.\n * @param path\n * @return [BrowserFS.node.fs.Stats]\n */\nexport async function lstat(path: PathLike, options?: { bigint?: false }): Promise<Stats>;\nexport async function lstat(path: PathLike, options: { bigint: true }): Promise<BigIntStats>;\nexport async function lstat(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats> {\n\tconst stats: Stats = await doOp('stat', false, path, cred);\n\treturn options?.bigint ? BigIntStats.clone(stats) : stats;\n}\n\n// FILE-ONLY METHODS\n\n/**\n * `truncate`.\n * @param path\n * @param len\n */\nexport async function truncate(path: PathLike, len: number = 0): Promise<void> {\n\tif (len < 0) {\n\t\tthrow new ApiError(ErrorCode.EINVAL);\n\t}\n\treturn doOp('truncate', true, path, len, cred);\n}\n\n/**\n * `unlink`.\n * @param path\n */\nexport async function unlink(path: PathLike): Promise<void> {\n\treturn doOp('unlink', false, path, cred);\n}\n\n/**\n * file open.\n * @see http://www.manpagez.com/man/2/open/\n * @param path\n * @param flags\n * @param mode defaults to `0644`\n */\nexport async function open(path: PathLike, flag: string, mode: number | string = 0o644): Promise<number> {\n\tconst file: File = await doOp('open', true, path, FileFlag.getFileFlag(flag), normalizeMode(mode, 0o644), cred);\n\treturn getFdForFile(file);\n}\n\n/**\n * Synchronously reads the entire contents of a file.\n * @param filename\n * @param options\n * options.encoding The string encoding for the file contents. Defaults to `null`.\n * options.flag Defaults to `'r'`.\n * @return Uint8Array\n */\nexport async function readFile(filename: PathLike, options?: { flag?: string }): Promise<Uint8Array>;\nexport async function readFile(filename: PathLike, options: { encoding: string; flag?: string }): Promise<string>;\nexport async function readFile(filename: PathLike, encoding: string): Promise<string>;\nexport async function readFile(filename: PathLike, arg2 = {}): Promise<Uint8Array | string> {\n\tconst options = normalizeOptions(arg2, null, 'r', null);\n\tconst flag = FileFlag.getFileFlag(options.flag);\n\tif (!flag.isReadable()) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Flag passed to readFile must allow for reading.');\n\t}\n\tconst data: Uint8Array = await doOp('readFile', true, filename, flag, cred);\n\tswitch (options.encoding) {\n\t\tcase 'utf8':\n\t\tcase 'utf-8':\n\t\t\treturn decode(data);\n\t\tdefault:\n\t\t\treturn data;\n\t}\n}\n\n/**\n * Synchronously writes data to a file, replacing the file if it already\n * exists.\n *\n * The encoding option is ignored if data is a buffer.\n * @param filename\n * @param data\n * @param options\n * @option options [String] encoding Defaults to `'utf8'`.\n * @option options [Number] mode Defaults to `0644`.\n * @option options [String] flag Defaults to `'w'`.\n */\nexport async function writeFile(filename: PathLike, data: FileContents, options?: { encoding?: string; mode?: number | string; flag?: string }): Promise<void>;\nexport async function writeFile(filename: PathLike, data: FileContents, encoding?: string): Promise<void>;\nexport async function writeFile(filename: PathLike, data: FileContents, options?: { encoding?: string; mode?: number | string; flag?: string } | string): Promise<void>;\nexport async function writeFile(filename: PathLike, data: FileContents, arg3?: { encoding?: string; mode?: number | string; flag?: string } | string): Promise<void> {\n\tconst options = normalizeOptions(arg3, 'utf8', 'w', 0o644);\n\tconst flag = FileFlag.getFileFlag(options.flag);\n\tif (!flag.isWriteable()) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Flag passed to writeFile must allow for writing.');\n\t}\n\tif (typeof data != 'string' && !options.encoding) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Encoding not specified');\n\t}\n\tconst encodedData = typeof data == 'string' ? encode(data) : data;\n\treturn doOp('writeFile', true, filename, encodedData, flag, options.mode, cred);\n}\n\n/**\n * Asynchronously append data to a file, creating the file if it not yet\n * exists.\n *\n * @example Usage example\n * fs.appendFile('message.txt', 'data to append', function (err) {\n * if (err) throw err;\n * console.log('The \"data to append\" was appended to file!');\n * });\n * @param filename\n * @param data\n * @param options\n * @option options [String] encoding Defaults to `'utf8'`.\n * @option options [Number] mode Defaults to `0644`.\n * @option options [String] flag Defaults to `'a'`.\n */\nexport async function appendFile(filename: PathLike, data: FileContents, options?: { encoding?: string; mode?: number | string; flag?: string }): Promise<void>;\nexport async function appendFile(filename: PathLike, data: FileContents, encoding?: string): Promise<void>;\nexport async function appendFile(filename: PathLike, data: FileContents, arg3?): Promise<void> {\n\tconst options = normalizeOptions(arg3, 'utf8', 'a', 0o644);\n\tconst flag = FileFlag.getFileFlag(options.flag);\n\tif (!flag.isAppendable()) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Flag passed to appendFile must allow for appending.');\n\t}\n\tif (typeof data != 'string' && !options.encoding) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Encoding not specified');\n\t}\n\tconst encodedData = typeof data == 'string' ? encode(data) : data;\n\treturn doOp('appendFile', true, filename, encodedData, flag, options.mode, cred);\n}\n\n// FILE DESCRIPTOR METHODS\n\n/**\n * `fstat`.\n * `fstat()` is identical to `stat()`, except that the file to be stat-ed is\n * specified by the file descriptor `fd`.\n * @param fd\n * @return [BrowserFS.node.fs.Stats]\n */\nexport async function fstat(fd: number, options?: { bigint?: false }): Promise<Stats>;\nexport async function fstat(fd: number, options: { bigint: true }): Promise<BigIntStats>;\nexport async function fstat(fd: number, options?: StatOptions): Promise<Stats | BigIntStats> {\n\tconst stats: Stats = await fd2file(fd).stat();\n\treturn options?.bigint ? BigIntStats.clone(stats) : stats;\n}\n\n/**\n * close.\n * @param fd\n */\nexport async function close(fd: number): Promise<void> {\n\tawait fd2file(fd).close();\n\tfdMap.delete(fd);\n\treturn;\n}\n\n/**\n * ftruncate.\n * @param fd\n * @param len\n */\nexport async function ftruncate(fd: number, len: number = 0): Promise<void> {\n\tconst file = fd2file(fd);\n\tif (len < 0) {\n\t\tthrow new ApiError(ErrorCode.EINVAL);\n\t}\n\treturn file.truncate(len);\n}\n\n/**\n * fsync.\n * @param fd\n */\nexport async function fsync(fd: number): Promise<void> {\n\treturn fd2file(fd).sync();\n}\n\n/**\n * fdatasync.\n * @param fd\n */\nexport async function fdatasync(fd: number): Promise<void> {\n\treturn fd2file(fd).datasync();\n}\n\n/**\n * Write buffer to the file specified by `fd`.\n * Note that it is unsafe to use fs.write multiple times on the same file\n * without waiting for it to return.\n * @param fd\n * @param buffer Uint8Array containing the data to write to\n * the file.\n * @param offset Offset in the buffer to start reading data from.\n * @param length The amount of bytes to write to the file.\n * @param position Offset from the beginning of the file where this\n * data should be written. If position is null, the data will be written at\n * the current position.\n */\nexport async function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number): Promise<number>;\nexport async function write(fd: number, data: string, position?: number | null, encoding?: BufferEncoding): Promise<number>;\nexport async function write(fd: number, arg2: Uint8Array | string, arg3?: number, arg4?: BufferEncoding | number, arg5?: number): Promise<number> {\n\tlet buffer: Uint8Array,\n\t\toffset: number = 0,\n\t\tlength: number,\n\t\tposition: number | null;\n\tif (typeof arg2 === 'string') {\n\t\t// Signature 1: (fd, string, [position?, [encoding?]])\n\t\tposition = typeof arg3 === 'number' ? arg3 : null;\n\t\tconst encoding = (typeof arg4 === 'string' ? arg4 : 'utf8') as BufferEncoding;\n\t\toffset = 0;\n\t\tbuffer = encode(arg2, encoding);\n\t\tlength = buffer.length;\n\t} else {\n\t\t// Signature 2: (fd, buffer, offset, length, position?)\n\t\tbuffer = arg2;\n\t\toffset = arg3;\n\t\tlength = arg4 as number;\n\t\tposition = typeof arg5 === 'number' ? arg5 : null;\n\t}\n\n\tconst file = fd2file(fd);\n\tif (position === undefined || position === null) {\n\t\tposition = file.getPos()!;\n\t}\n\treturn file.write(buffer, offset, length, position);\n}\n\n/**\n * Read data from the file specified by `fd`.\n * @param fd\n * @param buffer The buffer that the data will be\n * written to.\n * @param offset The offset within the buffer where writing will\n * start.\n * @param length An integer specifying the number of bytes to read.\n * @param position An integer specifying where to begin reading from\n * in the file. If position is null, data will be read from the current file\n * position.\n */\nexport async function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number): Promise<{ bytesRead: number; buffer: Uint8Array }> {\n\tconst file = fd2file(fd);\n\tif (isNaN(+position)) {\n\t\tposition = file.getPos()!;\n\t}\n\n\treturn file.read(buffer, offset, length, position);\n}\n\n/**\n * `fchown`.\n * @param fd\n * @param uid\n * @param gid\n */\nexport async function fchown(fd: number, uid: number, gid: number): Promise<void> {\n\treturn fd2file(fd).chown(uid, gid);\n}\n\n/**\n * `fchmod`.\n * @param fd\n * @param mode\n */\nexport async function fchmod(fd: number, mode: number | string): Promise<void> {\n\tconst numMode = typeof mode === 'string' ? parseInt(mode, 8) : mode;\n\treturn fd2file(fd).chmod(numMode);\n}\n\n/**\n * Change the file timestamps of a file referenced by the supplied file\n * descriptor.\n * @param fd\n * @param atime\n * @param mtime\n */\nexport async function futimes(fd: number, atime: number | Date, mtime: number | Date): Promise<void> {\n\treturn fd2file(fd).utimes(normalizeTime(atime), normalizeTime(mtime));\n}\n\n// DIRECTORY-ONLY METHODS\n\n/**\n * `rmdir`.\n * @param path\n */\nexport async function rmdir(path: PathLike): Promise<void> {\n\treturn doOp('rmdir', true, path, cred);\n}\n\n/**\n * `mkdir`.\n * @param path\n * @param mode defaults to `0777`\n */\nexport async function mkdir(path: PathLike, mode?: number | string): Promise<void> {\n\treturn doOp('mkdir', true, path, normalizeMode(mode, 0o777), cred);\n}\n\n/**\n * `readdir`. Reads the contents of a directory.\n * @param path\n */\nexport async function readdir(path: PathLike, options: { withFileTypes?: false }): Promise<string[]>;\nexport async function readdir(path: PathLike, options: { withFileTypes: true }): Promise<Dirent[]>;\nexport async function readdir(path: PathLike, options?: { withFileTypes?: boolean }): Promise<string[] | Dirent[]> {\n\tpath = normalizePath(path);\n\tconst entries: string[] = await doOp('readdir', true, path, cred);\n\tconst points = [...mounts.keys()];\n\tfor (const point of points) {\n\t\tif (point.startsWith(path)) {\n\t\t\tconst entry = point.slice(path.length);\n\t\t\tif (entry.includes('/') || entry.length == 0) {\n\t\t\t\t// ignore FSs mounted in subdirectories and any FS mounted to `path`.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tentries.push(entry);\n\t\t}\n\t}\n\tconst values: (string | Dirent)[] = [];\n\tfor (const entry of entries) {\n\t\tvalues.push(options?.withFileTypes ? new Dirent(entry, await stat(join(path, entry))) : entry);\n\t}\n\treturn values as string[] | Dirent[];\n}\n\n// SYMLINK METHODS\n\n/**\n * `link`.\n * @param srcpath\n * @param dstpath\n */\nexport async function link(srcpath: PathLike, dstpath: PathLike): Promise<void> {\n\tdstpath = normalizePath(dstpath);\n\treturn doOp('link', false, srcpath, dstpath, cred);\n}\n\n/**\n * `symlink`.\n * @param srcpath\n * @param dstpath\n * @param type can be either `'dir'` or `'file'` (default is `'file'`)\n */\nexport async function symlink(srcpath: PathLike, dstpath: PathLike, type: _symlink.Type = 'file'): Promise<void> {\n\tif (!['file', 'dir', 'junction'].includes(type)) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid type: ' + type);\n\t}\n\tdstpath = normalizePath(dstpath);\n\treturn doOp('symlink', false, srcpath, dstpath, type, cred);\n}\n\n/**\n * readlink.\n * @param path\n */\nexport async function readlink(path: PathLike, options?: BaseEncodingOptions | BufferEncoding): Promise<string>;\nexport async function readlink(path: PathLike, options: BufferEncodingOption): Promise<Uint8Array>;\nexport async function readlink(path: PathLike, options?: BaseEncodingOptions | string): Promise<string | Uint8Array>;\nexport async function readlink(path: PathLike, options?: BufferEncodingOption | BaseEncodingOptions | string): Promise<string | Uint8Array> {\n\tconst encoding = typeof options == 'object' ? options.encoding : options;\n\tconst value: string = await doOp('readlink', false, path, cred);\n\tif (encoding === 'buffer') {\n\t\treturn encode(value);\n\t} else {\n\t\treturn value;\n\t}\n}\n\n// PROPERTY OPERATIONS\n\n/**\n * `chown`.\n * @param path\n * @param uid\n * @param gid\n */\nexport async function chown(path: PathLike, uid: number, gid: number): Promise<void> {\n\treturn doOp('chown', true, path, uid, gid, cred);\n}\n\n/**\n * `lchown`.\n * @param path\n * @param uid\n * @param gid\n */\nexport async function lchown(path: PathLike, uid: number, gid: number): Promise<void> {\n\treturn doOp('chown', false, path, uid, gid, cred);\n}\n\n/**\n * `chmod`.\n * @param path\n * @param mode\n */\nexport async function chmod(path: PathLike, mode: string | number): Promise<void> {\n\tconst numMode = normalizeMode(mode, -1);\n\tif (numMode < 0) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, `Invalid mode.`);\n\t}\n\treturn doOp('chmod', true, path, numMode, cred);\n}\n\n/**\n * `lchmod`.\n * @param path\n * @param mode\n */\nexport async function lchmod(path: PathLike, mode: number | string): Promise<void> {\n\tconst numMode = normalizeMode(mode, -1);\n\tif (numMode < 1) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, `Invalid mode.`);\n\t}\n\treturn doOp('chmod', false, normalizePath(path), numMode, cred);\n}\n\n/**\n * Change file timestamps of the file referenced by the supplied path.\n * @param path\n * @param atime\n * @param mtime\n */\nexport async function utimes(path: PathLike, atime: number | Date, mtime: number | Date): Promise<void> {\n\treturn doOp('utimes', true, path, normalizeTime(atime), normalizeTime(mtime), cred);\n}\n\n/**\n * Change file timestamps of the file referenced by the supplied path.\n * @param path\n * @param atime\n * @param mtime\n */\nexport async function lutimes(path: PathLike, atime: number | Date, mtime: number | Date): Promise<void> {\n\treturn doOp('utimes', false, path, normalizeTime(atime), normalizeTime(mtime), cred);\n}\n\n/**\n * `realpath`.\n * @param path\n * @param options\n * @return resolved path\n *\n * Note: This *Can not* use doOp since doOp depends on it\n */\nexport async function realpath(path: PathLike, options?: BaseEncodingOptions): Promise<string> {\n\tpath = normalizePath(path);\n\tconst { fs, path: resolvedPath, mountPoint } = resolveFS(path);\n\ttry {\n\t\tconst stats = await fs.stat(resolvedPath, cred);\n\t\tif (!stats.isSymbolicLink()) {\n\t\t\treturn path;\n\t\t}\n\t\tconst dst = mountPoint + normalizePath(await fs.readlink(resolvedPath, cred));\n\t\treturn realpath(dst);\n\t} catch (e) {\n\t\tthrow fixError(e, { [resolvedPath]: path });\n\t}\n}\n\nexport async function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): Promise<void>;\nexport async function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number }, listener: (curr: Stats, prev: Stats) => void): Promise<void>;\nexport async function watchFile(filename: PathLike, arg2: any, listener: (curr: Stats, prev: Stats) => void = nop): Promise<void> {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport async function unwatchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void = nop): Promise<void> {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport async function watch(filename: PathLike, listener?: (event: string, filename: PathLike) => any): Promise<FSWatcher>;\nexport async function watch(filename: PathLike, options: { persistent?: boolean }, listener?: (event: string, filename: string) => any): Promise<FSWatcher>;\nexport async function watch(filename: PathLike, arg2: any, listener: (event: string, filename: string) => any = nop): Promise<FSWatcher> {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\n/**\n * `access`.\n * @param path\n * @param mode\n */\nexport async function access(path: PathLike, mode: number = 0o600): Promise<void> {\n\treturn doOp('access', true, path, mode, cred);\n}\n\nexport async function createReadStream(\n\tpath: PathLike,\n\toptions?: {\n\t\tflags?: string;\n\t\tencoding?: string;\n\t\tfd?: number;\n\t\tmode?: number;\n\t\tautoClose?: boolean;\n\t}\n): Promise<ReadStream> {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport async function createWriteStream(\n\tpath: PathLike,\n\toptions?: {\n\t\tflags?: string;\n\t\tencoding?: string;\n\t\tfd?: number;\n\t\tmode?: number;\n\t}\n): Promise<WriteStream> {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport async function rm(path: PathLike) {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport async function mkdtemp(path: PathLike) {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport async function copyFile(path: PathLike) {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n", "import { ApiError, ErrorCode } from '../ApiError.js';\nimport { File, FileFlag } from '../file.js';\nimport { FileContents, FileSystem } from '../filesystem.js';\nimport { BigIntStats, Stats } from '../stats.js';\nimport type { symlink, ReadSyncOptions, StatOptions, BaseEncodingOptions, BufferEncodingOption } from 'fs';\nimport type * as Node from 'fs';\nimport {\n\tnormalizePath,\n\tcred,\n\tgetFdForFile,\n\tnormalizeMode,\n\tnormalizeOptions,\n\tfdMap,\n\tfd2file,\n\tnormalizeTime,\n\tresolveFS,\n\tfixError,\n\tmounts,\n\tBufferToUint8Array,\n\tPathLike,\n} from './shared.js';\nimport { decode, encode } from '../utils.js';\nimport { Dir, Dirent } from './dir.js';\nimport { join } from './path.js';\n\ntype FileSystemMethod = {\n\t[K in keyof FileSystem]: FileSystem[K] extends (...args) => any ? (name: K, resolveSymlinks: boolean, ...args: Parameters<FileSystem[K]>) => ReturnType<FileSystem[K]> : never;\n}[keyof FileSystem]; // https://stackoverflow.com/a/76335220/17637456\n\nfunction doOp<M extends FileSystemMethod, RT extends ReturnType<M>>(...[name, resolveSymlinks, path, ...args]: Parameters<M>): RT {\n\tpath = normalizePath(path);\n\tconst { fs, path: resolvedPath } = resolveFS(resolveSymlinks && existsSync(path) ? realpathSync(path) : path);\n\ttry {\n\t\t// @ts-expect-error 2556 (since ...args is not correctly picked up as being a tuple)\n\t\treturn fs[name](resolvedPath, ...args) as RT;\n\t} catch (e) {\n\t\tthrow fixError(e, { [resolvedPath]: path });\n\t}\n}\n\n/**\n * Synchronous rename.\n * @param oldPath\n * @param newPath\n */\nexport function renameSync(oldPath: PathLike, newPath: PathLike): void {\n\toldPath = normalizePath(oldPath);\n\tnewPath = normalizePath(newPath);\n\tconst _old = resolveFS(oldPath);\n\tconst _new = resolveFS(newPath);\n\tconst paths = { [_old.path]: oldPath, [_new.path]: newPath };\n\ttry {\n\t\tif (_old === _new) {\n\t\t\treturn _old.fs.renameSync(_old.path, _new.path, cred);\n\t\t}\n\n\t\tconst data = readFileSync(oldPath);\n\t\twriteFileSync(newPath, data);\n\t\tunlinkSync(oldPath);\n\t} catch (e) {\n\t\tthrow fixError(e, paths);\n\t}\n}\nrenameSync satisfies typeof Node.renameSync;\n\n/**\n * Test whether or not the given path exists by checking with the file system.\n * @param path\n */\nexport function existsSync(path: PathLike): boolean {\n\tpath = normalizePath(path);\n\ttry {\n\t\tconst { fs, path: resolvedPath } = resolveFS(path);\n\t\treturn fs.existsSync(resolvedPath, cred);\n\t} catch (e) {\n\t\tif ((e as ApiError).errno == ErrorCode.ENOENT) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthrow e;\n\t}\n}\nexistsSync satisfies typeof Node.existsSync;\n\n/**\n * Synchronous `stat`.\n * @param path\n * @returns Stats\n */\nexport function statSync(path: PathLike, options?: { bigint: false }): Stats;\nexport function statSync(path: PathLike, options: { bigint: true }): BigIntStats;\nexport function statSync(path: PathLike, options?: StatOptions): Stats | BigIntStats {\n\tconst stats: Stats = doOp('statSync', true, path, cred);\n\treturn options?.bigint ? BigIntStats.clone(stats) : stats;\n}\nstatSync satisfies typeof Node.statSync;\n\n/**\n * Synchronous `lstat`.\n * `lstat()` is identical to `stat()`, except that if path is a symbolic link,\n * then the link itself is stat-ed, not the file that it refers to.\n * @param path\n */\nexport function lstatSync(path: PathLike, options?: { bigint: false }): Stats;\nexport function lstatSync(path: PathLike, options: { bigint: true }): BigIntStats;\nexport function lstatSync(path: PathLike, options?: StatOptions): Stats | BigIntStats {\n\tconst stats: Stats = doOp('statSync', false, path, cred);\n\treturn options?.bigint ? BigIntStats.clone(stats) : stats;\n}\nlstatSync satisfies typeof Node.lstatSync;\n\n/**\n * Synchronous `truncate`.\n * @param path\n * @param len\n */\nexport function truncateSync(path: PathLike, len: number = 0): void {\n\tif (len < 0) {\n\t\tthrow new ApiError(ErrorCode.EINVAL);\n\t}\n\treturn doOp('truncateSync', true, path, len, cred);\n}\ntruncateSync satisfies typeof Node.truncateSync;\n\n/**\n * Synchronous `unlink`.\n * @param path\n */\nexport function unlinkSync(path: PathLike): void {\n\treturn doOp('unlinkSync', false, path, cred);\n}\nunlinkSync satisfies typeof Node.unlinkSync;\n\n/**\n * Synchronous file open.\n * @see http://www.manpagez.com/man/2/open/\n * @param path\n * @param flags\n * @param mode defaults to `0644`\n * @returns file descriptor\n */\nexport function openSync(path: PathLike, flag: string, mode: number | string = 0o644): number {\n\tconst file: File = doOp('openSync', true, path, FileFlag.getFileFlag(flag), normalizeMode(mode, 0o644), cred);\n\treturn getFdForFile(file);\n}\nopenSync satisfies typeof Node.openSync;\n\n/**\n * Synchronously reads the entire contents of a file.\n * @param filename\n * @param options\n * @option options encoding The string encoding for the file contents. Defaults to `null`.\n * @option options flag Defaults to `'r'`.\n * @returns file contents\n */\nexport function readFileSync(filename: string, options?: { flag?: string }): Uint8Array;\nexport function readFileSync(filename: string, options: { encoding: string; flag?: string }): string;\nexport function readFileSync(filename: string, encoding: string): string;\nexport function readFileSync(filename: string, arg2: { encoding: string; flag?: string } | { flag?: string } | string = {}): FileContents {\n\tconst options = normalizeOptions(arg2, null, 'r', null);\n\tconst flag = FileFlag.getFileFlag(options.flag);\n\tif (!flag.isReadable()) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Flag passed to readFile must allow for reading.');\n\t}\n\tconst data: Uint8Array = doOp('readFileSync', true, filename, flag, cred);\n\tswitch (options.encoding) {\n\t\tcase 'utf8':\n\t\tcase 'utf-8':\n\t\t\treturn decode(data);\n\t\tdefault:\n\t\t\treturn data;\n\t}\n}\nreadFileSync satisfies BufferToUint8Array<typeof Node.readFileSync>;\n\n/**\n * Synchronously writes data to a file, replacing the file if it already\n * exists.\n *\n * The encoding option is ignored if data is a buffer.\n * @param filename\n * @param data\n * @param options\n * @option options encoding Defaults to `'utf8'`.\n * @option options mode Defaults to `0644`.\n * @option options flag Defaults to `'w'`.\n */\nexport function writeFileSync(filename: string, data: FileContents, options?: Node.WriteFileOptions): void;\nexport function writeFileSync(filename: string, data: FileContents, encoding?: string): void;\nexport function writeFileSync(filename: string, data: FileContents, arg3?: Node.WriteFileOptions | string): void {\n\tconst options = normalizeOptions(arg3, 'utf8', 'w', 0o644);\n\tconst flag = FileFlag.getFileFlag(options.flag);\n\tif (!flag.isWriteable()) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Flag passed to writeFile must allow for writing.');\n\t}\n\tif (typeof data != 'string' && !options.encoding) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Encoding not specified');\n\t}\n\tconst encodedData = typeof data == 'string' ? encode(data) : data;\n\treturn doOp('writeFileSync', true, filename, encodedData, flag, options.mode, cred);\n}\nwriteFileSync satisfies typeof Node.writeFileSync;\n\n/**\n * Asynchronously append data to a file, creating the file if it not yet\n * exists.\n *\n * @example Usage example\n * fs.appendFile('message.txt', 'data to append', function (err) {\n * if (err) throw err;\n * console.log('The \"data to append\" was appended to file!');\n * });\n * @param filename\n * @param data\n * @param options\n * @option options encoding Defaults to `'utf8'`.\n * @option options mode Defaults to `0644`.\n * @option options flag Defaults to `'a'`.\n */\nexport function appendFileSync(filename: string, data: FileContents, options?: Node.WriteFileOptions): void;\nexport function appendFileSync(filename: string, data: FileContents, encoding?: string): void;\nexport function appendFileSync(filename: string, data: FileContents, arg3?: Node.WriteFileOptions | string): void {\n\tconst options = normalizeOptions(arg3, 'utf8', 'a', 0o644);\n\tconst flag = FileFlag.getFileFlag(options.flag);\n\tif (!flag.isAppendable()) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Flag passed to appendFile must allow for appending.');\n\t}\n\tif (typeof data != 'string' && !options.encoding) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Encoding not specified');\n\t}\n\tconst encodedData = typeof data == 'string' ? encode(data) : data;\n\treturn doOp('appendFileSync', true, filename, encodedData, flag, options.mode, cred);\n}\nappendFileSync satisfies typeof Node.appendFileSync;\n\n/**\n * Synchronous `fstat`.\n * `fstat()` is identical to `stat()`, except that the file to be stat-ed is\n * specified by the file descriptor `fd`.\n * @param fd\n */\nexport function fstatSync(fd: number, options?: { bigint?: false }): Stats;\nexport function fstatSync(fd: number, options: { bigint: true }): BigIntStats;\nexport function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats {\n\tconst stats: Stats = fd2file(fd).statSync();\n\treturn options?.bigint ? BigIntStats.clone(stats) : stats;\n}\nfstatSync satisfies typeof Node.fstatSync;\n\n/**\n * Synchronous close.\n * @param fd\n */\nexport function closeSync(fd: number): void {\n\tfd2file(fd).closeSync();\n\tfdMap.delete(fd);\n}\ncloseSync satisfies typeof Node.closeSync;\n\n/**\n * Synchronous ftruncate.\n * @param fd\n * @param len\n */\nexport function ftruncateSync(fd: number, len: number = 0): void {\n\tconst file = fd2file(fd);\n\tif (len < 0) {\n\t\tthrow new ApiError(ErrorCode.EINVAL);\n\t}\n\tfile.truncateSync(len);\n}\nftruncateSync satisfies typeof Node.ftruncateSync;\n\n/**\n * Synchronous fsync.\n * @param fd\n */\nexport function fsyncSync(fd: number): void {\n\tfd2file(fd).syncSync();\n}\nfsyncSync satisfies typeof Node.fsyncSync;\n\n/**\n * Synchronous fdatasync.\n * @param fd\n */\nexport function fdatasyncSync(fd: number): void {\n\tfd2file(fd).datasyncSync();\n}\nfdatasyncSync satisfies typeof Node.fdatasyncSync;\n\n/**\n * Write buffer to the file specified by `fd`.\n * Note that it is unsafe to use fs.write multiple times on the same file\n * without waiting for it to return.\n * @param fd\n * @param buffer Uint8Array containing the data to write to\n * the file.\n * @param offset Offset in the buffer to start reading data from.\n * @param length The amount of bytes to write to the file.\n * @param position Offset from the beginning of the file where this\n * data should be written. If position is null, the data will be written at\n * the current position.\n */\nexport function writeSync(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number | null): number;\nexport function writeSync(fd: number, data: string, position?: number | null, encoding?: BufferEncoding): number;\nexport function writeSync(fd: number, arg2: Uint8Array | string, arg3?: number, arg4?: BufferEncoding | number, arg5?: number): number {\n\tlet buffer: Uint8Array,\n\t\toffset: number = 0,\n\t\tlength: number,\n\t\tposition: number | null;\n\tif (typeof arg2 === 'string') {\n\t\t// Signature 1: (fd, string, [position?, [encoding?]])\n\t\tposition = typeof arg3 === 'number' ? arg3 : null;\n\t\tconst encoding = (typeof arg4 === 'string' ? arg4 : 'utf8') as BufferEncoding;\n\t\toffset = 0;\n\t\tbuffer = encode(arg2);\n\t\tlength = buffer.length;\n\t} else {\n\t\t// Signature 2: (fd, buffer, offset, length, position?)\n\t\tbuffer = arg2;\n\t\toffset = arg3;\n\t\tlength = arg4 as number;\n\t\tposition = typeof arg5 === 'number' ? arg5 : null;\n\t}\n\n\tconst file = fd2file(fd);\n\tif (position === undefined || position === null) {\n\t\tposition = file.getPos()!;\n\t}\n\treturn file.writeSync(buffer, offset, length, position);\n}\nwriteSync satisfies typeof Node.writeSync;\n\n/**\n * Read data from the file specified by `fd`.\n * @param fd\n * @param buffer The buffer that the data will be\n * written to.\n * @param offset The offset within the buffer where writing will\n * start.\n * @param length An integer specifying the number of bytes to read.\n * @param position An integer specifying where to begin reading from\n * in the file. If position is null, data will be read from the current file\n * position.\n */\nexport function readSync(fd: number, buffer: Uint8Array, opts?: ReadSyncOptions): number;\nexport function readSync(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number): number;\nexport function readSync(fd: number, buffer: Uint8Array, opts?: ReadSyncOptions | number, length?: number, position?: number): number {\n\tconst file = fd2file(fd);\n\tlet offset = opts as number;\n\tif (typeof opts == 'object') {\n\t\t({ offset, length, position } = opts);\n\t}\n\n\tif (isNaN(+position)) {\n\t\tposition = file.getPos()!;\n\t}\n\n\treturn file.readSync(buffer, offset, length, position);\n}\nreadSync satisfies typeof Node.readSync;\n\n/**\n * Synchronous `fchown`.\n * @param fd\n * @param uid\n * @param gid\n */\nexport function fchownSync(fd: number, uid: number, gid: number): void {\n\tfd2file(fd).chownSync(uid, gid);\n}\nfchownSync satisfies typeof Node.fchownSync;\n\n/**\n * Synchronous `fchmod`.\n * @param fd\n * @param mode\n */\nexport function fchmodSync(fd: number, mode: number | string): void {\n\tconst numMode = typeof mode === 'string' ? parseInt(mode, 8) : mode;\n\tfd2file(fd).chmodSync(numMode);\n}\nfchmodSync satisfies typeof Node.fchmodSync;\n\n/**\n * Change the file timestamps of a file referenced by the supplied file\n * descriptor.\n * @param fd\n * @param atime\n * @param mtime\n */\nexport function futimesSync(fd: number, atime: number | Date, mtime: number | Date): void {\n\tfd2file(fd).utimesSync(normalizeTime(atime), normalizeTime(mtime));\n}\nfutimesSync satisfies typeof Node.futimesSync;\n\n// DIRECTORY-ONLY METHODS\n\n/**\n * Synchronous `rmdir`.\n * @param path\n */\nexport function rmdirSync(path: PathLike): void {\n\treturn doOp('rmdirSync', true, path, cred);\n}\nrmdirSync satisfies typeof Node.rmdirSync;\n\n/**\n * Synchronous `mkdir`.\n * @param path\n * @param mode defaults to o777\n * @todo Implement recursion\n */\nexport function mkdirSync(path: PathLike, options: Node.MakeDirectoryOptions & { recursive: true }): string;\nexport function mkdirSync(path: PathLike, options?: Node.Mode | (Node.MakeDirectoryOptions & { recursive?: false })): void;\nexport function mkdirSync(path: PathLike, options?: Node.Mode | Node.MakeDirectoryOptions): string | void {\n\tconst mode: Node.Mode = typeof options == 'number' || typeof options == 'string' ? options : options?.mode;\n\tconst recursive = typeof options == 'object' && options?.recursive;\n\tdoOp('mkdirSync', true, path, normalizeMode(mode, 0o777), cred);\n}\nmkdirSync satisfies typeof Node.mkdirSync;\n\n/**\n * Synchronous `readdir`. Reads the contents of a directory.\n * @param path\n */\nexport function readdirSync(path: PathLike, options: { encoding?: BufferEncoding; withFileTypes?: false } | BufferEncoding): string[];\nexport function readdirSync(path: PathLike, options: { encoding: 'buffer'; withFileTypes?: false } | 'buffer'): Uint8Array[];\nexport function readdirSync(path: PathLike, options: { withFileTypes: true }): Dirent[];\nexport function readdirSync(path: PathLike, options?: { encoding?: BufferEncoding | 'buffer'; withFileTypes?: boolean } | string): string[] | Dirent[] | Uint8Array[] {\n\tpath = normalizePath(path);\n\tconst entries: string[] = doOp('readdirSync', true, path, cred);\n\tfor (const mount of mounts.keys()) {\n\t\tif (!mount.startsWith(path)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst entry = mount.slice(path.length);\n\t\tif (entry.includes('/') || entry.length == 0) {\n\t\t\t// ignore FSs mounted in subdirectories and any FS mounted to `path`.\n\t\t\tcontinue;\n\t\t}\n\t\tentries.push(entry);\n\t}\n\treturn <string[] | Dirent[] | Uint8Array[]>entries.map((entry: string) => {\n\t\tif (typeof options == 'object' && options?.withFileTypes) {\n\t\t\treturn new Dirent(entry, statSync(join(path, entry)));\n\t\t}\n\n\t\tif (options == 'buffer' || (typeof options == 'object' && options.encoding == 'buffer')) {\n\t\t\treturn encode(entry);\n\t\t}\n\n\t\treturn entry;\n\t});\n}\nreaddirSync satisfies BufferToUint8Array<typeof Node.readdirSync>;\n\n// SYMLINK METHODS\n\n/**\n * Synchronous `link`.\n * @param srcpath\n * @param dstpath\n */\nexport function linkSync(srcpath: PathLike, dstpath: PathLike): void {\n\tdstpath = normalizePath(dstpath);\n\treturn doOp('linkSync', false, srcpath, dstpath, cred);\n}\nlinkSync satisfies typeof Node.linkSync;\n\n/**\n * Synchronous `symlink`.\n * @param srcpath\n * @param dstpath\n * @param type can be either `'dir'` or `'file'` (default is `'file'`)\n */\nexport function symlinkSync(srcpath: PathLike, dstpath: PathLike, type?: symlink.Type): void {\n\tif (!['file', 'dir', 'junction'].includes(type)) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, 'Invalid type: ' + type);\n\t}\n\tdstpath = normalizePath(dstpath);\n\treturn doOp('symlinkSync', false, srcpath, dstpath, type, cred);\n}\nsymlinkSync satisfies typeof Node.symlinkSync;\n\n/**\n * Synchronous readlink.\n * @param path\n */\nexport function readlinkSync(path: PathLike, options?: BufferEncodingOption): Uint8Array;\nexport function readlinkSync(path: PathLike, options: BaseEncodingOptions | BufferEncoding): string;\nexport function readlinkSync(path: PathLike, options?: BaseEncodingOptions | string | BufferEncodingOption): Uint8Array | string {\n\tconst encoding = typeof options == 'object' ? options.encoding : options;\n\tconst value: string = doOp('readlinkSync', false, path, cred);\n\tif (encoding === 'buffer') {\n\t\treturn encode(value);\n\t} else {\n\t\treturn value;\n\t}\n}\nreadlinkSync satisfies BufferToUint8Array<typeof Node.readlinkSync>;\n\n// PROPERTY OPERATIONS\n\n/**\n * Synchronous `chown`.\n * @param path\n * @param uid\n * @param gid\n */\nexport function chownSync(path: PathLike, uid: number, gid: number): void {\n\tdoOp('chownSync', true, path, uid, gid, cred);\n}\nchownSync satisfies typeof Node.chownSync;\n\n/**\n * Synchronous `lchown`.\n * @param path\n * @param uid\n * @param gid\n */\nexport function lchownSync(path: PathLike, uid: number, gid: number): void {\n\tdoOp('chownSync', false, path, uid, gid, cred);\n}\nlchownSync satisfies typeof Node.lchownSync;\n\n/**\n * Synchronous `chmod`.\n * @param path\n * @param mode\n */\nexport function chmodSync(path: PathLike, mode: string | number): void {\n\tconst numMode = normalizeMode(mode, -1);\n\tif (numMode < 0) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, `Invalid mode.`);\n\t}\n\tdoOp('chmodSync', true, path, numMode, cred);\n}\nchmodSync satisfies typeof Node.chmodSync;\n\n/**\n * Synchronous `lchmod`.\n * @param path\n * @param mode\n */\nexport function lchmodSync(path: PathLike, mode: number | string): void {\n\tconst numMode = normalizeMode(mode, -1);\n\tif (numMode < 1) {\n\t\tthrow new ApiError(ErrorCode.EINVAL, `Invalid mode.`);\n\t}\n\tdoOp('chmodSync', false, path, numMode, cred);\n}\nlchmodSync satisfies typeof Node.lchmodSync;\n\n/**\n * Change file timestamps of the file referenced by the supplied path.\n * @param path\n * @param atime\n * @param mtime\n */\nexport function utimesSync(path: PathLike, atime: number | Date, mtime: number | Date): void {\n\tdoOp('utimesSync', true, path, normalizeTime(atime), normalizeTime(mtime), cred);\n}\nutimesSync satisfies typeof Node.utimesSync;\n\n/**\n * Change file timestamps of the file referenced by the supplied path.\n * @param path\n * @param atime\n * @param mtime\n */\nexport function lutimesSync(path: PathLike, atime: number | Date, mtime: number | Date): void {\n\tdoOp('utimesSync', false, path, normalizeTime(atime), normalizeTime(mtime), cred);\n}\nlutimesSync satisfies typeof Node.lutimesSync;\n\n/**\n * Synchronous `realpath`.\n * @param path\n * @param cache An object literal of mapped paths that can be used to\n * force a specific path resolution or avoid additional `fs.stat` calls for\n * known real paths.\n * @returns the real path\n */\nexport function realpathSync(path: PathLike, options: BufferEncodingOption): Uint8Array;\nexport function realpathSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding): string;\nexport function realpathSync(path: PathLike, options?: BaseEncodingOptions | BufferEncoding | BufferEncodingOption): string | Uint8Array {\n\tpath = normalizePath(path);\n\tconst { fs, path: resolvedPath, mountPoint } = resolveFS(path);\n\ttry {\n\t\tconst stats = fs.statSync(resolvedPath, cred);\n\t\tif (!stats.isSymbolicLink()) {\n\t\t\treturn path;\n\t\t}\n\t\tconst dst = normalizePath(mountPoint + fs.readlinkSync(resolvedPath, cred));\n\t\treturn realpathSync(dst);\n\t} catch (e) {\n\t\tthrow fixError(e, { [resolvedPath]: path });\n\t}\n}\nrealpathSync satisfies BufferToUint8Array<typeof Node.realpathSync>;\n\n/**\n * Synchronous `access`.\n * @param path\n * @param mode\n */\nexport function accessSync(path: PathLike, mode: number = 0o600): void {\n\treturn doOp('accessSync', true, path, mode, cred);\n}\naccessSync satisfies typeof Node.accessSync;\n\nexport function rmSync(path: PathLike) {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\nrmSync satisfies typeof Node.rmSync;\n\nexport function mkdtempSync(prefix: string, options: BufferEncodingOption): Uint8Array;\nexport function mkdtempSync(prefix: string, options?: BaseEncodingOptions | BufferEncoding): string;\nexport function mkdtempSync(prefix: string, options?: BaseEncodingOptions | BufferEncoding | BufferEncodingOption): string | Uint8Array {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\nmkdtempSync satisfies BufferToUint8Array<typeof Node.mkdtempSync>;\n\nexport function copyFileSync(src: string, dest: string, flags?: number): void {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\ncopyFileSync satisfies typeof Node.copyFileSync;\n\nexport function readvSync(fd: number, buffers: readonly Uint8Array[], position?: number): number {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\nreadvSync satisfies typeof Node.readvSync;\n\nexport function writevSync(fd: number, buffers: readonly Uint8Array[], position?: number): number {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\nwritevSync satisfies typeof Node.writevSync;\n\nexport function opendirSync(path: PathLike, options?: Node.OpenDirOptions): Dir {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\nopendirSync satisfies typeof Node.opendirSync;\n", "import type { Dirent as _Dirent, Dir as _Dir } from 'fs';\nimport { NoArgCallback, TwoArgCallback } from '../filesystem.js';\nimport { Stats } from '../stats.js';\nimport { readdir } from './promises.js';\nimport { ApiError, ErrorCode } from '../ApiError.js';\nimport { readdirSync } from './sync.js';\n\nexport class Dirent implements _Dirent {\n\tconstructor(public name: string, protected stats: Stats) {}\n\n\tisFile(): boolean {\n\t\treturn this.stats.isFile();\n\t}\n\tisDirectory(): boolean {\n\t\treturn this.stats.isDirectory();\n\t}\n\tisBlockDevice(): boolean {\n\t\treturn this.stats.isBlockDevice();\n\t}\n\tisCharacterDevice(): boolean {\n\t\treturn this.stats.isCharacterDevice();\n\t}\n\tisSymbolicLink(): boolean {\n\t\treturn this.stats.isSymbolicLink();\n\t}\n\tisFIFO(): boolean {\n\t\treturn this.stats.isFIFO();\n\t}\n\tisSocket(): boolean {\n\t\treturn this.stats.isSocket();\n\t}\n}\n\n/**\n * A class representing a directory stream.\n */\nexport class Dir implements _Dir {\n\tprotected closed = false;\n\n\tprotected checkClosed(): void {\n\t\tif (this.closed) {\n\t\t\tthrow new ApiError(ErrorCode.EBADF, 'Can not use closed Dir');\n\t\t}\n\t}\n\n\tprotected _entries: Dirent[];\n\n\tconstructor(public readonly path: string) {}\n\n\t/**\n\t * Asynchronously close the directory's underlying resource handle.\n\t * Subsequent reads will result in errors.\n\t */\n\tclose(): Promise<void>;\n\tclose(cb: NoArgCallback): void;\n\tclose(cb?: NoArgCallback): void | Promise<void> {\n\t\tthis.closed = true;\n\t\tif (!cb) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tcb();\n\t}\n\n\t/**\n\t * Synchronously close the directory's underlying resource handle.\n\t * Subsequent reads will result in errors.\n\t */\n\tcloseSync(): void {\n\t\tthis.closed = true;\n\t}\n\n\tprotected async _read(): Promise<Dirent | null> {\n\t\tif (!this._entries) {\n\t\t\tthis._entries = await readdir(this.path, { withFileTypes: true });\n\t\t}\n\t\tif (this._entries.length == 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn this._entries.shift();\n\t}\n\n\t/**\n\t * Asynchronously read the next directory entry via `readdir(3)` as an `Dirent`.\n\t * After the read is completed, a value is returned that will be resolved with an `Dirent`, or `null` if there are no more directory entries to read.\n\t * Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.\n\t */\n\tread(): Promise<Dirent | null>;\n\tread(cb: TwoArgCallback<Dirent | null>): void;\n\tread(cb?: TwoArgCallback<Dirent | null>): void | Promise<Dirent | null> {\n\t\tif (!cb) {\n\t\t\treturn this._read();\n\t\t}\n\n\t\tthis._read().then(value => cb(null, value));\n\t}\n\n\t/**\n\t * Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.\n\t * If there are no more directory entries to read, null will be returned.\n\t * Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.\n\t */\n\treadSync(): Dirent | null {\n\t\tif (!this._entries) {\n\t\t\tthis._entries = readdirSync(this.path, { withFileTypes: true });\n\t\t}\n\t\tif (this._entries.length == 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn this._entries.shift();\n\t}\n\n\t/**\n\t * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.\n\t */\n\t[Symbol.asyncIterator](): AsyncIterableIterator<Dirent> {\n\t\tconst _this = this;\n\n\t\treturn {\n\t\t\t[Symbol.asyncIterator]: this[Symbol.asyncIterator],\n\t\t\tasync next(): Promise<IteratorResult<Dirent>> {\n\t\t\t\tconst value = await _this._read();\n\t\t\t\tif (value != null) {\n\t\t\t\t\treturn { done: false, value };\n\t\t\t\t}\n\n\t\t\t\tawait _this.close();\n\t\t\t\treturn { done: true, value: undefined };\n\t\t\t},\n\t\t};\n\t}\n}\n", "import type { BaseEncodingOptions, BufferEncodingOption, FSWatcher, StatOptions, symlink as _symlink } from 'fs';\nimport { ApiError, ErrorCode } from '../ApiError.js';\nimport { TwoArgCallback, NoArgCallback, ThreeArgCallback, FileContents } from '../filesystem.js';\nimport { BigIntStats, Stats } from '../stats.js';\nimport { nop, normalizeMode, PathLike } from './shared.js';\nimport * as promises from './promises.js';\nimport { R_OK } from './constants.js';\nimport { decode, encode } from '../utils.js';\nimport { ReadStream, WriteStream } from './streams.js';\nimport { Dirent } from './dir.js';\n\n/**\n * Asynchronous rename. No arguments other than a possible exception are given\n * to the completion callback.\n * @param oldPath\n * @param newPath\n * @param callback\n */\nexport function rename(oldPath: PathLike, newPath: PathLike, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.rename(oldPath, newPath)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Test whether or not the given path exists by checking with the file system.\n * Then call the callback argument with either true or false.\n * @example Sample invocation\n * fs.exists('/etc/passwd', function (exists) {\n * util.debug(exists ? \"it's there\" : \"no passwd!\");\n * });\n * @param path\n * @param callback\n */\nexport function exists(path: PathLike, cb: (exists: boolean) => unknown = nop): void {\n\tpromises\n\t\t.exists(path)\n\t\t.then(cb)\n\t\t.catch(() => cb(false));\n}\n\n/**\n * Asynchronous `stat`.\n * @param path\n * @param callback\n */\nexport function stat(path: PathLike, callback: TwoArgCallback<Stats>): void;\nexport function stat(path: PathLike, options: StatOptions & { bigint?: false }, callback: TwoArgCallback<Stats>): void;\nexport function stat(path: PathLike, options: StatOptions & { bigint: true }, callback: TwoArgCallback<BigIntStats>): void;\nexport function stat(path: PathLike, options: StatOptions, callback: TwoArgCallback<Stats | BigIntStats>): void;\nexport function stat(path: PathLike, options?: StatOptions | TwoArgCallback<Stats>, callback: TwoArgCallback<Stats> | TwoArgCallback<BigIntStats> = nop): void {\n\tcallback = typeof options == 'function' ? options : callback;\n\tpromises\n\t\t.stat(path, typeof options != 'function' ? options : ({} as object))\n\t\t.then(stats => callback(null, stats as Stats & BigIntStats))\n\t\t.catch(callback);\n}\n\n/**\n * Asynchronous `lstat`.\n * `lstat()` is identical to `stat()`, except that if path is a symbolic link,\n * then the link itself is stat-ed, not the file that it refers to.\n * @param path\n * @param callback\n */\nexport function lstat(path: PathLike, callback: TwoArgCallback<Stats>): void;\nexport function lstat(path: PathLike, options: StatOptions & { bigint?: false }, callback: TwoArgCallback<Stats>): void;\nexport function lstat(path: PathLike, options: StatOptions & { bigint: true }, callback: TwoArgCallback<BigIntStats>): void;\nexport function lstat(path: PathLike, options: StatOptions, callback: TwoArgCallback<Stats | BigIntStats>): void;\nexport function lstat(path: PathLike, options?: StatOptions | TwoArgCallback<Stats>, callback: TwoArgCallback<Stats> | TwoArgCallback<BigIntStats> = nop): void {\n\tcallback = typeof options == 'function' ? options : callback;\n\tpromises\n\t\t.lstat(path, typeof options != 'function' ? options : ({} as object))\n\t\t.then(stats => callback(null, stats as Stats & BigIntStats))\n\t\t.catch(callback);\n}\n\n/**\n * Asynchronous `truncate`.\n * @param path\n * @param len\n * @param callback\n */\nexport function truncate(path: PathLike, cb?: NoArgCallback): void;\nexport function truncate(path: PathLike, len: number, cb?: NoArgCallback): void;\nexport function truncate(path: PathLike, arg2: number | NoArgCallback = 0, cb: NoArgCallback = nop): void {\n\tcb = typeof arg2 === 'function' ? arg2 : cb;\n\tconst len = typeof arg2 === 'number' ? arg2 : 0;\n\tpromises\n\t\t.truncate(path, len)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `unlink`.\n * @param path\n * @param callback\n */\nexport function unlink(path: PathLike, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.unlink(path)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous file open.\n * Exclusive mode ensures that path is newly created.\n *\n * `flags` can be:\n *\n * * `'r'` - Open file for reading. An exception occurs if the file does not exist.\n * * `'r+'` - Open file for reading and writing. An exception occurs if the file does not exist.\n * * `'rs'` - Open file for reading in synchronous mode. Instructs the filesystem to not cache writes.\n * * `'rs+'` - Open file for reading and writing, and opens the file in synchronous mode.\n * * `'w'` - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).\n * * `'wx'` - Like 'w' but opens the file in exclusive mode.\n * * `'w+'` - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).\n * * `'wx+'` - Like 'w+' but opens the file in exclusive mode.\n * * `'a'` - Open file for appending. The file is created if it does not exist.\n * * `'ax'` - Like 'a' but opens the file in exclusive mode.\n * * `'a+'` - Open file for reading and appending. The file is created if it does not exist.\n * * `'ax+'` - Like 'a+' but opens the file in exclusive mode.\n *\n * @see http://www.manpagez.com/man/2/open/\n * @param path\n * @param flags\n * @param mode defaults to `0644`\n * @param callback\n */\nexport function open(path: PathLike, flag: string, cb?: TwoArgCallback<number>): void;\nexport function open(path: PathLike, flag: string, mode: number | string, cb?: TwoArgCallback<number>): void;\nexport function open(path: PathLike, flag: string, arg2?: number | string | TwoArgCallback<number>, cb: TwoArgCallback<number> = nop): void {\n\tconst mode = normalizeMode(arg2, 0o644);\n\tcb = typeof arg2 === 'function' ? arg2 : cb;\n\tpromises\n\t\t.open(path, flag, mode)\n\t\t.then(fd => cb(null, fd))\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronously reads the entire contents of a file.\n * @example Usage example\n * fs.readFile('/etc/passwd', function (err, data) {\n * if (err) throw err;\n * console.log(data);\n * });\n * @param filename\n * @param options\n * @option options [String] encoding The string encoding for the file contents. Defaults to `null`.\n * @option options [String] flag Defaults to `'r'`.\n * @param callback If no encoding is specified, then the raw buffer is returned.\n */\nexport function readFile(filename: PathLike, cb: TwoArgCallback<Uint8Array>): void;\nexport function readFile(filename: PathLike, options: { flag?: string }, callback?: TwoArgCallback<Uint8Array>): void;\nexport function readFile(filename: PathLike, options: { encoding: string; flag?: string }, callback?: TwoArgCallback<string>): void;\nexport function readFile(filename: PathLike, encoding: string, cb: TwoArgCallback<string>): void;\nexport function readFile(filename: PathLike, arg2: any = {}, cb: TwoArgCallback<string> | TwoArgCallback<Uint8Array> = nop) {\n\tcb = typeof arg2 === 'function' ? arg2 : cb;\n\n\tpromises.readFile(filename, typeof arg2 === 'function' ? null : arg2);\n}\n\n/**\n * Asynchronously writes data to a file, replacing the file if it already\n * exists.\n *\n * The encoding option is ignored if data is a buffer.\n *\n * @example Usage example\n * fs.writeFile('message.txt', 'Hello Node', function (err) {\n * if (err) throw err;\n * console.log('It\\'s saved!');\n * });\n * @param filename\n * @param data\n * @param options\n * @option options [String] encoding Defaults to `'utf8'`.\n * @option options [Number] mode Defaults to `0644`.\n * @option options [String] flag Defaults to `'w'`.\n * @param callback\n */\nexport function writeFile(filename: PathLike, data: FileContents, cb?: NoArgCallback): void;\nexport function writeFile(filename: PathLike, data: FileContents, encoding?: string, cb?: NoArgCallback): void;\nexport function writeFile(filename: PathLike, data: FileContents, options?: { encoding?: string; mode?: string | number; flag?: string }, cb?: NoArgCallback): void;\nexport function writeFile(\n\tfilename: PathLike,\n\tdata: FileContents,\n\targ3: { encoding?: string; mode?: string | number; flag?: string } | string | NoArgCallback = {},\n\tcb: NoArgCallback = nop\n): void {\n\tcb = typeof arg3 === 'function' ? arg3 : cb;\n\tpromises.writeFile(filename, data, typeof arg3 === 'function' ? undefined : arg3);\n}\n\n/**\n * Asynchronously append data to a file, creating the file if it not yet\n * exists.\n *\n * @example Usage example\n * fs.appendFile('message.txt', 'data to append', function (err) {\n * if (err) throw err;\n * console.log('The \"data to append\" was appended to file!');\n * });\n * @param filename\n * @param data\n * @param options\n * @option options [String] encoding Defaults to `'utf8'`.\n * @option options [Number] mode Defaults to `0644`.\n * @option options [String] flag Defaults to `'a'`.\n * @param callback\n */\nexport function appendFile(filename: PathLike, data: FileContents, cb?: NoArgCallback): void;\nexport function appendFile(filename: PathLike, data: FileContents, options?: { encoding?: string; mode?: number | string; flag?: string }, cb?: NoArgCallback): void;\nexport function appendFile(filename: PathLike, data: FileContents, encoding?: string, cb?: NoArgCallback): void;\nexport function appendFile(filename: PathLike, data: FileContents, arg3?: any, cb: NoArgCallback = nop): void {\n\tcb = typeof arg3 === 'function' ? arg3 : cb;\n\tpromises.appendFile(filename, data, typeof arg3 === 'function' ? null : arg3);\n}\n\n/**\n * Asynchronous `fstat`.\n * `fstat()` is identical to `stat()`, except that the file to be stat-ed is\n * specified by the file descriptor `fd`.\n * @param fd\n * @param callback\n */\nexport function fstat(fd: number, cb: TwoArgCallback<Stats>): void;\nexport function fstat(fd: number, options: StatOptions & { bigint?: false }, cb: TwoArgCallback<Stats>): void;\nexport function fstat(fd: number, options: StatOptions & { bigint: true }, cb: TwoArgCallback<BigIntStats>): void;\nexport function fstat(fd: number, options: StatOptions, cb: TwoArgCallback<Stats | BigIntStats>): void;\nexport function fstat(fd: number, options?: StatOptions | TwoArgCallback<Stats>, cb: TwoArgCallback<Stats> | TwoArgCallback<BigIntStats> = nop): void {\n\tcb = typeof options == 'function' ? options : cb;\n\tpromises\n\t\t.fstat(fd, typeof options != 'function' ? options : ({} as object))\n\t\t.then(stats => cb(null, stats as Stats & BigIntStats))\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous close.\n * @param fd\n * @param callback\n */\nexport function close(fd: number, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.close(fd)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous ftruncate.\n * @param fd\n * @param len\n * @param callback\n */\nexport function ftruncate(fd: number, cb?: NoArgCallback): void;\nexport function ftruncate(fd: number, len?: number, cb?: NoArgCallback): void;\nexport function ftruncate(fd: number, arg2?: any, cb: NoArgCallback = nop): void {\n\tconst length = typeof arg2 === 'number' ? arg2 : 0;\n\tcb = typeof arg2 === 'function' ? arg2 : cb;\n\tpromises.ftruncate(fd, length);\n}\n\n/**\n * Asynchronous fsync.\n * @param fd\n * @param callback\n */\nexport function fsync(fd: number, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.fsync(fd)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous fdatasync.\n * @param fd\n * @param callback\n */\nexport function fdatasync(fd: number, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.fdatasync(fd)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Write buffer to the file specified by `fd`.\n * Note that it is unsafe to use fs.write multiple times on the same file\n * without waiting for the callback.\n * @param fd\n * @param buffer Uint8Array containing the data to write to\n * the file.\n * @param offset Offset in the buffer to start reading data from.\n * @param length The amount of bytes to write to the file.\n * @param position Offset from the beginning of the file where this\n * data should be written. If position is null, the data will be written at\n * the current position.\n * @param callback The number specifies the number of bytes written into the file.\n */\nexport function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?: ThreeArgCallback<number, Uint8Array>): void;\nexport function write(fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null, cb?: ThreeArgCallback<number, Uint8Array>): void;\nexport function write(fd: number, data: FileContents, cb?: ThreeArgCallback<number, string>): void;\nexport function write(fd: number, data: FileContents, position: number | null, cb?: ThreeArgCallback<number, string>): void;\nexport function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: ThreeArgCallback<number, string>): void;\nexport function write(fd: number, arg2: FileContents, arg3?: any, arg4?: any, arg5?: any, cb: ThreeArgCallback<number, Uint8Array> | ThreeArgCallback<number, string> = nop): void {\n\tlet buffer: Uint8Array,\n\t\toffset: number,\n\t\tlength: number,\n\t\tposition: number | null = null,\n\t\tencoding: BufferEncoding;\n\tif (typeof arg2 === 'string') {\n\t\t// Signature 1: (fd, string, [position?, [encoding?]], cb?)\n\t\tencoding = 'utf8';\n\t\tswitch (typeof arg3) {\n\t\t\tcase 'function':\n\t\t\t\t// (fd, string, cb)\n\t\t\t\tcb = arg3;\n\t\t\t\tbreak;\n\t\t\tcase 'number':\n\t\t\t\t// (fd, string, position, encoding?, cb?)\n\t\t\t\tposition = arg3;\n\t\t\t\tencoding = (typeof arg4 === 'string' ? arg4 : 'utf8') as BufferEncoding;\n\t\t\t\tcb = typeof arg5 === 'function' ? arg5 : cb;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t// ...try to find the callback and get out of here!\n\t\t\t\tcb = typeof arg4 === 'function' ? arg4 : typeof arg5 === 'function' ? arg5 : cb;\n\t\t\t\tcb(new ApiError(ErrorCode.EINVAL, 'Invalid arguments.'));\n\t\t\t\treturn;\n\t\t}\n\t\tbuffer = encode(arg2);\n\t\toffset = 0;\n\t\tlength = buffer.length;\n\t\tconst _cb = cb as ThreeArgCallback<number, string>;\n\t\tpromises\n\t\t\t.write(fd, buffer, offset, length, position)\n\t\t\t.then(bytesWritten => _cb(null, bytesWritten, decode(buffer)))\n\t\t\t.catch(_cb);\n\t} else {\n\t\t// Signature 2: (fd, buffer, offset, length, position?, cb?)\n\t\tbuffer = arg2;\n\t\toffset = arg3;\n\t\tlength = arg4;\n\t\tposition = typeof arg5 === 'number' ? arg5 : null;\n\t\tconst _cb = (typeof arg5 === 'function' ? arg5 : cb) as ThreeArgCallback<number, Uint8Array>;\n\t\tpromises\n\t\t\t.write(fd, buffer, offset, length, position)\n\t\t\t.then(bytesWritten => _cb(null, bytesWritten, buffer))\n\t\t\t.catch(_cb);\n\t}\n}\n\n/**\n * Read data from the file specified by `fd`.\n * @param buffer The buffer that the data will be\n * written to.\n * @param offset The offset within the buffer where writing will\n * start.\n * @param length An integer specifying the number of bytes to read.\n * @param position An integer specifying where to begin reading from\n * in the file. If position is null, data will be read from the current file\n * position.\n * @param callback The number is the number of bytes read\n */\nexport function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb: ThreeArgCallback<number, Uint8Array> = nop): void {\n\tpromises\n\t\t.read(fd, buffer, offset, length, position)\n\t\t.then(({ bytesRead, buffer }) => cb(null, bytesRead, buffer))\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `fchown`.\n * @param fd\n * @param uid\n * @param gid\n * @param callback\n */\nexport function fchown(fd: number, uid: number, gid: number, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.fchown(fd, uid, gid)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `fchmod`.\n * @param fd\n * @param mode\n * @param callback\n */\nexport function fchmod(fd: number, mode: string | number, cb: NoArgCallback): void {\n\tpromises\n\t\t.fchmod(fd, mode)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Change the file timestamps of a file referenced by the supplied file\n * descriptor.\n * @param fd\n * @param atime\n * @param mtime\n * @param callback\n */\nexport function futimes(fd: number, atime: number | Date, mtime: number | Date, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.futimes(fd, atime, mtime)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `rmdir`.\n * @param path\n * @param callback\n */\nexport function rmdir(path: PathLike, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.rmdir(path)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `mkdir`.\n * @param path\n * @param mode defaults to `0777`\n * @param callback\n */\nexport function mkdir(path: PathLike, mode?: any, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.mkdir(path, mode)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `readdir`. Reads the contents of a directory.\n * The callback gets two arguments `(err, files)` where `files` is an array of\n * the names of the files in the directory excluding `'.'` and `'..'`.\n * @param path\n * @param callback\n */\nexport function readdir(path: PathLike, cb: TwoArgCallback<string[]>): void;\nexport function readdir(path: PathLike, options: { withFileTypes?: false }, cb: TwoArgCallback<string[]>): void;\nexport function readdir(path: PathLike, options: { withFileTypes: true }, cb: TwoArgCallback<Dirent[]>): void;\nexport function readdir(path: PathLike, _options: { withFileTypes?: boolean } | TwoArgCallback<string[]>, cb: TwoArgCallback<string[]> | TwoArgCallback<Dirent[]> = nop): void {\n\tcb = typeof _options == 'function' ? _options : cb;\n\tconst options = typeof _options != 'function' ? _options : {};\n\tpromises\n\t\t.readdir(path, options as object)\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t.then(entries => cb(null, entries as any))\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `link`.\n * @param srcpath\n * @param dstpath\n * @param callback\n */\nexport function link(srcpath: PathLike, dstpath: PathLike, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.link(srcpath, dstpath)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `symlink`.\n * @param srcpath\n * @param dstpath\n * @param type can be either `'dir'` or `'file'` (default is `'file'`)\n * @param callback\n */\nexport function symlink(srcpath: PathLike, dstpath: PathLike, cb?: NoArgCallback): void;\nexport function symlink(srcpath: PathLike, dstpath: PathLike, type?: _symlink.Type, cb?: NoArgCallback): void;\nexport function symlink(srcpath: PathLike, dstpath: PathLike, arg3?: _symlink.Type | NoArgCallback, cb: NoArgCallback = nop): void {\n\tconst type = typeof arg3 === 'string' ? arg3 : 'file';\n\tcb = typeof arg3 === 'function' ? arg3 : cb;\n\tpromises\n\t\t.symlink(srcpath, dstpath, typeof arg3 === 'function' ? null : arg3)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous readlink.\n * @param path\n * @param callback\n */\nexport function readlink(path: PathLike, callback: TwoArgCallback<string> & any): void;\nexport function readlink(path: PathLike, options: BufferEncodingOption, callback: TwoArgCallback<Uint8Array>): void;\nexport function readlink(path: PathLike, options: BaseEncodingOptions | string, callback: TwoArgCallback<string | Uint8Array>): void;\nexport function readlink(path: PathLike, options: BaseEncodingOptions | BufferEncoding, callback: TwoArgCallback<string>): void;\nexport function readlink(\n\tpath: PathLike,\n\toptions: BufferEncodingOption | BaseEncodingOptions | string | TwoArgCallback<string>,\n\tcallback: TwoArgCallback<string> | TwoArgCallback<Uint8Array> = nop\n): void {\n\tcallback = typeof options == 'function' ? options : callback;\n\tpromises\n\t\t.readlink(path)\n\t\t.then(result => callback(null, result as string & Uint8Array))\n\t\t.catch(callback);\n}\n\n/**\n * Asynchronous `chown`.\n * @param path\n * @param uid\n * @param gid\n * @param callback\n */\nexport function chown(path: PathLike, uid: number, gid: number, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.chown(path, uid, gid)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `lchown`.\n * @param path\n * @param uid\n * @param gid\n * @param callback\n */\nexport function lchown(path: PathLike, uid: number, gid: number, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.lchown(path, uid, gid)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `chmod`.\n * @param path\n * @param mode\n * @param callback\n */\nexport function chmod(path: PathLike, mode: number | string, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.chmod(path, mode)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `lchmod`.\n * @param path\n * @param mode\n * @param callback\n */\nexport function lchmod(path: PathLike, mode: number | string, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.lchmod(path, mode)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Change file timestamps of the file referenced by the supplied path.\n * @param path\n * @param atime\n * @param mtime\n * @param callback\n */\nexport function utimes(path: PathLike, atime: number | Date, mtime: number | Date, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.utimes(path, atime, mtime)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Change file timestamps of the file referenced by the supplied path.\n * @param path\n * @param atime\n * @param mtime\n * @param callback\n */\nexport function lutimes(path: PathLike, atime: number | Date, mtime: number | Date, cb: NoArgCallback = nop): void {\n\tpromises\n\t\t.lutimes(path, atime, mtime)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `realpath`. The callback gets two arguments\n * `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.\n *\n * @example Usage example\n * fs.realpath('/etc/passwd', function (err, resolvedPath) {\n * if (err) throw err;\n * console.log(resolvedPath);\n * });\n *\n * @param path\n * @param callback\n */\nexport function realpath(path: PathLike, cb?: TwoArgCallback<string>): void;\nexport function realpath(path: PathLike, options: BaseEncodingOptions, cb: TwoArgCallback<string>): void;\nexport function realpath(path: PathLike, arg2?: TwoArgCallback<string> | BaseEncodingOptions, cb: TwoArgCallback<string> = nop): void {\n\tcb = typeof arg2 === 'function' ? arg2 : cb;\n\tpromises\n\t\t.realpath(path, typeof arg2 === 'function' ? null : arg2)\n\t\t.then(result => cb(null, result))\n\t\t.catch(cb);\n}\n\n/**\n * Asynchronous `access`.\n * @param path\n * @param mode\n * @param callback\n */\nexport function access(path: PathLike, cb: NoArgCallback): void;\nexport function access(path: PathLike, mode: number, cb: NoArgCallback): void;\nexport function access(path: PathLike, arg2: any, cb: NoArgCallback = nop): void {\n\tconst mode = typeof arg2 === 'number' ? arg2 : R_OK;\n\tcb = typeof arg2 === 'function' ? arg2 : cb;\n\tpromises\n\t\t.access(path, typeof arg2 === 'function' ? null : arg2)\n\t\t.then(() => cb())\n\t\t.catch(cb);\n}\n\nexport function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;\nexport function watchFile(filename: PathLike, options: { persistent?: boolean; interval?: number }, listener: (curr: Stats, prev: Stats) => void): void;\nexport function watchFile(filename: PathLike, arg2: any, listener: (curr: Stats, prev: Stats) => void = nop): void {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function unwatchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void = nop): void {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function watch(filename: PathLike, listener?: (event: string, filename: string) => any): FSWatcher;\nexport function watch(filename: PathLike, options: { persistent?: boolean }, listener?: (event: string, filename: string) => any): FSWatcher;\nexport function watch(filename: PathLike, arg2: any, listener: (event: string, filename: string) => any = nop): FSWatcher {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function createReadStream(\n\tpath: PathLike,\n\toptions?: {\n\t\tflags?: string;\n\t\tencoding?: string;\n\t\tfd?: number;\n\t\tmode?: number;\n\t\tautoClose?: boolean;\n\t}\n): ReadStream {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function createWriteStream(\n\tpath: PathLike,\n\toptions?: {\n\t\tflags?: string;\n\t\tencoding?: string;\n\t\tfd?: number;\n\t\tmode?: number;\n\t}\n): WriteStream {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function rm(path: PathLike) {\n\tnew ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function mkdtemp(path: PathLike) {\n\tnew ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function copyFile(src: PathLike, dest: PathLike, callback: NoArgCallback): void;\nexport function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoArgCallback): void;\nexport function copyFile(src: PathLike, dest: PathLike, flags: number | NoArgCallback, callback?: NoArgCallback): void {\n\tnew ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function readv(path: PathLike) {\n\tnew ApiError(ErrorCode.ENOTSUP);\n}\n\ntype writevCallback = ThreeArgCallback<number, Uint8Array[]>;\n\nexport function writev(fd: number, buffers: Uint8Array[], cb: writevCallback): void;\nexport function writev(fd: number, buffers: Uint8Array[], position: number, cb: writevCallback): void;\nexport function writev(fd: number, buffers: Uint8Array[], position: number | writevCallback, cb?: writevCallback) {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n\nexport function opendir(path: PathLike) {\n\tthrow new ApiError(ErrorCode.ENOTSUP);\n}\n", "import type * as Node from 'fs';\nimport { Readable, Writable } from 'readable-stream';\nimport { NoArgCallback } from '../filesystem.js';\n\nexport class ReadStream extends Readable implements Node.ReadStream {\n\tclose(callback: NoArgCallback = () => null): void {\n\t\ttry {\n\t\t\tsuper.destroy();\n\t\t\tsuper.emit('close');\n\t\t\tcallback();\n\t\t} catch (err) {\n\t\t\tcallback(err);\n\t\t}\n\t}\n\tbytesRead: number;\n\tpath: string | Buffer;\n\tpending: boolean;\n\n\taddListener(event: 'close', listener: () => void): this;\n\taddListener(event: 'data', listener: (chunk: Buffer | string) => void): this;\n\taddListener(event: 'end', listener: () => void): this;\n\taddListener(event: 'error', listener: (err: Error) => void): this;\n\taddListener(event: 'open', listener: (fd: number) => void): this;\n\taddListener(event: 'pause', listener: () => void): this;\n\taddListener(event: 'readable', listener: () => void): this;\n\taddListener(event: 'ready', listener: () => void): this;\n\taddListener(event: 'resume', listener: () => void): this;\n\taddListener(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.addListener(event, listener);\n\t}\n\n\ton(event: 'close', listener: () => void): this;\n\ton(event: 'data', listener: (chunk: Buffer | string) => void): this;\n\ton(event: 'end', listener: () => void): this;\n\ton(event: 'error', listener: (err: Error) => void): this;\n\ton(event: 'open', listener: (fd: number) => void): this;\n\ton(event: 'pause', listener: () => void): this;\n\ton(event: 'readable', listener: () => void): this;\n\ton(event: 'ready', listener: () => void): this;\n\ton(event: 'resume', listener: () => void): this;\n\ton(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.on(event, listener);\n\t}\n\n\tonce(event: 'close', listener: () => void): this;\n\tonce(event: 'data', listener: (chunk: Buffer | string) => void): this;\n\tonce(event: 'end', listener: () => void): this;\n\tonce(event: 'error', listener: (err: Error) => void): this;\n\tonce(event: 'open', listener: (fd: number) => void): this;\n\tonce(event: 'pause', listener: () => void): this;\n\tonce(event: 'readable', listener: () => void): this;\n\tonce(event: 'ready', listener: () => void): this;\n\tonce(event: 'resume', listener: () => void): this;\n\tonce(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.once(event, listener);\n\t}\n\n\tprependListener(event: 'close', listener: () => void): this;\n\tprependListener(event: 'data', listener: (chunk: Buffer | string) => void): this;\n\tprependListener(event: 'end', listener: () => void): this;\n\tprependListener(event: 'error', listener: (err: Error) => void): this;\n\tprependListener(event: 'open', listener: (fd: number) => void): this;\n\tprependListener(event: 'pause', listener: () => void): this;\n\tprependListener(event: 'readable', listener: () => void): this;\n\tprependListener(event: 'ready', listener: () => void): this;\n\tprependListener(event: 'resume', listener: () => void): this;\n\tprependListener(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.prependListener(event, listener);\n\t}\n\n\tprependOnceListener(event: 'close', listener: () => void): this;\n\tprependOnceListener(event: 'data', listener: (chunk: Buffer | string) => void): this;\n\tprependOnceListener(event: 'end', listener: () => void): this;\n\tprependOnceListener(event: 'error', listener: (err: Error) => void): this;\n\tprependOnceListener(event: 'open', listener: (fd: number) => void): this;\n\tprependOnceListener(event: 'pause', listener: () => void): this;\n\tprependOnceListener(event: 'readable', listener: () => void): this;\n\tprependOnceListener(event: 'ready', listener: () => void): this;\n\tprependOnceListener(event: 'resume', listener: () => void): this;\n\tprependOnceListener(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.prependOnceListener(event, listener);\n\t}\n}\n\nexport class WriteStream extends Writable implements Node.WriteStream {\n\tclose(callback: NoArgCallback = () => null): void {\n\t\ttry {\n\t\t\tsuper.destroy();\n\t\t\tsuper.emit('close');\n\t\t\tcallback();\n\t\t} catch (err) {\n\t\t\tcallback(err);\n\t\t}\n\t}\n\tbytesWritten: number;\n\tpath: string | Buffer;\n\tpending: boolean;\n\n\taddListener(event: 'close', listener: () => void): this;\n\taddListener(event: 'drain', listener: () => void): this;\n\taddListener(event: 'error', listener: (err: Error) => void): this;\n\taddListener(event: 'finish', listener: () => void): this;\n\taddListener(event: 'open', listener: (fd: number) => void): this;\n\taddListener(event: 'pipe', listener: (src: Readable) => void): this;\n\taddListener(event: 'ready', listener: () => void): this;\n\taddListener(event: 'unpipe', listener: (src: Readable) => void): this;\n\taddListener(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.addListener(event, listener);\n\t}\n\n\ton(event: 'close', listener: () => void): this;\n\ton(event: 'drain', listener: () => void): this;\n\ton(event: 'error', listener: (err: Error) => void): this;\n\ton(event: 'finish', listener: () => void): this;\n\ton(event: 'open', listener: (fd: number) => void): this;\n\ton(event: 'pipe', listener: (src: Readable) => void): this;\n\ton(event: 'ready', listener: () => void): this;\n\ton(event: 'unpipe', listener: (src: Readable) => void): this;\n\ton(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.on(event, listener);\n\t}\n\n\tonce(event: 'close', listener: () => void): this;\n\tonce(event: 'drain', listener: () => void): this;\n\tonce(event: 'error', listener: (err: Error) => void): this;\n\tonce(event: 'finish', listener: () => void): this;\n\tonce(event: 'open', listener: (fd: number) => void): this;\n\tonce(event: 'pipe', listener: (src: Readable) => void): this;\n\tonce(event: 'ready', listener: () => void): this;\n\tonce(event: 'unpipe', listener: (src: Readable) => void): this;\n\tonce(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.once(event, listener);\n\t}\n\n\tprependListener(event: 'close', listener: () => void): this;\n\tprependListener(event: 'drain', listener: () => void): this;\n\tprependListener(event: 'error', listener: (err: Error) => void): this;\n\tprependListener(event: 'finish', listener: () => void): this;\n\tprependListener(event: 'open', listener: (fd: number) => void): this;\n\tprependListener(event: 'pipe', listener: (src: Readable) => void): this;\n\tprependListener(event: 'ready', listener: () => void): this;\n\tprependListener(event: 'unpipe', listener: (src: Readable) => void): this;\n\tprependListener(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.prependListener(event, listener);\n\t}\n\n\tprependOnceListener(event: 'close', listener: () => void): this;\n\tprependOnceListener(event: 'drain', listener: () => void): this;\n\tprependOnceListener(event: 'error', listener: (err: Error) => void): this;\n\tprependOnceListener(event: 'finish', listener: () => void): this;\n\tprependOnceListener(event: 'open', listener: (fd: number) => void): this;\n\tprependOnceListener(event: 'pipe', listener: (src: Readable) => void): this;\n\tprependOnceListener(event: 'ready', listener: () => void): this;\n\tprependOnceListener(event: 'unpipe', listener: (src: Readable) => void): this;\n\tprependOnceListener(event: string | symbol, listener: (...args) => void): this {\n\t\treturn super.prependOnceListener(event, listener);\n\t}\n}\n", "import * as fs_mock from './index.js';\nimport type * as fs_node from 'node:fs';\n\nconst fs = fs_mock as typeof fs_node & typeof fs_mock;\n\nexport * from './index.js';\nexport default fs;\n", "import { type FileSystem, SynchronousFileSystem, FileSystemMetadata } from '../filesystem.js';\nimport { ApiError, ErrorCode } from '../ApiError.js';\nimport { File, FileFlag, PreloadFile } from '../file.js';\nimport { Stats } from '../stats.js';\nimport { join } from '../emulation/path.js';\nimport { Cred } from '../cred.js';\nimport { CreateBackend, type BackendOptions } from './backend.js';\n\n/**\n * @internal\n */\ninterface AsyncOperation {\n\tapiMethod: string;\n\targuments: any[];\n}\n\n/**\n * We define our own file to interpose on syncSync() for mirroring purposes.\n */\nclass MirrorFile extends PreloadFile<AsyncMirror> implements File {\n\tconstructor(fs: AsyncMirror, path: string, flag: FileFlag, stat: Stats, data: Uint8Array) {\n\t\tsuper(fs, path, flag, stat, data);\n\t}\n\n\tpublic syncSync(): void {\n\t\tif (this.isDirty()) {\n\t\t\tthis._fs._syncSync(this);\n\t\t\tthis.resetDirty();\n\t\t}\n\t}\n\n\tpublic closeSync(): void {\n\t\tthis.syncSync();\n\t}\n}\n\nexport namespace AsyncMirror {\n\t/**\n\t * Configuration options for the AsyncMirror file system.\n\t */\n\texport interface Options {\n\t\t/**\n\t\t * The synchronous file system to mirror the asynchronous file system to.\n\t\t */\n\t\tsync: FileSystem;\n\t\t/**\n\t\t * The asynchronous file system to mirror.\n\t\t */\n\t\tasync: FileSystem;\n\t}\n}\n\n/**\n * AsyncMirrorFS mirrors a synchronous filesystem into an asynchronous filesystem\n * by:\n *\n * * Performing operations over the in-memory copy, while asynchronously pipelining them\n * to the backing store.\n * * During application loading, the contents of the async file system can be reloaded into\n * the synchronous store, if desired.\n *\n * The two stores will be kept in sync. The most common use-case is to pair a synchronous\n * in-memory filesystem with an asynchronous backing store.\n *\n * Example: Mirroring an IndexedDB file system to an in memory file system. Now, you can use\n * IndexedDB synchronously.\n *\n * ```javascript\n * BrowserFS.configure({\n * fs: \"AsyncMirror\",\n * options: {\n * sync: { fs: \"InMemory\" },\n * async: { fs: \"IndexedDB\" }\n * }\n * }, function(e) {\n * // BrowserFS is initialized and ready-to-use!\n * });\n * ```\n *\n * Or, alternatively:\n *\n * ```javascript\n * BrowserFS.Backend.IndexedDB.Create(function(e, idbfs) {\n * BrowserFS.Backend.InMemory.Create(function(e, inMemory) {\n * BrowserFS.Backend.AsyncMirror({\n * sync: inMemory, async: idbfs\n * }, function(e, mirrored) {\n * BrowserFS.initialize(mirrored);\n * });\n * });\n * });\n * ```\n */\nexport class AsyncMirror extends SynchronousFileSystem {\n\tpublic static readonly Name = 'AsyncMirror';\n\n\tpublic static Create = CreateBackend.bind(this);\n\n\tpublic static readonly Options: BackendOptions = {\n\t\tsync: {\n\t\t\ttype: 'object',\n\t\t\tdescription: 'The synchronous file system to mirror the asynchronous file system to.',\n\t\t\tvalidator: async (v: FileSystem): Promise<void> => {\n\t\t\t\tif (!v?.metadata.synchronous) {\n\t\t\t\t\tthrow new ApiError(ErrorCode.EINVAL, `'sync' option must be a file system that supports synchronous operations`);\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tasync: {\n\t\t\ttype: 'object',\n\t\t\tdescription: 'The asynchronous file system to mirror.',\n\t\t},\n\t};\n\n\tpublic static isAvailable(): boolean {\n\t\treturn true;\n\t}\n\n\t/**\n\t * Queue of pending asynchronous operations.\n\t */\n\tprivate _queue: AsyncOperation[] = [];\n\tprivate _queueRunning: boolean = false;\n\tprivate _sync: FileSystem;\n\tprivate _async: FileSystem;\n\tprivate _isInitialized: boolean = false;\n\tprivate _initializeCallbacks: ((e?: ApiError) => void)[] = [];\n\n\t/**\n\t *\n\t * Mirrors the synchronous file system into the asynchronous file system.\n\t *\n\t * @param sync The synchronous file system to mirror the asynchronous file system to.\n\t * @param async The asynchronous file system to mirror.\n\t */\n\tconstructor({ sync, async }: AsyncMirror.Options) {\n\t\tsuper();\n\t\tthis._sync = sync;\n\t\tthis._async = async;\n\t\tthis._ready = this._initialize();\n\t}\n\n\tpublic get metadata(): FileSystemMetadata {\n\t\treturn {\n\t\t\t...super.metadata,\n\t\t\tname: AsyncMirror.Name,\n\t\t\tsynchronous: true,\n\t\t\tsupportsProperties: this._sync.metadata.supportsProperties && this._async.metadata.supportsProperties,\n\t\t};\n\t}\n\n\tpublic _syncSync(fd: PreloadFile<AsyncMirror>) {\n\t\tconst stats = fd.getStats();\n\t\tthis._sync.writeFileSync(fd.getPath(), fd.getBuffer(), FileFlag.getFileFlag('w'), stats.mode, stats.getCred(0, 0));\n\t\tthis.enqueueOp({\n\t\t\tapiMethod: 'writeFile',\n\t\t\targuments: [fd.getPath(), fd.getBuffer(), fd.getFlag(), stats.mode, stats.getCred(0, 0)],\n\t\t});\n\t}\n\n\tpublic renameSync(oldPath: string, newPath: string, cred: Cred): void {\n\t\tthis._sync.renameSync(oldPath, newPath, cred);\n\t\tthis.enqueueOp({\n\t\t\tapiMethod: 'rename',\n\t\t\targuments: [oldPath, newPath, cred],\n\t\t});\n\t}\n\n\tpublic statSync(p: string, cred: Cred): Stats {\n\t\treturn this._sync.statSync(p, cred);\n\t}\n\n\tpublic openSync(p: string, flag: FileFlag, mode: number, cred: Cred): File {\n\t\t// Sanity check: Is this open/close permitted?\n\t\tconst fd = this._sync.openSync(p, flag, mode, cred);\n\t\tfd.closeSync();\n\t\treturn new MirrorFile(this, p, flag, this._sync.statSync(p, cred), this._sync.readFileSync(p, FileFlag.getFileFlag('r'), cred));\n\t}\n\n\tpublic unlinkSync(p: string, cred: Cred): void {\n\t\tthis._sync.unlinkSync(p, cred);\n\t\tthis.enqueueOp({\n\t\t\tapiMethod: 'unlink',\n\t\t\targuments: [p, cred],\n\t\t});\n\t}\n\n\tpublic rmdirSync(p: string, cred: Cred): void {\n\t\tthis._sync.rmdirSync(p, cred);\n\t\tthis.enqueueOp({\n\t\t\tapiMethod: 'rmdir',\n\t\t\targuments: [p, cred],\n\t\t});\n\t}\n\n\tpublic mkdirSync(p: string, mode: number, cred: Cred): void {\n\t\tthis._sync.mkdirSync(p, mode, cred);\n\t\tthis.enqueueOp({\n\t\t\tapiMethod: 'mkdir',\n\t\t\targuments: [p, mode, cred],\n\t\t});\n\t}\n\n\tpublic readdirSync(p: string, cred: Cred): string[] {\n\t\treturn this._sync.readdirSync(p, cred);\n\t}\n\n\tpublic existsSync(p: string, cred: Cred): boolean {\n\t\treturn this._sync.existsSync(p, cred);\n\t}\n\n\tpublic chmodSync(p: string, mode: number, cred: Cred): void {\n\t\tthis._sync.chmodSync(p, mode, cred);\n\t\tthis.enqueueOp({\n\t\t\tapiMethod: 'chmod',\n\t\t\targuments: [p, mode, cred],\n\t\t});\n\t}\n\n\tpublic chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void {\n\t\tthis._sync.chownSync(p, new_uid, new_gid, cred);\n\t\tthis.enqueueOp({\n\t\t\tapiMethod: 'chown',\n\t\t\targuments: [p, new_uid, new_gid, cred],\n\t\t});\n\t}\n\n\tpublic utimesSync(p: string, atime: Date, mtime: Date, cred: Cred): void {\n\t\tthis._sync.utimesSync(p, atime, mtime, cred);\n\t\tthis.enqueueOp({\n\t\t\tapiMethod: 'utimes',\n\t\t\targuments: [p, atime, mtime, cred],\n\t\t});\n\t}\n\n\t/**\n\t * Called once to load up files from async storage into sync storage.\n\t */\n\tprivate async _initialize(): Promise<this> {\n\t\tif (!this._isInitialized) {\n\t\t\t// First call triggers initialization, the rest wait.\n\t\t\tconst copyDirectory = async (p: string, mode: number): Promise<void> => {\n\t\t\t\t\tif (p !== '/') {\n\t\t\t\t\t\tconst stats = await this._async.stat(p, Cred.Root);\n\t\t\t\t\t\tthis._sync.mkdirSync(p, mode, stats.getCred());\n\t\t\t\t\t}\n\t\t\t\t\tconst files = await this._async.readdir(p, Cred.Root);\n\t\t\t\t\tfor (const file of files) {\n\t\t\t\t\t\tawait copyItem(join(p, file));\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcopyFile = async (p: string, mode: number): Promise<void> => {\n\t\t\t\t\tconst data = await this._async.readFile(p, FileFlag.getFileFlag('r'), Cred.Root);\n\t\t\t\t\tthis._sync.writeFileSync(p, data, FileFlag.getFileFlag('w'), mode, Cred.Root);\n\t\t\t\t},\n\t\t\t\tcopyItem = async (p: string): Promise<void> => {\n\t\t\t\t\tconst stats = await this._async.stat(p, Cred.Root);\n\t\t\t\t\tif (stats.isDirectory()) {\n\t\t\t\t\t\tawait copyDirectory(p, stats.mode);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait copyFile(p, stats.mode);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\ttry {\n\t\t\t\tawait copyDirectory('/', 0);\n\t\t\t\tthis._isInitialized = true;\n\t\t\t} catch (e) {\n\t\t\t\tthis._isInitialized = false;\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\tprivate enqueueOp(op: AsyncOperation) {\n\t\tthis._queue.push(op);\n\t\tif (!this._queueRunning) {\n\t\t\tthis._queueRunning = true;\n\t\t\tconst doNextOp = (err?: ApiError) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tthrow new Error(`WARNING: File system has desynchronized. Received following error: ${err}\\n$`);\n\t\t\t\t}\n\t\t\t\tif (this._queue.length > 0) {\n\t\t\t\t\tconst op = this._queue.shift()!;\n\t\t\t\t\top.arguments.push(doNextOp);\n\t\t\t\t\t(<Function>this._async[op.apiMethod]).apply(this._async, op.arguments);\n\t\t\t\t} else {\n\t\t\t\t\tthis._queueRunning = false;\n\t\t\t\t}\n\t\t\t};\n\t\t\tdoNextOp();\n\t\t}\n\t}\n}\n", "import { BaseFileSystem, type FileSystem } from '../filesystem.js';\nimport { relative, join } from '../emulation/path.js';\nimport { ApiError } from '../ApiError.js';\nimport { Cred } from '../cred.js';\nimport { CreateBackend, type BackendOptions } from './backend.js';\n\nexport namespace FolderAdapter {\n\t/**\n\t * Configuration options for a FolderAdapter file system.\n\t */\n\texport interface Options {\n\t\t// The folder to use as the root directory.\n\t\tfolder: string;\n\t\t// The file system to wrap.\n\t\twrapped: FileSystem;\n\t}\n}\n\n/**\n * The FolderAdapter file system wraps a file system, and scopes all interactions to a subfolder of that file system.\n *\n * Example: Given a file system `foo` with folder `bar` and file `bar/baz`...\n *\n * ```javascript\n * BrowserFS.configure({\n * fs: \"FolderAdapter\",\n * options: {\n * folder: \"bar\",\n * wrapped: foo\n * }\n * }, function(e) {\n * var fs = BrowserFS.BFSRequire('fs');\n * fs.readdirSync('/'); // ['baz']\n * });\n * ```\n */\nexport class FolderAdapter extends BaseFileSystem {\n\tpublic static readonly Name = 'FolderAdapter';\n\n\tpublic static Create = CreateBackend.bind(this);\n\n\tpublic static readonly Options: BackendOptions = {\n\t\tfolder: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'The folder to use as the root directory',\n\t\t},\n\t\twrapped: {\n\t\t\ttype: 'object',\n\t\t\tdescription: 'The file system to wrap',\n\t\t},\n\t};\n\n\tpublic static isAvailable(): boolean {\n\t\treturn true;\n\t}\n\n\tpublic _wrapped: FileSystem;\n\tpublic _folder: string;\n\n\tpublic constructor({ folder, wrapped }: FolderAdapter.Options) {\n\t\tsuper();\n\t\tthis._folder = folder;\n\t\tthis._wrapped = wrapped;\n\t\tthis._ready = this._initialize();\n\t}\n\n\tpublic get metadata() {\n\t\treturn { ...super.metadata, ...this._wrapped.metadata, supportsLinks: false };\n\t}\n\n\t/**\n\t * Initialize the file system. Ensures that the wrapped file system\n\t * has the given folder.\n\t */\n\tprivate async _initialize(): Promise<this> {\n\t\tconst exists = await this._wrapped.exists(this._folder, Cred.Root);\n\t\tif (!exists && this._wrapped.metadata.readonly) {\n\t\t\tthrow ApiError.ENOENT(this._folder);\n\t\t}\n\t\tawait this._wrapped.mkdir(this._folder, 0o777, Cred.Root);\n\t\treturn this;\n\t}\n}\n\n/**\n * @internal\n */\nfunction translateError(folder: string, e: any): any {\n\tif (e !== null && typeof e === 'object') {\n\t\tconst err = <ApiError>e;\n\t\tlet p = err.path;\n\t\tif (p) {\n\t\t\tp = '/' + relative(folder, p);\n\t\t\terr.message = err.message.replace(err.path!, p);\n\t\t\terr.path = p;\n\t\t}\n\t}\n\treturn e;\n}\n\n/**\n * @internal\n */\nfunction wrapCallback(folder: string, cb: any): any {\n\tif (typeof cb === 'function') {\n\t\treturn function (err: ApiError) {\n\t\t\tif (arguments.length > 0) {\n\t\t\t\targuments[0] = translateError(folder, err);\n\t\t\t}\n\t\t\t(<Function>cb).apply(null, arguments);\n\t\t};\n\t} else {\n\t\treturn cb;\n\t}\n}\n\n/**\n * @internal\n */\nfunction wrapFunction(name: string, wrapFirst: boolean, wrapSecond: boolean): Function {\n\tif (name.slice(name.length - 4) !== 'Sync') {\n\t\t// Async function. Translate error in callback.\n\t\treturn function (this: FolderAdapter) {\n\t\t\tif (arguments.length > 0) {\n\t\t\t\tif (wrapFirst) {\n\t\t\t\t\targuments[0] = join(this._folder, arguments[0]);\n\t\t\t\t}\n\t\t\t\tif (wrapSecond) {\n\t\t\t\t\targuments[1] = join(this._folder, arguments[1]);\n\t\t\t\t}\n\t\t\t\targuments[arguments.length - 1] = wrapCallback(this._folder, arguments[arguments.length - 1]);\n\t\t\t}\n\t\t\treturn (<any>this._wrapped)[name].apply(this._wrapped, arguments);\n\t\t};\n\t} else {\n\t\t// Sync function. Translate error in catch.\n\t\treturn function (this: FolderAdapter) {\n\t\t\ttry {\n\t\t\t\tif (wrapFirst) {\n\t\t\t\t\targuments[0] = join(this._folder, arguments[0]);\n\t\t\t\t}\n\t\t\t\tif (wrapSecond) {\n\t\t\t\t\targuments[1] = join(this._folder, arguments[1]);\n\t\t\t\t}\n\t\t\t\treturn (<any>this._wrapped)[name].apply(this._wrapped, arguments);\n\t\t\t} catch (e) {\n\t\t\t\tthrow translateError(this._folder, e);\n\t\t\t}\n\t\t};\n\t}\n}\n\n// First argument is a path.\n[\n\t'diskSpace',\n\t'stat',\n\t'statSync',\n\t'open',\n\t'openSync',\n\t'unlink',\n\t'unlinkSync',\n\t'rmdir',\n\t'rmdirSync',\n\t'mkdir',\n\t'mkdirSync',\n\t'readdir',\n\t'readdirSync',\n\t'exists',\n\t'existsSync',\n\t'realpath',\n\t'realpathSync',\n\t'truncate',\n\t'truncateSync',\n\t'readFile',\n\t'readFileSync',\n\t'writeFile',\n\t'writeFileSync',\n\t'appendFile',\n\t'appendFileSync',\n\t'chmod',\n\t'chmodSync',\n\t'chown',\n\t'chownSync',\n\t'utimes',\n\t'utimesSync',\n\t'readlink',\n\t'readlinkSync',\n].forEach((name: string) => {\n\t(<any>FolderAdapter.prototype)[name] = wrapFunction(name, true, false);\n});\n\n// First and second arguments are paths.\n['rename', 'renameSync', 'link', 'linkSync', 'symlink', 'symlinkSync'].forEach((name: string) => {\n\t(<any>FolderAdapter.prototype)[name] = wrapFunction(name, true, true);\n});\n", "export type MutexCallback = () => void;\n\n/**\n * Non-recursive mutex\n * @internal\n */\nexport default class Mutex {\n\tprivate _locks: Map<string, MutexCallback[]> = new Map();\n\n\tpublic lock(path: string): Promise<void> {\n\t\treturn new Promise(resolve => {\n\t\t\tif (this._locks.has(path)) {\n\t\t\t\tthis._locks.get(path).push(resolve);\n\t\t\t} else {\n\t\t\t\tthis._locks.set(path, []);\n\t\t\t}\n\t\t});\n\t}\n\n\tpublic unlock(path: string): void {\n\t\tif (!this._locks.has(path)) {\n\t\t\tthrow new Error('unlock of a non-locked mutex');\n\t\t}\n\n\t\tconst next = this._locks.get(path).shift();\n\t\t/* \n\t\t\tdon't unlock - we want to queue up next for the\n\t\t\tend of the current task execution, but we don't\n\t\t\twant it to be called inline with whatever the\n\t\t\tcurrent stack is. This way we still get the nice\n\t\t\tbehavior that an unlock immediately followed by a\n\t\t\tlock won't cause starvation.\n\t\t*/\n\t\tif (next) {\n\t\t\tsetTimeout(next, 0);\n\t\t\treturn;\n\t\t}\n\n\t\tthis._locks.delete(path);\n\t}\n\n\tpublic tryLock(path: string): boolean {\n\t\tif (this._locks.has(path)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tthis._locks.set(path, []);\n\t\treturn true;\n\t}\n\n\tpublic isLocked(path: string): boolean {\n\t\treturn this._locks.has(path);\n\t}\n}\n", "import Mutex from '../mutex.js';\nimport { FileSystem, FileSystemMetadata } from '../filesystem.js';\nimport { FileFlag } from '../file.js';\nimport { Stats } from '../stats.js';\nimport { File } from '../file.js';\nimport { Cred } from '../cred.js';\n\n/**\n * This class serializes access to an underlying async filesystem.\n * For example, on an OverlayFS instance with an async lower\n * directory operations like rename and rmdir may involve multiple\n * requests involving both the upper and lower filesystems -- they\n * are not executed in a single atomic step. OverlayFS uses this\n * LockedFS to avoid having to reason about the correctness of\n * multiple requests interleaving.\n */\nexport default class LockedFS<T extends FileSystem> implements FileSystem {\n\tprivate _fs: T;\n\tprivate _mu: Mutex;\n\n\tprotected _ready: Promise<this> = Promise.resolve(this);\n\n\tconstructor(fs: T) {\n\t\tthis._fs = fs;\n\t\tthis._mu = new Mutex();\n\t}\n\n\twhenReady(): Promise<this> {\n\t\treturn this._ready;\n\t}\n\n\tpublic get metadata(): FileSystemMetadata {\n\t\treturn {\n\t\t\t...this._fs.metadata,\n\t\t\tname: 'LockedFS<' + this._fs.metadata.name + '>',\n\t\t};\n\t}\n\n\tpublic get fs(): T {\n\t\treturn this._fs;\n\t}\n\n\tpublic async rename(oldPath: string, newPath: string, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(oldPath);\n\t\tawait this._fs.rename(oldPath, newPath, cred);\n\t\tthis._mu.unlock(oldPath);\n\t}\n\n\tpublic renameSync(oldPath: string, newPath: string, cred: Cred): void {\n\t\tif (this._mu.isLocked(oldPath)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.renameSync(oldPath, newPath, cred);\n\t}\n\n\tpublic async stat(p: string, cred: Cred): Promise<Stats> {\n\t\tawait this._mu.lock(p);\n\t\tconst stats = await this._fs.stat(p, cred);\n\t\tthis._mu.unlock(p);\n\t\treturn stats;\n\t}\n\n\tpublic statSync(p: string, cred: Cred): Stats {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.statSync(p, cred);\n\t}\n\n\tpublic async access(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(p);\n\t\tawait this._fs.access(p, mode, cred);\n\t\tthis._mu.unlock(p);\n\t}\n\n\tpublic accessSync(p: string, mode: number, cred: Cred): void {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.accessSync(p, mode, cred);\n\t}\n\n\tpublic async open(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File> {\n\t\tawait this._mu.lock(p);\n\t\tconst fd = await this._fs.open(p, flag, mode, cred);\n\t\tthis._mu.unlock(p);\n\t\treturn fd;\n\t}\n\n\tpublic openSync(p: string, flag: FileFlag, mode: number, cred: Cred): File {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.openSync(p, flag, mode, cred);\n\t}\n\n\tpublic async unlink(p: string, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(p);\n\t\tawait this._fs.unlink(p, cred);\n\t\tthis._mu.unlock(p);\n\t}\n\n\tpublic unlinkSync(p: string, cred: Cred): void {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.unlinkSync(p, cred);\n\t}\n\n\tpublic async rmdir(p: string, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(p);\n\t\tawait this._fs.rmdir(p, cred);\n\t\tthis._mu.unlock(p);\n\t}\n\n\tpublic rmdirSync(p: string, cred: Cred): void {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.rmdirSync(p, cred);\n\t}\n\n\tpublic async mkdir(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(p);\n\t\tawait this._fs.mkdir(p, mode, cred);\n\t\tthis._mu.unlock(p);\n\t}\n\n\tpublic mkdirSync(p: string, mode: number, cred: Cred): void {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.mkdirSync(p, mode, cred);\n\t}\n\n\tpublic async readdir(p: string, cred: Cred): Promise<string[]> {\n\t\tawait this._mu.lock(p);\n\t\tconst files = await this._fs.readdir(p, cred);\n\t\tthis._mu.unlock(p);\n\t\treturn files;\n\t}\n\n\tpublic readdirSync(p: string, cred: Cred): string[] {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.readdirSync(p, cred);\n\t}\n\n\tpublic async exists(p: string, cred: Cred): Promise<boolean> {\n\t\tawait this._mu.lock(p);\n\t\tconst exists = await this._fs.exists(p, cred);\n\t\tthis._mu.unlock(p);\n\t\treturn exists;\n\t}\n\n\tpublic existsSync(p: string, cred: Cred): boolean {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.existsSync(p, cred);\n\t}\n\n\tpublic async realpath(p: string, cred: Cred): Promise<string> {\n\t\tawait this._mu.lock(p);\n\t\tconst resolvedPath = await this._fs.realpath(p, cred);\n\t\tthis._mu.unlock(p);\n\t\treturn resolvedPath;\n\t}\n\n\tpublic realpathSync(p: string, cred: Cred): string {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.realpathSync(p, cred);\n\t}\n\n\tpublic async truncate(p: string, len: number, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(p);\n\t\tawait this._fs.truncate(p, len, cred);\n\t\tthis._mu.unlock(p);\n\t}\n\n\tpublic truncateSync(p: string, len: number, cred: Cred): void {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.truncateSync(p, len, cred);\n\t}\n\n\tpublic async readFile(fname: string, flag: FileFlag, cred: Cred): Promise<Uint8Array> {\n\t\tawait this._mu.lock(fname);\n\t\tconst data = await this._fs.readFile(fname, flag, cred);\n\t\tthis._mu.unlock(fname);\n\t\treturn data;\n\t}\n\n\tpublic readFileSync(fname: string, flag: FileFlag, cred: Cred): Uint8Array {\n\t\tif (this._mu.isLocked(fname)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.readFileSync(fname, flag, cred);\n\t}\n\n\tpublic async writeFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(fname);\n\t\tawait this._fs.writeFile(fname, data, flag, mode, cred);\n\t\tthis._mu.unlock(fname);\n\t}\n\n\tpublic writeFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void {\n\t\tif (this._mu.isLocked(fname)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.writeFileSync(fname, data, flag, mode, cred);\n\t}\n\n\tpublic async appendFile(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(fname);\n\t\tawait this._fs.appendFile(fname, data, flag, mode, cred);\n\t\tthis._mu.unlock(fname);\n\t}\n\n\tpublic appendFileSync(fname: string, data: Uint8Array, flag: FileFlag, mode: number, cred: Cred): void {\n\t\tif (this._mu.isLocked(fname)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.appendFileSync(fname, data, flag, mode, cred);\n\t}\n\n\tpublic async chmod(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(p);\n\t\tawait this._fs.chmod(p, mode, cred);\n\t\tthis._mu.unlock(p);\n\t}\n\n\tpublic chmodSync(p: string, mode: number, cred: Cred): void {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.chmodSync(p, mode, cred);\n\t}\n\n\tpublic async chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(p);\n\t\tawait this._fs.chown(p, new_uid, new_gid, cred);\n\t\tthis._mu.unlock(p);\n\t}\n\n\tpublic chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.chownSync(p, new_uid, new_gid, cred);\n\t}\n\n\tpublic async utimes(p: string, atime: Date, mtime: Date, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(p);\n\t\tawait this._fs.utimes(p, atime, mtime, cred);\n\t\tthis._mu.unlock(p);\n\t}\n\n\tpublic utimesSync(p: string, atime: Date, mtime: Date, cred: Cred): void {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.utimesSync(p, atime, mtime, cred);\n\t}\n\n\tpublic async link(srcpath: string, dstpath: string, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(srcpath);\n\t\tawait this._fs.link(srcpath, dstpath, cred);\n\t\tthis._mu.unlock(srcpath);\n\t}\n\n\tpublic linkSync(srcpath: string, dstpath: string, cred: Cred): void {\n\t\tif (this._mu.isLocked(srcpath)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.linkSync(srcpath, dstpath, cred);\n\t}\n\n\tpublic async symlink(srcpath: string, dstpath: string, type: string, cred: Cred): Promise<void> {\n\t\tawait this._mu.lock(srcpath);\n\t\tawait this._fs.symlink(srcpath, dstpath, type, cred);\n\t\tthis._mu.unlock(srcpath);\n\t}\n\n\tpublic symlinkSync(srcpath: string, dstpath: string, type: string, cred: Cred): void {\n\t\tif (this._mu.isLocked(srcpath)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.symlinkSync(srcpath, dstpath, type, cred);\n\t}\n\n\tpublic async readlink(p: string, cred: Cred): Promise<string> {\n\t\tawait this._mu.lock(p);\n\t\tconst linkString = await this._fs.readlink(p, cred);\n\t\tthis._mu.unlock(p);\n\t\treturn linkString;\n\t}\n\n\tpublic readlinkSync(p: string, cred: Cred): string {\n\t\tif (this._mu.isLocked(p)) {\n\t\t\tthrow new Error('invalid sync call');\n\t\t}\n\t\treturn this._fs.readlinkSync(p, cred);\n\t}\n}\n", "import { type FileSystem, BaseFileSystem, FileSystemMetadata } from '../filesystem.js';\nimport { ApiError, ErrorCode } from '../ApiError.js';\nimport { File, FileFlag, ActionType, PreloadFile } from '../file.js';\nimport { Stats } from '../stats.js';\nimport LockedFS from './Locked.js';\nimport { resolve, dirname } from '../emulation/path.js';\nimport { Cred } from '../cred.js';\nimport { CreateBackend, type BackendOptions } from './backend.js';\nimport { decode, encode } from '../utils.js';\n/**\n * @internal\n */\nconst deletionLogPath = '/.deletedFiles.log';\n\n/**\n * Given a read-only mode, makes it writable.\n * @internal\n */\nfunction makeModeWritable(mode: number): number {\n\treturn 0o222 | mode;\n}\n\n/**\n * @internal\n */\nfunction getFlag(f: string): FileFlag {\n\treturn FileFlag.getFileFlag(f);\n}\n\n/**\n * Overlays a RO file to make it writable.\n */\nclass OverlayFile extends PreloadFile<UnlockedOverlayFS> implements File {\n\tconstructor(fs: UnlockedOverlayFS, path: string, flag: FileFlag, stats: Stats, data: Uint8Array) {\n\t\tsuper(fs, path, flag, stats, data);\n\t}\n\n\tpublic async sync(): Promise<void> {\n\t\tif (!this.isDirty()) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait this._fs._syncAsync(this);\n\t\tthis.resetDirty();\n\t}\n\n\tpublic syncSync(): void {\n\t\tif (this.isDirty()) {\n\t\t\tthis._fs._syncSync(this);\n\t\t\tthis.resetDirty();\n\t\t}\n\t}\n\n\tpublic async close(): Promise<void> {\n\t\tawait this.sync();\n\t}\n\n\tpublic closeSync(): void {\n\t\tthis.syncSync();\n\t}\n}\n\nexport namespace OverlayFS {\n\t/**\n\t * Configuration options for OverlayFS instances.\n\t */\n\texport interface Options {\n\t\t/**\n\t\t * The file system to write modified files to.\n\t\t */\n\t\twritable: FileSystem;\n\t\t/**\n\t\t * The file system that initially populates this file system.\n\t\t */\n\t\treadable: FileSystem;\n\t}\n}\n\n/**\n * *INTERNAL, DO NOT USE DIRECTLY!*\n *\n * Core OverlayFS class that contains no locking whatsoever. We wrap these objects\n * in a LockedFS to prevent races.\n */\nexport class UnlockedOverlayFS extends BaseFileSystem {\n\tpublic static isAvailable(): boolean {\n\t\treturn true;\n\t}\n\n\tprivate _writable: FileSystem;\n\tprivate _readable: FileSystem;\n\tprivate _isInitialized: boolean = false;\n\tprivate _deletedFiles: { [path: string]: boolean } = {};\n\tprivate _deleteLog: string = '';\n\t// If 'true', we have scheduled a delete log update.\n\tprivate _deleteLogUpdatePending: boolean = false;\n\t// If 'true', a delete log update is needed after the scheduled delete log\n\t// update finishes.\n\tprivate _deleteLogUpdateNeeded: boolean = false;\n\t// If there was an error updating the delete log...\n\tprivate _deleteLogError: ApiError | null = null;\n\n\tconstructor({ writable, readable }: OverlayFS.Options) {\n\t\tsuper();\n\t\tthis._writable = writable;\n\t\tthis._readable = readable;\n\t\tif (this._writable.metadata.readonly) {\n\t\t\tthrow new ApiError(ErrorCode.EINVAL, 'Writable file system must be writable.');\n\t\t}\n\t}\n\n\tpublic get metadata(): FileSystemMetadata {\n\t\treturn {\n\t\t\t...super.metadata,\n\t\t\tname: OverlayFS.Name,\n\t\t\tsynchronous: this._readable.metadata.synchronous && this._writable.metadata.synchronous,\n\t\t\tsupportsProperties: this._readable.metadata.supportsProperties && this._writable.metadata.supportsProperties,\n\t\t};\n\t}\n\n\tpublic getOverlayedFileSystems(): { readable: FileSystem; writable: FileSystem } {\n\t\treturn {\n\t\t\treadable: this._readable,\n\t\t\twritable: this._writable,\n\t\t};\n\t}\n\n\tpublic async _syncAsync(file: PreloadFile<UnlockedOverlayFS>): Promise<void> {\n\t\tconst stats = file.getStats();\n\t\tawait this.createParentDirectoriesAsync(file.getPath(), stats.getCred(0, 0));\n\t\treturn this._writable.writeFile(file.getPath(), file.getBuffer(), getFlag('w'), stats.mode, stats.getCred(0, 0));\n\t}\n\n\tpublic _syncSync(file: PreloadFile<UnlockedOverlayFS>): void {\n\t\tconst stats = file.getStats();\n\t\tthis.createParentDirectories(file.getPath(), stats.getCred(0, 0));\n\t\tthis._writable.writeFileSync(file.getPath(), file.getBuffer(), getFlag('w'), stats.mode, stats.getCred(0, 0));\n\t}\n\n\t/**\n\t * **INTERNAL METHOD**\n\t *\n\t * Called once to load up metadata stored on the writable file system.\n\t */\n\tpublic async _initialize(): Promise<void> {\n\t\t// if we're already initialized, immediately invoke the callback\n\t\tif (this._isInitialized) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Read deletion log, process into metadata.\n\t\ttry {\n\t\t\tconst data = await this._writable.readFile(deletionLogPath, getFlag('r'), Cred.Root);\n\t\t\tthis._deleteLog = decode(data);\n\t\t} catch (err) {\n\t\t\tif (err.errno !== ErrorCode.ENOENT) {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t\tthis._isInitialized = true;\n\t\tthis._reparseDeletionLog();\n\t}\n\n\tpublic getDeletionLog(): string {\n\t\treturn this._deleteLog;\n\t}\n\n\tpublic restoreDeletionLog(log: string, cred: Cred): void {\n\t\tthis._deleteLog = log;\n\t\tthis._reparseDeletionLog();\n\t\tthis.updateLog('', cred);\n\t}\n\n\tpublic async rename(oldPath: string, newPath: string, cred: Cred): Promise<void> {\n\t\tthis.checkInitialized();\n\t\tthis.checkPath(oldPath);\n\t\tthis.checkPath(newPath);\n\t\tif (oldPath === deletionLogPath || newPath === deletionLogPath) {\n\t\t\tthrow ApiError.EPERM('Cannot rename deletion log.');\n\t\t}\n\t\t// Write newPath using oldPath's contents, delete oldPath.\n\t\tconst oldStats = await this.stat(oldPath, cred);\n\t\tif (oldStats.isDirectory()) {\n\t\t\t// Optimization: Don't bother moving if old === new.\n\t\t\tif (oldPath === newPath) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet mode = 0o777;\n\t\t\tif (await this.exists(newPath, cred)) {\n\t\t\t\tconst stats = await this.stat(newPath, cred);\n\t\t\t\tmode = stats.mode;\n\t\t\t\tif (stats.isDirectory()) {\n\t\t\t\t\tif ((await this.readdir(newPath, cred)).length > 0) {\n\t\t\t\t\t\tthrow ApiError.ENOTEMPTY(newPath);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow ApiError.ENOTDIR(newPath);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Take care of writable first. Move any files there, or create an empty directory\n\t\t\t// if it doesn't exist.\n\t\t\tif (await this._writable.exists(oldPath, cred)) {\n\t\t\t\tawait this._writable.rename(oldPath, newPath, cred);\n\t\t\t} else if (!(await this._writable.exists(newPath, cred))) {\n\t\t\t\tawait this._writable.mkdir(newPath, mode, cred);\n\t\t\t}\n\n\t\t\t// Need to move *every file/folder* currently stored on readable to its new location\n\t\t\t// on writable.\n\t\t\tif (await this._readable.exists(oldPath, cred)) {\n\t\t\t\tfor (const name of await this._readable.readdir(oldPath, cred)) {\n\t\t\t\t\t// Recursion! Should work for any nested files / folders.\n\t\t\t\t\tawait this.rename(resolve(oldPath, name), resolve(newPath, name), cred);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif ((await this.exists(newPath, cred)) && (await this.stat(newPath, cred)).isDirectory()) {\n\t\t\t\tthrow ApiError.EISDIR(newPath);\n\t\t\t}\n\n\t\t\tawait this.writeFile(newPath, await this.readFile(oldPath, getFlag('r'), cred), getFlag('w'), oldStats.mode, cred);\n\t\t}\n\n\t\tif (oldPath !== newPath && (await this.exists(oldPath, cred))) {\n\t\t\tawait this.unlink(oldPath, cred);\n\t\t}\n\t}\n\n\tpublic renameSync(oldPath: string, newPath: string, cred: Cred): void {\n\t\tthis.checkInitialized();\n\t\tthis.checkPath(oldPath);\n\t\tthis.checkPath(newPath);\n\t\tif (oldPath === deletionLogPath || newPath === deletionLogPath) {\n\t\t\tthrow ApiError.EPERM('Cannot rename deletion log.');\n\t\t}\n\t\t// Write newPath using oldPath's contents, delete oldPath.\n\t\tconst oldStats = this.statSync(oldPath, cred);\n\t\tif (oldStats.isDirectory()) {\n\t\t\t// Optimization: Don't bother moving if old === new.\n\t\t\tif (oldPath === newPath) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet mode = 0o777;\n\t\t\tif (this.existsSync(newPath, cred)) {\n\t\t\t\tconst stats = this.statSync(newPath, cred);\n\t\t\t\tmode = stats.mode;\n\t\t\t\tif (stats.isDirectory()) {\n\t\t\t\t\tif (this.readdirSync(newPath, cred).length > 0) {\n\t\t\t\t\t\tthrow ApiError.ENOTEMPTY(newPath);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow ApiError.ENOTDIR(newPath);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Take care of writable first. Move any files there, or create an empty directory\n\t\t\t// if it doesn't exist.\n\t\t\tif (this._writable.existsSync(oldPath, cred)) {\n\t\t\t\tthis._writable.renameSync(oldPath, newPath, cred);\n\t\t\t} else if (!this._writable.existsSync(newPath, cred)) {\n\t\t\t\tthis._writable.mkdirSync(newPath, mode, cred);\n\t\t\t}\n\n\t\t\t// Need to move *every file/folder* currently stored on readable to its new location\n\t\t\t// on writable.\n\t\t\tif (this._readable.existsSync(oldPath, cred)) {\n\t\t\t\tthis._readable.readdirSync(oldPath, cred).forEach(name => {\n\t\t\t\t\t// Recursion! Should work for any nested files / folders.\n\t\t\t\t\tthis.renameSync(resolve(oldPath, name), resolve(newPath, name), cred);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.existsSync(newPath, cred) && this.statSync(newPath, cred).isDirectory()) {\n\t\t\t\tthrow ApiError.EISDIR(newPath);\n\t\t\t}\n\n\t\t\tthis.writeFileSync(newPath, this.readFileSync(oldPath, getFlag('r'), cred), getFlag('w'), oldStats.mode, cred);\n\t\t}\n\n\t\tif (oldPath !== newPath && this.existsSync(oldPath, cred)) {\n\t\t\tthis.unlinkSync(oldPath, cred);\n\t\t}\n\t}\n\n\tpublic async stat(p: string, cred: Cred): Promise<Stats> {\n\t\tthis.checkInitialized();\n\t\ttry {\n\t\t\treturn this._writable.stat(p, cred);\n\t\t} catch (e) {\n\t\t\tif (this._deletedFiles[p]) {\n\t\t\t\tthrow ApiError.ENOENT(p);\n\t\t\t}\n\t\t\tconst oldStat = Stats.clone(await this._readable.stat(p, cred));\n\t\t\t// Make the oldStat's mode writable. Preserve the topmost part of the\n\t\t\t// mode, which specifies if it is a file or a directory.\n\t\t\toldStat.mode = makeModeWritable(oldStat.mode);\n\t\t\treturn oldStat;\n\t\t}\n\t}\n\n\tpublic statSync(p: string, cred: Cred): Stats {\n\t\tthis.checkInitialized();\n\t\ttry {\n\t\t\treturn this._writable.statSync(p, cred);\n\t\t} catch (e) {\n\t\t\tif (this._deletedFiles[p]) {\n\t\t\t\tthrow ApiError.ENOENT(p);\n\t\t\t}\n\t\t\tconst oldStat = Stats.clone(this._readable.statSync(p, cred));\n\t\t\t// Make the oldStat's mode writable. Preserve the topmost part of the\n\t\t\t// mode, which specifies if it is a file or a directory.\n\t\t\toldStat.mode = makeModeWritable(oldStat.mode);\n\t\t\treturn oldStat;\n\t\t}\n\t}\n\n\tpublic async open(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File> {\n\t\tthis.checkInitialized();\n\t\tthis.checkPath(p);\n\t\tif (p === deletionLogPath) {\n\t\t\tthrow ApiError.EPERM('Cannot open deletion log.');\n\t\t}\n\t\tif (await this.exists(p, cred)) {\n\t\t\tswitch (flag.pathExistsAction()) {\n\t\t\t\tcase ActionType.TRUNCATE_FILE:\n\t\t\t\t\tawait this.createParentDirectoriesAsync(p, cred);\n\t\t\t\t\treturn this._writable.open(p, flag, mode, cred);\n\t\t\t\tcase ActionType.NOP:\n\t\t\t\t\tif (await this._writable.exists(p, cred)) {\n\t\t\t\t\t\treturn this._writable.open(p, flag, mode, cred);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Create an OverlayFile.\n\t\t\t\t\t\tconst buf = await this._readable.readFile(p, getFlag('r'), cred);\n\t\t\t\t\t\tconst stats = Stats.clone(await this._readable.stat(p, cred));\n\t\t\t\t\t\tstats.mode = mode;\n\t\t\t\t\t\treturn new OverlayFile(this, p, flag, stats, buf as Uint8Array);\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tthrow ApiError.EEXIST(p);\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (flag.pathNotExistsAction()) {\n\t\t\t\tcase ActionType.CREATE_FILE:\n\t\t\t\t\tawait this.createParentDirectoriesAsync(p, cred);\n\t\t\t\t\treturn this._writable.open(p, flag, mode, cred);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow ApiError.ENOENT(p);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic openSync(p: string, flag: FileFlag, mode: number, cred: Cred): File {\n\t\tthis.checkInitialized();\n\t\tthis.checkPath(p);\n\t\tif (p === deletionLogPath) {\n\t\t\tthrow ApiError.EPERM('Cannot open deletion log.');\n\t\t}\n\t\tif (this.existsSync(p, cred)) {\n\t\t\tswitch (flag.pathExistsAction()) {\n\t\t\t\tcase ActionType.TRUNCATE_FILE:\n\t\t\t\t\tthis.createParentDirectories(p, cred);\n\t\t\t\t\treturn this._writable.openSync(p, flag, mode, cred);\n\t\t\t\tcase ActionType.NOP:\n\t\t\t\t\tif (this._writable.existsSync(p, cred)) {\n\t\t\t\t\t\treturn this._writable.openSync(p, flag, mode, cred);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Create an OverlayFile.\n\t\t\t\t\t\tconst buf = <Uint8Array>this._readable.readFileSync(p, getFlag('r'), cred);\n\t\t\t\t\t\tconst stats = Stats.clone(this._readable.statSync(p, cred));\n\t\t\t\t\t\tstats.mode = mode;\n\t\t\t\t\t\treturn new OverlayFile(this, p, flag, stats, buf);\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tthrow ApiError.EEXIST(p);\n\t\t\t}\n\t\t} else {\n\t\t\tswitch (flag.pathNotExistsAction()) {\n\t\t\t\tcase ActionType.CREATE_FILE:\n\t\t\t\t\tthis.createParentDirectories(p, cred);\n\t\t\t\t\treturn this._writable.openSync(p, flag, mode, cred);\n\t\t\t\tdefault:\n\t\t\t\t\tthrow ApiError.ENOENT(p);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async unlink(p: string, cred: Cred): Promise<void> {\n\t\tthis.checkInitialized();\n\t\tthis.checkPath(p);\n\t\tif (await this.exists(p, cred)) {\n\t\t\tif (await this._writable.exists(p, cred)) {\n\t\t\t\tawait this._writable.unlink(p, cred);\n\t\t\t}\n\n\t\t\t// if it still exists add to the delete log\n\t\t\tif (await this.exists(p, cred)) {\n\t\t\t\tthis.deletePath(p, cred);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t}\n\n\tpublic unlinkSync(p: string, cred: Cred): void {\n\t\tthis.checkInitialized();\n\t\tthis.checkPath(p);\n\t\tif (this.existsSync(p, cred)) {\n\t\t\tif (this._writable.existsSync(p, cred)) {\n\t\t\t\tthis._writable.unlinkSync(p, cred);\n\t\t\t}\n\n\t\t\t// if it still exists add to the delete log\n\t\t\tif (this.existsSync(p, cred)) {\n\t\t\t\tthis.deletePath(p, cred);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t}\n\n\tpublic async rmdir(p: string, cred: Cred): Promise<void> {\n\t\tthis.checkInitialized();\n\t\tif (await this.exists(p, cred)) {\n\t\t\tif (await this._writable.exists(p, cred)) {\n\t\t\t\tawait this._writable.rmdir(p, cred);\n\t\t\t}\n\t\t\tif (await this.exists(p, cred)) {\n\t\t\t\t// Check if directory is empty.\n\t\t\t\tif ((await this.readdir(p, cred)).length > 0) {\n\t\t\t\t\tthrow ApiError.ENOTEMPTY(p);\n\t\t\t\t} else {\n\t\t\t\t\tthis.deletePath(p, cred);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t}\n\n\tpublic rmdirSync(p: string, cred: Cred): void {\n\t\tthis.checkInitialized();\n\t\tif (this.existsSync(p, cred)) {\n\t\t\tif (this._writable.existsSync(p, cred)) {\n\t\t\t\tthis._writable.rmdirSync(p, cred);\n\t\t\t}\n\t\t\tif (this.existsSync(p, cred)) {\n\t\t\t\t// Check if directory is empty.\n\t\t\t\tif (this.readdirSync(p, cred).length > 0) {\n\t\t\t\t\tthrow ApiError.ENOTEMPTY(p);\n\t\t\t\t} else {\n\t\t\t\t\tthis.deletePath(p, cred);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t}\n\n\tpublic async mkdir(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tthis.checkInitialized();\n\t\tif (await this.exists(p, cred)) {\n\t\t\tthrow ApiError.EEXIST(p);\n\t\t} else {\n\t\t\t// The below will throw should any of the parent directories fail to exist\n\t\t\t// on _writable.\n\t\t\tawait this.createParentDirectoriesAsync(p, cred);\n\t\t\tawait this._writable.mkdir(p, mode, cred);\n\t\t}\n\t}\n\n\tpublic mkdirSync(p: string, mode: number, cred: Cred): void {\n\t\tthis.checkInitialized();\n\t\tif (this.existsSync(p, cred)) {\n\t\t\tthrow ApiError.EEXIST(p);\n\t\t} else {\n\t\t\t// The below will throw should any of the parent directories fail to exist\n\t\t\t// on _writable.\n\t\t\tthis.createParentDirectories(p, cred);\n\t\t\tthis._writable.mkdirSync(p, mode, cred);\n\t\t}\n\t}\n\n\tpublic async readdir(p: string, cred: Cred): Promise<string[]> {\n\t\tthis.checkInitialized();\n\t\tconst dirStats = await this.stat(p, cred);\n\t\tif (!dirStats.isDirectory()) {\n\t\t\tthrow ApiError.ENOTDIR(p);\n\t\t}\n\n\t\t// Readdir in both, check delete log on RO file system's listing, merge, return.\n\t\tlet contents: string[] = [];\n\t\ttry {\n\t\t\tcontents = contents.concat(await this._writable.readdir(p, cred));\n\t\t} catch (e) {\n\t\t\t// NOP.\n\t\t}\n\t\ttry {\n\t\t\tcontents = contents.concat((await this._readable.readdir(p, cred)).filter((fPath: string) => !this._deletedFiles[`${p}/${fPath}`]));\n\t\t} catch (e) {\n\t\t\t// NOP.\n\t\t}\n\t\tconst seenMap: { [name: string]: boolean } = {};\n\t\treturn contents.filter((fileP: string) => {\n\t\t\tconst result = !seenMap[fileP];\n\t\t\tseenMap[fileP] = true;\n\t\t\treturn result;\n\t\t});\n\t}\n\n\tpublic readdirSync(p: string, cred: Cred): string[] {\n\t\tthis.checkInitialized();\n\t\tconst dirStats = this.statSync(p, cred);\n\t\tif (!dirStats.isDirectory()) {\n\t\t\tthrow ApiError.ENOTDIR(p);\n\t\t}\n\n\t\t// Readdir in both, check delete log on RO file system's listing, merge, return.\n\t\tlet contents: string[] = [];\n\t\ttry {\n\t\t\tcontents = contents.concat(this._writable.readdirSync(p, cred));\n\t\t} catch (e) {\n\t\t\t// NOP.\n\t\t}\n\t\ttry {\n\t\t\tcontents = contents.concat(this._readable.readdirSync(p, cred).filter((fPath: string) => !this._deletedFiles[`${p}/${fPath}`]));\n\t\t} catch (e) {\n\t\t\t// NOP.\n\t\t}\n\t\tconst seenMap: { [name: string]: boolean } = {};\n\t\treturn contents.filter((fileP: string) => {\n\t\t\tconst result = !seenMap[fileP];\n\t\t\tseenMap[fileP] = true;\n\t\t\treturn result;\n\t\t});\n\t}\n\n\tpublic async exists(p: string, cred: Cred): Promise<boolean> {\n\t\tthis.checkInitialized();\n\t\treturn (await this._writable.exists(p, cred)) || ((await this._readable.exists(p, cred)) && this._deletedFiles[p] !== true);\n\t}\n\n\tpublic existsSync(p: string, cred: Cred): boolean {\n\t\tthis.checkInitialized();\n\t\treturn this._writable.existsSync(p, cred) || (this._readable.existsSync(p, cred) && this._deletedFiles[p] !== true);\n\t}\n\n\tpublic async chmod(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tthis.checkInitialized();\n\t\tawait this.operateOnWritableAsync(p, cred);\n\t\tawait this._writable.chmod(p, mode, cred);\n\t}\n\n\tpublic chmodSync(p: string, mode: number, cred: Cred): void {\n\t\tthis.checkInitialized();\n\t\tthis.operateOnWritable(p, cred);\n\t\tthis._writable.chmodSync(p, mode, cred);\n\t}\n\n\tpublic async chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void> {\n\t\tthis.checkInitialized();\n\t\tawait this.operateOnWritableAsync(p, cred);\n\t\tawait this._writable.chown(p, new_uid, new_gid, cred);\n\t}\n\n\tpublic chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void {\n\t\tthis.checkInitialized();\n\t\tthis.operateOnWritable(p, cred);\n\t\tthis._writable.chownSync(p, new_uid, new_gid, cred);\n\t}\n\n\tpublic async utimes(p: string, atime: Date, mtime: Date, cred: Cred): Promise<void> {\n\t\tthis.checkInitialized();\n\t\tawait this.operateOnWritableAsync(p, cred);\n\t\tawait this._writable.utimes(p, atime, mtime, cred);\n\t}\n\n\tpublic utimesSync(p: string, atime: Date, mtime: Date, cred: Cred): void {\n\t\tthis.checkInitialized();\n\t\tthis.operateOnWritable(p, cred);\n\t\tthis._writable.utimesSync(p, atime, mtime, cred);\n\t}\n\n\tprivate deletePath(p: string, cred: Cred): void {\n\t\tthis._deletedFiles[p] = true;\n\t\tthis.updateLog(`d${p}\\n`, cred);\n\t}\n\n\tprivate updateLog(addition: string, cred: Cred) {\n\t\tthis._deleteLog += addition;\n\t\tif (this._deleteLogUpdatePending) {\n\t\t\tthis._deleteLogUpdateNeeded = true;\n\t\t} else {\n\t\t\tthis._deleteLogUpdatePending = true;\n\t\t\tthis._writable\n\t\t\t\t.writeFile(deletionLogPath, encode(this._deleteLog), FileFlag.getFileFlag('w'), 0o644, cred)\n\t\t\t\t.then(() => {\n\t\t\t\t\tif (this._deleteLogUpdateNeeded) {\n\t\t\t\t\t\tthis._deleteLogUpdateNeeded = false;\n\t\t\t\t\t\tthis.updateLog('', cred);\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(e => {\n\t\t\t\t\tthis._deleteLogError = e;\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis._deleteLogUpdatePending = false;\n\t\t\t\t});\n\t\t}\n\t}\n\n\tprivate _reparseDeletionLog(): void {\n\t\tthis._deletedFiles = {};\n\t\tthis._deleteLog.split('\\n').forEach((path: string) => {\n\t\t\t// If the log entry begins w/ 'd', it's a deletion.\n\t\t\tthis._deletedFiles[path.slice(1)] = path.slice(0, 1) === 'd';\n\t\t});\n\t}\n\n\tprivate checkInitialized(): void {\n\t\tif (!this._isInitialized) {\n\t\t\tthrow new ApiError(ErrorCode.EPERM, 'OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.');\n\t\t} else if (this._deleteLogError !== null) {\n\t\t\tconst e = this._deleteLogError;\n\t\t\tthis._deleteLogError = null;\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\tprivate checkPath(p: string): void {\n\t\tif (p === deletionLogPath) {\n\t\t\tthrow ApiError.EPERM(p);\n\t\t}\n\t}\n\n\t/**\n\t * With the given path, create the needed parent directories on the writable storage\n\t * should they not exist. Use modes from the read-only storage.\n\t */\n\tprivate createParentDirectories(p: string, cred: Cred): void {\n\t\tlet parent = dirname(p),\n\t\t\ttoCreate: string[] = [];\n\t\twhile (!this._writable.existsSync(parent, cred)) {\n\t\t\ttoCreate.push(parent);\n\t\t\tparent = dirname(parent);\n\t\t}\n\t\ttoCreate = toCreate.reverse();\n\n\t\tfor (const p of toCreate) {\n\t\t\tthis._writable.mkdirSync(p, this.statSync(p, cred).mode, cred);\n\t\t}\n\t}\n\n\tprivate async createParentDirectoriesAsync(p: string, cred: Cred): Promise<void> {\n\t\tlet parent = dirname(p),\n\t\t\ttoCreate: string[] = [];\n\t\twhile (!(await this._writable.exists(parent, cred))) {\n\t\t\ttoCreate.push(parent);\n\t\t\tparent = dirname(parent);\n\t\t}\n\t\ttoCreate = toCreate.reverse();\n\n\t\tfor (const p of toCreate) {\n\t\t\tconst stats = await this.stat(p, cred);\n\t\t\tawait this._writable.mkdir(p, stats.mode, cred);\n\t\t}\n\t}\n\n\t/**\n\t * Helper function:\n\t * - Ensures p is on writable before proceeding. Throws an error if it doesn't exist.\n\t * - Calls f to perform operation on writable.\n\t */\n\tprivate operateOnWritable(p: string, cred: Cred): void {\n\t\tif (!this.existsSync(p, cred)) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t\tif (!this._writable.existsSync(p, cred)) {\n\t\t\t// File is on readable storage. Copy to writable storage before\n\t\t\t// changing its mode.\n\t\t\tthis.copyToWritable(p, cred);\n\t\t}\n\t}\n\n\tprivate async operateOnWritableAsync(p: string, cred: Cred): Promise<void> {\n\t\tif (!(await this.exists(p, cred))) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\n\t\tif (!(await this._writable.exists(p, cred))) {\n\t\t\treturn this.copyToWritableAsync(p, cred);\n\t\t}\n\t}\n\n\t/**\n\t * Copy from readable to writable storage.\n\t * PRECONDITION: File does not exist on writable storage.\n\t */\n\tprivate copyToWritable(p: string, cred: Cred): void {\n\t\tconst pStats = this.statSync(p, cred);\n\t\tif (pStats.isDirectory()) {\n\t\t\tthis._writable.mkdirSync(p, pStats.mode, cred);\n\t\t} else {\n\t\t\tthis.writeFileSync(p, this._readable.readFileSync(p, getFlag('r'), cred), getFlag('w'), pStats.mode, cred);\n\t\t}\n\t}\n\n\tprivate async copyToWritableAsync(p: string, cred: Cred): Promise<void> {\n\t\tconst pStats = await this.stat(p, cred);\n\t\tif (pStats.isDirectory()) {\n\t\t\tawait this._writable.mkdir(p, pStats.mode, cred);\n\t\t} else {\n\t\t\tawait this.writeFile(p, await this._readable.readFile(p, getFlag('r'), cred), getFlag('w'), pStats.mode, cred);\n\t\t}\n\t}\n}\n\n/**\n * OverlayFS makes a read-only filesystem writable by storing writes on a second,\n * writable file system. Deletes are persisted via metadata stored on the writable\n * file system.\n */\nexport class OverlayFS extends LockedFS<UnlockedOverlayFS> {\n\tpublic static readonly Name = 'OverlayFS';\n\n\tpublic static Create = CreateBackend.bind(this);\n\n\tpublic static readonly Options: BackendOptions = {\n\t\twritable: {\n\t\t\ttype: 'object',\n\t\t\tdescription: 'The file system to write modified files to.',\n\t\t},\n\t\treadable: {\n\t\t\ttype: 'object',\n\t\t\tdescription: 'The file system that initially populates this file system.',\n\t\t},\n\t};\n\n\tpublic static isAvailable(): boolean {\n\t\treturn UnlockedOverlayFS.isAvailable();\n\t}\n\n\t/**\n\t * @param options The options to initialize the OverlayFS with\n\t */\n\tconstructor(options: OverlayFS.Options) {\n\t\tsuper(new UnlockedOverlayFS(options));\n\t\tthis._ready = this._initialize();\n\t}\n\n\tpublic getOverlayedFileSystems(): OverlayFS.Options {\n\t\treturn super.fs.getOverlayedFileSystems();\n\t}\n\n\tpublic getDeletionLog(): string {\n\t\treturn super.fs.getDeletionLog();\n\t}\n\n\tpublic resDeletionLog(): string {\n\t\treturn super.fs.getDeletionLog();\n\t}\n\n\tpublic unwrap(): UnlockedOverlayFS {\n\t\treturn super.fs;\n\t}\n\n\tprivate async _initialize(): Promise<this> {\n\t\tawait super.fs._initialize();\n\t\treturn this;\n\t}\n}\n", "import { AsyncMirror } from './AsyncMirror.js';\nimport { FolderAdapter } from './FolderAdapter.js';\nimport { InMemoryFileSystem as InMemory } from './InMemory.js';\nimport { OverlayFS } from './OverlayFS.js';\nimport { BackendConstructor } from './backend.js';\n\nexport const backends: { [backend: string]: BackendConstructor } = {};\nexport default backends;\nexport { AsyncMirror, FolderAdapter, InMemory, OverlayFS };\n\nexport function registerBackend(..._backends: BackendConstructor[]) {\n\tfor (const backend of _backends) {\n\t\tbackends[backend.Name] = backend;\n\t}\n}\n\nregisterBackend(AsyncMirror, FolderAdapter, InMemory, OverlayFS);\n", "import { dirname, basename, join, resolve } from '../emulation/path.js';\nimport { ApiError, ErrorCode } from '../ApiError.js';\nimport { Cred } from '../cred.js';\nimport { W_OK, R_OK } from '../emulation/constants.js';\nimport { PreloadFile, File, FileFlag } from '../file.js';\nimport { BaseFileSystem } from '../filesystem.js';\nimport Inode from '../inode.js';\nimport { Stats, FileType } from '../stats.js';\nimport { ROOT_NODE_ID, randomUUID, encode, decode } from '../utils.js';\n\nclass LRUNode {\n\tpublic prev: LRUNode | null = null;\n\tpublic next: LRUNode | null = null;\n\tconstructor(public key: string, public value: string) {}\n}\n\n// Adapted from https://chrisrng.svbtle.com/lru-cache-in-javascript\nclass LRUCache {\n\tprivate size = 0;\n\tprivate map: { [id: string]: LRUNode } = {};\n\tprivate head: LRUNode | null = null;\n\tprivate tail: LRUNode | null = null;\n\tconstructor(public readonly limit: number) {}\n\n\t/**\n\t * Change or add a new value in the cache\n\t * We overwrite the entry if it already exists\n\t */\n\tpublic set(key: string, value: string): void {\n\t\tconst node = new LRUNode(key, value);\n\t\tif (this.map[key]) {\n\t\t\tthis.map[key].value = node.value;\n\t\t\tthis.remove(node.key);\n\t\t} else {\n\t\t\tif (this.size >= this.limit) {\n\t\t\t\tdelete this.map[this.tail!.key];\n\t\t\t\tthis.size--;\n\t\t\t\tthis.tail = this.tail!.prev;\n\t\t\t\tthis.tail!.next = null;\n\t\t\t}\n\t\t}\n\t\tthis.setHead(node);\n\t}\n\n\t/* Retrieve a single entry from the cache */\n\tpublic get(key: string): string | null {\n\t\tif (this.map[key]) {\n\t\t\tconst value = this.map[key].value;\n\t\t\tconst node = new LRUNode(key, value);\n\t\t\tthis.remove(key);\n\t\t\tthis.setHead(node);\n\t\t\treturn value;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/* Remove a single entry from the cache */\n\tpublic remove(key: string): void {\n\t\tconst node = this.map[key];\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tif (node.prev !== null) {\n\t\t\tnode.prev.next = node.next;\n\t\t} else {\n\t\t\tthis.head = node.next;\n\t\t}\n\t\tif (node.next !== null) {\n\t\t\tnode.next.prev = node.prev;\n\t\t} else {\n\t\t\tthis.tail = node.prev;\n\t\t}\n\t\tdelete this.map[key];\n\t\tthis.size--;\n\t}\n\n\t/* Resets the entire cache - Argument limit is optional to be reset */\n\tpublic removeAll() {\n\t\tthis.size = 0;\n\t\tthis.map = {};\n\t\tthis.head = null;\n\t\tthis.tail = null;\n\t}\n\n\tprivate setHead(node: LRUNode): void {\n\t\tnode.next = this.head;\n\t\tnode.prev = null;\n\t\tif (this.head !== null) {\n\t\t\tthis.head.prev = node;\n\t\t}\n\t\tthis.head = node;\n\t\tif (this.tail === null) {\n\t\t\tthis.tail = node;\n\t\t}\n\t\tthis.size++;\n\t\tthis.map[node.key] = node;\n\t}\n}\n\n/**\n * Represents an *asynchronous* key-value store.\n */\nexport interface AsyncKeyValueStore {\n\t/**\n\t * The name of the key-value store.\n\t */\n\tname(): string;\n\t/**\n\t * Empties the key-value store completely.\n\t */\n\tclear(): Promise<void>;\n\t/**\n\t * Begins a read-write transaction.\n\t */\n\tbeginTransaction(type: 'readwrite'): AsyncKeyValueRWTransaction;\n\t/**\n\t * Begins a read-only transaction.\n\t */\n\tbeginTransaction(type: 'readonly'): AsyncKeyValueROTransaction;\n\tbeginTransaction(type: string): AsyncKeyValueROTransaction;\n}\n\n/**\n * Represents an asynchronous read-only transaction.\n */\nexport interface AsyncKeyValueROTransaction {\n\t/**\n\t * Retrieves the data at the given key.\n\t * @param key The key to look under for data.\n\t */\n\tget(key: string): Promise<Uint8Array>;\n}\n\n/**\n * Represents an asynchronous read-write transaction.\n */\nexport interface AsyncKeyValueRWTransaction extends AsyncKeyValueROTransaction {\n\t/**\n\t * Adds the data to the store under the given key. Overwrites any existing\n\t * data.\n\t * @param key The key to add the data under.\n\t * @param data The data to add to the store.\n\t * @param overwrite If 'true', overwrite any existing data. If 'false',\n\t * avoids writing the data if the key exists.\n\t */\n\tput(key: string, data: Uint8Array, overwrite: boolean): Promise<boolean>;\n\t/**\n\t * Deletes the data at the given key.\n\t * @param key The key to delete from the store.\n\t */\n\tdel(key: string): Promise<void>;\n\t/**\n\t * Commits the transaction.\n\t */\n\tcommit(): Promise<void>;\n\t/**\n\t * Aborts and rolls back the transaction.\n\t */\n\tabort(): Promise<void>;\n}\n\nexport class AsyncKeyValueFile extends PreloadFile<AsyncKeyValueFileSystem> implements File {\n\tconstructor(_fs: AsyncKeyValueFileSystem, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array) {\n\t\tsuper(_fs, _path, _flag, _stat, contents);\n\t}\n\n\tpublic async sync(): Promise<void> {\n\t\tif (!this.isDirty()) {\n\t\t\treturn;\n\t\t}\n\n\t\tawait this._fs._sync(this.getPath(), this.getBuffer(), this.getStats());\n\n\t\tthis.resetDirty();\n\t}\n\n\tpublic async close(): Promise<void> {\n\t\tthis.sync();\n\t}\n}\n\n/**\n * An \"Asynchronous key-value file system\". Stores data to/retrieves data from\n * an underlying asynchronous key-value store.\n */\nexport class AsyncKeyValueFileSystem extends BaseFileSystem {\n\tpublic static isAvailable(): boolean {\n\t\treturn true;\n\t}\n\n\tprotected store: AsyncKeyValueStore;\n\tprivate _cache: LRUCache | null = null;\n\n\tconstructor(cacheSize: number) {\n\t\tsuper();\n\t\tif (cacheSize > 0) {\n\t\t\tthis._cache = new LRUCache(cacheSize);\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the file system. Typically called by subclasses' async\n\t * constructors.\n\t */\n\tpublic async init(store: AsyncKeyValueStore) {\n\t\tthis.store = store;\n\t\t// INVARIANT: Ensure that the root exists.\n\t\tawait this.makeRootDirectory();\n\t}\n\tpublic getName(): string {\n\t\treturn this.store.name();\n\t}\n\tpublic isReadOnly(): boolean {\n\t\treturn false;\n\t}\n\tpublic supportsSymlinks(): boolean {\n\t\treturn false;\n\t}\n\tpublic supportsProps(): boolean {\n\t\treturn true;\n\t}\n\tpublic supportsSynch(): boolean {\n\t\treturn false;\n\t}\n\n\t/**\n\t * Delete all contents stored in the file system.\n\t */\n\tpublic async empty(): Promise<void> {\n\t\tif (this._cache) {\n\t\t\tthis._cache.removeAll();\n\t\t}\n\t\tawait this.store.clear();\n\t\t// INVARIANT: Root always exists.\n\t\tawait this.makeRootDirectory();\n\t}\n\n\tpublic async access(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tconst tx = this.store.beginTransaction('readonly');\n\t\tconst inode = await this.findINode(tx, p);\n\t\tif (!inode) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t\tif (!inode.toStats().hasAccess(mode, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\t}\n\n\t/**\n\t * @todo Make rename compatible with the cache.\n\t */\n\tpublic async rename(oldPath: string, newPath: string, cred: Cred): Promise<void> {\n\t\tconst c = this._cache;\n\t\tif (this._cache) {\n\t\t\t// Clear and disable cache during renaming process.\n\t\t\tthis._cache = null;\n\t\t\tc.removeAll();\n\t\t}\n\n\t\ttry {\n\t\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\t\toldParent = dirname(oldPath),\n\t\t\t\toldName = basename(oldPath),\n\t\t\t\tnewParent = dirname(newPath),\n\t\t\t\tnewName = basename(newPath),\n\t\t\t\t// Remove oldPath from parent's directory listing.\n\t\t\t\toldDirNode = await this.findINode(tx, oldParent),\n\t\t\t\toldDirList = await this.getDirListing(tx, oldParent, oldDirNode);\n\n\t\t\tif (!oldDirNode.toStats().hasAccess(W_OK, cred)) {\n\t\t\t\tthrow ApiError.EACCES(oldPath);\n\t\t\t}\n\n\t\t\tif (!oldDirList[oldName]) {\n\t\t\t\tthrow ApiError.ENOENT(oldPath);\n\t\t\t}\n\t\t\tconst nodeId: string = oldDirList[oldName];\n\t\t\tdelete oldDirList[oldName];\n\n\t\t\t// Invariant: Can't move a folder inside itself.\n\t\t\t// This funny little hack ensures that the check passes only if oldPath\n\t\t\t// is a subpath of newParent. We append '/' to avoid matching folders that\n\t\t\t// are a substring of the bottom-most folder in the path.\n\t\t\tif ((newParent + '/').indexOf(oldPath + '/') === 0) {\n\t\t\t\tthrow new ApiError(ErrorCode.EBUSY, oldParent);\n\t\t\t}\n\n\t\t\t// Add newPath to parent's directory listing.\n\t\t\tlet newDirNode: Inode, newDirList: typeof oldDirList;\n\t\t\tif (newParent === oldParent) {\n\t\t\t\t// Prevent us from re-grabbing the same directory listing, which still\n\t\t\t\t// contains oldName.\n\t\t\t\tnewDirNode = oldDirNode;\n\t\t\t\tnewDirList = oldDirList;\n\t\t\t} else {\n\t\t\t\tnewDirNode = await this.findINode(tx, newParent);\n\t\t\t\tnewDirList = await this.getDirListing(tx, newParent, newDirNode);\n\t\t\t}\n\n\t\t\tif (newDirList[newName]) {\n\t\t\t\t// If it's a file, delete it.\n\t\t\t\tconst newNameNode = await this.getINode(tx, newPath, newDirList[newName]);\n\t\t\t\tif (newNameNode.isFile()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait tx.del(newNameNode.id);\n\t\t\t\t\t\tawait tx.del(newDirList[newName]);\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tawait tx.abort();\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// If it's a directory, throw a permissions error.\n\t\t\t\t\tthrow ApiError.EPERM(newPath);\n\t\t\t\t}\n\t\t\t}\n\t\t\tnewDirList[newName] = nodeId;\n\t\t\t// Commit the two changed directory listings.\n\t\t\ttry {\n\t\t\t\tawait tx.put(oldDirNode.id, encode(JSON.stringify(oldDirList)), true);\n\t\t\t\tawait tx.put(newDirNode.id, encode(JSON.stringify(newDirList)), true);\n\t\t\t} catch (e) {\n\t\t\t\tawait tx.abort();\n\t\t\t\tthrow e;\n\t\t\t}\n\n\t\t\tawait tx.commit();\n\t\t} finally {\n\t\t\tif (c) {\n\t\t\t\tthis._cache = c;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async stat(p: string, cred: Cred): Promise<Stats> {\n\t\tconst tx = this.store.beginTransaction('readonly');\n\t\tconst inode = await this.findINode(tx, p);\n\t\tconst stats = inode!.toStats();\n\t\tif (!stats.hasAccess(R_OK, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\t\treturn stats;\n\t}\n\n\tpublic async createFile(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File> {\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\tdata = new Uint8Array(0),\n\t\t\tnewFile = await this.commitNewFile(tx, p, FileType.FILE, mode, cred, data);\n\t\t// Open the file.\n\t\treturn new AsyncKeyValueFile(this, p, flag, newFile.toStats(), data);\n\t}\n\n\tpublic async openFile(p: string, flag: FileFlag, cred: Cred): Promise<File> {\n\t\tconst tx = this.store.beginTransaction('readonly'),\n\t\t\tnode = await this.findINode(tx, p),\n\t\t\tdata = await tx.get(node.id);\n\t\tif (!node.toStats().hasAccess(flag.getMode(), cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\t\tif (data === undefined) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t\treturn new AsyncKeyValueFile(this, p, flag, node.toStats(), data);\n\t}\n\n\tpublic async unlink(p: string, cred: Cred): Promise<void> {\n\t\treturn this.removeEntry(p, false, cred);\n\t}\n\n\tpublic async rmdir(p: string, cred: Cred): Promise<void> {\n\t\t// Check first if directory is empty.\n\t\tconst list = await this.readdir(p, cred);\n\t\tif (list.length > 0) {\n\t\t\tthrow ApiError.ENOTEMPTY(p);\n\t\t}\n\t\tawait this.removeEntry(p, true, cred);\n\t}\n\n\tpublic async mkdir(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\tdata = encode('{}');\n\t\tawait this.commitNewFile(tx, p, FileType.DIRECTORY, mode, cred, data);\n\t}\n\n\tpublic async readdir(p: string, cred: Cred): Promise<string[]> {\n\t\tconst tx = this.store.beginTransaction('readonly');\n\t\tconst node = await this.findINode(tx, p);\n\t\tif (!node.toStats().hasAccess(R_OK, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\t\treturn Object.keys(await this.getDirListing(tx, p, node));\n\t}\n\n\tpublic async chmod(p: string, mode: number, cred: Cred): Promise<void> {\n\t\tconst fd = await this.openFile(p, FileFlag.getFileFlag('r+'), cred);\n\t\tawait fd.chmod(mode);\n\t}\n\n\tpublic async chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void> {\n\t\tconst fd = await this.openFile(p, FileFlag.getFileFlag('r+'), cred);\n\t\tawait fd.chown(new_uid, new_gid);\n\t}\n\n\tpublic async _sync(p: string, data: Uint8Array, stats: Stats): Promise<void> {\n\t\t// @todo Ensure mtime updates properly, and use that to determine if a data\n\t\t// update is required.\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\t// We use the _findInode helper because we actually need the INode id.\n\t\t\tfileInodeId = await this._findINode(tx, dirname(p), basename(p)),\n\t\t\tfileInode = await this.getINode(tx, p, fileInodeId),\n\t\t\tinodeChanged = fileInode.update(stats);\n\n\t\ttry {\n\t\t\t// Sync data.\n\t\t\tawait tx.put(fileInode.id, data, true);\n\t\t\t// Sync metadata.\n\t\t\tif (inodeChanged) {\n\t\t\t\tawait tx.put(fileInodeId, fileInode.serialize(), true);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tawait tx.abort();\n\t\t\tthrow e;\n\t\t}\n\t\tawait tx.commit();\n\t}\n\n\t/**\n\t * Checks if the root directory exists. Creates it if it doesn't.\n\t */\n\tprivate async makeRootDirectory(): Promise<void> {\n\t\tconst tx = this.store.beginTransaction('readwrite');\n\t\tif ((await tx.get(ROOT_NODE_ID)) === undefined) {\n\t\t\t// Create new inode.\n\t\t\tconst currTime = new Date().getTime(),\n\t\t\t\t// Mode 0666, owned by root:root\n\t\t\t\tdirInode = new Inode(randomUUID(), 4096, 511 | FileType.DIRECTORY, currTime, currTime, currTime, 0, 0);\n\t\t\t// If the root doesn't exist, the first random ID shouldn't exist,\n\t\t\t// either.\n\t\t\tawait tx.put(dirInode.id, encode('{}'), false);\n\t\t\tawait tx.put(ROOT_NODE_ID, dirInode.serialize(), false);\n\t\t\tawait tx.commit();\n\t\t}\n\t}\n\n\t/**\n\t * Helper function for findINode.\n\t * @param parent The parent directory of the file we are attempting to find.\n\t * @param filename The filename of the inode we are attempting to find, minus\n\t * the parent.\n\t */\n\tprivate async _findINode(tx: AsyncKeyValueROTransaction, parent: string, filename: string, visited: Set<string> = new Set<string>()): Promise<string> {\n\t\tconst currentPath = join(parent, filename);\n\t\tif (visited.has(currentPath)) {\n\t\t\tthrow new ApiError(ErrorCode.EIO, 'Infinite loop detected while finding inode', currentPath);\n\t\t}\n\n\t\tvisited.add(currentPath);\n\t\tif (this._cache) {\n\t\t\tconst id = this._cache.get(currentPath);\n\t\t\tif (id) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t}\n\n\t\tif (parent === '/') {\n\t\t\tif (filename === '') {\n\t\t\t\t// BASE CASE #1: Return the root's ID.\n\t\t\t\tif (this._cache) {\n\t\t\t\t\tthis._cache.set(currentPath, ROOT_NODE_ID);\n\t\t\t\t}\n\t\t\t\treturn ROOT_NODE_ID;\n\t\t\t} else {\n\t\t\t\t// BASE CASE #2: Find the item in the root node.\n\t\t\t\tconst inode = await this.getINode(tx, parent, ROOT_NODE_ID);\n\t\t\t\tconst dirList = await this.getDirListing(tx, parent, inode!);\n\t\t\t\tif (dirList![filename]) {\n\t\t\t\t\tconst id = dirList![filename];\n\t\t\t\t\tif (this._cache) {\n\t\t\t\t\t\tthis._cache.set(currentPath, id);\n\t\t\t\t\t}\n\t\t\t\t\treturn id;\n\t\t\t\t} else {\n\t\t\t\t\tthrow ApiError.ENOENT(resolve(parent, filename));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Get the parent directory's INode, and find the file in its directory\n\t\t\t// listing.\n\t\t\tconst inode = await this.findINode(tx, parent, visited);\n\t\t\tconst dirList = await this.getDirListing(tx, parent, inode!);\n\t\t\tif (dirList![filename]) {\n\t\t\t\tconst id = dirList![filename];\n\t\t\t\tif (this._cache) {\n\t\t\t\t\tthis._cache.set(currentPath, id);\n\t\t\t\t}\n\t\t\t\treturn id;\n\t\t\t} else {\n\t\t\t\tthrow ApiError.ENOENT(resolve(parent, filename));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the Inode of the given path.\n\t * @param p The path to look up.\n\t * @todo memoize/cache\n\t */\n\tprivate async findINode(tx: AsyncKeyValueROTransaction, p: string, visited: Set<string> = new Set<string>()): Promise<Inode> {\n\t\tconst id = await this._findINode(tx, dirname(p), basename(p), visited);\n\t\treturn this.getINode(tx, p, id!);\n\t}\n\n\t/**\n\t * Given the ID of a node, retrieves the corresponding Inode.\n\t * @param tx The transaction to use.\n\t * @param p The corresponding path to the file (used for error messages).\n\t * @param id The ID to look up.\n\t */\n\tprivate async getINode(tx: AsyncKeyValueROTransaction, p: string, id: string): Promise<Inode> {\n\t\tconst data = await tx.get(id);\n\t\tif (!data) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t\treturn Inode.Deserialize(data);\n\t}\n\n\t/**\n\t * Given the Inode of a directory, retrieves the corresponding directory\n\t * listing.\n\t */\n\tprivate async getDirListing(tx: AsyncKeyValueROTransaction, p: string, inode: Inode): Promise<{ [fileName: string]: string }> {\n\t\tif (!inode.isDirectory()) {\n\t\t\tthrow ApiError.ENOTDIR(p);\n\t\t}\n\t\tconst data = await tx.get(inode.id);\n\t\ttry {\n\t\t\treturn JSON.parse(decode(data));\n\t\t} catch (e) {\n\t\t\t// Occurs when data is undefined, or corresponds to something other\n\t\t\t// than a directory listing. The latter should never occur unless\n\t\t\t// the file system is corrupted.\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a new node under a random ID. Retries 5 times before giving up in\n\t * the exceedingly unlikely chance that we try to reuse a random GUID.\n\t */\n\tprivate async addNewNode(tx: AsyncKeyValueRWTransaction, data: Uint8Array): Promise<string> {\n\t\tlet retries = 0;\n\t\tconst reroll = async () => {\n\t\t\tif (++retries === 5) {\n\t\t\t\t// Max retries hit. Return with an error.\n\t\t\t\tthrow new ApiError(ErrorCode.EIO, 'Unable to commit data to key-value store.');\n\t\t\t} else {\n\t\t\t\t// Try again.\n\t\t\t\tconst currId = randomUUID();\n\t\t\t\tconst committed = await tx.put(currId, data, false);\n\t\t\t\tif (!committed) {\n\t\t\t\t\treturn reroll();\n\t\t\t\t} else {\n\t\t\t\t\treturn currId;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\treturn reroll();\n\t}\n\n\t/**\n\t * Commits a new file (well, a FILE or a DIRECTORY) to the file system with\n\t * the given mode.\n\t * Note: This will commit the transaction.\n\t * @param p The path to the new file.\n\t * @param type The type of the new file.\n\t * @param mode The mode to create the new file with.\n\t * @param cred The UID/GID to create the file with\n\t * @param data The data to store at the file's data node.\n\t */\n\tprivate async commitNewFile(tx: AsyncKeyValueRWTransaction, p: string, type: FileType, mode: number, cred: Cred, data: Uint8Array): Promise<Inode> {\n\t\tconst parentDir = dirname(p),\n\t\t\tfname = basename(p),\n\t\t\tparentNode = await this.findINode(tx, parentDir),\n\t\t\tdirListing = await this.getDirListing(tx, parentDir, parentNode),\n\t\t\tcurrTime = new Date().getTime();\n\n\t\t//Check that the creater has correct access\n\t\tif (!parentNode.toStats().hasAccess(W_OK, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\n\t\t// Invariant: The root always exists.\n\t\t// If we don't check this prior to taking steps below, we will create a\n\t\t// file with name '' in root should p == '/'.\n\t\tif (p === '/') {\n\t\t\tthrow ApiError.EEXIST(p);\n\t\t}\n\n\t\t// Check if file already exists.\n\t\tif (dirListing[fname]) {\n\t\t\tawait tx.abort();\n\t\t\tthrow ApiError.EEXIST(p);\n\t\t}\n\t\ttry {\n\t\t\t// Commit data.\n\t\t\tconst dataId = await this.addNewNode(tx, data);\n\t\t\tconst fileNode = new Inode(dataId, data.length, mode | type, currTime, currTime, currTime, cred.uid, cred.gid);\n\t\t\t// Commit file node.\n\t\t\tconst fileNodeId = await this.addNewNode(tx, fileNode.serialize());\n\t\t\t// Update and commit parent directory listing.\n\t\t\tdirListing[fname] = fileNodeId;\n\t\t\tawait tx.put(parentNode.id, encode(JSON.stringify(dirListing)), true);\n\t\t\tawait tx.commit();\n\t\t\treturn fileNode;\n\t\t} catch (e) {\n\t\t\ttx.abort();\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t/**\n\t * Remove all traces of the given path from the file system.\n\t * @param p The path to remove from the file system.\n\t * @param isDir Does the path belong to a directory, or a file?\n\t * @todo Update mtime.\n\t */\n\t/**\n\t * Remove all traces of the given path from the file system.\n\t * @param p The path to remove from the file system.\n\t * @param isDir Does the path belong to a directory, or a file?\n\t * @todo Update mtime.\n\t */\n\tprivate async removeEntry(p: string, isDir: boolean, cred: Cred): Promise<void> {\n\t\tif (this._cache) {\n\t\t\tthis._cache.remove(p);\n\t\t}\n\t\tconst tx = this.store.beginTransaction('readwrite'),\n\t\t\tparent: string = dirname(p),\n\t\t\tparentNode = await this.findINode(tx, parent),\n\t\t\tparentListing = await this.getDirListing(tx, parent, parentNode),\n\t\t\tfileName: string = basename(p);\n\n\t\tif (!parentListing[fileName]) {\n\t\t\tthrow ApiError.ENOENT(p);\n\t\t}\n\n\t\tconst fileNodeId = parentListing[fileName];\n\n\t\t// Get file inode.\n\t\tconst fileNode = await this.getINode(tx, p, fileNodeId);\n\n\t\tif (!fileNode.toStats().hasAccess(W_OK, cred)) {\n\t\t\tthrow ApiError.EACCES(p);\n\t\t}\n\n\t\t// Remove from directory listing of parent.\n\t\tdelete parentListing[fileName];\n\n\t\tif (!isDir && fileNode.isDirectory()) {\n\t\t\tthrow ApiError.EISDIR(p);\n\t\t} else if (isDir && !fileNode.isDirectory()) {\n\t\t\tthrow ApiError.ENOTDIR(p);\n\t\t}\n\n\t\ttry {\n\t\t\t// Delete data.\n\t\t\tawait tx.del(fileNode.id);\n\t\t\t// Delete node.\n\t\t\tawait tx.del(fileNodeId);\n\t\t\t// Update directory listing.\n\t\t\tawait tx.put(parentNode.id, encode(JSON.stringify(parentListing)), true);\n\t\t} catch (e) {\n\t\t\tawait tx.abort();\n\t\t\tthrow e;\n\t\t}\n\t\t// Success.\n\t\tawait tx.commit();\n\t}\n}\n", "import { Stats, FileType } from './stats.js';\nimport * as path from './emulation/path.js';\n\n/**\n * A simple class for storing a filesystem index. Assumes that all paths passed\n * to it are *absolute* paths.\n *\n * Can be used as a partial or a full index, although care must be taken if used\n * for the former purpose, especially when directories are concerned.\n */\nexport class FileIndex<T> {\n\t/**\n\t * Static method for constructing indices from a JSON listing.\n\t * @param listing Directory listing generated by tools/XHRIndexer.coffee\n\t * @return A new FileIndex object.\n\t */\n\tpublic static fromListing<T>(listing: any): FileIndex<T> {\n\t\tconst idx = new FileIndex<T>();\n\t\t// Add a root DirNode.\n\t\tconst rootInode = new IndexDirInode<T>();\n\t\tidx._index['/'] = rootInode;\n\t\tconst queue = [['', listing, rootInode]];\n\t\twhile (queue.length > 0) {\n\t\t\tlet inode: IndexInode;\n\t\t\tconst next = queue.pop();\n\t\t\tconst pwd = next![0];\n\t\t\tconst tree = next![1];\n\t\t\tconst parent = next![2];\n\t\t\tfor (const node in tree) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(tree, node)) {\n\t\t\t\t\tconst children = tree[node];\n\t\t\t\t\tconst name = `${pwd}/${node}`;\n\t\t\t\t\tif (children) {\n\t\t\t\t\t\tidx._index[name] = inode = new IndexDirInode<T>();\n\t\t\t\t\t\tqueue.push([name, children, inode]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// This inode doesn't have correct size information, noted with -1.\n\t\t\t\t\t\tinode = new IndexFileInode<Stats>(new Stats(FileType.FILE, -1, 0x16d));\n\t\t\t\t\t}\n\t\t\t\t\tif (parent) {\n\t\t\t\t\t\tparent._ls[node] = inode;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn idx;\n\t}\n\n\t// Maps directory paths to directory inodes, which contain files.\n\tprivate _index: { [path: string]: IndexDirInode<T> };\n\n\t/**\n\t * Constructs a new FileIndex.\n\t */\n\tconstructor() {\n\t\t// _index is a single-level key,value store that maps *directory* paths to\n\t\t// DirInodes. File information is only contained in DirInodes themselves.\n\t\tthis._index = {};\n\t\t// Create the root directory.\n\t\tthis.addPath('/', new IndexDirInode());\n\t}\n\n\t/**\n\t * Runs the given function over all files in the index.\n\t */\n\tpublic fileIterator<T>(cb: (file: T | null) => void): void {\n\t\tfor (const path in this._index) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(this._index, path)) {\n\t\t\t\tconst dir = this._index[path];\n\t\t\t\tconst files = dir.getListing();\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\tconst item = dir.getItem(file);\n\t\t\t\t\tif (isIndexFileInode<T>(item)) {\n\t\t\t\t\t\tcb(item.getData());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Adds the given absolute path to the index if it is not already in the index.\n\t * Creates any needed parent directories.\n\t * @param path The path to add to the index.\n\t * @param inode The inode for the\n\t * path to add.\n\t * @return 'True' if it was added or already exists, 'false' if there\n\t * was an issue adding it (e.g. item in path is a file, item exists but is\n\t * different).\n\t * @todo If adding fails and implicitly creates directories, we do not clean up\n\t * the new empty directories.\n\t */\n\tpublic addPath(path: string, inode: IndexInode): boolean {\n\t\tif (!inode) {\n\t\t\tthrow new Error('Inode must be specified');\n\t\t}\n\t\tif (path[0] !== '/') {\n\t\t\tthrow new Error('Path must be absolute, got: ' + path);\n\t\t}\n\n\t\t// Check if it already exists.\n\t\tif (Object.prototype.hasOwnProperty.call(this._index, path)) {\n\t\t\treturn this._index[path] === inode;\n\t\t}\n\n\t\tconst splitPath = this._split_path(path);\n\t\tconst dirpath = splitPath[0];\n\t\tconst itemname = splitPath[1];\n\t\t// Try to add to its parent directory first.\n\t\tlet parent = this._index[dirpath];\n\t\tif (parent === undefined && path !== '/') {\n\t\t\t// Create parent.\n\t\t\tparent = new IndexDirInode<T>();\n\t\t\tif (!this.addPath(dirpath, parent)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t// Add myself to my parent.\n\t\tif (path !== '/') {\n\t\t\tif (!parent.addItem(itemname, inode)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t// If I'm a directory, add myself to the index.\n\t\tif (isIndexDirInode<T>(inode)) {\n\t\t\tthis._index[path] = inode;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Adds the given absolute path to the index if it is not already in the index.\n\t * The path is added without special treatment (no joining of adjacent separators, etc).\n\t * Creates any needed parent directories.\n\t * @param path The path to add to the index.\n\t * @param inode The inode for the\n\t * path to add.\n\t * @return 'True' if it was added or already exists, 'false' if there\n\t * was an issue adding it (e.g. item in path is a file, item exists but is\n\t * different).\n\t * @todo If adding fails and implicitly creates directories, we do not clean up\n\t * the new empty directories.\n\t */\n\tpublic addPathFast(path: string, inode: IndexInode): boolean {\n\t\tconst itemNameMark = path.lastIndexOf('/');\n\t\tconst parentPath = itemNameMark === 0 ? '/' : path.substring(0, itemNameMark);\n\t\tconst itemName = path.substring(itemNameMark + 1);\n\n\t\t// Try to add to its parent directory first.\n\t\tlet parent = this._index[parentPath];\n\t\tif (parent === undefined) {\n\t\t\t// Create parent.\n\t\t\tparent = new IndexDirInode<T>();\n\t\t\tthis.addPathFast(parentPath, parent);\n\t\t}\n\n\t\tif (!parent.addItem(itemName, inode)) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// If adding a directory, add to the index as well.\n\t\tif (inode.isDir()) {\n\t\t\tthis._index[path] = <IndexDirInode<T>>inode;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Removes the given path. Can be a file or a directory.\n\t * @return The removed item,\n\t * or null if it did not exist.\n\t */\n\tpublic removePath(path: string): IndexInode | null {\n\t\tconst splitPath = this._split_path(path);\n\t\tconst dirpath = splitPath[0];\n\t\tconst itemname = splitPath[1];\n\n\t\t// Try to remove it from its parent directory first.\n\t\tconst parent = this._index[dirpath];\n\t\tif (parent === undefined) {\n\t\t\treturn null;\n\t\t}\n\t\t// Remove myself from my parent.\n\t\tconst inode = parent.remItem(itemname);\n\t\tif (inode === null) {\n\t\t\treturn null;\n\t\t}\n\t\t// If I'm a directory, remove myself from the index, and remove my children.\n\t\tif (isIndexDirInode(inode)) {\n\t\t\tconst children = inode.getListing();\n\t\t\tfor (const child of children) {\n\t\t\t\tthis.removePath(path + '/' + child);\n\t\t\t}\n\n\t\t\t// Remove the directory from the index, unless it's the root.\n\t\t\tif (path !== '/') {\n\t\t\t\tdelete this._index[path];\n\t\t\t}\n\t\t}\n\t\treturn inode;\n\t}\n\n\t/**\n\t * Retrieves the directory listing of the given path.\n\t * @return An array of files in the given path, or 'null' if it does not exist.\n\t */\n\tpublic ls(path: string): string[] | null {\n\t\tconst item = this._index[path];\n\t\tif (item === undefined) {\n\t\t\treturn null;\n\t\t}\n\t\treturn item.getListing();\n\t}\n\n\t/**\n\t * Returns the inode of the given item.\n\t * @return Returns null if the item does not exist.\n\t */\n\tpublic getInode(path: string): IndexInode | null {\n\t\tconst splitPath = this._split_path(path);\n\t\tconst dirpath = splitPath[0];\n\t\tconst itemname = splitPath[1];\n\t\t// Retrieve from its parent directory.\n\t\tconst parent = this._index[dirpath];\n\t\tif (parent === undefined) {\n\t\t\treturn null;\n\t\t}\n\t\t// Root case\n\t\tif (dirpath === path) {\n\t\t\treturn parent;\n\t\t}\n\t\treturn parent.getItem(itemname);\n\t}\n\n\t/**\n\t * Split into a (directory path, item name) pair\n\t */\n\tprivate _split_path(p: string): string[] {\n\t\tconst dirpath = path.dirname(p);\n\t\tconst itemname = p.slice(dirpath.length + (dirpath === '/' ? 0 : 1));\n\t\treturn [dirpath, itemname];\n\t}\n}\n\n/**\n * Generic interface for file/directory inodes.\n * Note that Stats objects are what we use for file inodes.\n */\nexport interface IndexInode {\n\t// Is this an inode for a file?\n\tisFile(): boolean;\n\t// Is this an inode for a directory?\n\tisDir(): boolean;\n\t//compatibility with other Inode types\n\ttoStats(): Stats;\n}\n\n/**\n * Inode for a file. Stores an arbitrary (filesystem-specific) data payload.\n */\nexport class IndexFileInode<T> implements IndexInode {\n\tconstructor(private data: T) {}\n\tpublic isFile(): boolean {\n\t\treturn true;\n\t}\n\tpublic isDir(): boolean {\n\t\treturn false;\n\t}\n\tpublic getData(): T {\n\t\treturn this.data;\n\t}\n\tpublic setData(data: T): void {\n\t\tthis.data = data;\n\t}\n\tpublic toStats(): Stats {\n\t\treturn new Stats(FileType.FILE, 4096, 0o666);\n\t}\n}\n\n/**\n * Inode for a directory. Currently only contains the directory listing.\n */\nexport class IndexDirInode<T> implements IndexInode {\n\tprivate _ls: { [path: string]: IndexInode } = {};\n\t/**\n\t * Constructs an inode for a directory.\n\t */\n\tconstructor(private data: T | null = null) {}\n\tpublic isFile(): boolean {\n\t\treturn false;\n\t}\n\tpublic isDir(): boolean {\n\t\treturn true;\n\t}\n\tpublic getData(): T | null {\n\t\treturn this.data;\n\t}\n\n\t/**\n\t * Return a Stats object for this inode.\n\t * @todo Should probably remove this at some point. This isn't the\n\t * responsibility of the FileIndex.\n\t */\n\tpublic getStats(): Stats {\n\t\treturn new Stats(FileType.DIRECTORY, 4096, 0o555);\n\t}\n\t/**\n\t * Alias of getStats()\n\t * @todo Remove this at some point. This isn't the\n\t * responsibility of the FileIndex.\n\t */\n\tpublic toStats(): Stats {\n\t\treturn this.getStats();\n\t}\n\t/**\n\t * Returns the directory listing for this directory. Paths in the directory are\n\t * relative to the directory's path.\n\t * @return The directory listing for this directory.\n\t */\n\tpublic getListing(): string[] {\n\t\treturn Object.keys(this._ls);\n\t}\n\t/**\n\t * Returns the inode for the indicated item, or null if it does not exist.\n\t * @param p Name of item in this directory.\n\t */\n\tpublic getItem(p: string): IndexInode | null {\n\t\tconst item = this._ls[p];\n\t\treturn item ? item : null;\n\t}\n\t/**\n\t * Add the given item to the directory listing. Note that the given inode is\n\t * not copied, and will be mutated by the DirInode if it is a DirInode.\n\t * @param p Item name to add to the directory listing.\n\t * @param inode The inode for the\n\t * item to add to the directory inode.\n\t * @return True if it was added, false if it already existed.\n\t */\n\tpublic addItem(p: string, inode: IndexInode): boolean {\n\t\tif (p in this._ls) {\n\t\t\treturn false;\n\t\t}\n\t\tthis._ls[p] = inode;\n\t\treturn true;\n\t}\n\t/**\n\t * Removes the given item from the directory listing.\n\t * @param p Name of item to remove from the directory listing.\n\t * @return Returns the item\n\t * removed, or null if the item did not exist.\n\t */\n\tpublic remItem(p: string): IndexInode | null {\n\t\tconst item = this._ls[p];\n\t\tif (item === undefined) {\n\t\t\treturn null;\n\t\t}\n\t\tdelete this._ls[p];\n\t\treturn item;\n\t}\n}\n\n/**\n * @hidden\n */\nexport function isIndexFileInode<T>(inode: IndexInode | null): inode is IndexFileInode<T> {\n\treturn !!inode && inode.isFile();\n}\n\n/**\n * @hidden\n */\nexport function isIndexDirInode<T>(inode: IndexInode | null): inode is IndexDirInode<T> {\n\treturn !!inode && inode.isDir();\n}\n"],
"mappings": "osBAAA,IAAAA,GAAAC,EAAAC,IAAA,cAEAA,GAAQ,WAAaC,GACrBD,GAAQ,YAAcE,GACtBF,GAAQ,cAAgBG,GAExB,IAAIC,GAAS,CAAC,EACVC,GAAY,CAAC,EACbC,GAAM,OAAO,WAAe,IAAc,WAAa,MAEvDC,GAAO,mEACX,IAASC,GAAI,EAAGC,GAAMF,GAAK,OAAQC,GAAIC,GAAK,EAAED,GAC5CJ,GAAOI,EAAC,EAAID,GAAKC,EAAC,EAClBH,GAAUE,GAAK,WAAWC,EAAC,CAAC,EAAIA,GAFzB,IAAAA,GAAOC,GAOhBJ,GAAU,IAAI,WAAW,CAAC,CAAC,EAAI,GAC/BA,GAAU,IAAI,WAAW,CAAC,CAAC,EAAI,GAE/B,SAASK,GAASC,EAAK,CACrB,IAAIF,EAAME,EAAI,OAEd,GAAIF,EAAM,EAAI,EACZ,MAAM,IAAI,MAAM,gDAAgD,EAKlE,IAAIG,EAAWD,EAAI,QAAQ,GAAG,EAC1BC,IAAa,KAAIA,EAAWH,GAEhC,IAAII,EAAkB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,CAAG,CAAC,CAEvB,CAXgBT,EAAAO,GAAA,aA6ChB,eAAeG,GAAe,CAAE,GAAIC,EAAQ,QAAAC,EAAU,CAAC,CAAE,EAAiD,CACzG,GAAI,CAACD,EACJ,MAAM,IAAIE,IAA0B,gDAAgD,EAGrF,GAAI,OAAOD,GAAY,UAAYA,IAAY,KAC9C,MAAM,IAAIC,KAA2B,qDAAqD,EAG3F,IAAMC,EAAQ,OAAO,KAAKF,CAAO,EAAE,OAAOG,GAAKA,GAAK,IAAI,EAExD,QAAWC,KAAQF,EAAO,CACzB,IAAMG,EAAML,EAAQI,CAAI,EACxB,GAAIC,IAAQ,MAAQ,OAAOA,GAAQ,UAAY,EAAE,OAAQA,GACxD,SAGD,IAAMC,EAAK,MAAMR,GAAeO,CAAG,EACnCL,EAAQI,CAAI,EAAIE,EAGjB,IAAMC,EAA4CC,GAAUT,CAAM,EAClE,GAAKQ,EAGJ,OAAOA,EAAI,OAAOP,CAAO,EAFzB,MAAM,IAAIC,IAA0B,eAAeF,kCAAuC,CAI5F,CA3BeX,EAAAU,GAAA,kBAoCR,SAASJ,GAAcJ,EAAiCM,EAA6D,CAE3H,GAAI,OAAOA,GAAM,WAChB,OAAOE,GAAeR,CAAM,EAI7BQ,GAAeR,CAAM,EACnB,KAAKgB,GAAMV,EAAG,KAAMU,CAAE,CAAC,EACvB,MAAMT,GAAOD,EAAGC,CAAG,CAAC,CAEvB,CAXgBT,EAAAM,GAAA,iBA0BhB,IAAOe,GAAQC",
"names": ["require_base64_js", "__commonJSMin", "exports", "byteLength", "toByteArray", "fromByteArray", "lookup", "revLookup", "Arr", "code", "i", "len", "getLens", "b64", "validLen", "placeHoldersLen", "__name", "lens", "_byteLength", "tmp", "arr", "curByte", "tripletToBase64", "num", "encodeChunk", "uint8", "start", "end", "output", "extraBytes", "parts", "maxChunkLength", "len2", "require_ieee754", "__commonJSMin", "exports", "buffer", "offset", "isLE", "mLen", "nBytes", "e", "m", "eLen", "eMax", "eBias", "nBits", "i", "d", "s", "value", "rt", "require_buffer", "__commonJSMin", "exports", "base64", "ieee754", "customInspectSymbol", "Buffer", "SlowBuffer", "K_MAX_LENGTH", "typedArraySupport", "arr", "proto", "__name", "createBuffer", "length", "buf", "arg", "encodingOrOffset", "allocUnsafe", "from", "value", "fromString", "fromArrayView", "isInstance", "fromArrayBuffer", "valueOf", "b", "fromObject", "assertSize", "size", "alloc", "fill", "encoding", "checked", "string", "byteLength", "actual", "fromArrayLike", "array", "arrayView", "copy", "byteOffset", "obj", "len", "numberIsNaN", "a", "x", "y", "i", "list", "buffer", "pos", "mustMatch", "loweredCase", "utf8ToBytes", "base64ToBytes", "slowToString", "start", "end", "hexSlice", "utf8Slice", "asciiSlice", "latin1Slice", "base64Slice", "utf16leSlice", "swap", "n", "m", "str", "max", "target", "thisStart", "thisEnd", "thisCopy", "targetCopy", "bidirectionalIndexOf", "val", "dir", "arrayIndexOf", "indexSize", "arrLength", "valLength", "read", "foundIndex", "found", "j", "hexWrite", "offset", "remaining", "strLen", "parsed", "utf8Write", "blitBuffer", "asciiWrite", "asciiToBytes", "base64Write", "ucs2Write", "utf16leToBytes", "res", "firstByte", "codePoint", "bytesPerSequence", "secondByte", "thirdByte", "fourthByte", "tempCodePoint", "decodeCodePointsArray", "MAX_ARGUMENTS_LENGTH", "codePoints", "ret", "out", "hexSliceLookupTable", "bytes", "newBuf", "checkOffset", "ext", "noAssert", "mul", "defineBigIntMethod", "validateNumber", "first", "last", "boundsError", "lo", "hi", "checkInt", "min", "maxBytes", "wrtBigUInt64LE", "checkIntBI", "wrtBigUInt64BE", "limit", "sub", "checkIEEE754", "writeFloat", "littleEndian", "writeDouble", "targetStart", "code", "errors", "E", "sym", "getMessage", "Base", "name", "range", "input", "msg", "received", "addNumericalSeparator", "checkBounds", "type", "INVALID_BASE64_RE", "base64clean", "units", "leadSurrogate", "byteArray", "c", "src", "dst", "alphabet", "table", "i16", "fn", "BufferBigIntNotDefined", "require_primordials", "__commonJSMin", "exports", "module", "self", "el", "sep", "fn", "start", "end", "thisArgs", "args", "instance", "props", "name", "prop", "obj", "target", "proto", "thenFn", "catchFn", "err", "val", "value", "buf", "len", "require_browser", "__commonJSMin", "exports", "module", "AbortController", "AbortSignal", "require_events", "__commonJSMin", "exports", "module", "R", "ReflectApply", "__name", "target", "receiver", "args", "ReflectOwnKeys", "ProcessEmitWarning", "warning", "NumberIsNaN", "value", "EventEmitter", "once", "defaultMaxListeners", "checkListener", "listener", "arg", "n", "_getMaxListeners", "that", "type", "doError", "events", "er", "err", "handler", "len", "listeners", "arrayClone", "_addListener", "prepend", "m", "existing", "w", "onceWrapper", "_onceWrap", "state", "wrapped", "list", "position", "i", "originalListener", "spliceOne", "keys", "key", "_listeners", "unwrap", "evlistener", "unwrapListeners", "emitter", "listenerCount", "arr", "copy", "index", "ret", "name", "resolve", "reject", "errorListener", "resolver", "eventTargetAgnosticAddListener", "addErrorHandlerIfEventEmitter", "flags", "wrapListener", "require_util", "__commonJSMin", "exports", "module", "bufferModule", "kResistStopPropagation", "SymbolDispose", "AbortSignal", "AbortController", "AsyncFunction", "Blob", "isBlob", "__name", "b", "validateAbortSignal", "signal", "name", "validateFunction", "value", "AggregateError", "errors", "message", "callback", "called", "args", "resolve", "reject", "res", "rej", "fn", "err", "format", "_unused", "type", "replacement", "arr", "listener", "removeEventListener", "_removeEventListener", "signals", "ac", "abort", "require_errors", "__commonJSMin", "exports", "module", "format", "inspect", "CustomAggregateError", "AggregateError", "kIsNodeError", "kTypes", "classRegExp", "nodeInternalPrefix", "codes", "assert", "value", "message", "__name", "addNumericalSeparator", "val", "res", "i", "start", "getMessage", "key", "msg", "args", "expectedLength", "E", "code", "Base", "NodeError", "hideStackFrames", "fn", "hidden", "aggregateTwoErrors", "innerError", "outerError", "err", "AbortError", "options", "name", "expected", "actual", "types", "instances", "other", "pos", "last", "_actual$constructor", "inspected", "reason", "input", "_value$constructor", "type", "len", "a", "str", "range", "received", "require_validators", "__commonJSMin", "exports", "module", "ArrayIsArray", "ArrayPrototypeIncludes", "ArrayPrototypeJoin", "ArrayPrototypeMap", "NumberIsInteger", "NumberIsNaN", "NumberMAX_SAFE_INTEGER", "NumberMIN_SAFE_INTEGER", "NumberParseInt", "ObjectPrototypeHasOwnProperty", "RegExpPrototypeExec", "String", "StringPrototypeToUpperCase", "StringPrototypeTrim", "hideStackFrames", "ERR_SOCKET_BAD_PORT", "ERR_INVALID_ARG_TYPE", "ERR_INVALID_ARG_VALUE", "ERR_OUT_OF_RANGE", "ERR_UNKNOWN_SIGNAL", "normalizeEncoding", "isAsyncFunction", "isArrayBufferView", "signals", "isInt32", "value", "__name", "isUint32", "octalReg", "modeDesc", "parseFileMode", "name", "def", "validateUint32", "validateInteger", "min", "max", "validateInt32", "positive", "validateString", "validateNumber", "validateOneOf", "oneOf", "reason", "v", "validateBoolean", "getOwnPropertyValueOrDefault", "options", "key", "defaultValue", "validateObject", "allowArray", "allowFunction", "validateDictionary", "validateArray", "minLength", "validateStringArray", "i", "validateBooleanArray", "validateAbortSignalArray", "signal", "indexedName", "validateAbortSignal", "validateSignalName", "validateBuffer", "buffer", "validateEncoding", "data", "encoding", "normalizedEncoding", "length", "validatePort", "port", "allowZero", "validateFunction", "validatePlainFunction", "validateUndefined", "validateUnion", "union", "linkValueRegExp", "validateLinkHeaderFormat", "validateLinkHeaderValue", "hints", "hintsLength", "result", "link", "require_browser", "__commonJSMin", "exports", "module", "process", "cachedSetTimeout", "cachedClearTimeout", "defaultSetTimout", "__name", "defaultClearTimeout", "runTimeout", "fun", "runClearTimeout", "marker", "queue", "draining", "currentQueue", "queueIndex", "cleanUpNextTick", "drainQueue", "timeout", "len", "args", "i", "Item", "array", "noop", "name", "dir", "require_utils", "__commonJSMin", "exports", "module", "SymbolAsyncIterator", "SymbolIterator", "SymbolFor", "kIsDestroyed", "kIsErrored", "kIsReadable", "kIsWritable", "kIsDisturbed", "kIsClosedPromise", "kControllerErrorFunction", "isReadableNodeStream", "obj", "strict", "_obj$_readableState", "__name", "isWritableNodeStream", "_obj$_writableState", "isDuplexNodeStream", "isNodeStream", "isReadableStream", "isWritableStream", "isTransformStream", "isWebStream", "isIterable", "isAsync", "isDestroyed", "stream", "wState", "rState", "state", "isWritableEnded", "isWritableFinished", "isReadableEnded", "isReadableFinished", "isReadable", "isWritable", "isFinished", "opts", "isWritableErrored", "_stream$_writableStat", "_stream$_writableStat2", "isReadableErrored", "_stream$_readableStat", "_stream$_readableStat2", "isClosed", "isOutgoingMessage", "isServerResponse", "isServerRequest", "_stream$req", "willEmitClose", "isDisturbed", "_stream$kIsDisturbed", "isErrored", "_ref", "_ref2", "_ref3", "_ref4", "_ref5", "_stream$kIsErrored", "_stream$_readableStat3", "_stream$_writableStat3", "_stream$_readableStat4", "_stream$_writableStat4", "require_end_of_stream", "__commonJSMin", "exports", "module", "process", "AbortError", "codes", "ERR_INVALID_ARG_TYPE", "ERR_STREAM_PREMATURE_CLOSE", "kEmptyObject", "once", "validateAbortSignal", "validateFunction", "validateObject", "validateBoolean", "Promise", "PromisePrototypeThen", "SymbolDispose", "isClosed", "isReadable", "isReadableNodeStream", "isReadableStream", "isReadableFinished", "isReadableErrored", "isWritable", "isWritableNodeStream", "isWritableStream", "isWritableFinished", "isWritableErrored", "isNodeStream", "_willEmitClose", "kIsClosedPromise", "addAbortListener", "isRequest", "stream", "__name", "nop", "eos", "options", "callback", "_options$readable", "_options$writable", "eosWeb", "readable", "writable", "wState", "rState", "onlegacyfinish", "onfinish", "willEmitClose", "writableFinished", "readableFinished", "onend", "onerror", "err", "closed", "onclose", "errored", "onclosed", "onrequest", "cleanup", "abort", "endCallback", "disposable", "originalCallback", "args", "isAborted", "resolverFn", "finished", "opts", "_opts", "autoCleanup", "resolve", "reject", "require_destroy", "__commonJSMin", "exports", "module", "process", "aggregateTwoErrors", "ERR_MULTIPLE_CALLBACK", "AbortError", "Symbol", "kIsDestroyed", "isDestroyed", "isFinished", "isServerRequest", "kDestroy", "kConstruct", "checkError", "err", "w", "r", "__name", "destroy", "cb", "s", "_destroy", "er", "self", "called", "onDestroy", "emitErrorCloseNT", "emitCloseNT", "emitErrorNT", "undestroy", "errorOrDestroy", "stream", "sync", "construct", "constructNT", "onConstruct", "emitConstructNT", "isRequest", "emitCloseLegacy", "emitErrorCloseLegacy", "destroyer", "require_legacy", "__commonJSMin", "exports", "module", "ArrayIsArray", "ObjectSetPrototypeOf", "EE", "Stream", "opts", "__name", "dest", "options", "source", "ondata", "chunk", "ondrain", "onend", "onclose", "didOnEnd", "onerror", "er", "cleanup", "prependListener", "emitter", "event", "fn", "require_add_abort_signal", "__commonJSMin", "exports", "module", "SymbolDispose", "AbortError", "codes", "isNodeStream", "isWebStream", "kControllerErrorFunction", "eos", "ERR_INVALID_ARG_TYPE", "addAbortListener", "validateAbortSignal", "__name", "signal", "name", "stream", "onAbort", "disposable", "require_buffer_list", "__commonJSMin", "exports", "module", "StringPrototypeSlice", "SymbolIterator", "TypedArrayPrototypeSet", "Uint8Array", "Buffer", "inspect", "__name", "v", "entry", "ret", "s", "p", "n", "i", "hasStrings", "data", "slice", "c", "str", "retLen", "buf", "_", "options", "require_state", "__commonJSMin", "exports", "module", "MathFloor", "NumberIsInteger", "validateInteger", "ERR_INVALID_ARG_VALUE", "defaultHighWaterMarkBytes", "defaultHighWaterMarkObjectMode", "highWaterMarkFrom", "options", "isDuplex", "duplexKey", "__name", "getDefaultHighWaterMark", "objectMode", "setDefaultHighWaterMark", "value", "getHighWaterMark", "state", "hwm", "name", "require_safe_buffer", "__commonJSMin", "exports", "module", "buffer", "Buffer", "copyProps", "src", "dst", "key", "__name", "SafeBuffer", "arg", "encodingOrOffset", "length", "size", "fill", "encoding", "buf", "require_string_decoder", "__commonJSMin", "exports", "Buffer", "isEncoding", "encoding", "_normalizeEncoding", "enc", "retried", "__name", "normalizeEncoding", "nenc", "StringDecoder", "nb", "utf16Text", "utf16End", "utf8FillLast", "base64Text", "base64End", "simpleWrite", "simpleEnd", "buf", "r", "i", "utf8End", "utf8Text", "utf8CheckByte", "byte", "utf8CheckIncomplete", "self", "j", "utf8CheckExtraBytes", "p", "total", "end", "c", "n", "require_from", "__commonJSMin", "exports", "module", "process", "PromisePrototypeThen", "SymbolAsyncIterator", "SymbolIterator", "Buffer", "ERR_INVALID_ARG_TYPE", "ERR_STREAM_NULL_VALUES", "from", "Readable", "iterable", "opts", "iterator", "isAsync", "readable", "reading", "next", "error", "cb", "close", "e", "hadError", "hasThrow", "value", "done", "__name", "res", "err", "require_readable", "__commonJSMin", "exports", "module", "process", "ArrayPrototypeIndexOf", "NumberIsInteger", "NumberIsNaN", "NumberParseInt", "ObjectDefineProperties", "ObjectKeys", "ObjectSetPrototypeOf", "Promise", "SafeSet", "SymbolAsyncDispose", "SymbolAsyncIterator", "Symbol", "Readable", "ReadableState", "EE", "Stream", "prependListener", "Buffer", "addAbortSignal", "eos", "debug", "fn", "BufferList", "destroyImpl", "getHighWaterMark", "getDefaultHighWaterMark", "aggregateTwoErrors", "ERR_INVALID_ARG_TYPE", "ERR_METHOD_NOT_IMPLEMENTED", "ERR_OUT_OF_RANGE", "ERR_STREAM_PUSH_AFTER_EOF", "ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "AbortError", "validateObject", "kPaused", "StringDecoder", "from", "nop", "__name", "errorOrDestroy", "kObjectMode", "kEnded", "kEndEmitted", "kReading", "kConstructed", "kSync", "kNeedReadable", "kEmittedReadable", "kReadableListening", "kResumeScheduled", "kErrorEmitted", "kEmitClose", "kAutoDestroy", "kDestroyed", "kClosed", "kCloseEmitted", "kMultiAwaitDrain", "kReadingMore", "kDataEmitted", "makeBitMapDescriptor", "bit", "value", "options", "stream", "isDuplex", "maybeReadMore", "err", "cb", "error", "resolve", "reject", "chunk", "encoding", "readableAddChunk", "addToFront", "state", "onEofChunk", "addChunk", "emitReadable", "enc", "decoder", "buffer", "content", "data", "MAX_HWM", "computeNewHighWaterMark", "n", "howMuchToRead", "nOrig", "endReadable", "doRead", "ret", "fromList", "emitReadable_", "flow", "maybeReadMore_", "len", "dest", "pipeOpts", "src", "endFn", "onend", "unpipe", "onunpipe", "readable", "unpipeInfo", "cleanup", "ondrain", "cleanedUp", "onclose", "onfinish", "onerror", "ondata", "pause", "pipeOnDrain", "er", "s", "dests", "i", "index", "ev", "res", "nReadingNextTick", "updateReadableListening", "self", "resume", "resume_", "paused", "streamKeys", "j", "streamToAsyncIterator", "iter", "createAsyncIterator", "callback", "next", "val", "endReadableNT", "endWritableNT", "wState", "iterable", "opts", "webStreamsAdapters", "lazyWebStreams", "readableStream", "streamReadable", "_ref", "_src$readableObjectMo", "require_writable", "__commonJSMin", "exports", "module", "process", "ArrayPrototypeSlice", "Error", "FunctionPrototypeSymbolHasInstance", "ObjectDefineProperty", "ObjectDefineProperties", "ObjectSetPrototypeOf", "StringPrototypeToLowerCase", "Symbol", "SymbolHasInstance", "Writable", "WritableState", "EE", "Stream", "Buffer", "destroyImpl", "addAbortSignal", "getHighWaterMark", "getDefaultHighWaterMark", "ERR_INVALID_ARG_TYPE", "ERR_METHOD_NOT_IMPLEMENTED", "ERR_MULTIPLE_CALLBACK", "ERR_STREAM_CANNOT_PIPE", "ERR_STREAM_DESTROYED", "ERR_STREAM_ALREADY_FINISHED", "ERR_STREAM_NULL_VALUES", "ERR_STREAM_WRITE_AFTER_END", "ERR_UNKNOWN_ENCODING", "errorOrDestroy", "nop", "__name", "kOnFinished", "options", "stream", "isDuplex", "noDecode", "onwrite", "resetBuffer", "state", "clearBuffer", "finishMaybe", "object", "_write", "chunk", "encoding", "cb", "err", "writeOrBuffer", "callback", "len", "ret", "doWrite", "writev", "onwriteError", "er", "errorBuffer", "sync", "afterWriteTick", "afterWrite", "count", "_state$errored", "onfinishCallbacks", "i", "_state$errored2", "buffered", "bufferedIndex", "objectMode", "bufferedLength", "n", "chunks", "needFinish", "callFinal", "called", "onFinish", "finish", "prefinish", "rState", "value", "w", "val", "wState", "destroy", "webStreamsAdapters", "lazyWebStreams", "writableStream", "streamWritable", "require_duplexify", "__commonJSMin", "exports", "module", "process", "bufferModule", "isReadable", "isWritable", "isIterable", "isNodeStream", "isReadableNodeStream", "isWritableNodeStream", "isDuplexNodeStream", "isReadableStream", "isWritableStream", "eos", "AbortError", "ERR_INVALID_ARG_TYPE", "ERR_INVALID_RETURN_VALUE", "destroyer", "Duplex", "Readable", "Writable", "createDeferredPromise", "from", "Blob", "isBlob", "__name", "b", "AbortController", "FunctionPrototypeCall", "Duplexify", "options", "duplexify", "body", "name", "_duplexify", "value", "write", "final", "destroy", "fromAsyncGen", "then", "d", "promise", "val", "err", "cb", "readable", "writable", "fn", "resolve", "ac", "signal", "_promise", "chunk", "done", "encoding", "_resolve", "pair", "r", "w", "ondrain", "onfinish", "onreadable", "onclose", "onfinished", "callback", "buf", "require_duplex", "__commonJSMin", "exports", "module", "ObjectDefineProperties", "ObjectGetOwnPropertyDescriptor", "ObjectKeys", "ObjectSetPrototypeOf", "Duplex", "Readable", "Writable", "keys", "i", "method", "options", "__name", "value", "webStreamsAdapters", "lazyWebStreams", "pair", "duplex", "duplexify", "body", "require_transform", "__commonJSMin", "exports", "module", "ObjectSetPrototypeOf", "Symbol", "Transform", "ERR_METHOD_NOT_IMPLEMENTED", "Duplex", "getHighWaterMark", "kCallback", "options", "readableHighWaterMark", "prefinish", "__name", "final", "cb", "er", "data", "chunk", "encoding", "callback", "rState", "wState", "length", "err", "val", "require_passthrough", "__commonJSMin", "exports", "module", "ObjectSetPrototypeOf", "PassThrough", "Transform", "options", "__name", "chunk", "encoding", "cb", "require_pipeline", "__commonJSMin", "exports", "module", "process", "ArrayIsArray", "Promise", "SymbolAsyncIterator", "SymbolDispose", "eos", "once", "destroyImpl", "Duplex", "aggregateTwoErrors", "ERR_INVALID_ARG_TYPE", "ERR_INVALID_RETURN_VALUE", "ERR_MISSING_ARGS", "ERR_STREAM_DESTROYED", "ERR_STREAM_PREMATURE_CLOSE", "AbortError", "validateFunction", "validateAbortSignal", "isIterable", "isReadable", "isReadableNodeStream", "isNodeStream", "isTransformStream", "isWebStream", "isReadableStream", "isReadableFinished", "AbortController", "PassThrough", "Readable", "addAbortListener", "destroyer", "stream", "reading", "writing", "finished", "cleanup", "err", "__name", "popCallback", "streams", "makeAsyncIterable", "val", "fromReadable", "pumpToNode", "iterable", "writable", "finish", "end", "error", "onresolve", "resume", "callback", "wait", "resolve", "reject", "chunk", "pumpToWeb", "readable", "writer", "pipeline", "pipelineImpl", "opts", "ac", "signal", "outerSignal", "lastStreamCleanup", "abort", "finishImpl", "disposable", "value", "destroys", "finishCount", "final", "_disposable", "fn", "ret", "i", "isLastStream", "onError", "destroy", "_ret", "_ret2", "pt", "then", "toRead", "pipe", "src", "dst", "ended", "endFn", "rState", "require_compose", "__commonJSMin", "exports", "module", "pipeline", "Duplex", "destroyer", "isNodeStream", "isReadable", "isWritable", "isWebStream", "isTransformStream", "isWritableStream", "isReadableStream", "AbortError", "ERR_INVALID_ARG_VALUE", "ERR_MISSING_ARGS", "eos", "__name", "streams", "orgStreams", "idx", "n", "ondrain", "onfinish", "onreadable", "onclose", "d", "onfinished", "err", "cb", "readable", "writable", "head", "tail", "chunk", "encoding", "callback", "writer", "toRead", "buf", "reader", "value", "done", "require_operators", "__commonJSMin", "exports", "module", "AbortController", "ERR_INVALID_ARG_VALUE", "ERR_INVALID_ARG_TYPE", "ERR_MISSING_ARGS", "ERR_OUT_OF_RANGE", "AbortError", "validateAbortSignal", "validateInteger", "validateObject", "kWeakHandler", "kResistStopPropagation", "finished", "staticCompose", "addAbortSignalNoValidate", "isWritable", "isNodeStream", "deprecate", "ArrayPrototypePush", "Boolean", "MathFloor", "Number", "NumberIsNaN", "Promise", "PromiseReject", "PromiseResolve", "PromisePrototypeThen", "Symbol", "kEmpty", "kEof", "compose", "stream", "options", "composedStream", "__name", "map", "fn", "concurrency", "highWaterMark", "signal", "queue", "signalOpt", "next", "resume", "done", "cnt", "onCatch", "afterItemProcessed", "maybeResume", "pump", "val", "err", "resolve", "asIndexedPairs", "index", "_options$signal", "some", "unused", "filter", "every", "args", "find", "result", "forEach", "forEachFn", "value", "filterFn", "ReduceAwareErrMissingArgs", "reduce", "reducer", "initialValue", "_options$signal2", "hasInitialValue", "ac", "opts", "gotAnyItemFromStream", "_options$signal3", "toArray", "_options$signal4", "flatMap", "values", "toIntegerOrInfinity", "number", "drop", "_options$signal5", "_options$signal6", "take", "_options$signal7", "_options$signal8", "require_promises", "__commonJSMin", "exports", "module", "ArrayPrototypePop", "Promise", "isIterable", "isNodeStream", "isWebStream", "pl", "finished", "pipeline", "streams", "resolve", "reject", "signal", "end", "lastArg", "options", "err", "value", "__name", "require_stream", "__commonJSMin", "exports", "module", "Buffer", "ObjectDefineProperty", "ObjectKeys", "ReflectApply", "customPromisify", "streamReturningOperators", "promiseReturningOperators", "ERR_ILLEGAL_CONSTRUCTOR", "compose", "setDefaultHighWaterMark", "getDefaultHighWaterMark", "pipeline", "destroyer", "eos", "promises", "utils", "Stream", "key", "fn", "args", "op", "__name", "addAbortSignal", "value", "chunk", "require_browser", "__commonJSMin", "exports", "module", "CustomStream", "promises", "originalDestroy", "src_exports", "__export", "ActionType", "ApiError", "AsyncKeyValueFile", "AsyncKeyValueFileSystem", "AsyncMirror", "BaseFile", "BaseFileSystem", "BigIntStats", "Cred", "ErrorCode", "ErrorStrings", "FileFlag", "FileIndex", "FileSystem", "FileType", "FolderAdapter", "InMemoryFileSystem", "IndexDirInode", "IndexFileInode", "NoSyncFile", "OverlayFS", "PreloadFile", "ROOT_NODE_ID", "SimpleSyncRWTransaction", "Stats", "StatsCommon", "SyncKeyValueFile", "SyncKeyValueFileSystem", "SynchronousFileSystem", "backends", "checkOptions", "configure", "decode", "src_default", "encode", "fs_default", "getFileSystem", "initialize", "isIndexDirInode", "isIndexFileInode", "mkdirpSync", "randomUUID", "registerBackend", "setImmediate", "toPromise", "wait", "emulation_exports", "__export", "BigIntStats", "Dir", "Dirent", "ReadStream", "Stats", "WriteStream", "_toUnixTimestamp", "access", "accessSync", "appendFile", "appendFileSync", "chmod", "chmodSync", "chown", "chownSync", "close", "closeSync", "constants_exports", "copyFile", "copyFileSync", "createReadStream", "createWriteStream", "exists", "existsSync", "fchmod", "fchmodSync", "fchown", "fchownSync", "fdatasync", "fdatasyncSync", "fstat", "fstatSync", "fsync", "fsyncSync", "ftruncate", "ftruncateSync", "futimes", "futimesSync", "getMount", "getMounts", "initialize", "lchmod", "lchmodSync", "lchown", "lchownSync", "link", "linkSync", "lstat", "lstatSync", "lutimes", "lutimesSync", "mkdir", "mkdirSync", "mkdtemp", "mkdtempSync", "mount", "open", "openSync", "opendir", "opendirSync", "promises_exports", "read", "readFile", "readFileSync", "readSync", "readdir", "readdirSync", "readlink", "readlinkSync", "readv", "readvSync", "realpath", "realpathSync", "rename", "renameSync", "rm", "rmSync", "rmdir", "rmdirSync", "stat", "statSync", "symlink", "symlinkSync", "truncate", "truncateSync", "umount", "unlink", "unlinkSync", "unwatchFile", "utimes", "utimesSync", "watch", "watchFile", "write", "writeFile", "writeFileSync", "writeSync", "writev", "writevSync", "cwd", "sep", "validateString", "str", "name", "__name", "normalizeString", "path", "allowAboveRoot", "res", "lastSegmentLength", "lastSlash", "dots", "char", "i", "lastSlashIndex", "__name", "resolve", "args", "resolvedPath", "resolvedAbsolute", "path", "cwd", "validateString", "normalizeString", "__name", "normalize", "isAbsolute", "trailingSeparator", "join", "args", "joined", "i", "arg", "validateString", "normalize", "__name", "relative", "from", "to", "resolve", "fromStart", "fromEnd", "fromLen", "toStart", "toLen", "length", "lastCommonSep", "fromCode", "out", "dirname", "path", "hasRoot", "end", "matchedSlash", "basename", "suffix", "start", "extIdx", "firstNonSlashEnd", "mkdirpSync", "p", "mode", "cred", "fs", "dirname", "__name", "_min", "d0", "d1", "d2", "bx", "ay", "levenshtein", "a", "b", "la", "lb", "offset", "vector", "y", "x", "d3", "bx0", "bx1", "bx2", "bx3", "dd", "dy", "checkOptions", "backend", "opts", "optsInfo", "fsName", "pendingValidators", "callbackCalled", "loopEnded", "optName", "opt", "providedValue", "incorrectOptions", "o", "ApiError", "typeMatches", "e", "wait", "ms", "resolve", "toPromise", "fn", "args", "reject", "cbArgs", "setImmediate", "cb", "ROOT_NODE_ID", "encode", "string", "encoding", "input", "c", "s", "decode", "data", "randomUUID", "r", "ErrorCode", "ErrorStrings", "ApiError", "type", "message", "path", "json", "err", "data", "view", "dataText", "decode", "code", "p", "buffer", "newData", "encode", "__name", "_Cred", "uid", "gid", "suid", "sgid", "euid", "egid", "Cred", "__name", "constants_exports", "__export", "COPYFILE_EXCL", "COPYFILE_FICLONE", "COPYFILE_FICLONE_FORCE", "F_OK", "O_APPEND", "O_CREAT", "O_DIRECT", "O_DIRECTORY", "O_DSYNC", "O_EXCL", "O_NOATIME", "O_NOCTTY", "O_NOFOLLOW", "O_NONBLOCK", "O_RDONLY", "O_RDWR", "O_SYMLINK", "O_SYNC", "O_TRUNC", "O_WRONLY", "R_OK", "S_IFBLK", "S_IFCHR", "S_IFDIR", "S_IFIFO", "S_IFLNK", "S_IFMT", "S_IFREG", "S_IFSOCK", "S_IRGRP", "S_IROTH", "S_IRUSR", "S_IRWXG", "S_IRWXO", "S_IRWXU", "S_IWGRP", "S_IWOTH", "S_IWUSR", "S_IXGRP", "S_IXOTH", "S_IXUSR", "W_OK", "X_OK", "FileType", "StatsCommon", "itemType", "size", "mode", "atimeMs", "mtimeMs", "ctimeMs", "uid", "gid", "birthtimeMs", "currentTime", "resolveT", "__name", "v", "def", "data", "arg", "cred", "perms", "uMode", "gMode", "wMode", "uPerms", "gPerms", "wPerms", "Cred", "Stats", "s", "view", "atime", "mtime", "ctime", "BigIntStats", "ActionType", "_FileFlag", "flag", "ApiError", "mode", "FileFlag", "__name", "BaseFile", "uid", "gid", "atime", "mtime", "PreloadFile", "_fs", "_path", "_flag", "_stat", "contents", "delta", "newPos", "Stats", "len", "buf", "buffer", "offset", "length", "position", "endFp", "newBuffer", "NoSyncFile", "FileSystem", "options", "__name", "_BaseFileSystem", "p", "flag", "cred", "ApiError", "mode", "stats", "fd", "parentStats", "dirname", "oldPath", "newPath", "splitPath", "sep", "i", "addPaths", "join", "len", "FileFlag", "fname", "stat", "buf", "data", "encode", "new_uid", "new_gid", "atime", "mtime", "srcpath", "dstpath", "type", "BaseFileSystem", "SynchronousFileSystem", "flags", "Inode", "id", "size", "mode", "atime", "mtime", "ctime", "uid", "gid", "data", "view", "decode", "Stats", "FileType", "buffer", "encode", "stats", "hasChanged", "atimeMs", "mtimeMs", "ctimeMs", "__name", "SimpleSyncRWTransaction", "store", "key", "val", "data", "overwrite", "value", "__name", "SyncKeyValueFile", "PreloadFile", "_fs", "_path", "_flag", "_stat", "contents", "SyncKeyValueFileSystem", "SynchronousFileSystem", "options", "p", "mode", "cred", "tx", "ApiError", "oldPath", "newPath", "oldParent", "dirname", "oldName", "basename", "newParent", "newName", "oldDirNode", "oldDirList", "nodeId", "newDirNode", "newDirList", "newNameNode", "e", "encode", "stats", "flag", "newFile", "FileType", "node", "FileFlag", "new_uid", "new_gid", "fileInodeId", "fileInode", "inodeChanged", "ROOT_NODE_ID", "currTime", "dirInode", "Inode", "randomUUID", "parent", "filename", "visited", "currentPath", "join", "readDirectory", "inode", "dirList", "resolve", "sep", "id", "decode", "currId", "type", "parentDir", "fname", "parentNode", "dirListing", "fileNode", "dataId", "fileNodeId", "isDir", "parentListing", "fileName", "CreateBackend", "options", "cb", "checkOptions", "fs", "err", "__name", "InMemoryStore", "InMemoryFileSystem", "type", "SimpleSyncRWTransaction", "key", "data", "overwrite", "__name", "_InMemoryFileSystem", "SyncKeyValueFileSystem", "CreateBackend", "_toUnixTimestamp", "time", "__name", "normalizeMode", "mode", "def", "trueMode", "normalizeTime", "ApiError", "normalizePath", "p", "resolve", "normalizeOptions", "options", "defEnc", "defFlag", "defMode", "nop", "cred", "Cred", "setCred", "val", "fdMap", "nextFd", "getFdForFile", "file", "fd", "fd2file", "mounts", "InMemoryFileSystem", "fs", "mount", "getMount", "mountPoint", "getMounts", "umount", "resolveFS", "path", "sortedMounts", "a", "b", "fixPaths", "text", "paths", "from", "to", "fixError", "e", "initialize", "mountMapping", "point", "promises_exports", "__export", "access", "appendFile", "chmod", "chown", "close", "constants_exports", "copyFile", "createReadStream", "createWriteStream", "exists", "fchmod", "fchown", "fdatasync", "fstat", "fsync", "ftruncate", "futimes", "lchmod", "lchown", "link", "lstat", "lutimes", "mkdir", "mkdtemp", "open", "read", "readFile", "readdir", "readlink", "realpath", "rename", "rm", "rmdir", "stat", "symlink", "truncate", "unlink", "unwatchFile", "utimes", "watch", "watchFile", "write", "writeFile", "doOp", "name", "resolveSymlinks", "path", "args", "normalizePath", "fs", "resolvedPath", "resolveFS", "existsSync", "realpathSync", "e", "fixError", "__name", "renameSync", "oldPath", "newPath", "_old", "_new", "paths", "cred", "data", "readFileSync", "writeFileSync", "unlinkSync", "statSync", "options", "stats", "BigIntStats", "lstatSync", "truncateSync", "len", "ApiError", "openSync", "flag", "mode", "file", "FileFlag", "normalizeMode", "getFdForFile", "filename", "arg2", "normalizeOptions", "decode", "arg3", "encodedData", "encode", "appendFileSync", "fstatSync", "fd", "fd2file", "closeSync", "fdMap", "ftruncateSync", "fsyncSync", "fdatasyncSync", "writeSync", "arg4", "arg5", "buffer", "offset", "length", "position", "encoding", "readSync", "opts", "fchownSync", "uid", "gid", "fchmodSync", "numMode", "futimesSync", "atime", "mtime", "normalizeTime", "rmdirSync", "mkdirSync", "recursive", "readdirSync", "entries", "mount", "mounts", "entry", "Dirent", "join", "linkSync", "srcpath", "dstpath", "symlinkSync", "type", "readlinkSync", "value", "chownSync", "lchownSync", "chmodSync", "lchmodSync", "utimesSync", "lutimesSync", "mountPoint", "dst", "accessSync", "rmSync", "mkdtempSync", "prefix", "copyFileSync", "src", "dest", "flags", "readvSync", "buffers", "writevSync", "opendirSync", "Dirent", "name", "stats", "__name", "Dir", "path", "ApiError", "cb", "readdir", "value", "readdirSync", "_this", "doOp", "name", "resolveSymlinks", "path", "args", "normalizePath", "fs", "resolvedPath", "resolveFS", "exists", "realpath", "e", "fixError", "__name", "rename", "oldPath", "newPath", "_old", "_new", "paths", "cred", "data", "readFile", "writeFile", "unlink", "stat", "options", "stats", "BigIntStats", "lstat", "truncate", "len", "ApiError", "open", "flag", "mode", "file", "FileFlag", "normalizeMode", "getFdForFile", "filename", "arg2", "normalizeOptions", "decode", "arg3", "encodedData", "encode", "appendFile", "fstat", "fd", "fd2file", "close", "fdMap", "ftruncate", "fsync", "fdatasync", "write", "arg4", "arg5", "buffer", "offset", "length", "position", "encoding", "read", "fchown", "uid", "gid", "fchmod", "numMode", "futimes", "atime", "mtime", "normalizeTime", "rmdir", "mkdir", "readdir", "entries", "points", "mounts", "point", "entry", "values", "Dirent", "join", "link", "srcpath", "dstpath", "symlink", "type", "readlink", "value", "chown", "lchown", "chmod", "lchmod", "utimes", "lutimes", "mountPoint", "dst", "watchFile", "listener", "nop", "unwatchFile", "watch", "access", "createReadStream", "createWriteStream", "rm", "mkdtemp", "copyFile", "rename", "oldPath", "newPath", "cb", "nop", "__name", "exists", "path", "stat", "options", "callback", "stats", "lstat", "truncate", "arg2", "unlink", "open", "flag", "mode", "normalizeMode", "fd", "readFile", "filename", "writeFile", "data", "arg3", "appendFile", "fstat", "close", "ftruncate", "length", "fsync", "fdatasync", "write", "arg4", "arg5", "buffer", "offset", "position", "encoding", "ApiError", "encode", "_cb", "bytesWritten", "decode", "read", "bytesRead", "fchown", "uid", "gid", "fchmod", "futimes", "atime", "mtime", "rmdir", "mkdir", "readdir", "_options", "entries", "link", "srcpath", "dstpath", "symlink", "type", "readlink", "result", "chown", "lchown", "chmod", "lchmod", "utimes", "lutimes", "realpath", "access", "watchFile", "listener", "unwatchFile", "watch", "createReadStream", "createWriteStream", "rm", "mkdtemp", "copyFile", "src", "dest", "flags", "readv", "writev", "buffers", "opendir", "import_readable_stream", "ReadStream", "callback", "err", "event", "listener", "__name", "WriteStream", "fs", "emulation_exports", "fs_default", "MirrorFile", "PreloadFile", "fs", "path", "flag", "stat", "data", "__name", "_AsyncMirror", "SynchronousFileSystem", "sync", "async", "fd", "stats", "FileFlag", "oldPath", "newPath", "cred", "p", "mode", "new_uid", "new_gid", "atime", "mtime", "copyDirectory", "Cred", "files", "file", "copyItem", "join", "copyFile", "e", "op", "doNextOp", "err", "AsyncMirror", "CreateBackend", "v", "ApiError", "_FolderAdapter", "BaseFileSystem", "folder", "wrapped", "Cred", "ApiError", "FolderAdapter", "__name", "CreateBackend", "translateError", "err", "p", "relative", "wrapCallback", "cb", "wrapFunction", "name", "wrapFirst", "wrapSecond", "join", "e", "Mutex", "path", "resolve", "next", "__name", "LockedFS", "fs", "Mutex", "oldPath", "newPath", "cred", "p", "stats", "mode", "flag", "fd", "files", "exists", "resolvedPath", "len", "fname", "data", "new_uid", "new_gid", "atime", "mtime", "srcpath", "dstpath", "type", "linkString", "__name", "deletionLogPath", "makeModeWritable", "mode", "__name", "getFlag", "f", "FileFlag", "OverlayFile", "PreloadFile", "fs", "path", "flag", "stats", "data", "UnlockedOverlayFS", "BaseFileSystem", "writable", "readable", "ApiError", "OverlayFS", "file", "Cred", "decode", "err", "log", "cred", "oldPath", "newPath", "oldStats", "name", "resolve", "p", "oldStat", "Stats", "buf", "contents", "fPath", "seenMap", "fileP", "result", "new_uid", "new_gid", "atime", "mtime", "addition", "encode", "e", "parent", "dirname", "toCreate", "pStats", "_OverlayFS", "LockedFS", "options", "CreateBackend", "backends", "registerBackend", "_backends", "backend", "backends", "__name", "AsyncMirror", "FolderAdapter", "InMemoryFileSystem", "OverlayFS", "LRUNode", "key", "value", "__name", "LRUCache", "limit", "node", "AsyncKeyValueFile", "PreloadFile", "_fs", "_path", "_flag", "_stat", "contents", "AsyncKeyValueFileSystem", "BaseFileSystem", "cacheSize", "store", "p", "mode", "cred", "tx", "inode", "ApiError", "oldPath", "newPath", "c", "oldParent", "dirname", "oldName", "basename", "newParent", "newName", "oldDirNode", "oldDirList", "nodeId", "newDirNode", "newDirList", "newNameNode", "e", "encode", "stats", "flag", "data", "newFile", "FileType", "FileFlag", "new_uid", "new_gid", "fileInodeId", "fileInode", "inodeChanged", "ROOT_NODE_ID", "currTime", "dirInode", "Inode", "randomUUID", "parent", "filename", "visited", "currentPath", "join", "id", "dirList", "resolve", "decode", "retries", "reroll", "currId", "type", "parentDir", "fname", "parentNode", "dirListing", "dataId", "fileNode", "fileNodeId", "isDir", "parentListing", "fileName", "FileIndex", "listing", "idx", "rootInode", "IndexDirInode", "queue", "inode", "next", "pwd", "tree", "parent", "node", "children", "name", "IndexFileInode", "Stats", "FileType", "cb", "path", "dir", "files", "file", "item", "isIndexFileInode", "splitPath", "dirpath", "itemname", "isIndexDirInode", "itemNameMark", "parentPath", "itemName", "child", "p", "dirname", "__name", "data", "initialize", "mounts", "uid", "gid", "setCred", "Cred", "fs_default", "__name", "_configure", "config", "FileSystem", "point", "value", "getFileSystem", "configure", "cb", "err", "_getFileSystem", "fsName", "options", "ApiError", "props", "k", "prop", "opt", "fs", "fsc", "backends", "src_default", "fs_default"]
}