Skip to content

Instantly share code, notes, and snippets.

@guest271314
Last active January 20, 2024 04:00
Show Gist options
  • Save guest271314/08b19ba88c98a465dd09bcd8a04606f6 to your computer and use it in GitHub Desktop.
Save guest271314/08b19ba88c98a465dd09bcd8a04606f6 to your computer and use it in GitHub Desktop.
feross/buffer bundled to Ecmascript Module
// git clone https://github.com/feross/buffer
// cd buffer
// bun install base64-js ieee754
// bun build ./index.js --target=browser --outfile=buffer.js
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
// node_modules/base64-js/index.js
var require_base64_js = __commonJS((exports) => {
var getLens = function(b64) {
var len2 = b64.length;
if (len2 % 4 > 0) {
throw new Error("Invalid string. Length must be a multiple of 4");
}
var validLen = b64.indexOf("=");
if (validLen === -1)
validLen = len2;
var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
return [validLen, placeHoldersLen];
};
var byteLength = function(b64) {
var lens = getLens(b64);
var validLen = lens[0];
var placeHoldersLen = lens[1];
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
};
var _byteLength = function(b64, validLen, placeHoldersLen) {
return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
};
var toByteArray = function(b64) {
var tmp;
var lens = getLens(b64);
var validLen = lens[0];
var placeHoldersLen = lens[1];
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
var curByte = 0;
var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
var i2;
for (i2 = 0;i2 < len2; i2 += 4) {
tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
arr[curByte++] = tmp >> 16 & 255;
arr[curByte++] = tmp >> 8 & 255;
arr[curByte++] = tmp & 255;
}
if (placeHoldersLen === 2) {
tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
arr[curByte++] = tmp & 255;
}
if (placeHoldersLen === 1) {
tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
arr[curByte++] = tmp >> 8 & 255;
arr[curByte++] = tmp & 255;
}
return arr;
};
var tripletToBase64 = function(num) {
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
};
var encodeChunk = function(uint8, start, end) {
var tmp;
var output = [];
for (var i2 = start;i2 < end; i2 += 3) {
tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
output.push(tripletToBase64(tmp));
}
return output.join("");
};
var fromByteArray = function(uint8) {
var tmp;
var len2 = uint8.length;
var extraBytes = len2 % 3;
var parts = [];
var maxChunkLength = 16383;
for (var i2 = 0, len22 = len2 - extraBytes;i2 < len22; i2 += maxChunkLength) {
parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
}
if (extraBytes === 1) {
tmp = uint8[len2 - 1];
parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
} else if (extraBytes === 2) {
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
}
return parts.join("");
};
exports.byteLength = byteLength;
exports.toByteArray = toByteArray;
exports.fromByteArray = fromByteArray;
var lookup = [];
var revLookup = [];
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
for (i = 0, len = code.length;i < len; ++i) {
lookup[i] = code[i];
revLookup[code.charCodeAt(i)] = i;
}
var i;
var len;
revLookup["-".charCodeAt(0)] = 62;
revLookup["_".charCodeAt(0)] = 63;
});
// node_modules/ieee754/index.js
var require_ieee754 = __commonJS((exports) => {
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
var e, m;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var nBits = -7;
var i = isLE ? nBytes - 1 : 0;
var d = isLE ? -1 : 1;
var s = buffer[offset + i];
i += d;
e = s & (1 << -nBits) - 1;
s >>= -nBits;
nBits += eLen;
for (;nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
}
m = e & (1 << -nBits) - 1;
e >>= -nBits;
nBits += mLen;
for (;nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
}
if (e === 0) {
e = 1 - eBias;
} else if (e === eMax) {
return m ? NaN : (s ? -1 : 1) * Infinity;
} else {
m = m + Math.pow(2, mLen);
e = e - eBias;
}
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
};
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
var e, m, c;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
var i = isLE ? 0 : nBytes - 1;
var d = isLE ? 1 : -1;
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
value = Math.abs(value);
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0;
e = eMax;
} else {
e = Math.floor(Math.log(value) / Math.LN2);
if (value * (c = Math.pow(2, -e)) < 1) {
e--;
c *= 2;
}
if (e + eBias >= 1) {
value += rt / c;
} else {
value += rt * Math.pow(2, 1 - eBias);
}
if (value * c >= 2) {
e++;
c /= 2;
}
if (e + eBias >= eMax) {
m = 0;
e = eMax;
} else if (e + eBias >= 1) {
m = (value * c - 1) * Math.pow(2, mLen);
e = e + eBias;
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
e = 0;
}
}
for (;mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
}
e = e << mLen | m;
eLen += mLen;
for (;eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
}
buffer[offset + i - d] |= s * 128;
};
});
// index.js
var typedArraySupport = function() {
try {
const arr = new Uint8Array(1);
const proto = { foo: function() {
return 42;
} };
Object.setPrototypeOf(proto, Uint8Array.prototype);
Object.setPrototypeOf(arr, proto);
return arr.foo() === 42;
} catch (e) {
return false;
}
};
var createBuffer = function(length) {
if (length > K_MAX_LENGTH) {
throw new RangeError('The value "' + length + '" is invalid for option "size"');
}
const buf = new Uint8Array(length);
Object.setPrototypeOf(buf, Buffer.prototype);
return buf;
};
var Buffer = function(arg, encodingOrOffset, length) {
if (typeof arg === "number") {
if (typeof encodingOrOffset === "string") {
throw new TypeError('The "string" argument must be of type string. Received type number');
}
return allocUnsafe(arg);
}
return from(arg, encodingOrOffset, length);
};
var from = function(value, encodingOrOffset, length) {
if (typeof value === "string") {
return fromString(value, encodingOrOffset);
}
if (ArrayBuffer.isView(value)) {
return fromArrayView(value);
}
if (value == null) {
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
}
if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
return fromArrayBuffer(value, encodingOrOffset, length);
}
if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
return fromArrayBuffer(value, encodingOrOffset, length);
}
if (typeof value === "number") {
throw new TypeError('The "value" argument must not be of type number. Received type number');
}
const valueOf = value.valueOf && value.valueOf();
if (valueOf != null && valueOf !== value) {
return Buffer.from(valueOf, encodingOrOffset, length);
}
const b = fromObject(value);
if (b)
return b;
if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
return Buffer.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
}
throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
};
var assertSize = function(size) {
if (typeof size !== "number") {
throw new TypeError('"size" argument must be of type number');
} else if (size < 0) {
throw new RangeError('The value "' + size + '" is invalid for option "size"');
}
};
var alloc = function(size, fill, encoding) {
assertSize(size);
if (size <= 0) {
return createBuffer(size);
}
if (fill !== undefined) {
return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
}
return createBuffer(size);
};
var allocUnsafe = function(size) {
assertSize(size);
return createBuffer(size < 0 ? 0 : checked(size) | 0);
};
var fromString = function(string, encoding) {
if (typeof encoding !== "string" || encoding === "") {
encoding = "utf8";
}
if (!Buffer.isEncoding(encoding)) {
throw new TypeError("Unknown encoding: " + encoding);
}
const length = byteLength(string, encoding) | 0;
let buf = createBuffer(length);
const actual = buf.write(string, encoding);
if (actual !== length) {
buf = buf.slice(0, actual);
}
return buf;
};
var fromArrayLike = function(array) {
const length = array.length < 0 ? 0 : checked(array.length) | 0;
const buf = createBuffer(length);
for (let i = 0;i < length; i += 1) {
buf[i] = array[i] & 255;
}
return buf;
};
var fromArrayView = function(arrayView) {
if (isInstance(arrayView, Uint8Array)) {
const copy = new Uint8Array(arrayView);
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
}
return fromArrayLike(arrayView);
};
var fromArrayBuffer = function(array, byteOffset, length) {
if (byteOffset < 0 || array.byteLength < byteOffset) {
throw new RangeError('"offset" is outside of buffer bounds');
}
if (array.byteLength < byteOffset + (length || 0)) {
throw new RangeError('"length" is outside of buffer bounds');
}
let buf;
if (byteOffset === undefined && length === undefined) {
buf = new Uint8Array(array);
} else if (length === undefined) {
buf = new Uint8Array(array, byteOffset);
} else {
buf = new Uint8Array(array, byteOffset, length);
}
Object.setPrototypeOf(buf, Buffer.prototype);
return buf;
};
var fromObject = function(obj) {
if (Buffer.isBuffer(obj)) {
const len = checked(obj.length) | 0;
const buf = createBuffer(len);
if (buf.length === 0) {
return buf;
}
obj.copy(buf, 0, 0, len);
return buf;
}
if (obj.length !== undefined) {
if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
return createBuffer(0);
}
return fromArrayLike(obj);
}
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
return fromArrayLike(obj.data);
}
};
var checked = function(length) {
if (length >= K_MAX_LENGTH) {
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
}
return length | 0;
};
var SlowBuffer = function(length) {
if (+length != length) {
length = 0;
}
return Buffer.alloc(+length);
};
var byteLength = function(string, encoding) {
if (Buffer.isBuffer(string)) {
return string.length;
}
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
return string.byteLength;
}
if (typeof string !== "string") {
throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string);
}
const len = string.length;
const mustMatch = arguments.length > 2 && arguments[2] === true;
if (!mustMatch && len === 0)
return 0;
let loweredCase = false;
for (;; ) {
switch (encoding) {
case "ascii":
case "latin1":
case "binary":
return len;
case "utf8":
case "utf-8":
return utf8ToBytes(string).length;
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return len * 2;
case "hex":
return len >>> 1;
case "base64":
return base64ToBytes(string).length;
default:
if (loweredCase) {
return mustMatch ? -1 : utf8ToBytes(string).length;
}
encoding = ("" + encoding).toLowerCase();
loweredCase = true;
}
}
};
var slowToString = function(encoding, start, end) {
let loweredCase = false;
if (start === undefined || start < 0) {
start = 0;
}
if (start > this.length) {
return "";
}
if (end === undefined || end > this.length) {
end = this.length;
}
if (end <= 0) {
return "";
}
end >>>= 0;
start >>>= 0;
if (end <= start) {
return "";
}
if (!encoding)
encoding = "utf8";
while (true) {
switch (encoding) {
case "hex":
return hexSlice(this, start, end);
case "utf8":
case "utf-8":
return utf8Slice(this, start, end);
case "ascii":
return asciiSlice(this, start, end);
case "latin1":
case "binary":
return latin1Slice(this, start, end);
case "base64":
return base64Slice(this, start, end);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return utf16leSlice(this, start, end);
default:
if (loweredCase)
throw new TypeError("Unknown encoding: " + encoding);
encoding = (encoding + "").toLowerCase();
loweredCase = true;
}
}
};
var swap = function(b, n, m) {
const i = b[n];
b[n] = b[m];
b[m] = i;
};
var bidirectionalIndexOf = function(buffer, val, byteOffset, encoding, dir) {
if (buffer.length === 0)
return -1;
if (typeof byteOffset === "string") {
encoding = byteOffset;
byteOffset = 0;
} else if (byteOffset > 2147483647) {
byteOffset = 2147483647;
} else if (byteOffset < -2147483648) {
byteOffset = -2147483648;
}
byteOffset = +byteOffset;
if (numberIsNaN(byteOffset)) {
byteOffset = dir ? 0 : buffer.length - 1;
}
if (byteOffset < 0)
byteOffset = buffer.length + byteOffset;
if (byteOffset >= buffer.length) {
if (dir)
return -1;
else
byteOffset = buffer.length - 1;
} else if (byteOffset < 0) {
if (dir)
byteOffset = 0;
else
return -1;
}
if (typeof val === "string") {
val = Buffer.from(val, encoding);
}
if (Buffer.isBuffer(val)) {
if (val.length === 0) {
return -1;
}
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
} else if (typeof val === "number") {
val = val & 255;
if (typeof Uint8Array.prototype.indexOf === "function") {
if (dir) {
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
} else {
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
}
}
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
}
throw new TypeError("val must be string, number or Buffer");
};
var arrayIndexOf = function(arr, val, byteOffset, encoding, dir) {
let indexSize = 1;
let arrLength = arr.length;
let valLength = val.length;
if (encoding !== undefined) {
encoding = String(encoding).toLowerCase();
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
if (arr.length < 2 || val.length < 2) {
return -1;
}
indexSize = 2;
arrLength /= 2;
valLength /= 2;
byteOffset /= 2;
}
}
function read(buf, i2) {
if (indexSize === 1) {
return buf[i2];
} else {
return buf.readUInt16BE(i2 * indexSize);
}
}
let i;
if (dir) {
let foundIndex = -1;
for (i = byteOffset;i < arrLength; i++) {
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
if (foundIndex === -1)
foundIndex = i;
if (i - foundIndex + 1 === valLength)
return foundIndex * indexSize;
} else {
if (foundIndex !== -1)
i -= i - foundIndex;
foundIndex = -1;
}
}
} else {
if (byteOffset + valLength > arrLength)
byteOffset = arrLength - valLength;
for (i = byteOffset;i >= 0; i--) {
let found = true;
for (let j = 0;j < valLength; j++) {
if (read(arr, i + j) !== read(val, j)) {
found = false;
break;
}
}
if (found)
return i;
}
}
return -1;
};
var hexWrite = function(buf, string, offset, length) {
offset = Number(offset) || 0;
const remaining = buf.length - offset;
if (!length) {
length = remaining;
} else {
length = Number(length);
if (length > remaining) {
length = remaining;
}
}
const strLen = string.length;
if (length > strLen / 2) {
length = strLen / 2;
}
let i;
for (i = 0;i < length; ++i) {
const a = hexCharValueTable[string[i * 2]];
const b = hexCharValueTable[string[i * 2 + 1]];
if (a === undefined || b === undefined) {
return i;
}
buf[offset + i] = a << 4 | b;
}
return i;
};
var utf8Write = function(buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
};
var asciiWrite = function(buf, string, offset, length) {
return blitBuffer(asciiToBytes(string), buf, offset, length);
};
var base64Write = function(buf, string, offset, length) {
return blitBuffer(base64ToBytes(string), buf, offset, length);
};
var ucs2Write = function(buf, string, offset, length) {
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
};
var base64Slice = function(buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.fromByteArray(buf);
} else {
return base64.fromByteArray(buf.slice(start, end));
}
};
var utf8Slice = function(buf, start, end) {
end = Math.min(buf.length, end);
const res = [];
let i = start;
while (i < end) {
const firstByte = buf[i];
let codePoint = null;
let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
if (i + bytesPerSequence <= end) {
let secondByte, thirdByte, fourthByte, tempCodePoint;
switch (bytesPerSequence) {
case 1:
if (firstByte < 128) {
codePoint = firstByte;
}
break;
case 2:
secondByte = buf[i + 1];
if ((secondByte & 192) === 128) {
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
if (tempCodePoint > 127) {
codePoint = tempCodePoint;
}
}
break;
case 3:
secondByte = buf[i + 1];
thirdByte = buf[i + 2];
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
codePoint = tempCodePoint;
}
}
break;
case 4:
secondByte = buf[i + 1];
thirdByte = buf[i + 2];
fourthByte = buf[i + 3];
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
codePoint = tempCodePoint;
}
}
}
}
if (codePoint === null) {
codePoint = 65533;
bytesPerSequence = 1;
} else if (codePoint > 65535) {
codePoint -= 65536;
res.push(codePoint >>> 10 & 1023 | 55296);
codePoint = 56320 | codePoint & 1023;
}
res.push(codePoint);
i += bytesPerSequence;
}
return decodeCodePointsArray(res);
};
var decodeCodePointsArray = function(codePoints) {
const len = codePoints.length;
if (len <= MAX_ARGUMENTS_LENGTH) {
return String.fromCharCode.apply(String, codePoints);
}
let res = "";
let i = 0;
while (i < len) {
res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
}
return res;
};
var asciiSlice = function(buf, start, end) {
let ret = "";
end = Math.min(buf.length, end);
for (let i = start;i < end; ++i) {
ret += String.fromCharCode(buf[i] & 127);
}
return ret;
};
var latin1Slice = function(buf, start, end) {
let ret = "";
end = Math.min(buf.length, end);
for (let i = start;i < end; ++i) {
ret += String.fromCharCode(buf[i]);
}
return ret;
};
var hexSlice = function(buf, start, end) {
const len = buf.length;
if (!start || start < 0)
start = 0;
if (!end || end < 0 || end > len)
end = len;
let out = "";
for (let i = start;i < end; ++i) {
out += hexSliceLookupTable[buf[i]];
}
return out;
};
var utf16leSlice = function(buf, start, end) {
const bytes = buf.slice(start, end);
let res = "";
for (let i = 0;i < bytes.length - 1; i += 2) {
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
}
return res;
};
var checkOffset = function(offset, ext, length) {
if (offset % 1 !== 0 || offset < 0)
throw new RangeError("offset is not uint");
if (offset + ext > length)
throw new RangeError("Trying to access beyond buffer length");
};
var checkInt = function(buf, value, offset, ext, max, min) {
if (!Buffer.isBuffer(buf))
throw new TypeError('"buffer" argument must be a Buffer instance');
if (value > max || value < min)
throw new RangeError('"value" argument is out of bounds');
if (offset + ext > buf.length)
throw new RangeError("Index out of range");
};
var wrtBigUInt64LE = function(buf, value, offset, min, max) {
checkIntBI(value, min, max, buf, offset, 7);
let lo = Number(value & BigInt(4294967295));
buf[offset++] = lo;
lo = lo >> 8;
buf[offset++] = lo;
lo = lo >> 8;
buf[offset++] = lo;
lo = lo >> 8;
buf[offset++] = lo;
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
buf[offset++] = hi;
hi = hi >> 8;
buf[offset++] = hi;
hi = hi >> 8;
buf[offset++] = hi;
hi = hi >> 8;
buf[offset++] = hi;
return offset;
};
var wrtBigUInt64BE = function(buf, value, offset, min, max) {
checkIntBI(value, min, max, buf, offset, 7);
let lo = Number(value & BigInt(4294967295));
buf[offset + 7] = lo;
lo = lo >> 8;
buf[offset + 6] = lo;
lo = lo >> 8;
buf[offset + 5] = lo;
lo = lo >> 8;
buf[offset + 4] = lo;
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
buf[offset + 3] = hi;
hi = hi >> 8;
buf[offset + 2] = hi;
hi = hi >> 8;
buf[offset + 1] = hi;
hi = hi >> 8;
buf[offset] = hi;
return offset + 8;
};
var checkIEEE754 = function(buf, value, offset, ext, max, min) {
if (offset + ext > buf.length)
throw new RangeError("Index out of range");
if (offset < 0)
throw new RangeError("Index out of range");
};
var writeFloat = function(buf, value, offset, littleEndian, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert) {
checkIEEE754(buf, value, offset, 4, 340282346638528860000000000000000000000, -340282346638528860000000000000000000000);
}
ieee754.write(buf, value, offset, littleEndian, 23, 4);
return offset + 4;
};
var writeDouble = function(buf, value, offset, littleEndian, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert) {
checkIEEE754(buf, value, offset, 8, 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, -179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
}
ieee754.write(buf, value, offset, littleEndian, 52, 8);
return offset + 8;
};
var E = function(sym, getMessage, Base) {
errors[sym] = class NodeError extends Base {
constructor() {
super();
Object.defineProperty(this, "message", {
value: getMessage.apply(this, arguments),
writable: true,
configurable: true
});
this.name = `${this.name} [${sym}]`;
this.stack;
delete this.name;
}
get code() {
return sym;
}
set code(value) {
Object.defineProperty(this, "code", {
configurable: true,
enumerable: true,
value,
writable: true
});
}
toString() {
return `${this.name} [${sym}]: ${this.message}`;
}
};
};
var addNumericalSeparator = function(val) {
let res = "";
let i = val.length;
const start = val[0] === "-" ? 1 : 0;
for (;i >= start + 4; i -= 3) {
res = `_${val.slice(i - 3, i)}${res}`;
}
return `${val.slice(0, i)}${res}`;
};
var checkBounds = function(buf, offset, byteLength2) {
validateNumber(offset, "offset");
if (buf[offset] === undefined || buf[offset + byteLength2] === undefined) {
boundsError(offset, buf.length - (byteLength2 + 1));
}
};
var checkIntBI = function(value, min, max, buf, offset, byteLength2) {
if (value > max || value < min) {
const n = typeof min === "bigint" ? "n" : "";
let range;
if (byteLength2 > 3) {
if (min === 0 || min === BigInt(0)) {
range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
} else {
range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ` + `${(byteLength2 + 1) * 8 - 1}${n}`;
}
} else {
range = `>= ${min}${n} and <= ${max}${n}`;
}
throw new errors.ERR_OUT_OF_RANGE("value", range, value);
}
checkBounds(buf, offset, byteLength2);
};
var validateNumber = function(value, name) {
if (typeof value !== "number") {
throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
}
};
var boundsError = function(value, length, type) {
if (Math.floor(value) !== value) {
validateNumber(value, type);
throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
}
if (length < 0) {
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS;
}
throw new errors.ERR_OUT_OF_RANGE(type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value);
};
var base64clean = function(str) {
str = str.split("=")[0];
str = str.trim().replace(INVALID_BASE64_RE, "");
if (str.length < 2)
return "";
while (str.length % 4 !== 0) {
str = str + "=";
}
return str;
};
var utf8ToBytes = function(string, units) {
units = units || Infinity;
let codePoint;
const length = string.length;
let leadSurrogate = null;
const bytes = [];
for (let i = 0;i < length; ++i) {
codePoint = string.charCodeAt(i);
if (codePoint > 55295 && codePoint < 57344) {
if (!leadSurrogate) {
if (codePoint > 56319) {
if ((units -= 3) > -1)
bytes.push(239, 191, 189);
continue;
} else if (i + 1 === length) {
if ((units -= 3) > -1)
bytes.push(239, 191, 189);
continue;
}
leadSurrogate = codePoint;
continue;
}
if (codePoint < 56320) {
if ((units -= 3) > -1)
bytes.push(239, 191, 189);
leadSurrogate = codePoint;
continue;
}
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
} else if (leadSurrogate) {
if ((units -= 3) > -1)
bytes.push(239, 191, 189);
}
leadSurrogate = null;
if (codePoint < 128) {
if ((units -= 1) < 0)
break;
bytes.push(codePoint);
} else if (codePoint < 2048) {
if ((units -= 2) < 0)
break;
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
} else if (codePoint < 65536) {
if ((units -= 3) < 0)
break;
bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
} else if (codePoint < 1114112) {
if ((units -= 4) < 0)
break;
bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
} else {
throw new Error("Invalid code point");
}
}
return bytes;
};
var asciiToBytes = function(str) {
const byteArray = [];
for (let i = 0;i < str.length; ++i) {
byteArray.push(str.charCodeAt(i) & 255);
}
return byteArray;
};
var utf16leToBytes = function(str, units) {
let c, hi, lo;
const byteArray = [];
for (let i = 0;i < str.length; ++i) {
if ((units -= 2) < 0)
break;
c = str.charCodeAt(i);
hi = c >> 8;
lo = c % 256;
byteArray.push(lo);
byteArray.push(hi);
}
return byteArray;
};
var base64ToBytes = function(str) {
return base64.toByteArray(base64clean(str));
};
var blitBuffer = function(src, dst, offset, length) {
let i;
for (i = 0;i < length; ++i) {
if (i + offset >= dst.length || i >= src.length)
break;
dst[i + offset] = src[i];
}
return i;
};
var isInstance = function(obj, type) {
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
};
var numberIsNaN = function(obj) {
return obj !== obj;
};
var defineBigIntMethod = function(fn) {
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
};
var BufferBigIntNotDefined = function() {
throw new Error("BigInt not supported");
};
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
var base64 = require_base64_js();
var ieee754 = require_ieee754();
var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
var $Buffer = Buffer;
var $SlowBuffer = SlowBuffer;
var $INSPECT_MAX_BYTES = 50;
var K_MAX_LENGTH = 2147483647;
var $kMaxLength = K_MAX_LENGTH;
var K_STRING_MAX_LENGTH = (1 << 28) - 16;
var $kStringMaxLength = K_STRING_MAX_LENGTH;
var $constants = {
MAX_LENGTH: K_MAX_LENGTH,
MAX_STRING_LENGTH: K_STRING_MAX_LENGTH
};
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");
}
Object.defineProperty(Buffer.prototype, "parent", {
enumerable: true,
get: function() {
if (!Buffer.isBuffer(this))
return;
return this.buffer;
}
});
Object.defineProperty(Buffer.prototype, "offset", {
enumerable: true,
get: function() {
if (!Buffer.isBuffer(this))
return;
return this.byteOffset;
}
});
Buffer.poolSize = 8192;
Buffer.from = function(value, encodingOrOffset, length) {
return from(value, encodingOrOffset, length);
};
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
Object.setPrototypeOf(Buffer, Uint8Array);
Buffer.alloc = function(size, fill, encoding) {
return alloc(size, fill, encoding);
};
Buffer.allocUnsafe = function(size) {
return allocUnsafe(size);
};
Buffer.allocUnsafeSlow = function(size) {
return allocUnsafe(size);
};
Buffer.isBuffer = function isBuffer(b) {
return b != null && b._isBuffer === true && b !== Buffer.prototype;
};
Buffer.compare = function compare(a, b) {
if (isInstance(a, Uint8Array))
a = Buffer.from(a, a.offset, a.byteLength);
if (isInstance(b, Uint8Array))
b = Buffer.from(b, b.offset, b.byteLength);
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
}
if (a === b)
return 0;
let x = a.length;
let y = b.length;
for (let i = 0, len = Math.min(x, y);i < len; ++i) {
if (a[i] !== b[i]) {
x = a[i];
y = b[i];
break;
}
}
if (x < y)
return -1;
if (y < x)
return 1;
return 0;
};
Buffer.isEncoding = function isEncoding(encoding) {
switch (String(encoding).toLowerCase()) {
case "hex":
case "utf8":
case "utf-8":
case "ascii":
case "latin1":
case "binary":
case "base64":
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return true;
default:
return false;
}
};
Buffer.concat = function concat(list, length) {
if (!Array.isArray(list)) {
throw new TypeError('"list" argument must be an Array of Buffers');
}
if (list.length === 0) {
return Buffer.alloc(0);
}
let i;
if (length === undefined) {
length = 0;
for (i = 0;i < list.length; ++i) {
length += list[i].length;
}
}
const buffer = Buffer.allocUnsafe(length);
let pos = 0;
for (i = 0;i < list.length; ++i) {
let buf = list[i];
if (isInstance(buf, Uint8Array)) {
if (pos + buf.length > buffer.length) {
if (!Buffer.isBuffer(buf)) {
buf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
}
buf.copy(buffer, pos);
} else {
Uint8Array.prototype.set.call(buffer, buf, pos);
}
} else if (!Buffer.isBuffer(buf)) {
throw new TypeError('"list" argument must be an Array of Buffers');
} else {
buf.copy(buffer, pos);
}
pos += buf.length;
}
return buffer;
};
Buffer.byteLength = byteLength;
Buffer.prototype._isBuffer = true;
Buffer.prototype.swap16 = function swap16() {
const len = this.length;
if (len % 2 !== 0) {
throw new RangeError("Buffer size must be a multiple of 16-bits");
}
for (let i = 0;i < len; i += 2) {
swap(this, i, i + 1);
}
return this;
};
Buffer.prototype.swap32 = function swap32() {
const len = this.length;
if (len % 4 !== 0) {
throw new RangeError("Buffer size must be a multiple of 32-bits");
}
for (let i = 0;i < len; i += 4) {
swap(this, i, i + 3);
swap(this, i + 1, i + 2);
}
return this;
};
Buffer.prototype.swap64 = function swap64() {
const len = this.length;
if (len % 8 !== 0) {
throw new RangeError("Buffer size must be a multiple of 64-bits");
}
for (let i = 0;i < len; i += 8) {
swap(this, i, i + 7);
swap(this, i + 1, i + 6);
swap(this, i + 2, i + 5);
swap(this, i + 3, i + 4);
}
return this;
};
Buffer.prototype.toString = function toString() {
const length = this.length;
if (length === 0)
return "";
if (arguments.length === 0)
return utf8Slice(this, 0, length);
return slowToString.apply(this, arguments);
};
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
Buffer.prototype.equals = function equals(b) {
if (!Buffer.isBuffer(b))
throw new TypeError("Argument must be a Buffer");
if (this === b)
return true;
return Buffer.compare(this, b) === 0;
};
Buffer.prototype.inspect = function inspect() {
let str = "";
const max = $INSPECT_MAX_BYTES;
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
if (this.length > max)
str += " ... ";
return "<Buffer " + str + ">";
};
if (customInspectSymbol) {
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
}
Buffer.prototype.compare = function compare2(target, start, end, thisStart, thisEnd) {
if (isInstance(target, Uint8Array)) {
target = Buffer.from(target, target.offset, target.byteLength);
}
if (!Buffer.isBuffer(target)) {
throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target);
}
if (start === undefined) {
start = 0;
}
if (end === undefined) {
end = target ? target.length : 0;
}
if (thisStart === undefined) {
thisStart = 0;
}
if (thisEnd === undefined) {
thisEnd = this.length;
}
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
throw new RangeError("out of range index");
}
if (thisStart >= thisEnd && start >= end) {
return 0;
}
if (thisStart >= thisEnd) {
return -1;
}
if (start >= end) {
return 1;
}
start >>>= 0;
end >>>= 0;
thisStart >>>= 0;
thisEnd >>>= 0;
if (this === target)
return 0;
let x = thisEnd - thisStart;
let y = end - start;
const len = Math.min(x, y);
const thisCopy = this.slice(thisStart, thisEnd);
const targetCopy = target.slice(start, end);
for (let i = 0;i < len; ++i) {
if (thisCopy[i] !== targetCopy[i]) {
x = thisCopy[i];
y = targetCopy[i];
break;
}
}
if (x < y)
return -1;
if (y < x)
return 1;
return 0;
};
Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
return this.indexOf(val, byteOffset, encoding) !== -1;
};
Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
};
Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
};
Buffer.prototype.write = function write(string, offset, length, encoding) {
if (offset === undefined) {
encoding = "utf8";
length = this.length;
offset = 0;
} else if (length === undefined && typeof offset === "string") {
encoding = offset;
length = this.length;
offset = 0;
} else if (isFinite(offset)) {
offset = offset >>> 0;
if (isFinite(length)) {
length = length >>> 0;
if (encoding === undefined)
encoding = "utf8";
} else {
encoding = length;
length = undefined;
}
} else {
throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
}
const remaining = this.length - offset;
if (length === undefined || length > remaining)
length = remaining;
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
throw new RangeError("Attempt to write outside buffer bounds");
}
if (!encoding)
encoding = "utf8";
let loweredCase = false;
for (;; ) {
switch (encoding) {
case "hex":
return hexWrite(this, string, offset, length);
case "utf8":
case "utf-8":
return utf8Write(this, string, offset, length);
case "ascii":
case "latin1":
case "binary":
return asciiWrite(this, string, offset, length);
case "base64":
return base64Write(this, string, offset, length);
case "ucs2":
case "ucs-2":
case "utf16le":
case "utf-16le":
return ucs2Write(this, string, offset, length);
default:
if (loweredCase)
throw new TypeError("Unknown encoding: " + encoding);
encoding = ("" + encoding).toLowerCase();
loweredCase = true;
}
}
};
Buffer.prototype.toJSON = function toJSON() {
return {
type: "Buffer",
data: Array.prototype.slice.call(this._arr || this, 0)
};
};
var MAX_ARGUMENTS_LENGTH = 4096;
Buffer.prototype.slice = function slice(start, end) {
const len = this.length;
start = ~~start;
end = end === undefined ? len : ~~end;
if (start < 0) {
start += len;
if (start < 0)
start = 0;
} else if (start > len) {
start = len;
}
if (end < 0) {
end += len;
if (end < 0)
end = 0;
} else if (end > len) {
end = len;
}
if (end < start)
end = start;
const newBuf = this.subarray(start, end);
Object.setPrototypeOf(newBuf, Buffer.prototype);
return newBuf;
};
Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
offset = offset >>> 0;
byteLength2 = byteLength2 >>> 0;
if (!noAssert)
checkOffset(offset, byteLength2, this.length);
let val = this[offset];
let mul = 1;
let i = 0;
while (++i < byteLength2 && (mul *= 256)) {
val += this[offset + i] * mul;
}
return val;
};
Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
offset = offset >>> 0;
byteLength2 = byteLength2 >>> 0;
if (!noAssert) {
checkOffset(offset, byteLength2, this.length);
}
let val = this[offset + --byteLength2];
let mul = 1;
while (byteLength2 > 0 && (mul *= 256)) {
val += this[offset + --byteLength2] * mul;
}
return val;
};
Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 1, this.length);
return this[offset];
};
Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 2, this.length);
return this[offset] | this[offset + 1] << 8;
};
Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 2, this.length);
return this[offset] << 8 | this[offset + 1];
};
Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 4, this.length);
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
};
Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 4, this.length);
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
};
Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
offset = offset >>> 0;
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 7];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 8);
}
const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
return BigInt(lo) + (BigInt(hi) << BigInt(32));
});
Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
offset = offset >>> 0;
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 7];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 8);
}
const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
});
Buffer.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
offset = offset >>> 0;
byteLength2 = byteLength2 >>> 0;
if (!noAssert)
checkOffset(offset, byteLength2, this.length);
let val = this[offset];
let mul = 1;
let i = 0;
while (++i < byteLength2 && (mul *= 256)) {
val += this[offset + i] * mul;
}
mul *= 128;
if (val >= mul)
val -= Math.pow(2, 8 * byteLength2);
return val;
};
Buffer.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
offset = offset >>> 0;
byteLength2 = byteLength2 >>> 0;
if (!noAssert)
checkOffset(offset, byteLength2, this.length);
let i = byteLength2;
let mul = 1;
let val = this[offset + --i];
while (i > 0 && (mul *= 256)) {
val += this[offset + --i] * mul;
}
mul *= 128;
if (val >= mul)
val -= Math.pow(2, 8 * byteLength2);
return val;
};
Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 1, this.length);
if (!(this[offset] & 128))
return this[offset];
return (255 - this[offset] + 1) * -1;
};
Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 2, this.length);
const val = this[offset] | this[offset + 1] << 8;
return val & 32768 ? val | 4294901760 : val;
};
Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 2, this.length);
const val = this[offset + 1] | this[offset] << 8;
return val & 32768 ? val | 4294901760 : val;
};
Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 4, this.length);
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
};
Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 4, this.length);
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
};
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
offset = offset >>> 0;
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 7];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 8);
}
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
});
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
offset = offset >>> 0;
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 7];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 8);
}
const val = (first << 24) + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
});
Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 4, this.length);
return ieee754.read(this, offset, true, 23, 4);
};
Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 4, this.length);
return ieee754.read(this, offset, false, 23, 4);
};
Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 8, this.length);
return ieee754.read(this, offset, true, 52, 8);
};
Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 8, this.length);
return ieee754.read(this, offset, false, 52, 8);
};
Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset >>> 0;
byteLength2 = byteLength2 >>> 0;
if (!noAssert) {
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
checkInt(this, value, offset, byteLength2, maxBytes, 0);
}
let mul = 1;
let i = 0;
this[offset] = value & 255;
while (++i < byteLength2 && (mul *= 256)) {
this[offset + i] = value / mul & 255;
}
return offset + byteLength2;
};
Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset >>> 0;
byteLength2 = byteLength2 >>> 0;
if (!noAssert) {
const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
checkInt(this, value, offset, byteLength2, maxBytes, 0);
}
let i = byteLength2 - 1;
let mul = 1;
this[offset + i] = value & 255;
while (--i >= 0 && (mul *= 256)) {
this[offset + i] = value / mul & 255;
}
return offset + byteLength2;
};
Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 1, 255, 0);
this[offset] = value & 255;
return offset + 1;
};
Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 2, 65535, 0);
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
return offset + 2;
};
Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 2, 65535, 0);
this[offset] = value >>> 8;
this[offset + 1] = value & 255;
return offset + 2;
};
Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 4, 4294967295, 0);
this[offset + 3] = value >>> 24;
this[offset + 2] = value >>> 16;
this[offset + 1] = value >>> 8;
this[offset] = value & 255;
return offset + 4;
};
Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 4, 4294967295, 0);
this[offset] = value >>> 24;
this[offset + 1] = value >>> 16;
this[offset + 2] = value >>> 8;
this[offset + 3] = value & 255;
return offset + 4;
};
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
});
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
});
Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert) {
const limit = Math.pow(2, 8 * byteLength2 - 1);
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
}
let i = 0;
let mul = 1;
let sub = 0;
this[offset] = value & 255;
while (++i < byteLength2 && (mul *= 256)) {
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
sub = 1;
}
this[offset + i] = (value / mul >> 0) - sub & 255;
}
return offset + byteLength2;
};
Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert) {
const limit = Math.pow(2, 8 * byteLength2 - 1);
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
}
let i = byteLength2 - 1;
let mul = 1;
let sub = 0;
this[offset + i] = value & 255;
while (--i >= 0 && (mul *= 256)) {
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
sub = 1;
}
this[offset + i] = (value / mul >> 0) - sub & 255;
}
return offset + byteLength2;
};
Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 1, 127, -128);
if (value < 0)
value = 255 + value + 1;
this[offset] = value & 255;
return offset + 1;
};
Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 2, 32767, -32768);
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
return offset + 2;
};
Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 2, 32767, -32768);
this[offset] = value >>> 8;
this[offset + 1] = value & 255;
return offset + 2;
};
Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 4, 2147483647, -2147483648);
this[offset] = value & 255;
this[offset + 1] = value >>> 8;
this[offset + 2] = value >>> 16;
this[offset + 3] = value >>> 24;
return offset + 4;
};
Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
value = +value;
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 4, 2147483647, -2147483648);
if (value < 0)
value = 4294967295 + value + 1;
this[offset] = value >>> 24;
this[offset + 1] = value >>> 16;
this[offset + 2] = value >>> 8;
this[offset + 3] = value & 255;
return offset + 4;
};
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
});
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
});
Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
return writeFloat(this, value, offset, true, noAssert);
};
Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
return writeFloat(this, value, offset, false, noAssert);
};
Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
return writeDouble(this, value, offset, true, noAssert);
};
Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
return writeDouble(this, value, offset, false, noAssert);
};
Buffer.prototype.copy = function copy(target, targetStart, start, end) {
if (!Buffer.isBuffer(target))
throw new TypeError("argument should be a Buffer");
if (!start)
start = 0;
if (!end && end !== 0)
end = this.length;
if (targetStart >= target.length)
targetStart = target.length;
if (!targetStart)
targetStart = 0;
if (end > 0 && end < start)
end = start;
if (end === start)
return 0;
if (target.length === 0 || this.length === 0)
return 0;
if (targetStart < 0) {
throw new RangeError("targetStart out of bounds");
}
if (start < 0 || start >= this.length)
throw new RangeError("Index out of range");
if (end < 0)
throw new RangeError("sourceEnd out of bounds");
if (end > this.length)
end = this.length;
if (target.length - targetStart < end - start) {
end = target.length - targetStart + start;
}
const len = end - start;
if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
this.copyWithin(targetStart, start, end);
} else {
Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
}
return len;
};
Buffer.prototype.fill = function fill(val, start, end, encoding) {
if (typeof val === "string") {
if (typeof start === "string") {
encoding = start;
start = 0;
end = this.length;
} else if (typeof end === "string") {
encoding = end;
end = this.length;
}
if (encoding !== undefined && typeof encoding !== "string") {
throw new TypeError("encoding must be a string");
}
if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) {
throw new TypeError("Unknown encoding: " + encoding);
}
if (val.length === 1) {
const code = val.charCodeAt(0);
if (encoding === "utf8" && code < 128 || encoding === "latin1") {
val = code;
}
}
} else if (typeof val === "number") {
val = val & 255;
} else if (typeof val === "boolean") {
val = Number(val);
}
if (start < 0 || this.length < start || this.length < end) {
throw new RangeError("Out of range index");
}
if (end <= start) {
return this;
}
start = start >>> 0;
end = end === undefined ? this.length : end >>> 0;
if (!val)
val = 0;
let i;
if (typeof val === "number") {
for (i = start;i < end; ++i) {
this[i] = val;
}
} else {
const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding);
const len = bytes.length;
if (len === 0) {
throw new TypeError('The value "' + val + '" is invalid for argument "value"');
}
for (i = 0;i < end - start; ++i) {
this[i + start] = bytes[i % len];
}
}
return this;
};
var errors = {};
E("ERR_BUFFER_OUT_OF_BOUNDS", function(name) {
if (name) {
return `${name} is outside of buffer bounds`;
}
return "Attempt to access memory outside buffer bounds";
}, RangeError);
E("ERR_INVALID_ARG_TYPE", function(name, actual) {
return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
}, TypeError);
E("ERR_OUT_OF_RANGE", function(str, range, input) {
let msg = `The value of "${str}" is out of range.`;
let received = input;
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
received = addNumericalSeparator(String(input));
} else if (typeof input === "bigint") {
received = String(input);
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
received = addNumericalSeparator(received);
}
received += "n";
}
msg += ` It must be ${range}. Received ${received}`;
return msg;
}, RangeError);
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
var hexSliceLookupTable = function() {
const alphabet = "0123456789abcdef";
const table = new Array(256);
for (let i = 0;i < 16; ++i) {
const i16 = i * 16;
for (let j = 0;j < 16; ++j) {
table[i16 + j] = alphabet[i] + alphabet[j];
}
}
return table;
}();
var hexCharValueTable = {
"0": 0,
"1": 1,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
"6": 6,
"7": 7,
"8": 8,
"9": 9,
a: 10,
b: 11,
c: 12,
d: 13,
e: 14,
f: 15,
A: 10,
B: 11,
C: 12,
D: 13,
E: 14,
F: 15
};
export {
$kStringMaxLength as kStringMaxLength,
$kMaxLength as kMaxLength,
$constants as constants,
$SlowBuffer as SlowBuffer,
$INSPECT_MAX_BYTES as INSPECT_MAX_BYTES,
$Buffer as Buffer
};
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
const codes = {};
var Encodings;
(function(Encodings) {
Encodings[Encodings["ASCII"] = 0] = "ASCII";
Encodings[Encodings["UTF8"] = 1] = "UTF8";
Encodings[Encodings["BASE64"] = 2] = "BASE64";
Encodings[Encodings["UCS2"] = 3] = "UCS2";
Encodings[Encodings["BINARY"] = 4] = "BINARY";
Encodings[Encodings["HEX"] = 5] = "HEX";
Encodings[Encodings["BUFFER"] = 6] = "BUFFER";
Encodings[Encodings["BASE64URL"] = 7] = "BASE64URL";
Encodings[Encodings["LATIN1"] = 4] = "LATIN1";
})(Encodings || (Encodings = {}));
const encodings = [];
encodings[Encodings.ASCII] = "ascii";
encodings[Encodings.BASE64] = "base64";
encodings[Encodings.BASE64URL] = "base64url";
encodings[Encodings.BUFFER] = "buffer";
encodings[Encodings.HEX] = "hex";
encodings[Encodings.LATIN1] = "latin1";
encodings[Encodings.UCS2] = "utf16le";
encodings[Encodings.UTF8] = "utf8";
function indexOfNeedle(source, needle, start = 0) {
if (start >= source.length) {
return -1;
}
if (start < 0) {
start = Math.max(0, source.length + start);
}
const s = needle[0];
for(let i = start; i < source.length; i++){
if (source[i] !== s) continue;
const pin = i;
let matched = 1;
let j = i;
while(matched < needle.length){
j++;
if (source[j] !== needle[j - pin]) {
break;
}
matched++;
}
if (matched === needle.length) {
return pin;
}
}
return -1;
}
function numberToBytes(n) {
if (n === 0) return new Uint8Array([
0
]);
const bytes = [];
bytes.unshift(n & 255);
while(n >= 256){
n = n >>> 8;
bytes.unshift(n & 255);
}
return new Uint8Array(bytes);
}
function findLastIndex(targetBuffer, buffer, offset) {
offset = offset > targetBuffer.length ? targetBuffer.length : offset;
const searchableBuffer = targetBuffer.slice(0, offset + buffer.length);
const searchableBufferLastIndex = searchableBuffer.length - 1;
const bufferLastIndex = buffer.length - 1;
let lastMatchIndex = -1;
let matches = 0;
let index = -1;
for(let x = 0; x <= searchableBufferLastIndex; x++){
if (searchableBuffer[searchableBufferLastIndex - x] === buffer[bufferLastIndex - matches]) {
if (lastMatchIndex === -1) {
lastMatchIndex = x;
}
matches++;
} else {
matches = 0;
if (lastMatchIndex !== -1) {
x = lastMatchIndex + 1;
lastMatchIndex = -1;
}
continue;
}
if (matches === buffer.length) {
index = x;
break;
}
}
if (index === -1) return index;
return searchableBufferLastIndex - index;
}
function indexOfBuffer(targetBuffer, buffer, byteOffset, encoding, forwardDirection) {
if (!Encodings[encoding] === undefined) {
throw new Error(`Unknown encoding code ${encoding}`);
}
if (!forwardDirection) {
if (byteOffset < 0) {
byteOffset = targetBuffer.length + byteOffset;
}
if (buffer.length === 0) {
return byteOffset <= targetBuffer.length ? byteOffset : targetBuffer.length;
}
return findLastIndex(targetBuffer, buffer, byteOffset);
}
if (buffer.length === 0) {
return byteOffset <= targetBuffer.length ? byteOffset : targetBuffer.length;
}
return indexOfNeedle(targetBuffer, buffer, byteOffset);
}
function indexOfNumber(targetBuffer, number, byteOffset, forwardDirection) {
const bytes = numberToBytes(number);
if (bytes.length > 1) {
throw new Error("Multi byte number search is not supported");
}
return indexOfBuffer(targetBuffer, numberToBytes(number), byteOffset, Encodings.UTF8, forwardDirection);
}
const base64abc = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"+",
"/"
];
function encode(data) {
const uint8 = typeof data === "string" ? new TextEncoder().encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data);
let result = "", i;
const l = uint8.length;
for(i = 2; i < l; i += 3){
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 0x03) << 4 | uint8[i - 1] >> 4];
result += base64abc[(uint8[i - 1] & 0x0f) << 2 | uint8[i] >> 6];
result += base64abc[uint8[i] & 0x3f];
}
if (i === l + 1) {
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 0x03) << 4];
result += "==";
}
if (i === l) {
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 0x03) << 4 | uint8[i - 1] >> 4];
result += base64abc[(uint8[i - 1] & 0x0f) << 2];
result += "=";
}
return result;
}
function decode(b64) {
const binString = atob(b64);
const size = binString.length;
const bytes = new Uint8Array(size);
for(let i = 0; i < size; i++){
bytes[i] = binString.charCodeAt(i);
}
return bytes;
}
function addPaddingToBase64url(base64url) {
if (base64url.length % 4 === 2) return base64url + "==";
if (base64url.length % 4 === 3) return base64url + "=";
if (base64url.length % 4 === 1) {
throw new TypeError("Illegal base64url string!");
}
return base64url;
}
function convertBase64urlToBase64(b64url) {
if (!/^[-_A-Z0-9]*?={0,2}$/i.test(b64url)) {
throw new TypeError("Failed to decode base64url: invalid character");
}
return addPaddingToBase64url(b64url).replace(/\-/g, "+").replace(/_/g, "/");
}
function convertBase64ToBase64url(b64) {
return b64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
}
function encode1(data) {
return convertBase64ToBase64url(encode(data));
}
function decode1(b64url) {
return decode(convertBase64urlToBase64(b64url));
}
function asciiToBytes(str) {
const byteArray = [];
for(let i = 0; i < str.length; ++i){
byteArray.push(str.charCodeAt(i) & 255);
}
return new Uint8Array(byteArray);
}
function base64ToBytes(str) {
str = base64clean(str);
str = str.replaceAll("-", "+").replaceAll("_", "/");
return decode(str);
}
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
function base64clean(str) {
str = str.split("=")[0];
str = str.trim().replace(INVALID_BASE64_RE, "");
if (str.length < 2) return "";
while(str.length % 4 !== 0){
str = str + "=";
}
return str;
}
function base64UrlToBytes(str) {
str = base64clean(str);
str = str.replaceAll("+", "-").replaceAll("/", "_");
return decode1(str);
}
function hexToBytes(str) {
const byteArray = new Uint8Array(Math.floor((str || "").length / 2));
let i;
for(i = 0; i < byteArray.length; i++){
const a = Number.parseInt(str[i * 2], 16);
const b = Number.parseInt(str[i * 2 + 1], 16);
if (Number.isNaN(a) && Number.isNaN(b)) {
break;
}
byteArray[i] = a << 4 | b;
}
return new Uint8Array(i === byteArray.length ? byteArray : byteArray.slice(0, i));
}
function utf16leToBytes(str, units) {
let c, hi, lo;
const byteArray = [];
for(let i = 0; i < str.length; ++i){
if ((units -= 2) < 0) {
break;
}
c = str.charCodeAt(i);
hi = c >> 8;
lo = c % 256;
byteArray.push(lo);
byteArray.push(hi);
}
return new Uint8Array(byteArray);
}
function bytesToAscii(bytes) {
let ret = "";
for(let i = 0; i < bytes.length; ++i){
ret += String.fromCharCode(bytes[i] & 127);
}
return ret;
}
function bytesToUtf16le(bytes) {
let res = "";
for(let i = 0; i < bytes.length - 1; i += 2){
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
}
return res;
}
let DenoCore;
const { Deno: Deno1 } = globalThis;
if (Deno1?.[Deno1.internal]?.core) {
DenoCore = Deno1[Deno1.internal].core;
} else if (Deno1?.core) {
DenoCore = Deno1.core;
} else {
DenoCore = {};
}
const core = {
runMicrotasks: DenoCore.runMicrotasks ?? function() {
throw new Error("Deno.core.runMicrotasks() is not supported in this environment");
},
setHasTickScheduled: DenoCore.setHasTickScheduled ?? function() {
throw new Error("Deno.core.setHasTickScheduled() is not supported in this environment");
},
hasTickScheduled: DenoCore.hasTickScheduled ?? function() {
throw new Error("Deno.core.hasTickScheduled() is not supported in this environment");
},
setNextTickCallback: DenoCore.setNextTickCallback ?? undefined,
setMacrotaskCallback: DenoCore.setMacrotaskCallback ?? function() {
throw new Error("Deno.core.setNextTickCallback() is not supported in this environment");
},
evalContext: DenoCore.evalContext ?? function(_code, _filename) {
throw new Error("Deno.core.evalContext is not supported in this environment");
},
encode: DenoCore.encode ?? function(chunk) {
return new TextEncoder().encode(chunk);
},
eventLoopHasMoreWork: DenoCore.eventLoopHasMoreWork ?? function() {
return false;
},
isProxy: DenoCore.isProxy ?? function() {
return false;
},
getPromiseDetails: DenoCore.getPromiseDetails ?? function(_promise) {
throw new Error("Deno.core.getPromiseDetails is not supported in this environment");
},
setPromiseHooks: DenoCore.setPromiseHooks ?? function() {
throw new Error("Deno.core.setPromiseHooks is not supported in this environment");
},
ops: DenoCore.ops ?? {
op_napi_open (_filename) {
throw new Error("Node API is not supported in this environment");
}
}
};
const _toString = Object.prototype.toString;
const _bigIntValueOf = BigInt.prototype.valueOf;
const _booleanValueOf = Boolean.prototype.valueOf;
const _dateValueOf = Date.prototype.valueOf;
const _numberValueOf = Number.prototype.valueOf;
const _stringValueOf = String.prototype.valueOf;
const _symbolValueOf = Symbol.prototype.valueOf;
const _weakMapHas = WeakMap.prototype.has;
const _weakSetHas = WeakSet.prototype.has;
const _getArrayBufferByteLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
const _getSharedArrayBufferByteLength = globalThis.SharedArrayBuffer ? Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get : undefined;
const _getTypedArrayToStringTag = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array).prototype, Symbol.toStringTag).get;
const _getSetSize = Object.getOwnPropertyDescriptor(Set.prototype, "size").get;
const _getMapSize = Object.getOwnPropertyDescriptor(Map.prototype, "size").get;
function isObjectLike(value) {
return value !== null && typeof value === "object";
}
function isAnyArrayBuffer(value) {
return isArrayBuffer(value) || isSharedArrayBuffer(value);
}
function isArgumentsObject(value) {
return isObjectLike(value) && value[Symbol.toStringTag] === undefined && _toString.call(value) === "[object Arguments]";
}
function isArrayBuffer(value) {
try {
_getArrayBufferByteLength.call(value);
return true;
} catch {
return false;
}
}
function isAsyncFunction(value) {
return typeof value === "function" && value[Symbol.toStringTag] === "AsyncFunction";
}
function isBooleanObject(value) {
if (!isObjectLike(value)) {
return false;
}
try {
_booleanValueOf.call(value);
return true;
} catch {
return false;
}
}
function isBoxedPrimitive(value) {
return isBooleanObject(value) || isStringObject(value) || isNumberObject(value) || isSymbolObject(value) || isBigIntObject(value);
}
function isDataView(value) {
return ArrayBuffer.isView(value) && _getTypedArrayToStringTag.call(value) === undefined;
}
function isDate(value) {
try {
_dateValueOf.call(value);
return true;
} catch {
return false;
}
}
function isGeneratorFunction(value) {
return typeof value === "function" && value[Symbol.toStringTag] === "GeneratorFunction";
}
function isGeneratorObject(value) {
return isObjectLike(value) && value[Symbol.toStringTag] === "Generator";
}
function isMap(value) {
try {
_getMapSize.call(value);
return true;
} catch {
return false;
}
}
function isMapIterator(value) {
return isObjectLike(value) && value[Symbol.toStringTag] === "Map Iterator";
}
function isModuleNamespaceObject(value) {
return isObjectLike(value) && value[Symbol.toStringTag] === "Module";
}
function isNativeError(value) {
return isObjectLike(value) && value[Symbol.toStringTag] === undefined && _toString.call(value) === "[object Error]";
}
function isNumberObject(value) {
if (!isObjectLike(value)) {
return false;
}
try {
_numberValueOf.call(value);
return true;
} catch {
return false;
}
}
function isBigIntObject(value) {
if (!isObjectLike(value)) {
return false;
}
try {
_bigIntValueOf.call(value);
return true;
} catch {
return false;
}
}
function isPromise(value) {
return isObjectLike(value) && value[Symbol.toStringTag] === "Promise";
}
function isProxy(value) {
return core.isProxy(value);
}
function isRegExp(value) {
return isObjectLike(value) && value[Symbol.toStringTag] === undefined && _toString.call(value) === "[object RegExp]";
}
function isSet(value) {
try {
_getSetSize.call(value);
return true;
} catch {
return false;
}
}
function isSetIterator(value) {
return isObjectLike(value) && value[Symbol.toStringTag] === "Set Iterator";
}
function isSharedArrayBuffer(value) {
if (_getSharedArrayBufferByteLength === undefined) {
return false;
}
try {
_getSharedArrayBufferByteLength.call(value);
return true;
} catch {
return false;
}
}
function isStringObject(value) {
if (!isObjectLike(value)) {
return false;
}
try {
_stringValueOf.call(value);
return true;
} catch {
return false;
}
}
function isSymbolObject(value) {
if (!isObjectLike(value)) {
return false;
}
try {
_symbolValueOf.call(value);
return true;
} catch {
return false;
}
}
function isWeakMap(value) {
try {
_weakMapHas.call(value, null);
return true;
} catch {
return false;
}
}
function isWeakSet(value) {
try {
_weakSetHas.call(value, null);
return true;
} catch {
return false;
}
}
const __default = {
isAsyncFunction,
isGeneratorFunction,
isAnyArrayBuffer,
isArrayBuffer,
isArgumentsObject,
isBoxedPrimitive,
isDataView,
isMap,
isMapIterator,
isModuleNamespaceObject,
isNativeError,
isPromise,
isSet,
isSetIterator,
isWeakMap,
isWeakSet,
isRegExp,
isDate,
isStringObject,
isNumberObject,
isBooleanObject,
isBigIntObject
};
const mod = {
isAnyArrayBuffer: isAnyArrayBuffer,
isArgumentsObject: isArgumentsObject,
isArrayBuffer: isArrayBuffer,
isAsyncFunction: isAsyncFunction,
isBooleanObject: isBooleanObject,
isBoxedPrimitive: isBoxedPrimitive,
isDataView: isDataView,
isDate: isDate,
isGeneratorFunction: isGeneratorFunction,
isGeneratorObject: isGeneratorObject,
isMap: isMap,
isMapIterator: isMapIterator,
isModuleNamespaceObject: isModuleNamespaceObject,
isNativeError: isNativeError,
isNumberObject: isNumberObject,
isBigIntObject: isBigIntObject,
isPromise: isPromise,
isProxy: isProxy,
isRegExp: isRegExp,
isSet: isSet,
isSetIterator: isSetIterator,
isSharedArrayBuffer: isSharedArrayBuffer,
isStringObject: isStringObject,
isSymbolObject: isSymbolObject,
isWeakMap: isWeakMap,
isWeakSet: isWeakSet,
default: __default
};
Symbol("kHandle");
Symbol("kKeyObject");
Symbol("kKeyType");
const _getTypedArrayToStringTag1 = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array).prototype, Symbol.toStringTag).get;
function isArrayBufferView(value) {
return ArrayBuffer.isView(value);
}
function isTypedArray(value) {
return _getTypedArrayToStringTag1.call(value) !== undefined;
}
function isUint8Array(value) {
return _getTypedArrayToStringTag1.call(value) === "Uint8Array";
}
const { isDate: isDate1, isArgumentsObject: isArgumentsObject1, isBigIntObject: isBigIntObject1, isBooleanObject: isBooleanObject1, isNumberObject: isNumberObject1, isStringObject: isStringObject1, isSymbolObject: isSymbolObject1, isNativeError: isNativeError1, isRegExp: isRegExp1, isAsyncFunction: isAsyncFunction1, isGeneratorFunction: isGeneratorFunction1, isGeneratorObject: isGeneratorObject1, isPromise: isPromise1, isMap: isMap1, isSet: isSet1, isMapIterator: isMapIterator1, isSetIterator: isSetIterator1, isWeakMap: isWeakMap1, isWeakSet: isWeakSet1, isArrayBuffer: isArrayBuffer1, isDataView: isDataView1, isSharedArrayBuffer: isSharedArrayBuffer1, isProxy: isProxy1, isModuleNamespaceObject: isModuleNamespaceObject1, isAnyArrayBuffer: isAnyArrayBuffer1, isBoxedPrimitive: isBoxedPrimitive1 } = mod;
function hideStackFrames(fn) {
const hidden = "__node_internal_" + fn.name;
Object.defineProperty(fn, "name", {
value: hidden
});
return fn;
}
function normalizeEncoding(enc) {
if (enc == null || enc === "utf8" || enc === "utf-8") return "utf8";
return slowCases(enc);
}
function slowCases(enc) {
switch(enc.length){
case 4:
if (enc === "UTF8") return "utf8";
if (enc === "ucs2" || enc === "UCS2") return "utf16le";
enc = `${enc}`.toLowerCase();
if (enc === "utf8") return "utf8";
if (enc === "ucs2") return "utf16le";
break;
case 3:
if (enc === "hex" || enc === "HEX" || `${enc}`.toLowerCase() === "hex") {
return "hex";
}
break;
case 5:
if (enc === "ascii") return "ascii";
if (enc === "ucs-2") return "utf16le";
if (enc === "UTF-8") return "utf8";
if (enc === "ASCII") return "ascii";
if (enc === "UCS-2") return "utf16le";
enc = `${enc}`.toLowerCase();
if (enc === "utf-8") return "utf8";
if (enc === "ascii") return "ascii";
if (enc === "ucs-2") return "utf16le";
break;
case 6:
if (enc === "base64") return "base64";
if (enc === "latin1" || enc === "binary") return "latin1";
if (enc === "BASE64") return "base64";
if (enc === "LATIN1" || enc === "BINARY") return "latin1";
enc = `${enc}`.toLowerCase();
if (enc === "base64") return "base64";
if (enc === "latin1" || enc === "binary") return "latin1";
break;
case 7:
if (enc === "utf16le" || enc === "UTF16LE" || `${enc}`.toLowerCase() === "utf16le") {
return "utf16le";
}
break;
case 8:
if (enc === "utf-16le" || enc === "UTF-16LE" || `${enc}`.toLowerCase() === "utf-16le") {
return "utf16le";
}
break;
case 9:
if (enc === "base64url" || enc === "BASE64URL" || `${enc}`.toLowerCase() === "base64url") {
return "base64url";
}
break;
default:
if (enc === "") return "utf8";
}
}
function isInt32(value) {
return value === (value | 0);
}
function isUint32(value) {
return value === value >>> 0;
}
const validateBuffer = hideStackFrames((buffer, name = "buffer")=>{
if (!isArrayBufferView(buffer)) {
throw new codes.ERR_INVALID_ARG_TYPE(name, [
"Buffer",
"TypedArray",
"DataView"
], buffer);
}
});
hideStackFrames((value, name, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER)=>{
if (typeof value !== "number") {
throw new codes.ERR_INVALID_ARG_TYPE(name, "number", value);
}
if (!Number.isInteger(value)) {
throw new codes.ERR_OUT_OF_RANGE(name, "an integer", value);
}
if (value < min || value > max) {
throw new codes.ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
}
});
const validateObject = hideStackFrames((value, name, options)=>{
const useDefaultOptions = options == null;
const allowArray = useDefaultOptions ? false : options.allowArray;
const allowFunction = useDefaultOptions ? false : options.allowFunction;
const nullable = useDefaultOptions ? false : options.nullable;
if (!nullable && value === null || !allowArray && Array.isArray(value) || typeof value !== "object" && (!allowFunction || typeof value !== "function")) {
throw new codes.ERR_INVALID_ARG_TYPE(name, "Object", value);
}
});
hideStackFrames((value, name, min = -2147483648, max = 2147483647)=>{
if (!isInt32(value)) {
if (typeof value !== "number") {
throw new codes.ERR_INVALID_ARG_TYPE(name, "number", value);
}
if (!Number.isInteger(value)) {
throw new codes.ERR_OUT_OF_RANGE(name, "an integer", value);
}
throw new codes.ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
}
if (value < min || value > max) {
throw new codes.ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
}
});
hideStackFrames((value, name, positive)=>{
if (!isUint32(value)) {
if (typeof value !== "number") {
throw new codes.ERR_INVALID_ARG_TYPE(name, "number", value);
}
if (!Number.isInteger(value)) {
throw new codes.ERR_OUT_OF_RANGE(name, "an integer", value);
}
const min = positive ? 1 : 0;
throw new codes.ERR_OUT_OF_RANGE(name, `>= ${min} && < 4294967296`, value);
}
if (positive && value === 0) {
throw new codes.ERR_OUT_OF_RANGE(name, ">= 1 && < 4294967296", value);
}
});
function validateString(value, name) {
if (typeof value !== "string") {
throw new codes.ERR_INVALID_ARG_TYPE(name, "string", value);
}
}
hideStackFrames((value, name, oneOf)=>{
if (!Array.prototype.includes.call(oneOf, value)) {
const allowed = Array.prototype.join.call(Array.prototype.map.call(oneOf, (v)=>typeof v === "string" ? `'${v}'` : String(v)), ", ");
const reason = "must be one of: " + allowed;
throw new codes.ERR_INVALID_ARG_VALUE(name, value, reason);
}
});
hideStackFrames((signal, name)=>{
if (signal !== undefined && (signal === null || typeof signal !== "object" || !("aborted" in signal))) {
throw new codes.ERR_INVALID_ARG_TYPE(name, "AbortSignal", signal);
}
});
const validateFunction = hideStackFrames((value, name)=>{
if (typeof value !== "function") {
throw new codes.ERR_INVALID_ARG_TYPE(name, "Function", value);
}
});
hideStackFrames((value, name, minLength = 0)=>{
if (!Array.isArray(value)) {
throw new codes.ERR_INVALID_ARG_TYPE(name, "Array", value);
}
if (value.length < minLength) {
const reason = `must be longer than ${minLength}`;
throw new codes.ERR_INVALID_ARG_VALUE(name, value, reason);
}
});
Array.isArray;
Object.assign;
Object.create;
Object.hasOwn;
RegExp.prototype.exec;
String.fromCharCode;
class DenoStdInternalError extends Error {
constructor(message){
super(message);
this.name = "DenoStdInternalError";
}
}
function assert(expr, msg = "") {
if (!expr) {
throw new DenoStdInternalError(msg);
}
}
function unreachable() {
throw new DenoStdInternalError("unreachable");
}
const osType = (()=>{
const { Deno: Deno1 } = globalThis;
if (typeof Deno1?.build?.os === "string") {
return Deno1.build.os;
}
const { navigator } = globalThis;
if (navigator?.appVersion?.includes?.("Win")) {
return "windows";
}
return "linux";
})();
const codeToErrorWindows = [
[
-4093,
[
"E2BIG",
"argument list too long"
]
],
[
-4092,
[
"EACCES",
"permission denied"
]
],
[
-4091,
[
"EADDRINUSE",
"address already in use"
]
],
[
-4090,
[
"EADDRNOTAVAIL",
"address not available"
]
],
[
-4089,
[
"EAFNOSUPPORT",
"address family not supported"
]
],
[
-4088,
[
"EAGAIN",
"resource temporarily unavailable"
]
],
[
-3000,
[
"EAI_ADDRFAMILY",
"address family not supported"
]
],
[
-3001,
[
"EAI_AGAIN",
"temporary failure"
]
],
[
-3002,
[
"EAI_BADFLAGS",
"bad ai_flags value"
]
],
[
-3013,
[
"EAI_BADHINTS",
"invalid value for hints"
]
],
[
-3003,
[
"EAI_CANCELED",
"request canceled"
]
],
[
-3004,
[
"EAI_FAIL",
"permanent failure"
]
],
[
-3005,
[
"EAI_FAMILY",
"ai_family not supported"
]
],
[
-3006,
[
"EAI_MEMORY",
"out of memory"
]
],
[
-3007,
[
"EAI_NODATA",
"no address"
]
],
[
-3008,
[
"EAI_NONAME",
"unknown node or service"
]
],
[
-3009,
[
"EAI_OVERFLOW",
"argument buffer overflow"
]
],
[
-3014,
[
"EAI_PROTOCOL",
"resolved protocol is unknown"
]
],
[
-3010,
[
"EAI_SERVICE",
"service not available for socket type"
]
],
[
-3011,
[
"EAI_SOCKTYPE",
"socket type not supported"
]
],
[
-4084,
[
"EALREADY",
"connection already in progress"
]
],
[
-4083,
[
"EBADF",
"bad file descriptor"
]
],
[
-4082,
[
"EBUSY",
"resource busy or locked"
]
],
[
-4081,
[
"ECANCELED",
"operation canceled"
]
],
[
-4080,
[
"ECHARSET",
"invalid Unicode character"
]
],
[
-4079,
[
"ECONNABORTED",
"software caused connection abort"
]
],
[
-4078,
[
"ECONNREFUSED",
"connection refused"
]
],
[
-4077,
[
"ECONNRESET",
"connection reset by peer"
]
],
[
-4076,
[
"EDESTADDRREQ",
"destination address required"
]
],
[
-4075,
[
"EEXIST",
"file already exists"
]
],
[
-4074,
[
"EFAULT",
"bad address in system call argument"
]
],
[
-4036,
[
"EFBIG",
"file too large"
]
],
[
-4073,
[
"EHOSTUNREACH",
"host is unreachable"
]
],
[
-4072,
[
"EINTR",
"interrupted system call"
]
],
[
-4071,
[
"EINVAL",
"invalid argument"
]
],
[
-4070,
[
"EIO",
"i/o error"
]
],
[
-4069,
[
"EISCONN",
"socket is already connected"
]
],
[
-4068,
[
"EISDIR",
"illegal operation on a directory"
]
],
[
-4067,
[
"ELOOP",
"too many symbolic links encountered"
]
],
[
-4066,
[
"EMFILE",
"too many open files"
]
],
[
-4065,
[
"EMSGSIZE",
"message too long"
]
],
[
-4064,
[
"ENAMETOOLONG",
"name too long"
]
],
[
-4063,
[
"ENETDOWN",
"network is down"
]
],
[
-4062,
[
"ENETUNREACH",
"network is unreachable"
]
],
[
-4061,
[
"ENFILE",
"file table overflow"
]
],
[
-4060,
[
"ENOBUFS",
"no buffer space available"
]
],
[
-4059,
[
"ENODEV",
"no such device"
]
],
[
-4058,
[
"ENOENT",
"no such file or directory"
]
],
[
-4057,
[
"ENOMEM",
"not enough memory"
]
],
[
-4056,
[
"ENONET",
"machine is not on the network"
]
],
[
-4035,
[
"ENOPROTOOPT",
"protocol not available"
]
],
[
-4055,
[
"ENOSPC",
"no space left on device"
]
],
[
-4054,
[
"ENOSYS",
"function not implemented"
]
],
[
-4053,
[
"ENOTCONN",
"socket is not connected"
]
],
[
-4052,
[
"ENOTDIR",
"not a directory"
]
],
[
-4051,
[
"ENOTEMPTY",
"directory not empty"
]
],
[
-4050,
[
"ENOTSOCK",
"socket operation on non-socket"
]
],
[
-4049,
[
"ENOTSUP",
"operation not supported on socket"
]
],
[
-4048,
[
"EPERM",
"operation not permitted"
]
],
[
-4047,
[
"EPIPE",
"broken pipe"
]
],
[
-4046,
[
"EPROTO",
"protocol error"
]
],
[
-4045,
[
"EPROTONOSUPPORT",
"protocol not supported"
]
],
[
-4044,
[
"EPROTOTYPE",
"protocol wrong type for socket"
]
],
[
-4034,
[
"ERANGE",
"result too large"
]
],
[
-4043,
[
"EROFS",
"read-only file system"
]
],
[
-4042,
[
"ESHUTDOWN",
"cannot send after transport endpoint shutdown"
]
],
[
-4041,
[
"ESPIPE",
"invalid seek"
]
],
[
-4040,
[
"ESRCH",
"no such process"
]
],
[
-4039,
[
"ETIMEDOUT",
"connection timed out"
]
],
[
-4038,
[
"ETXTBSY",
"text file is busy"
]
],
[
-4037,
[
"EXDEV",
"cross-device link not permitted"
]
],
[
-4094,
[
"UNKNOWN",
"unknown error"
]
],
[
-4095,
[
"EOF",
"end of file"
]
],
[
-4033,
[
"ENXIO",
"no such device or address"
]
],
[
-4032,
[
"EMLINK",
"too many links"
]
],
[
-4031,
[
"EHOSTDOWN",
"host is down"
]
],
[
-4030,
[
"EREMOTEIO",
"remote I/O error"
]
],
[
-4029,
[
"ENOTTY",
"inappropriate ioctl for device"
]
],
[
-4028,
[
"EFTYPE",
"inappropriate file type or format"
]
],
[
-4027,
[
"EILSEQ",
"illegal byte sequence"
]
]
];
const errorToCodeWindows = codeToErrorWindows.map(([status, [error]])=>[
error,
status
]);
const codeToErrorDarwin = [
[
-7,
[
"E2BIG",
"argument list too long"
]
],
[
-13,
[
"EACCES",
"permission denied"
]
],
[
-48,
[
"EADDRINUSE",
"address already in use"
]
],
[
-49,
[
"EADDRNOTAVAIL",
"address not available"
]
],
[
-47,
[
"EAFNOSUPPORT",
"address family not supported"
]
],
[
-35,
[
"EAGAIN",
"resource temporarily unavailable"
]
],
[
-3000,
[
"EAI_ADDRFAMILY",
"address family not supported"
]
],
[
-3001,
[
"EAI_AGAIN",
"temporary failure"
]
],
[
-3002,
[
"EAI_BADFLAGS",
"bad ai_flags value"
]
],
[
-3013,
[
"EAI_BADHINTS",
"invalid value for hints"
]
],
[
-3003,
[
"EAI_CANCELED",
"request canceled"
]
],
[
-3004,
[
"EAI_FAIL",
"permanent failure"
]
],
[
-3005,
[
"EAI_FAMILY",
"ai_family not supported"
]
],
[
-3006,
[
"EAI_MEMORY",
"out of memory"
]
],
[
-3007,
[
"EAI_NODATA",
"no address"
]
],
[
-3008,
[
"EAI_NONAME",
"unknown node or service"
]
],
[
-3009,
[
"EAI_OVERFLOW",
"argument buffer overflow"
]
],
[
-3014,
[
"EAI_PROTOCOL",
"resolved protocol is unknown"
]
],
[
-3010,
[
"EAI_SERVICE",
"service not available for socket type"
]
],
[
-3011,
[
"EAI_SOCKTYPE",
"socket type not supported"
]
],
[
-37,
[
"EALREADY",
"connection already in progress"
]
],
[
-9,
[
"EBADF",
"bad file descriptor"
]
],
[
-16,
[
"EBUSY",
"resource busy or locked"
]
],
[
-89,
[
"ECANCELED",
"operation canceled"
]
],
[
-4080,
[
"ECHARSET",
"invalid Unicode character"
]
],
[
-53,
[
"ECONNABORTED",
"software caused connection abort"
]
],
[
-61,
[
"ECONNREFUSED",
"connection refused"
]
],
[
-54,
[
"ECONNRESET",
"connection reset by peer"
]
],
[
-39,
[
"EDESTADDRREQ",
"destination address required"
]
],
[
-17,
[
"EEXIST",
"file already exists"
]
],
[
-14,
[
"EFAULT",
"bad address in system call argument"
]
],
[
-27,
[
"EFBIG",
"file too large"
]
],
[
-65,
[
"EHOSTUNREACH",
"host is unreachable"
]
],
[
-4,
[
"EINTR",
"interrupted system call"
]
],
[
-22,
[
"EINVAL",
"invalid argument"
]
],
[
-5,
[
"EIO",
"i/o error"
]
],
[
-56,
[
"EISCONN",
"socket is already connected"
]
],
[
-21,
[
"EISDIR",
"illegal operation on a directory"
]
],
[
-62,
[
"ELOOP",
"too many symbolic links encountered"
]
],
[
-24,
[
"EMFILE",
"too many open files"
]
],
[
-40,
[
"EMSGSIZE",
"message too long"
]
],
[
-63,
[
"ENAMETOOLONG",
"name too long"
]
],
[
-50,
[
"ENETDOWN",
"network is down"
]
],
[
-51,
[
"ENETUNREACH",
"network is unreachable"
]
],
[
-23,
[
"ENFILE",
"file table overflow"
]
],
[
-55,
[
"ENOBUFS",
"no buffer space available"
]
],
[
-19,
[
"ENODEV",
"no such device"
]
],
[
-2,
[
"ENOENT",
"no such file or directory"
]
],
[
-12,
[
"ENOMEM",
"not enough memory"
]
],
[
-4056,
[
"ENONET",
"machine is not on the network"
]
],
[
-42,
[
"ENOPROTOOPT",
"protocol not available"
]
],
[
-28,
[
"ENOSPC",
"no space left on device"
]
],
[
-78,
[
"ENOSYS",
"function not implemented"
]
],
[
-57,
[
"ENOTCONN",
"socket is not connected"
]
],
[
-20,
[
"ENOTDIR",
"not a directory"
]
],
[
-66,
[
"ENOTEMPTY",
"directory not empty"
]
],
[
-38,
[
"ENOTSOCK",
"socket operation on non-socket"
]
],
[
-45,
[
"ENOTSUP",
"operation not supported on socket"
]
],
[
-1,
[
"EPERM",
"operation not permitted"
]
],
[
-32,
[
"EPIPE",
"broken pipe"
]
],
[
-100,
[
"EPROTO",
"protocol error"
]
],
[
-43,
[
"EPROTONOSUPPORT",
"protocol not supported"
]
],
[
-41,
[
"EPROTOTYPE",
"protocol wrong type for socket"
]
],
[
-34,
[
"ERANGE",
"result too large"
]
],
[
-30,
[
"EROFS",
"read-only file system"
]
],
[
-58,
[
"ESHUTDOWN",
"cannot send after transport endpoint shutdown"
]
],
[
-29,
[
"ESPIPE",
"invalid seek"
]
],
[
-3,
[
"ESRCH",
"no such process"
]
],
[
-60,
[
"ETIMEDOUT",
"connection timed out"
]
],
[
-26,
[
"ETXTBSY",
"text file is busy"
]
],
[
-18,
[
"EXDEV",
"cross-device link not permitted"
]
],
[
-4094,
[
"UNKNOWN",
"unknown error"
]
],
[
-4095,
[
"EOF",
"end of file"
]
],
[
-6,
[
"ENXIO",
"no such device or address"
]
],
[
-31,
[
"EMLINK",
"too many links"
]
],
[
-64,
[
"EHOSTDOWN",
"host is down"
]
],
[
-4030,
[
"EREMOTEIO",
"remote I/O error"
]
],
[
-25,
[
"ENOTTY",
"inappropriate ioctl for device"
]
],
[
-79,
[
"EFTYPE",
"inappropriate file type or format"
]
],
[
-92,
[
"EILSEQ",
"illegal byte sequence"
]
]
];
const errorToCodeDarwin = codeToErrorDarwin.map(([status, [code]])=>[
code,
status
]);
const codeToErrorLinux = [
[
-7,
[
"E2BIG",
"argument list too long"
]
],
[
-13,
[
"EACCES",
"permission denied"
]
],
[
-98,
[
"EADDRINUSE",
"address already in use"
]
],
[
-99,
[
"EADDRNOTAVAIL",
"address not available"
]
],
[
-97,
[
"EAFNOSUPPORT",
"address family not supported"
]
],
[
-11,
[
"EAGAIN",
"resource temporarily unavailable"
]
],
[
-3000,
[
"EAI_ADDRFAMILY",
"address family not supported"
]
],
[
-3001,
[
"EAI_AGAIN",
"temporary failure"
]
],
[
-3002,
[
"EAI_BADFLAGS",
"bad ai_flags value"
]
],
[
-3013,
[
"EAI_BADHINTS",
"invalid value for hints"
]
],
[
-3003,
[
"EAI_CANCELED",
"request canceled"
]
],
[
-3004,
[
"EAI_FAIL",
"permanent failure"
]
],
[
-3005,
[
"EAI_FAMILY",
"ai_family not supported"
]
],
[
-3006,
[
"EAI_MEMORY",
"out of memory"
]
],
[
-3007,
[
"EAI_NODATA",
"no address"
]
],
[
-3008,
[
"EAI_NONAME",
"unknown node or service"
]
],
[
-3009,
[
"EAI_OVERFLOW",
"argument buffer overflow"
]
],
[
-3014,
[
"EAI_PROTOCOL",
"resolved protocol is unknown"
]
],
[
-3010,
[
"EAI_SERVICE",
"service not available for socket type"
]
],
[
-3011,
[
"EAI_SOCKTYPE",
"socket type not supported"
]
],
[
-114,
[
"EALREADY",
"connection already in progress"
]
],
[
-9,
[
"EBADF",
"bad file descriptor"
]
],
[
-16,
[
"EBUSY",
"resource busy or locked"
]
],
[
-125,
[
"ECANCELED",
"operation canceled"
]
],
[
-4080,
[
"ECHARSET",
"invalid Unicode character"
]
],
[
-103,
[
"ECONNABORTED",
"software caused connection abort"
]
],
[
-111,
[
"ECONNREFUSED",
"connection refused"
]
],
[
-104,
[
"ECONNRESET",
"connection reset by peer"
]
],
[
-89,
[
"EDESTADDRREQ",
"destination address required"
]
],
[
-17,
[
"EEXIST",
"file already exists"
]
],
[
-14,
[
"EFAULT",
"bad address in system call argument"
]
],
[
-27,
[
"EFBIG",
"file too large"
]
],
[
-113,
[
"EHOSTUNREACH",
"host is unreachable"
]
],
[
-4,
[
"EINTR",
"interrupted system call"
]
],
[
-22,
[
"EINVAL",
"invalid argument"
]
],
[
-5,
[
"EIO",
"i/o error"
]
],
[
-106,
[
"EISCONN",
"socket is already connected"
]
],
[
-21,
[
"EISDIR",
"illegal operation on a directory"
]
],
[
-40,
[
"ELOOP",
"too many symbolic links encountered"
]
],
[
-24,
[
"EMFILE",
"too many open files"
]
],
[
-90,
[
"EMSGSIZE",
"message too long"
]
],
[
-36,
[
"ENAMETOOLONG",
"name too long"
]
],
[
-100,
[
"ENETDOWN",
"network is down"
]
],
[
-101,
[
"ENETUNREACH",
"network is unreachable"
]
],
[
-23,
[
"ENFILE",
"file table overflow"
]
],
[
-105,
[
"ENOBUFS",
"no buffer space available"
]
],
[
-19,
[
"ENODEV",
"no such device"
]
],
[
-2,
[
"ENOENT",
"no such file or directory"
]
],
[
-12,
[
"ENOMEM",
"not enough memory"
]
],
[
-64,
[
"ENONET",
"machine is not on the network"
]
],
[
-92,
[
"ENOPROTOOPT",
"protocol not available"
]
],
[
-28,
[
"ENOSPC",
"no space left on device"
]
],
[
-38,
[
"ENOSYS",
"function not implemented"
]
],
[
-107,
[
"ENOTCONN",
"socket is not connected"
]
],
[
-20,
[
"ENOTDIR",
"not a directory"
]
],
[
-39,
[
"ENOTEMPTY",
"directory not empty"
]
],
[
-88,
[
"ENOTSOCK",
"socket operation on non-socket"
]
],
[
-95,
[
"ENOTSUP",
"operation not supported on socket"
]
],
[
-1,
[
"EPERM",
"operation not permitted"
]
],
[
-32,
[
"EPIPE",
"broken pipe"
]
],
[
-71,
[
"EPROTO",
"protocol error"
]
],
[
-93,
[
"EPROTONOSUPPORT",
"protocol not supported"
]
],
[
-91,
[
"EPROTOTYPE",
"protocol wrong type for socket"
]
],
[
-34,
[
"ERANGE",
"result too large"
]
],
[
-30,
[
"EROFS",
"read-only file system"
]
],
[
-108,
[
"ESHUTDOWN",
"cannot send after transport endpoint shutdown"
]
],
[
-29,
[
"ESPIPE",
"invalid seek"
]
],
[
-3,
[
"ESRCH",
"no such process"
]
],
[
-110,
[
"ETIMEDOUT",
"connection timed out"
]
],
[
-26,
[
"ETXTBSY",
"text file is busy"
]
],
[
-18,
[
"EXDEV",
"cross-device link not permitted"
]
],
[
-4094,
[
"UNKNOWN",
"unknown error"
]
],
[
-4095,
[
"EOF",
"end of file"
]
],
[
-6,
[
"ENXIO",
"no such device or address"
]
],
[
-31,
[
"EMLINK",
"too many links"
]
],
[
-112,
[
"EHOSTDOWN",
"host is down"
]
],
[
-121,
[
"EREMOTEIO",
"remote I/O error"
]
],
[
-25,
[
"ENOTTY",
"inappropriate ioctl for device"
]
],
[
-4028,
[
"EFTYPE",
"inappropriate file type or format"
]
],
[
-84,
[
"EILSEQ",
"illegal byte sequence"
]
]
];
const errorToCodeLinux = codeToErrorLinux.map(([status, [code]])=>[
code,
status
]);
const codeToErrorFreebsd = [
[
-7,
[
"E2BIG",
"argument list too long"
]
],
[
-13,
[
"EACCES",
"permission denied"
]
],
[
-48,
[
"EADDRINUSE",
"address already in use"
]
],
[
-49,
[
"EADDRNOTAVAIL",
"address not available"
]
],
[
-47,
[
"EAFNOSUPPORT",
"address family not supported"
]
],
[
-35,
[
"EAGAIN",
"resource temporarily unavailable"
]
],
[
-3000,
[
"EAI_ADDRFAMILY",
"address family not supported"
]
],
[
-3001,
[
"EAI_AGAIN",
"temporary failure"
]
],
[
-3002,
[
"EAI_BADFLAGS",
"bad ai_flags value"
]
],
[
-3013,
[
"EAI_BADHINTS",
"invalid value for hints"
]
],
[
-3003,
[
"EAI_CANCELED",
"request canceled"
]
],
[
-3004,
[
"EAI_FAIL",
"permanent failure"
]
],
[
-3005,
[
"EAI_FAMILY",
"ai_family not supported"
]
],
[
-3006,
[
"EAI_MEMORY",
"out of memory"
]
],
[
-3007,
[
"EAI_NODATA",
"no address"
]
],
[
-3008,
[
"EAI_NONAME",
"unknown node or service"
]
],
[
-3009,
[
"EAI_OVERFLOW",
"argument buffer overflow"
]
],
[
-3014,
[
"EAI_PROTOCOL",
"resolved protocol is unknown"
]
],
[
-3010,
[
"EAI_SERVICE",
"service not available for socket type"
]
],
[
-3011,
[
"EAI_SOCKTYPE",
"socket type not supported"
]
],
[
-37,
[
"EALREADY",
"connection already in progress"
]
],
[
-9,
[
"EBADF",
"bad file descriptor"
]
],
[
-16,
[
"EBUSY",
"resource busy or locked"
]
],
[
-85,
[
"ECANCELED",
"operation canceled"
]
],
[
-4080,
[
"ECHARSET",
"invalid Unicode character"
]
],
[
-53,
[
"ECONNABORTED",
"software caused connection abort"
]
],
[
-61,
[
"ECONNREFUSED",
"connection refused"
]
],
[
-54,
[
"ECONNRESET",
"connection reset by peer"
]
],
[
-39,
[
"EDESTADDRREQ",
"destination address required"
]
],
[
-17,
[
"EEXIST",
"file already exists"
]
],
[
-14,
[
"EFAULT",
"bad address in system call argument"
]
],
[
-27,
[
"EFBIG",
"file too large"
]
],
[
-65,
[
"EHOSTUNREACH",
"host is unreachable"
]
],
[
-4,
[
"EINTR",
"interrupted system call"
]
],
[
-22,
[
"EINVAL",
"invalid argument"
]
],
[
-5,
[
"EIO",
"i/o error"
]
],
[
-56,
[
"EISCONN",
"socket is already connected"
]
],
[
-21,
[
"EISDIR",
"illegal operation on a directory"
]
],
[
-62,
[
"ELOOP",
"too many symbolic links encountered"
]
],
[
-24,
[
"EMFILE",
"too many open files"
]
],
[
-40,
[
"EMSGSIZE",
"message too long"
]
],
[
-63,
[
"ENAMETOOLONG",
"name too long"
]
],
[
-50,
[
"ENETDOWN",
"network is down"
]
],
[
-51,
[
"ENETUNREACH",
"network is unreachable"
]
],
[
-23,
[
"ENFILE",
"file table overflow"
]
],
[
-55,
[
"ENOBUFS",
"no buffer space available"
]
],
[
-19,
[
"ENODEV",
"no such device"
]
],
[
-2,
[
"ENOENT",
"no such file or directory"
]
],
[
-12,
[
"ENOMEM",
"not enough memory"
]
],
[
-4056,
[
"ENONET",
"machine is not on the network"
]
],
[
-42,
[
"ENOPROTOOPT",
"protocol not available"
]
],
[
-28,
[
"ENOSPC",
"no space left on device"
]
],
[
-78,
[
"ENOSYS",
"function not implemented"
]
],
[
-57,
[
"ENOTCONN",
"socket is not connected"
]
],
[
-20,
[
"ENOTDIR",
"not a directory"
]
],
[
-66,
[
"ENOTEMPTY",
"directory not empty"
]
],
[
-38,
[
"ENOTSOCK",
"socket operation on non-socket"
]
],
[
-45,
[
"ENOTSUP",
"operation not supported on socket"
]
],
[
-84,
[
"EOVERFLOW",
"value too large for defined data type"
]
],
[
-1,
[
"EPERM",
"operation not permitted"
]
],
[
-32,
[
"EPIPE",
"broken pipe"
]
],
[
-92,
[
"EPROTO",
"protocol error"
]
],
[
-43,
[
"EPROTONOSUPPORT",
"protocol not supported"
]
],
[
-41,
[
"EPROTOTYPE",
"protocol wrong type for socket"
]
],
[
-34,
[
"ERANGE",
"result too large"
]
],
[
-30,
[
"EROFS",
"read-only file system"
]
],
[
-58,
[
"ESHUTDOWN",
"cannot send after transport endpoint shutdown"
]
],
[
-29,
[
"ESPIPE",
"invalid seek"
]
],
[
-3,
[
"ESRCH",
"no such process"
]
],
[
-60,
[
"ETIMEDOUT",
"connection timed out"
]
],
[
-26,
[
"ETXTBSY",
"text file is busy"
]
],
[
-18,
[
"EXDEV",
"cross-device link not permitted"
]
],
[
-4094,
[
"UNKNOWN",
"unknown error"
]
],
[
-4095,
[
"EOF",
"end of file"
]
],
[
-6,
[
"ENXIO",
"no such device or address"
]
],
[
-31,
[
"EMLINK",
"too many links"
]
],
[
-64,
[
"EHOSTDOWN",
"host is down"
]
],
[
-4030,
[
"EREMOTEIO",
"remote I/O error"
]
],
[
-25,
[
"ENOTTY",
"inappropriate ioctl for device"
]
],
[
-79,
[
"EFTYPE",
"inappropriate file type or format"
]
],
[
-86,
[
"EILSEQ",
"illegal byte sequence"
]
],
[
-44,
[
"ESOCKTNOSUPPORT",
"socket type not supported"
]
]
];
const errorToCodeFreebsd = codeToErrorFreebsd.map(([status, [code]])=>[
code,
status
]);
const errorMap = new Map(osType === "windows" ? codeToErrorWindows : osType === "darwin" ? codeToErrorDarwin : osType === "linux" ? codeToErrorLinux : osType === "freebsd" ? codeToErrorFreebsd : unreachable());
const codeMap = new Map(osType === "windows" ? errorToCodeWindows : osType === "darwin" ? errorToCodeDarwin : osType === "linux" ? errorToCodeLinux : osType === "freebsd" ? errorToCodeFreebsd : unreachable());
codeMap.get("EAI_MEMORY");
codeMap.get("EBADF");
codeMap.get("EEXIST");
codeMap.get("EINVAL");
codeMap.get("ENOENT");
codeMap.get("ENOTSOCK");
codeMap.get("UNKNOWN");
TextDecoder;
TextEncoder;
const NumberIsSafeInteger = Number.isSafeInteger;
function getSystemErrorName(code) {
if (typeof code !== "number") {
throw new codes.ERR_INVALID_ARG_TYPE("err", "number", code);
}
if (code >= 0 || !NumberIsSafeInteger(code)) {
throw new codes.ERR_OUT_OF_RANGE("err", "a negative integer", code);
}
return errorMap.get(code)?.[0];
}
const isNumericLookup = {};
function isArrayIndex(value) {
switch(typeof value){
case "number":
return value >= 0 && (value | 0) === value;
case "string":
{
const result = isNumericLookup[value];
if (result !== void 0) {
return result;
}
const length = value.length;
if (length === 0) {
return isNumericLookup[value] = false;
}
let ch = 0;
let i = 0;
for(; i < length; ++i){
ch = value.charCodeAt(i);
if (i === 0 && ch === 0x30 && length > 1 || ch < 0x30 || ch > 0x39) {
return isNumericLookup[value] = false;
}
}
return isNumericLookup[value] = true;
}
default:
return false;
}
}
function getOwnNonIndexProperties(obj, filter) {
let allProperties = [
...Object.getOwnPropertyNames(obj),
...Object.getOwnPropertySymbols(obj)
];
if (Array.isArray(obj)) {
allProperties = allProperties.filter((k)=>!isArrayIndex(k));
}
if (filter === 0) {
return allProperties;
}
const result = [];
for (const key of allProperties){
const desc = Object.getOwnPropertyDescriptor(obj, key);
if (desc === undefined) {
continue;
}
if (filter & 1 && !desc.writable) {
continue;
}
if (filter & 2 && !desc.enumerable) {
continue;
}
if (filter & 4 && !desc.configurable) {
continue;
}
if (filter & 8 && typeof key === "string") {
continue;
}
if (filter & 16 && typeof key === "symbol") {
continue;
}
result.push(key);
}
return result;
}
const kObjectType = 0;
const kArrayExtrasType = 2;
const kRejected = 2;
const meta = [
'\\x00',
'\\x01',
'\\x02',
'\\x03',
'\\x04',
'\\x05',
'\\x06',
'\\x07',
'\\b',
'\\t',
'\\n',
'\\x0B',
'\\f',
'\\r',
'\\x0E',
'\\x0F',
'\\x10',
'\\x11',
'\\x12',
'\\x13',
'\\x14',
'\\x15',
'\\x16',
'\\x17',
'\\x18',
'\\x19',
'\\x1A',
'\\x1B',
'\\x1C',
'\\x1D',
'\\x1E',
'\\x1F',
'',
'',
'',
'',
'',
'',
'',
"\\'",
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'\\\\',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'\\x7F',
'\\x80',
'\\x81',
'\\x82',
'\\x83',
'\\x84',
'\\x85',
'\\x86',
'\\x87',
'\\x88',
'\\x89',
'\\x8A',
'\\x8B',
'\\x8C',
'\\x8D',
'\\x8E',
'\\x8F',
'\\x90',
'\\x91',
'\\x92',
'\\x93',
'\\x94',
'\\x95',
'\\x96',
'\\x97',
'\\x98',
'\\x99',
'\\x9A',
'\\x9B',
'\\x9C',
'\\x9D',
'\\x9E',
'\\x9F'
];
const isUndetectableObject = (v)=>typeof v === "undefined" && v !== undefined;
const strEscapeSequencesRegExp = /[\x00-\x1f\x27\x5c\x7f-\x9f]/;
const strEscapeSequencesReplacer = /[\x00-\x1f\x27\x5c\x7f-\x9f]/g;
const strEscapeSequencesRegExpSingle = /[\x00-\x1f\x5c\x7f-\x9f]/;
const strEscapeSequencesReplacerSingle = /[\x00-\x1f\x5c\x7f-\x9f]/g;
const keyStrRegExp = /^[a-zA-Z_][a-zA-Z_0-9]*$/;
const numberRegExp = /^(0|[1-9][0-9]*)$/;
const nodeModulesRegExp = /[/\\]node_modules[/\\](.+?)(?=[/\\])/g;
const classRegExp = /^(\s+[^(]*?)\s*{/;
const stripCommentsRegExp = /(\/\/.*?\n)|(\/\*(.|\n)*?\*\/)/g;
const inspectDefaultOptions = {
showHidden: false,
depth: 2,
colors: false,
customInspect: true,
showProxy: false,
maxArrayLength: 100,
maxStringLength: 10000,
breakLength: 80,
compact: 3,
sorted: false,
getters: false
};
function getUserOptions(ctx, isCrossContext) {
const ret = {
stylize: ctx.stylize,
showHidden: ctx.showHidden,
depth: ctx.depth,
colors: ctx.colors,
customInspect: ctx.customInspect,
showProxy: ctx.showProxy,
maxArrayLength: ctx.maxArrayLength,
maxStringLength: ctx.maxStringLength,
breakLength: ctx.breakLength,
compact: ctx.compact,
sorted: ctx.sorted,
getters: ctx.getters,
...ctx.userOptions
};
if (isCrossContext) {
Object.setPrototypeOf(ret, null);
for (const key of Object.keys(ret)){
if ((typeof ret[key] === "object" || typeof ret[key] === "function") && ret[key] !== null) {
delete ret[key];
}
}
ret.stylize = Object.setPrototypeOf((value, flavour)=>{
let stylized;
try {
stylized = `${ctx.stylize(value, flavour)}`;
} catch {}
if (typeof stylized !== "string") return value;
return stylized;
}, null);
}
return ret;
}
function inspect(value, opts) {
const ctx = {
budget: {},
indentationLvl: 0,
seen: [],
currentDepth: 0,
stylize: stylizeNoColor,
showHidden: inspectDefaultOptions.showHidden,
depth: inspectDefaultOptions.depth,
colors: inspectDefaultOptions.colors,
customInspect: inspectDefaultOptions.customInspect,
showProxy: inspectDefaultOptions.showProxy,
maxArrayLength: inspectDefaultOptions.maxArrayLength,
maxStringLength: inspectDefaultOptions.maxStringLength,
breakLength: inspectDefaultOptions.breakLength,
compact: inspectDefaultOptions.compact,
sorted: inspectDefaultOptions.sorted,
getters: inspectDefaultOptions.getters
};
if (arguments.length > 1) {
if (arguments.length > 2) {
if (arguments[2] !== undefined) {
ctx.depth = arguments[2];
}
if (arguments.length > 3 && arguments[3] !== undefined) {
ctx.colors = arguments[3];
}
}
if (typeof opts === "boolean") {
ctx.showHidden = opts;
} else if (opts) {
const optKeys = Object.keys(opts);
for(let i = 0; i < optKeys.length; ++i){
const key = optKeys[i];
if (inspectDefaultOptions.hasOwnProperty(key) || key === "stylize") {
ctx[key] = opts[key];
} else if (ctx.userOptions === undefined) {
ctx.userOptions = opts;
}
}
}
}
if (ctx.colors) ctx.stylize = stylizeWithColor;
if (ctx.maxArrayLength === null) ctx.maxArrayLength = Infinity;
if (ctx.maxStringLength === null) ctx.maxStringLength = Infinity;
return formatValue(ctx, value, 0);
}
const customInspectSymbol = Symbol.for("nodejs.util.inspect.custom");
inspect.custom = customInspectSymbol;
Object.defineProperty(inspect, "defaultOptions", {
get () {
return inspectDefaultOptions;
},
set (options) {
validateObject(options, "options");
return Object.assign(inspectDefaultOptions, options);
}
});
const defaultFG = 39;
const defaultBG = 49;
inspect.colors = Object.assign(Object.create(null), {
reset: [
0,
0
],
bold: [
1,
22
],
dim: [
2,
22
],
italic: [
3,
23
],
underline: [
4,
24
],
blink: [
5,
25
],
inverse: [
7,
27
],
hidden: [
8,
28
],
strikethrough: [
9,
29
],
doubleunderline: [
21,
24
],
black: [
30,
defaultFG
],
red: [
31,
defaultFG
],
green: [
32,
defaultFG
],
yellow: [
33,
defaultFG
],
blue: [
34,
defaultFG
],
magenta: [
35,
defaultFG
],
cyan: [
36,
defaultFG
],
white: [
37,
defaultFG
],
bgBlack: [
40,
defaultBG
],
bgRed: [
41,
defaultBG
],
bgGreen: [
42,
defaultBG
],
bgYellow: [
43,
defaultBG
],
bgBlue: [
44,
defaultBG
],
bgMagenta: [
45,
defaultBG
],
bgCyan: [
46,
defaultBG
],
bgWhite: [
47,
defaultBG
],
framed: [
51,
54
],
overlined: [
53,
55
],
gray: [
90,
defaultFG
],
redBright: [
91,
defaultFG
],
greenBright: [
92,
defaultFG
],
yellowBright: [
93,
defaultFG
],
blueBright: [
94,
defaultFG
],
magentaBright: [
95,
defaultFG
],
cyanBright: [
96,
defaultFG
],
whiteBright: [
97,
defaultFG
],
bgGray: [
100,
defaultBG
],
bgRedBright: [
101,
defaultBG
],
bgGreenBright: [
102,
defaultBG
],
bgYellowBright: [
103,
defaultBG
],
bgBlueBright: [
104,
defaultBG
],
bgMagentaBright: [
105,
defaultBG
],
bgCyanBright: [
106,
defaultBG
],
bgWhiteBright: [
107,
defaultBG
]
});
function defineColorAlias(target, alias) {
Object.defineProperty(inspect.colors, alias, {
get () {
return this[target];
},
set (value) {
this[target] = value;
},
configurable: true,
enumerable: false
});
}
defineColorAlias("gray", "grey");
defineColorAlias("gray", "blackBright");
defineColorAlias("bgGray", "bgGrey");
defineColorAlias("bgGray", "bgBlackBright");
defineColorAlias("dim", "faint");
defineColorAlias("strikethrough", "crossedout");
defineColorAlias("strikethrough", "strikeThrough");
defineColorAlias("strikethrough", "crossedOut");
defineColorAlias("hidden", "conceal");
defineColorAlias("inverse", "swapColors");
defineColorAlias("inverse", "swapcolors");
defineColorAlias("doubleunderline", "doubleUnderline");
inspect.styles = Object.assign(Object.create(null), {
special: "cyan",
number: "yellow",
bigint: "yellow",
boolean: "yellow",
undefined: "grey",
null: "bold",
string: "green",
symbol: "green",
date: "magenta",
regexp: "red",
module: "underline"
});
function addQuotes(str, quotes) {
if (quotes === -1) {
return `"${str}"`;
}
if (quotes === -2) {
return `\`${str}\``;
}
return `'${str}'`;
}
const escapeFn = (str)=>meta[str.charCodeAt(0)];
function strEscape(str) {
let escapeTest = strEscapeSequencesRegExp;
let escapeReplace = strEscapeSequencesReplacer;
let singleQuote = 39;
if (str.includes("'")) {
if (!str.includes('"')) {
singleQuote = -1;
} else if (!str.includes("`") && !str.includes("${")) {
singleQuote = -2;
}
if (singleQuote !== 39) {
escapeTest = strEscapeSequencesRegExpSingle;
escapeReplace = strEscapeSequencesReplacerSingle;
}
}
if (str.length < 5000 && !escapeTest.test(str)) {
return addQuotes(str, singleQuote);
}
if (str.length > 100) {
str = str.replace(escapeReplace, escapeFn);
return addQuotes(str, singleQuote);
}
let result = "";
let last = 0;
const lastIndex = str.length;
for(let i = 0; i < lastIndex; i++){
const point = str.charCodeAt(i);
if (point === singleQuote || point === 92 || point < 32 || point > 126 && point < 160) {
if (last === i) {
result += meta[point];
} else {
result += `${str.slice(last, i)}${meta[point]}`;
}
last = i + 1;
}
}
if (last !== lastIndex) {
result += str.slice(last);
}
return addQuotes(result, singleQuote);
}
function stylizeWithColor(str, styleType) {
const style = inspect.styles[styleType];
if (style !== undefined) {
const color = inspect.colors[style];
if (color !== undefined) {
return `\u001b[${color[0]}m${str}\u001b[${color[1]}m`;
}
}
return str;
}
function stylizeNoColor(str) {
return str;
}
function formatValue(ctx, value, recurseTimes, typedArray) {
if (typeof value !== "object" && typeof value !== "function" && !isUndetectableObject(value)) {
return formatPrimitive(ctx.stylize, value, ctx);
}
if (value === null) {
return ctx.stylize("null", "null");
}
const context = value;
const proxy = undefined;
if (ctx.customInspect) {
const maybeCustom = value[customInspectSymbol];
if (typeof maybeCustom === "function" && maybeCustom !== inspect && !(value.constructor && value.constructor.prototype === value)) {
const depth = ctx.depth === null ? null : ctx.depth - recurseTimes;
const isCrossContext = proxy !== undefined || !(context instanceof Object);
const ret = maybeCustom.call(context, depth, getUserOptions(ctx, isCrossContext));
if (ret !== context) {
if (typeof ret !== "string") {
return formatValue(ctx, ret, recurseTimes);
}
return ret.replace(/\n/g, `\n${" ".repeat(ctx.indentationLvl)}`);
}
}
}
if (ctx.seen.includes(value)) {
let index = 1;
if (ctx.circular === undefined) {
ctx.circular = new Map();
ctx.circular.set(value, index);
} else {
index = ctx.circular.get(value);
if (index === undefined) {
index = ctx.circular.size + 1;
ctx.circular.set(value, index);
}
}
return ctx.stylize(`[Circular *${index}]`, "special");
}
return formatRaw(ctx, value, recurseTimes, typedArray);
}
function formatRaw(ctx, value, recurseTimes, typedArray) {
let keys;
let protoProps;
if (ctx.showHidden && (recurseTimes <= ctx.depth || ctx.depth === null)) {
protoProps = [];
}
const constructor = getConstructorName(value, ctx, recurseTimes, protoProps);
if (protoProps !== undefined && protoProps.length === 0) {
protoProps = undefined;
}
let tag = value[Symbol.toStringTag];
if (typeof tag !== "string") {
tag = "";
}
let base = "";
let formatter = getEmptyFormatArray;
let braces;
let noIterator = true;
let i = 0;
const filter = ctx.showHidden ? 0 : 2;
let extrasType = 0;
if (value[Symbol.iterator] || constructor === null) {
noIterator = false;
if (Array.isArray(value)) {
const prefix = constructor !== "Array" || tag !== "" ? getPrefix(constructor, tag, "Array", `(${value.length})`) : "";
keys = getOwnNonIndexProperties(value, filter);
braces = [
`${prefix}[`,
"]"
];
if (value.length === 0 && keys.length === 0 && protoProps === undefined) {
return `${braces[0]}]`;
}
extrasType = kArrayExtrasType;
formatter = formatArray;
} else if (isSet1(value)) {
const size = value.size;
const prefix = getPrefix(constructor, tag, "Set", `(${size})`);
keys = getKeys(value, ctx.showHidden);
formatter = constructor !== null ? formatSet.bind(null, value) : formatSet.bind(null, value.values());
if (size === 0 && keys.length === 0 && protoProps === undefined) {
return `${prefix}{}`;
}
braces = [
`${prefix}{`,
"}"
];
} else if (isMap1(value)) {
const size = value.size;
const prefix = getPrefix(constructor, tag, "Map", `(${size})`);
keys = getKeys(value, ctx.showHidden);
formatter = constructor !== null ? formatMap.bind(null, value) : formatMap.bind(null, value.entries());
if (size === 0 && keys.length === 0 && protoProps === undefined) {
return `${prefix}{}`;
}
braces = [
`${prefix}{`,
"}"
];
} else if (isTypedArray(value)) {
keys = getOwnNonIndexProperties(value, filter);
const bound = value;
const fallback = "";
if (constructor === null) {}
const size = value.length;
const prefix = getPrefix(constructor, tag, fallback, `(${size})`);
braces = [
`${prefix}[`,
"]"
];
if (value.length === 0 && keys.length === 0 && !ctx.showHidden) {
return `${braces[0]}]`;
}
formatter = formatTypedArray.bind(null, bound, size);
extrasType = kArrayExtrasType;
} else if (isMapIterator1(value)) {
keys = getKeys(value, ctx.showHidden);
braces = getIteratorBraces("Map", tag);
formatter = formatIterator.bind(null, braces);
} else if (isSetIterator1(value)) {
keys = getKeys(value, ctx.showHidden);
braces = getIteratorBraces("Set", tag);
formatter = formatIterator.bind(null, braces);
} else {
noIterator = true;
}
}
if (noIterator) {
keys = getKeys(value, ctx.showHidden);
braces = [
"{",
"}"
];
if (constructor === "Object") {
if (isArgumentsObject1(value)) {
braces[0] = "[Arguments] {";
} else if (tag !== "") {
braces[0] = `${getPrefix(constructor, tag, "Object")}{`;
}
if (keys.length === 0 && protoProps === undefined) {
return `${braces[0]}}`;
}
} else if (typeof value === "function") {
base = getFunctionBase(value, constructor, tag);
if (keys.length === 0 && protoProps === undefined) {
return ctx.stylize(base, "special");
}
} else if (isRegExp1(value)) {
base = RegExp(constructor !== null ? value : new RegExp(value)).toString();
const prefix = getPrefix(constructor, tag, "RegExp");
if (prefix !== "RegExp ") {
base = `${prefix}${base}`;
}
if (keys.length === 0 && protoProps === undefined || recurseTimes > ctx.depth && ctx.depth !== null) {
return ctx.stylize(base, "regexp");
}
} else if (isDate1(value)) {
base = Number.isNaN(value.getTime()) ? value.toString() : value.toISOString();
const prefix = getPrefix(constructor, tag, "Date");
if (prefix !== "Date ") {
base = `${prefix}${base}`;
}
if (keys.length === 0 && protoProps === undefined) {
return ctx.stylize(base, "date");
}
} else if (value instanceof Error) {
base = formatError(value, constructor, tag, ctx, keys);
if (keys.length === 0 && protoProps === undefined) {
return base;
}
} else if (isAnyArrayBuffer1(value)) {
const arrayType = isArrayBuffer1(value) ? "ArrayBuffer" : "SharedArrayBuffer";
const prefix = getPrefix(constructor, tag, arrayType);
if (typedArray === undefined) {
formatter = formatArrayBuffer;
} else if (keys.length === 0 && protoProps === undefined) {
return prefix + `{ byteLength: ${formatNumber(ctx.stylize, value.byteLength)} }`;
}
braces[0] = `${prefix}{`;
Array.prototype.unshift.call(keys, "byteLength");
} else if (isDataView1(value)) {
braces[0] = `${getPrefix(constructor, tag, "DataView")}{`;
Array.prototype.unshift.call(keys, "byteLength", "byteOffset", "buffer");
} else if (isPromise1(value)) {
braces[0] = `${getPrefix(constructor, tag, "Promise")}{`;
formatter = formatPromise;
} else if (isWeakSet1(value)) {
braces[0] = `${getPrefix(constructor, tag, "WeakSet")}{`;
formatter = ctx.showHidden ? formatWeakSet : formatWeakCollection;
} else if (isWeakMap1(value)) {
braces[0] = `${getPrefix(constructor, tag, "WeakMap")}{`;
formatter = ctx.showHidden ? formatWeakMap : formatWeakCollection;
} else if (isModuleNamespaceObject1(value)) {
braces[0] = `${getPrefix(constructor, tag, "Module")}{`;
formatter = formatNamespaceObject.bind(null, keys);
} else if (isBoxedPrimitive1(value)) {
base = getBoxedBase(value, ctx, keys, constructor, tag);
if (keys.length === 0 && protoProps === undefined) {
return base;
}
} else {
if (keys.length === 0 && protoProps === undefined) {
return `${getCtxStyle(value, constructor, tag)}{}`;
}
braces[0] = `${getCtxStyle(value, constructor, tag)}{`;
}
}
if (recurseTimes > ctx.depth && ctx.depth !== null) {
let constructorName = getCtxStyle(value, constructor, tag).slice(0, -1);
if (constructor !== null) {
constructorName = `[${constructorName}]`;
}
return ctx.stylize(constructorName, "special");
}
recurseTimes += 1;
ctx.seen.push(value);
ctx.currentDepth = recurseTimes;
let output;
const indentationLvl = ctx.indentationLvl;
try {
output = formatter(ctx, value, recurseTimes);
for(i = 0; i < keys.length; i++){
output.push(formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
}
if (protoProps !== undefined) {
output.push(...protoProps);
}
} catch (err) {
const constructorName = getCtxStyle(value, constructor, tag).slice(0, -1);
return handleMaxCallStackSize(ctx, err, constructorName, indentationLvl);
}
if (ctx.circular !== undefined) {
const index = ctx.circular.get(value);
if (index !== undefined) {
const reference = ctx.stylize(`<ref *${index}>`, "special");
if (ctx.compact !== true) {
base = base === "" ? reference : `${reference} ${base}`;
} else {
braces[0] = `${reference} ${braces[0]}`;
}
}
}
ctx.seen.pop();
if (ctx.sorted) {
const comparator = ctx.sorted === true ? undefined : ctx.sorted;
if (extrasType === 0) {
output = output.sort(comparator);
} else if (keys.length > 1) {
const sorted = output.slice(output.length - keys.length).sort(comparator);
output.splice(output.length - keys.length, keys.length, ...sorted);
}
}
const res = reduceToSingleString(ctx, output, base, braces, extrasType, recurseTimes, value);
const budget = ctx.budget[ctx.indentationLvl] || 0;
const newLength = budget + res.length;
ctx.budget[ctx.indentationLvl] = newLength;
if (newLength > 2 ** 27) {
ctx.depth = -1;
}
return res;
}
const builtInObjects = new Set(Object.getOwnPropertyNames(globalThis).filter((e)=>/^[A-Z][a-zA-Z0-9]+$/.test(e)));
function addPrototypeProperties(ctx, main, obj, recurseTimes, output) {
let depth = 0;
let keys;
let keySet;
do {
if (depth !== 0 || main === obj) {
obj = Object.getPrototypeOf(obj);
if (obj === null) {
return;
}
const descriptor = Object.getOwnPropertyDescriptor(obj, "constructor");
if (descriptor !== undefined && typeof descriptor.value === "function" && builtInObjects.has(descriptor.value.name)) {
return;
}
}
if (depth === 0) {
keySet = new Set();
} else {
Array.prototype.forEach.call(keys, (key)=>keySet.add(key));
}
keys = Reflect.ownKeys(obj);
Array.prototype.push.call(ctx.seen, main);
for (const key of keys){
if (key === "constructor" || main.hasOwnProperty(key) || depth !== 0 && keySet.has(key)) {
continue;
}
const desc = Object.getOwnPropertyDescriptor(obj, key);
if (typeof desc.value === "function") {
continue;
}
const value = formatProperty(ctx, obj, recurseTimes, key, 0, desc, main);
if (ctx.colors) {
Array.prototype.push.call(output, `\u001b[2m${value}\u001b[22m`);
} else {
Array.prototype.push.call(output, value);
}
}
Array.prototype.pop.call(ctx.seen);
}while (++depth !== 3)
}
function getConstructorName(obj, ctx, recurseTimes, protoProps) {
let firstProto;
const tmp = obj;
while(obj || isUndetectableObject(obj)){
const descriptor = Object.getOwnPropertyDescriptor(obj, "constructor");
if (descriptor !== undefined && typeof descriptor.value === "function" && descriptor.value.name !== "" && isInstanceof(tmp, descriptor.value)) {
if (protoProps !== undefined && (firstProto !== obj || !builtInObjects.has(descriptor.value.name))) {
addPrototypeProperties(ctx, tmp, firstProto || tmp, recurseTimes, protoProps);
}
return descriptor.value.name;
}
obj = Object.getPrototypeOf(obj);
if (firstProto === undefined) {
firstProto = obj;
}
}
if (firstProto === null) {
return null;
}
const res = undefined;
if (recurseTimes > ctx.depth && ctx.depth !== null) {
return `${res} <Complex prototype>`;
}
const protoConstr = getConstructorName(firstProto, ctx, recurseTimes + 1, protoProps);
if (protoConstr === null) {
return `${res} <${inspect(firstProto, {
...ctx,
customInspect: false,
depth: -1
})}>`;
}
return `${res} <${protoConstr}>`;
}
function formatPrimitive(fn, value, ctx) {
if (typeof value === "string") {
let trailer = "";
if (value.length > ctx.maxStringLength) {
const remaining = value.length - ctx.maxStringLength;
value = value.slice(0, ctx.maxStringLength);
trailer = `... ${remaining} more character${remaining > 1 ? "s" : ""}`;
}
if (ctx.compact !== true && value.length > 16 && value.length > ctx.breakLength - ctx.indentationLvl - 4) {
return value.split(/(?<=\n)/).map((line)=>fn(strEscape(line), "string")).join(` +\n${" ".repeat(ctx.indentationLvl + 2)}`) + trailer;
}
return fn(strEscape(value), "string") + trailer;
}
if (typeof value === "number") {
return formatNumber(fn, value);
}
if (typeof value === "bigint") {
return formatBigInt(fn, value);
}
if (typeof value === "boolean") {
return fn(`${value}`, "boolean");
}
if (typeof value === "undefined") {
return fn("undefined", "undefined");
}
return fn(value.toString(), "symbol");
}
function getEmptyFormatArray() {
return [];
}
function isInstanceof(object, proto) {
try {
return object instanceof proto;
} catch {
return false;
}
}
function getPrefix(constructor, tag, fallback, size = "") {
if (constructor === null) {
if (tag !== "" && fallback !== tag) {
return `[${fallback}${size}: null prototype] [${tag}] `;
}
return `[${fallback}${size}: null prototype] `;
}
if (tag !== "" && constructor !== tag) {
return `${constructor}${size} [${tag}] `;
}
return `${constructor}${size} `;
}
function formatArray(ctx, value, recurseTimes) {
const valLen = value.length;
const len = Math.min(Math.max(0, ctx.maxArrayLength), valLen);
const remaining = valLen - len;
const output = [];
for(let i = 0; i < len; i++){
if (!value.hasOwnProperty(i)) {
return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
}
output.push(formatProperty(ctx, value, recurseTimes, i, 1));
}
if (remaining > 0) {
output.push(`... ${remaining} more item${remaining > 1 ? "s" : ""}`);
}
return output;
}
function getCtxStyle(_value, constructor, tag) {
let fallback = "";
if (constructor === null) {
if (fallback === tag) {
fallback = "Object";
}
}
return getPrefix(constructor, tag, fallback);
}
function getKeys(value, showHidden) {
let keys;
const symbols = Object.getOwnPropertySymbols(value);
if (showHidden) {
keys = Object.getOwnPropertyNames(value);
if (symbols.length !== 0) {
Array.prototype.push.apply(keys, symbols);
}
} else {
try {
keys = Object.keys(value);
} catch (_err) {
keys = Object.getOwnPropertyNames(value);
}
if (symbols.length !== 0) {}
}
return keys;
}
function formatSet(value, ctx, _ignored, recurseTimes) {
const output = [];
ctx.indentationLvl += 2;
for (const v of value){
Array.prototype.push.call(output, formatValue(ctx, v, recurseTimes));
}
ctx.indentationLvl -= 2;
return output;
}
function formatMap(value, ctx, _gnored, recurseTimes) {
const output = [];
ctx.indentationLvl += 2;
for (const { 0: k, 1: v } of value){
output.push(`${formatValue(ctx, k, recurseTimes)} => ${formatValue(ctx, v, recurseTimes)}`);
}
ctx.indentationLvl -= 2;
return output;
}
function formatTypedArray(value, length, ctx, _ignored, recurseTimes) {
const maxLength = Math.min(Math.max(0, ctx.maxArrayLength), length);
const remaining = value.length - maxLength;
const output = new Array(maxLength);
const elementFormatter = value.length > 0 && typeof value[0] === "number" ? formatNumber : formatBigInt;
for(let i = 0; i < maxLength; ++i){
output[i] = elementFormatter(ctx.stylize, value[i]);
}
if (remaining > 0) {
output[maxLength] = `... ${remaining} more item${remaining > 1 ? "s" : ""}`;
}
if (ctx.showHidden) {
ctx.indentationLvl += 2;
for (const key of [
"BYTES_PER_ELEMENT",
"length",
"byteLength",
"byteOffset",
"buffer"
]){
const str = formatValue(ctx, value[key], recurseTimes, true);
Array.prototype.push.call(output, `[${key}]: ${str}`);
}
ctx.indentationLvl -= 2;
}
return output;
}
function getIteratorBraces(type, tag) {
if (tag !== `${type} Iterator`) {
if (tag !== "") {
tag += "] [";
}
tag += `${type} Iterator`;
}
return [
`[${tag}] {`,
"}"
];
}
function formatIterator(braces, ctx, value, recurseTimes) {
const { 0: entries, 1: isKeyValue } = value;
if (isKeyValue) {
braces[0] = braces[0].replace(/ Iterator] {$/, " Entries] {");
return formatMapIterInner(ctx, recurseTimes, entries, 2);
}
return formatSetIterInner(ctx, recurseTimes, entries, 1);
}
function getFunctionBase(value, constructor, tag) {
const stringified = Function.prototype.toString.call(value);
if (stringified.slice(0, 5) === "class" && stringified.endsWith("}")) {
const slice = stringified.slice(5, -1);
const bracketIndex = slice.indexOf("{");
if (bracketIndex !== -1 && (!slice.slice(0, bracketIndex).includes("(") || classRegExp.test(slice.replace(stripCommentsRegExp)))) {
return getClassBase(value, constructor, tag);
}
}
let type = "Function";
if (isGeneratorFunction1(value)) {
type = `Generator${type}`;
}
if (isAsyncFunction1(value)) {
type = `Async${type}`;
}
let base = `[${type}`;
if (constructor === null) {
base += " (null prototype)";
}
if (value.name === "") {
base += " (anonymous)";
} else {
base += `: ${value.name}`;
}
base += "]";
if (constructor !== type && constructor !== null) {
base += ` ${constructor}`;
}
if (tag !== "" && constructor !== tag) {
base += ` [${tag}]`;
}
return base;
}
function formatError(err, constructor, tag, ctx, keys) {
const name = err.name != null ? String(err.name) : "Error";
let len = name.length;
let stack = err.stack ? String(err.stack) : err.toString();
if (!ctx.showHidden && keys.length !== 0) {
for (const name of [
"name",
"message",
"stack"
]){
const index = keys.indexOf(name);
if (index !== -1 && stack.includes(err[name])) {
keys.splice(index, 1);
}
}
}
if (constructor === null || name.endsWith("Error") && stack.startsWith(name) && (stack.length === len || stack[len] === ":" || stack[len] === "\n")) {
let fallback = "Error";
if (constructor === null) {
const start = stack.match(/^([A-Z][a-z_ A-Z0-9[\]()-]+)(?::|\n {4}at)/) || stack.match(/^([a-z_A-Z0-9-]*Error)$/);
fallback = start && start[1] || "";
len = fallback.length;
fallback = fallback || "Error";
}
const prefix = getPrefix(constructor, tag, fallback).slice(0, -1);
if (name !== prefix) {
if (prefix.includes(name)) {
if (len === 0) {
stack = `${prefix}: ${stack}`;
} else {
stack = `${prefix}${stack.slice(len)}`;
}
} else {
stack = `${prefix} [${name}]${stack.slice(len)}`;
}
}
}
let pos = err.message && stack.indexOf(err.message) || -1;
if (pos !== -1) {
pos += err.message.length;
}
const stackStart = stack.indexOf("\n at", pos);
if (stackStart === -1) {
stack = `[${stack}]`;
} else if (ctx.colors) {
let newStack = stack.slice(0, stackStart);
const lines = stack.slice(stackStart + 1).split("\n");
for (const line of lines){
let nodeModule;
newStack += "\n";
let pos = 0;
while(nodeModule = nodeModulesRegExp.exec(line)){
newStack += line.slice(pos, nodeModule.index + 14);
newStack += ctx.stylize(nodeModule[1], "module");
pos = nodeModule.index + nodeModule[0].length;
}
newStack += pos === 0 ? line : line.slice(pos);
}
stack = newStack;
}
if (ctx.indentationLvl !== 0) {
const indentation = " ".repeat(ctx.indentationLvl);
stack = stack.replace(/\n/g, `\n${indentation}`);
}
return stack;
}
let hexSlice;
function formatArrayBuffer(ctx, value) {
let buffer;
try {
buffer = new Uint8Array(value);
} catch {
return [
ctx.stylize("(detached)", "special")
];
}
let str = hexSlice(buffer, 0, Math.min(ctx.maxArrayLength, buffer.length)).replace(/(.{2})/g, "$1 ").trim();
const remaining = buffer.length - ctx.maxArrayLength;
if (remaining > 0) {
str += ` ... ${remaining} more byte${remaining > 1 ? "s" : ""}`;
}
return [
`${ctx.stylize("[Uint8Contents]", "special")}: <${str}>`
];
}
function formatNumber(fn, value) {
return fn(Object.is(value, -0) ? "-0" : `${value}`, "number");
}
function formatPromise(ctx, value, recurseTimes) {
let output;
const { 0: state, 1: result } = value;
if (state === 0) {
output = [
ctx.stylize("<pending>", "special")
];
} else {
ctx.indentationLvl += 2;
const str = formatValue(ctx, result, recurseTimes);
ctx.indentationLvl -= 2;
output = [
state === kRejected ? `${ctx.stylize("<rejected>", "special")} ${str}` : str
];
}
return output;
}
function formatWeakCollection(ctx) {
return [
ctx.stylize("<items unknown>", "special")
];
}
function formatWeakSet(ctx, value, recurseTimes) {
const entries = value;
return formatSetIterInner(ctx, recurseTimes, entries, 0);
}
function formatWeakMap(ctx, value, recurseTimes) {
const entries = value;
return formatMapIterInner(ctx, recurseTimes, entries, 0);
}
function formatProperty(ctx, value, recurseTimes, key, type, desc, original = value) {
let name, str;
let extra = " ";
desc = desc || Object.getOwnPropertyDescriptor(value, key) || {
value: value[key],
enumerable: true
};
if (desc.value !== undefined) {
const diff = ctx.compact !== true || type !== 0 ? 2 : 3;
ctx.indentationLvl += diff;
str = formatValue(ctx, desc.value, recurseTimes);
if (diff === 3 && ctx.breakLength < getStringWidth(str, ctx.colors)) {
extra = `\n${" ".repeat(ctx.indentationLvl)}`;
}
ctx.indentationLvl -= diff;
} else if (desc.get !== undefined) {
const label = desc.set !== undefined ? "Getter/Setter" : "Getter";
const s = ctx.stylize;
const sp = "special";
if (ctx.getters && (ctx.getters === true || ctx.getters === "get" && desc.set === undefined || ctx.getters === "set" && desc.set !== undefined)) {
try {
const tmp = desc.get.call(original);
ctx.indentationLvl += 2;
if (tmp === null) {
str = `${s(`[${label}:`, sp)} ${s("null", "null")}${s("]", sp)}`;
} else if (typeof tmp === "object") {
str = `${s(`[${label}]`, sp)} ${formatValue(ctx, tmp, recurseTimes)}`;
} else {
const primitive = formatPrimitive(s, tmp, ctx);
str = `${s(`[${label}:`, sp)} ${primitive}${s("]", sp)}`;
}
ctx.indentationLvl -= 2;
} catch (err) {
const message = `<Inspection threw (${err.message})>`;
str = `${s(`[${label}:`, sp)} ${message}${s("]", sp)}`;
}
} else {
str = ctx.stylize(`[${label}]`, sp);
}
} else if (desc.set !== undefined) {
str = ctx.stylize("[Setter]", "special");
} else {
str = ctx.stylize("undefined", "undefined");
}
if (type === 1) {
return str;
}
if (typeof key === "symbol") {
const tmp = key.toString().replace(strEscapeSequencesReplacer, escapeFn);
name = `[${ctx.stylize(tmp, "symbol")}]`;
} else if (key === "__proto__") {
name = "['__proto__']";
} else if (desc.enumerable === false) {
const tmp = key.replace(strEscapeSequencesReplacer, escapeFn);
name = `[${tmp}]`;
} else if (keyStrRegExp.test(key)) {
name = ctx.stylize(key, "name");
} else {
name = ctx.stylize(strEscape(key), "string");
}
return `${name}:${extra}${str}`;
}
function handleMaxCallStackSize(_ctx, _err, _constructorName, _indentationLvl) {}
const colorRegExp = /\u001b\[\d\d?m/g;
function removeColors(str) {
return str.replace(colorRegExp, "");
}
function isBelowBreakLength(ctx, output, start, base) {
let totalLength = output.length + start;
if (totalLength + output.length > ctx.breakLength) {
return false;
}
for(let i = 0; i < output.length; i++){
if (ctx.colors) {
totalLength += removeColors(output[i]).length;
} else {
totalLength += output[i].length;
}
if (totalLength > ctx.breakLength) {
return false;
}
}
return base === "" || !base.includes("\n");
}
function formatBigInt(fn, value) {
return fn(`${value}n`, "bigint");
}
function formatNamespaceObject(keys, ctx, value, recurseTimes) {
const output = new Array(keys.length);
for(let i = 0; i < keys.length; i++){
try {
output[i] = formatProperty(ctx, value, recurseTimes, keys[i], kObjectType);
} catch (_err) {
const tmp = {
[keys[i]]: ""
};
output[i] = formatProperty(ctx, tmp, recurseTimes, keys[i], kObjectType);
const pos = output[i].lastIndexOf(" ");
output[i] = output[i].slice(0, pos + 1) + ctx.stylize("<uninitialized>", "special");
}
}
keys.length = 0;
return output;
}
function formatSpecialArray(ctx, value, recurseTimes, maxLength, output, i) {
const keys = Object.keys(value);
let index = i;
for(; i < keys.length && output.length < maxLength; i++){
const key = keys[i];
const tmp = +key;
if (tmp > 2 ** 32 - 2) {
break;
}
if (`${index}` !== key) {
if (!numberRegExp.test(key)) {
break;
}
const emptyItems = tmp - index;
const ending = emptyItems > 1 ? "s" : "";
const message = `<${emptyItems} empty item${ending}>`;
output.push(ctx.stylize(message, "undefined"));
index = tmp;
if (output.length === maxLength) {
break;
}
}
output.push(formatProperty(ctx, value, recurseTimes, key, 1));
index++;
}
const remaining = value.length - index;
if (output.length !== maxLength) {
if (remaining > 0) {
const ending = remaining > 1 ? "s" : "";
const message = `<${remaining} empty item${ending}>`;
output.push(ctx.stylize(message, "undefined"));
}
} else if (remaining > 0) {
output.push(`... ${remaining} more item${remaining > 1 ? "s" : ""}`);
}
return output;
}
function getBoxedBase(value, ctx, keys, constructor, tag) {
let type;
if (isNumberObject1(value)) {
type = "Number";
} else if (isStringObject1(value)) {
type = "String";
keys.splice(0, value.length);
} else if (isBooleanObject1(value)) {
type = "Boolean";
} else if (isBigIntObject1(value)) {
type = "BigInt";
} else {
type = "Symbol";
}
let base = `[${type}`;
if (type !== constructor) {
if (constructor === null) {
base += " (null prototype)";
} else {
base += ` (${constructor})`;
}
}
base += `: ${formatPrimitive(stylizeNoColor, value.valueOf(), ctx)}]`;
if (tag !== "" && tag !== constructor) {
base += ` [${tag}]`;
}
if (keys.length !== 0 || ctx.stylize === stylizeNoColor) {
return base;
}
return ctx.stylize(base, type.toLowerCase());
}
function getClassBase(value, constructor, tag) {
const hasName = value.hasOwnProperty("name");
const name = hasName && value.name || "(anonymous)";
let base = `class ${name}`;
if (constructor !== "Function" && constructor !== null) {
base += ` [${constructor}]`;
}
if (tag !== "" && constructor !== tag) {
base += ` [${tag}]`;
}
if (constructor !== null) {
const superName = Object.getPrototypeOf(value).name;
if (superName) {
base += ` extends ${superName}`;
}
} else {
base += " extends [null prototype]";
}
return `[${base}]`;
}
function reduceToSingleString(ctx, output, base, braces, extrasType, recurseTimes, value) {
if (ctx.compact !== true) {
if (typeof ctx.compact === "number" && ctx.compact >= 1) {
const entries = output.length;
if (extrasType === 2 && entries > 6) {
output = groupArrayElements(ctx, output, value);
}
if (ctx.currentDepth - recurseTimes < ctx.compact && entries === output.length) {
const start = output.length + ctx.indentationLvl + braces[0].length + base.length + 10;
if (isBelowBreakLength(ctx, output, start, base)) {
return `${base ? `${base} ` : ""}${braces[0]} ${join(output, ", ")}` + ` ${braces[1]}`;
}
}
}
const indentation = `\n${" ".repeat(ctx.indentationLvl)}`;
return `${base ? `${base} ` : ""}${braces[0]}${indentation} ` + `${join(output, `,${indentation} `)}${indentation}${braces[1]}`;
}
if (isBelowBreakLength(ctx, output, 0, base)) {
return `${braces[0]}${base ? ` ${base}` : ""} ${join(output, ", ")} ` + braces[1];
}
const indentation = " ".repeat(ctx.indentationLvl);
const ln = base === "" && braces[0].length === 1 ? " " : `${base ? ` ${base}` : ""}\n${indentation} `;
return `${braces[0]}${ln}${join(output, `,\n${indentation} `)} ${braces[1]}`;
}
function join(output, separator) {
let str = "";
if (output.length !== 0) {
const lastIndex = output.length - 1;
for(let i = 0; i < lastIndex; i++){
str += output[i];
str += separator;
}
str += output[lastIndex];
}
return str;
}
function groupArrayElements(ctx, output, value) {
let totalLength = 0;
let maxLength = 0;
let i = 0;
let outputLength = output.length;
if (ctx.maxArrayLength < output.length) {
outputLength--;
}
const separatorSpace = 2;
const dataLen = new Array(outputLength);
for(; i < outputLength; i++){
const len = getStringWidth(output[i], ctx.colors);
dataLen[i] = len;
totalLength += len + separatorSpace;
if (maxLength < len) {
maxLength = len;
}
}
const actualMax = maxLength + 2;
if (actualMax * 3 + ctx.indentationLvl < ctx.breakLength && (totalLength / actualMax > 5 || maxLength <= 6)) {
const averageBias = Math.sqrt(actualMax - totalLength / output.length);
const biasedMax = Math.max(actualMax - 3 - averageBias, 1);
const columns = Math.min(Math.round(Math.sqrt(2.5 * biasedMax * outputLength) / biasedMax), Math.floor((ctx.breakLength - ctx.indentationLvl) / actualMax), ctx.compact * 4, 15);
if (columns <= 1) {
return output;
}
const tmp = [];
const maxLineLength = [];
for(let i = 0; i < columns; i++){
let lineMaxLength = 0;
for(let j = i; j < output.length; j += columns){
if (dataLen[j] > lineMaxLength) {
lineMaxLength = dataLen[j];
}
}
lineMaxLength += separatorSpace;
maxLineLength[i] = lineMaxLength;
}
let order = String.prototype.padStart;
if (value !== undefined) {
for(let i = 0; i < output.length; i++){
if (typeof value[i] !== "number" && typeof value[i] !== "bigint") {
order = String.prototype.padEnd;
break;
}
}
}
for(let i = 0; i < outputLength; i += columns){
const max = Math.min(i + columns, outputLength);
let str = "";
let j = i;
for(; j < max - 1; j++){
const padding = maxLineLength[j - i] + output[j].length - dataLen[j];
str += `${output[j]}, `.padStart(padding, " ");
}
if (order === String.prototype.padStart) {
const padding = maxLineLength[j - i] + output[j].length - dataLen[j] - 2;
str += output[j].padStart(padding, " ");
} else {
str += output[j];
}
Array.prototype.push.call(tmp, str);
}
if (ctx.maxArrayLength < output.length) {
Array.prototype.push.call(tmp, output[outputLength]);
}
output = tmp;
}
return output;
}
function formatMapIterInner(ctx, recurseTimes, entries, state) {
const maxArrayLength = Math.max(ctx.maxArrayLength, 0);
const len = entries.length / 2;
const remaining = len - maxArrayLength;
const maxLength = Math.min(maxArrayLength, len);
let output = new Array(maxLength);
let i = 0;
ctx.indentationLvl += 2;
if (state === 0) {
for(; i < maxLength; i++){
const pos = i * 2;
output[i] = `${formatValue(ctx, entries[pos], recurseTimes)} => ${formatValue(ctx, entries[pos + 1], recurseTimes)}`;
}
if (!ctx.sorted) {
output = output.sort();
}
} else {
for(; i < maxLength; i++){
const pos = i * 2;
const res = [
formatValue(ctx, entries[pos], recurseTimes),
formatValue(ctx, entries[pos + 1], recurseTimes)
];
output[i] = reduceToSingleString(ctx, res, "", [
"[",
"]"
], kArrayExtrasType, recurseTimes);
}
}
ctx.indentationLvl -= 2;
if (remaining > 0) {
output.push(`... ${remaining} more item${remaining > 1 ? "s" : ""}`);
}
return output;
}
function formatSetIterInner(ctx, recurseTimes, entries, state) {
const maxArrayLength = Math.max(ctx.maxArrayLength, 0);
const maxLength = Math.min(maxArrayLength, entries.length);
const output = new Array(maxLength);
ctx.indentationLvl += 2;
for(let i = 0; i < maxLength; i++){
output[i] = formatValue(ctx, entries[i], recurseTimes);
}
ctx.indentationLvl -= 2;
if (state === 0 && !ctx.sorted) {
output.sort();
}
const remaining = entries.length - maxLength;
if (remaining > 0) {
Array.prototype.push.call(output, `... ${remaining} more item${remaining > 1 ? "s" : ""}`);
}
return output;
}
const ansiPattern = "[\\u001B\\u009B][[\\]()#;?]*" + "(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*" + "|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)" + "|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))";
const ansi = new RegExp(ansiPattern, "g");
function getStringWidth(str, removeControlChars = true) {
let width = 0;
if (removeControlChars) {
str = stripVTControlCharacters(str);
}
str = str.normalize("NFC");
for (const __char of str[Symbol.iterator]()){
const code = __char.codePointAt(0);
if (isFullWidthCodePoint(code)) {
width += 2;
} else if (!isZeroWidthCodePoint(code)) {
width++;
}
}
return width;
}
const isFullWidthCodePoint = (code)=>{
return code >= 0x1100 && (code <= 0x115f || code === 0x2329 || code === 0x232a || code >= 0x2e80 && code <= 0x3247 && code !== 0x303f || code >= 0x3250 && code <= 0x4dbf || code >= 0x4e00 && code <= 0xa4c6 || code >= 0xa960 && code <= 0xa97c || code >= 0xac00 && code <= 0xd7a3 || code >= 0xf900 && code <= 0xfaff || code >= 0xfe10 && code <= 0xfe19 || code >= 0xfe30 && code <= 0xfe6b || code >= 0xff01 && code <= 0xff60 || code >= 0xffe0 && code <= 0xffe6 || code >= 0x1b000 && code <= 0x1b001 || code >= 0x1f200 && code <= 0x1f251 || code >= 0x1f300 && code <= 0x1f64f || code >= 0x20000 && code <= 0x3fffd);
};
const isZeroWidthCodePoint = (code)=>{
return code <= 0x1F || code >= 0x7F && code <= 0x9F || code >= 0x300 && code <= 0x36F || code >= 0x200B && code <= 0x200F || code >= 0x20D0 && code <= 0x20FF || code >= 0xFE00 && code <= 0xFE0F || code >= 0xFE20 && code <= 0xFE2F || code >= 0xE0100 && code <= 0xE01EF;
};
function stripVTControlCharacters(str) {
validateString(str, "str");
return str.replace(ansi, "");
}
let os;
if (Deno.build.os === "darwin") {
os = {
UV_UDP_REUSEADDR: 4,
dlopen: {
RTLD_LAZY: 1,
RTLD_NOW: 2,
RTLD_GLOBAL: 8,
RTLD_LOCAL: 4
},
errno: {
E2BIG: 7,
EACCES: 13,
EADDRINUSE: 48,
EADDRNOTAVAIL: 49,
EAFNOSUPPORT: 47,
EAGAIN: 35,
EALREADY: 37,
EBADF: 9,
EBADMSG: 94,
EBUSY: 16,
ECANCELED: 89,
ECHILD: 10,
ECONNABORTED: 53,
ECONNREFUSED: 61,
ECONNRESET: 54,
EDEADLK: 11,
EDESTADDRREQ: 39,
EDOM: 33,
EDQUOT: 69,
EEXIST: 17,
EFAULT: 14,
EFBIG: 27,
EHOSTUNREACH: 65,
EIDRM: 90,
EILSEQ: 92,
EINPROGRESS: 36,
EINTR: 4,
EINVAL: 22,
EIO: 5,
EISCONN: 56,
EISDIR: 21,
ELOOP: 62,
EMFILE: 24,
EMLINK: 31,
EMSGSIZE: 40,
EMULTIHOP: 95,
ENAMETOOLONG: 63,
ENETDOWN: 50,
ENETRESET: 52,
ENETUNREACH: 51,
ENFILE: 23,
ENOBUFS: 55,
ENODATA: 96,
ENODEV: 19,
ENOENT: 2,
ENOEXEC: 8,
ENOLCK: 77,
ENOLINK: 97,
ENOMEM: 12,
ENOMSG: 91,
ENOPROTOOPT: 42,
ENOSPC: 28,
ENOSR: 98,
ENOSTR: 99,
ENOSYS: 78,
ENOTCONN: 57,
ENOTDIR: 20,
ENOTEMPTY: 66,
ENOTSOCK: 38,
ENOTSUP: 45,
ENOTTY: 25,
ENXIO: 6,
EOPNOTSUPP: 102,
EOVERFLOW: 84,
EPERM: 1,
EPIPE: 32,
EPROTO: 100,
EPROTONOSUPPORT: 43,
EPROTOTYPE: 41,
ERANGE: 34,
EROFS: 30,
ESPIPE: 29,
ESRCH: 3,
ESTALE: 70,
ETIME: 101,
ETIMEDOUT: 60,
ETXTBSY: 26,
EWOULDBLOCK: 35,
EXDEV: 18
},
signals: {
SIGHUP: 1,
SIGINT: 2,
SIGQUIT: 3,
SIGILL: 4,
SIGTRAP: 5,
SIGABRT: 6,
SIGIOT: 6,
SIGBUS: 10,
SIGFPE: 8,
SIGKILL: 9,
SIGUSR1: 30,
SIGSEGV: 11,
SIGUSR2: 31,
SIGPIPE: 13,
SIGALRM: 14,
SIGTERM: 15,
SIGCHLD: 20,
SIGCONT: 19,
SIGSTOP: 17,
SIGTSTP: 18,
SIGTTIN: 21,
SIGTTOU: 22,
SIGURG: 16,
SIGXCPU: 24,
SIGXFSZ: 25,
SIGVTALRM: 26,
SIGPROF: 27,
SIGWINCH: 28,
SIGIO: 23,
SIGINFO: 29,
SIGSYS: 12
},
priority: {
PRIORITY_LOW: 19,
PRIORITY_BELOW_NORMAL: 10,
PRIORITY_NORMAL: 0,
PRIORITY_ABOVE_NORMAL: -7,
PRIORITY_HIGH: -14,
PRIORITY_HIGHEST: -20
}
};
} else if (Deno.build.os === "linux") {
os = {
UV_UDP_REUSEADDR: 4,
dlopen: {
RTLD_LAZY: 1,
RTLD_NOW: 2,
RTLD_GLOBAL: 256,
RTLD_LOCAL: 0,
RTLD_DEEPBIND: 8
},
errno: {
E2BIG: 7,
EACCES: 13,
EADDRINUSE: 98,
EADDRNOTAVAIL: 99,
EAFNOSUPPORT: 97,
EAGAIN: 11,
EALREADY: 114,
EBADF: 9,
EBADMSG: 74,
EBUSY: 16,
ECANCELED: 125,
ECHILD: 10,
ECONNABORTED: 103,
ECONNREFUSED: 111,
ECONNRESET: 104,
EDEADLK: 35,
EDESTADDRREQ: 89,
EDOM: 33,
EDQUOT: 122,
EEXIST: 17,
EFAULT: 14,
EFBIG: 27,
EHOSTUNREACH: 113,
EIDRM: 43,
EILSEQ: 84,
EINPROGRESS: 115,
EINTR: 4,
EINVAL: 22,
EIO: 5,
EISCONN: 106,
EISDIR: 21,
ELOOP: 40,
EMFILE: 24,
EMLINK: 31,
EMSGSIZE: 90,
EMULTIHOP: 72,
ENAMETOOLONG: 36,
ENETDOWN: 100,
ENETRESET: 102,
ENETUNREACH: 101,
ENFILE: 23,
ENOBUFS: 105,
ENODATA: 61,
ENODEV: 19,
ENOENT: 2,
ENOEXEC: 8,
ENOLCK: 37,
ENOLINK: 67,
ENOMEM: 12,
ENOMSG: 42,
ENOPROTOOPT: 92,
ENOSPC: 28,
ENOSR: 63,
ENOSTR: 60,
ENOSYS: 38,
ENOTCONN: 107,
ENOTDIR: 20,
ENOTEMPTY: 39,
ENOTSOCK: 88,
ENOTSUP: 95,
ENOTTY: 25,
ENXIO: 6,
EOPNOTSUPP: 95,
EOVERFLOW: 75,
EPERM: 1,
EPIPE: 32,
EPROTO: 71,
EPROTONOSUPPORT: 93,
EPROTOTYPE: 91,
ERANGE: 34,
EROFS: 30,
ESPIPE: 29,
ESRCH: 3,
ESTALE: 116,
ETIME: 62,
ETIMEDOUT: 110,
ETXTBSY: 26,
EWOULDBLOCK: 11,
EXDEV: 18
},
signals: {
SIGHUP: 1,
SIGINT: 2,
SIGQUIT: 3,
SIGILL: 4,
SIGTRAP: 5,
SIGABRT: 6,
SIGIOT: 6,
SIGBUS: 7,
SIGFPE: 8,
SIGKILL: 9,
SIGUSR1: 10,
SIGSEGV: 11,
SIGUSR2: 12,
SIGPIPE: 13,
SIGALRM: 14,
SIGTERM: 15,
SIGCHLD: 17,
SIGSTKFLT: 16,
SIGCONT: 18,
SIGSTOP: 19,
SIGTSTP: 20,
SIGTTIN: 21,
SIGTTOU: 22,
SIGURG: 23,
SIGXCPU: 24,
SIGXFSZ: 25,
SIGVTALRM: 26,
SIGPROF: 27,
SIGWINCH: 28,
SIGIO: 29,
SIGPOLL: 29,
SIGPWR: 30,
SIGSYS: 31,
SIGUNUSED: 31
},
priority: {
PRIORITY_LOW: 19,
PRIORITY_BELOW_NORMAL: 10,
PRIORITY_NORMAL: 0,
PRIORITY_ABOVE_NORMAL: -7,
PRIORITY_HIGH: -14,
PRIORITY_HIGHEST: -20
}
};
} else {
os = {
UV_UDP_REUSEADDR: 4,
dlopen: {},
errno: {
E2BIG: 7,
EACCES: 13,
EADDRINUSE: 100,
EADDRNOTAVAIL: 101,
EAFNOSUPPORT: 102,
EAGAIN: 11,
EALREADY: 103,
EBADF: 9,
EBADMSG: 104,
EBUSY: 16,
ECANCELED: 105,
ECHILD: 10,
ECONNABORTED: 106,
ECONNREFUSED: 107,
ECONNRESET: 108,
EDEADLK: 36,
EDESTADDRREQ: 109,
EDOM: 33,
EEXIST: 17,
EFAULT: 14,
EFBIG: 27,
EHOSTUNREACH: 110,
EIDRM: 111,
EILSEQ: 42,
EINPROGRESS: 112,
EINTR: 4,
EINVAL: 22,
EIO: 5,
EISCONN: 113,
EISDIR: 21,
ELOOP: 114,
EMFILE: 24,
EMLINK: 31,
EMSGSIZE: 115,
ENAMETOOLONG: 38,
ENETDOWN: 116,
ENETRESET: 117,
ENETUNREACH: 118,
ENFILE: 23,
ENOBUFS: 119,
ENODATA: 120,
ENODEV: 19,
ENOENT: 2,
ENOEXEC: 8,
ENOLCK: 39,
ENOLINK: 121,
ENOMEM: 12,
ENOMSG: 122,
ENOPROTOOPT: 123,
ENOSPC: 28,
ENOSR: 124,
ENOSTR: 125,
ENOSYS: 40,
ENOTCONN: 126,
ENOTDIR: 20,
ENOTEMPTY: 41,
ENOTSOCK: 128,
ENOTSUP: 129,
ENOTTY: 25,
ENXIO: 6,
EOPNOTSUPP: 130,
EOVERFLOW: 132,
EPERM: 1,
EPIPE: 32,
EPROTO: 134,
EPROTONOSUPPORT: 135,
EPROTOTYPE: 136,
ERANGE: 34,
EROFS: 30,
ESPIPE: 29,
ESRCH: 3,
ETIME: 137,
ETIMEDOUT: 138,
ETXTBSY: 139,
EWOULDBLOCK: 140,
EXDEV: 18,
WSAEINTR: 10004,
WSAEBADF: 10009,
WSAEACCES: 10013,
WSAEFAULT: 10014,
WSAEINVAL: 10022,
WSAEMFILE: 10024,
WSAEWOULDBLOCK: 10035,
WSAEINPROGRESS: 10036,
WSAEALREADY: 10037,
WSAENOTSOCK: 10038,
WSAEDESTADDRREQ: 10039,
WSAEMSGSIZE: 10040,
WSAEPROTOTYPE: 10041,
WSAENOPROTOOPT: 10042,
WSAEPROTONOSUPPORT: 10043,
WSAESOCKTNOSUPPORT: 10044,
WSAEOPNOTSUPP: 10045,
WSAEPFNOSUPPORT: 10046,
WSAEAFNOSUPPORT: 10047,
WSAEADDRINUSE: 10048,
WSAEADDRNOTAVAIL: 10049,
WSAENETDOWN: 10050,
WSAENETUNREACH: 10051,
WSAENETRESET: 10052,
WSAECONNABORTED: 10053,
WSAECONNRESET: 10054,
WSAENOBUFS: 10055,
WSAEISCONN: 10056,
WSAENOTCONN: 10057,
WSAESHUTDOWN: 10058,
WSAETOOMANYREFS: 10059,
WSAETIMEDOUT: 10060,
WSAECONNREFUSED: 10061,
WSAELOOP: 10062,
WSAENAMETOOLONG: 10063,
WSAEHOSTDOWN: 10064,
WSAEHOSTUNREACH: 10065,
WSAENOTEMPTY: 10066,
WSAEPROCLIM: 10067,
WSAEUSERS: 10068,
WSAEDQUOT: 10069,
WSAESTALE: 10070,
WSAEREMOTE: 10071,
WSASYSNOTREADY: 10091,
WSAVERNOTSUPPORTED: 10092,
WSANOTINITIALISED: 10093,
WSAEDISCON: 10101,
WSAENOMORE: 10102,
WSAECANCELLED: 10103,
WSAEINVALIDPROCTABLE: 10104,
WSAEINVALIDPROVIDER: 10105,
WSAEPROVIDERFAILEDINIT: 10106,
WSASYSCALLFAILURE: 10107,
WSASERVICE_NOT_FOUND: 10108,
WSATYPE_NOT_FOUND: 10109,
WSA_E_NO_MORE: 10110,
WSA_E_CANCELLED: 10111,
WSAEREFUSED: 10112
},
signals: {
SIGHUP: 1,
SIGINT: 2,
SIGILL: 4,
SIGABRT: 22,
SIGFPE: 8,
SIGKILL: 9,
SIGSEGV: 11,
SIGTERM: 15,
SIGBREAK: 21,
SIGWINCH: 28
},
priority: {
PRIORITY_LOW: 19,
PRIORITY_BELOW_NORMAL: 10,
PRIORITY_NORMAL: 0,
PRIORITY_ABOVE_NORMAL: -7,
PRIORITY_HIGH: -14,
PRIORITY_HIGHEST: -20
}
};
}
const { errno: { ENOTDIR, ENOENT } } = os;
const kIsNodeError = Symbol("kIsNodeError");
const classRegExp1 = /^([A-Z][a-z0-9]*)+$/;
const kTypes = [
"string",
"function",
"number",
"object",
"Function",
"Object",
"boolean",
"bigint",
"symbol"
];
function addNumericalSeparator(val) {
let res = "";
let i = val.length;
const start = val[0] === "-" ? 1 : 0;
for(; i >= start + 4; i -= 3){
res = `_${val.slice(i - 3, i)}${res}`;
}
return `${val.slice(0, i)}${res}`;
}
const captureLargerStackTrace = hideStackFrames(function captureLargerStackTrace(err) {
Error.captureStackTrace(err);
return err;
});
hideStackFrames(function uvExceptionWithHostPort(err, syscall, address, port) {
const { 0: code, 1: uvmsg } = uvErrmapGet(err) || uvUnmappedError;
const message = `${syscall} ${code}: ${uvmsg}`;
let details = "";
if (port && port > 0) {
details = ` ${address}:${port}`;
} else if (address) {
details = ` ${address}`;
}
const ex = new Error(`${message}${details}`);
ex.code = code;
ex.errno = err;
ex.syscall = syscall;
ex.address = address;
if (port) {
ex.port = port;
}
return captureLargerStackTrace(ex);
});
hideStackFrames(function errnoException(err, syscall, original) {
const code = getSystemErrorName(err);
const message = original ? `${syscall} ${code} ${original}` : `${syscall} ${code}`;
const ex = new Error(message);
ex.errno = err;
ex.code = code;
ex.syscall = syscall;
return captureLargerStackTrace(ex);
});
function uvErrmapGet(name) {
return errorMap.get(name);
}
const uvUnmappedError = [
"UNKNOWN",
"unknown error"
];
hideStackFrames(function uvException(ctx) {
const { 0: code, 1: uvmsg } = uvErrmapGet(ctx.errno) || uvUnmappedError;
let message = `${code}: ${ctx.message || uvmsg}, ${ctx.syscall}`;
let path;
let dest;
if (ctx.path) {
path = ctx.path.toString();
message += ` '${path}'`;
}
if (ctx.dest) {
dest = ctx.dest.toString();
message += ` -> '${dest}'`;
}
const err = new Error(message);
for (const prop of Object.keys(ctx)){
if (prop === "message" || prop === "path" || prop === "dest") {
continue;
}
err[prop] = ctx[prop];
}
err.code = code;
if (path) {
err.path = path;
}
if (dest) {
err.dest = dest;
}
return captureLargerStackTrace(err);
});
hideStackFrames(function exceptionWithHostPort(err, syscall, address, port, additional) {
const code = getSystemErrorName(err);
let details = "";
if (port && port > 0) {
details = ` ${address}:${port}`;
} else if (address) {
details = ` ${address}`;
}
if (additional) {
details += ` - Local (${additional})`;
}
const ex = new Error(`${syscall} ${code}${details}`);
ex.errno = err;
ex.code = code;
ex.syscall = syscall;
ex.address = address;
if (port) {
ex.port = port;
}
return captureLargerStackTrace(ex);
});
hideStackFrames(function(code, syscall, hostname) {
let errno;
if (typeof code === "number") {
errno = code;
if (code === codeMap.get("EAI_NODATA") || code === codeMap.get("EAI_NONAME")) {
code = "ENOTFOUND";
} else {
code = getSystemErrorName(code);
}
}
const message = `${syscall} ${code}${hostname ? ` ${hostname}` : ""}`;
const ex = new Error(message);
ex.errno = errno;
ex.code = code;
ex.syscall = syscall;
if (hostname) {
ex.hostname = hostname;
}
return captureLargerStackTrace(ex);
});
class NodeErrorAbstraction extends Error {
code;
constructor(name, code, message){
super(message);
this.code = code;
this.name = name;
this.stack = this.stack && `${name} [${this.code}]${this.stack.slice(20)}`;
}
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
}
class NodeError extends NodeErrorAbstraction {
constructor(code, message){
super(Error.prototype.name, code, message);
}
}
class NodeRangeError extends NodeErrorAbstraction {
constructor(code, message){
super(RangeError.prototype.name, code, message);
Object.setPrototypeOf(this, RangeError.prototype);
this.toString = function() {
return `${this.name} [${this.code}]: ${this.message}`;
};
}
}
class NodeTypeError extends NodeErrorAbstraction {
constructor(code, message){
super(TypeError.prototype.name, code, message);
Object.setPrototypeOf(this, TypeError.prototype);
this.toString = function() {
return `${this.name} [${this.code}]: ${this.message}`;
};
}
}
class NodeSystemError extends NodeErrorAbstraction {
constructor(key, context, msgPrefix){
let message = `${msgPrefix}: ${context.syscall} returned ` + `${context.code} (${context.message})`;
if (context.path !== undefined) {
message += ` ${context.path}`;
}
if (context.dest !== undefined) {
message += ` => ${context.dest}`;
}
super("SystemError", key, message);
captureLargerStackTrace(this);
Object.defineProperties(this, {
[kIsNodeError]: {
value: true,
enumerable: false,
writable: false,
configurable: true
},
info: {
value: context,
enumerable: true,
configurable: true,
writable: false
},
errno: {
get () {
return context.errno;
},
set: (value)=>{
context.errno = value;
},
enumerable: true,
configurable: true
},
syscall: {
get () {
return context.syscall;
},
set: (value)=>{
context.syscall = value;
},
enumerable: true,
configurable: true
}
});
if (context.path !== undefined) {
Object.defineProperty(this, "path", {
get () {
return context.path;
},
set: (value)=>{
context.path = value;
},
enumerable: true,
configurable: true
});
}
if (context.dest !== undefined) {
Object.defineProperty(this, "dest", {
get () {
return context.dest;
},
set: (value)=>{
context.dest = value;
},
enumerable: true,
configurable: true
});
}
}
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
}
function makeSystemErrorWithCode(key, msgPrfix) {
return class NodeError extends NodeSystemError {
constructor(ctx){
super(key, ctx, msgPrfix);
}
};
}
makeSystemErrorWithCode("ERR_FS_EISDIR", "Path is a directory");
function createInvalidArgType(name, expected) {
expected = Array.isArray(expected) ? expected : [
expected
];
let msg = "The ";
if (name.endsWith(" argument")) {
msg += `${name} `;
} else {
const type = name.includes(".") ? "property" : "argument";
msg += `"${name}" ${type} `;
}
msg += "must be ";
const types = [];
const instances = [];
const other = [];
for (const value of expected){
if (kTypes.includes(value)) {
types.push(value.toLocaleLowerCase());
} else if (classRegExp1.test(value)) {
instances.push(value);
} else {
other.push(value);
}
}
if (instances.length > 0) {
const pos = types.indexOf("object");
if (pos !== -1) {
types.splice(pos, 1);
instances.push("Object");
}
}
if (types.length > 0) {
if (types.length > 2) {
const last = types.pop();
msg += `one of type ${types.join(", ")}, or ${last}`;
} else if (types.length === 2) {
msg += `one of type ${types[0]} or ${types[1]}`;
} else {
msg += `of type ${types[0]}`;
}
if (instances.length > 0 || other.length > 0) {
msg += " or ";
}
}
if (instances.length > 0) {
if (instances.length > 2) {
const last = instances.pop();
msg += `an instance of ${instances.join(", ")}, or ${last}`;
} else {
msg += `an instance of ${instances[0]}`;
if (instances.length === 2) {
msg += ` or ${instances[1]}`;
}
}
if (other.length > 0) {
msg += " or ";
}
}
if (other.length > 0) {
if (other.length > 2) {
const last = other.pop();
msg += `one of ${other.join(", ")}, or ${last}`;
} else if (other.length === 2) {
msg += `one of ${other[0]} or ${other[1]}`;
} else {
if (other[0].toLowerCase() !== other[0]) {
msg += "an ";
}
msg += `${other[0]}`;
}
}
return msg;
}
class ERR_INVALID_ARG_TYPE_RANGE extends NodeRangeError {
constructor(name, expected, actual){
const msg = createInvalidArgType(name, expected);
super("ERR_INVALID_ARG_TYPE", `${msg}.${invalidArgTypeHelper(actual)}`);
}
}
class ERR_INVALID_ARG_TYPE extends NodeTypeError {
constructor(name, expected, actual){
const msg = createInvalidArgType(name, expected);
super("ERR_INVALID_ARG_TYPE", `${msg}.${invalidArgTypeHelper(actual)}`);
}
static RangeError = ERR_INVALID_ARG_TYPE_RANGE;
}
class ERR_INVALID_ARG_VALUE_RANGE extends NodeRangeError {
constructor(name, value, reason = "is invalid"){
const type = name.includes(".") ? "property" : "argument";
const inspected = inspect(value);
super("ERR_INVALID_ARG_VALUE", `The ${type} '${name}' ${reason}. Received ${inspected}`);
}
}
class ERR_INVALID_ARG_VALUE extends NodeTypeError {
constructor(name, value, reason = "is invalid"){
const type = name.includes(".") ? "property" : "argument";
const inspected = inspect(value);
super("ERR_INVALID_ARG_VALUE", `The ${type} '${name}' ${reason}. Received ${inspected}`);
}
static RangeError = ERR_INVALID_ARG_VALUE_RANGE;
}
function invalidArgTypeHelper(input) {
if (input == null) {
return ` Received ${input}`;
}
if (typeof input === "function" && input.name) {
return ` Received function ${input.name}`;
}
if (typeof input === "object") {
if (input.constructor && input.constructor.name) {
return ` Received an instance of ${input.constructor.name}`;
}
return ` Received ${inspect(input, {
depth: -1
})}`;
}
let inspected = inspect(input, {
colors: false
});
if (inspected.length > 25) {
inspected = `${inspected.slice(0, 25)}...`;
}
return ` Received type ${typeof input} (${inspected})`;
}
class ERR_OUT_OF_RANGE extends RangeError {
code = "ERR_OUT_OF_RANGE";
constructor(str, range, input, replaceDefaultBoolean = false){
assert(range, 'Missing "range" argument');
let msg = replaceDefaultBoolean ? str : `The value of "${str}" is out of range.`;
let received;
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
received = addNumericalSeparator(String(input));
} else if (typeof input === "bigint") {
received = String(input);
if (input > 2n ** 32n || input < -(2n ** 32n)) {
received = addNumericalSeparator(received);
}
received += "n";
} else {
received = inspect(input);
}
msg += ` It must be ${range}. Received ${received}`;
super(msg);
const { name } = this;
this.name = `${name} [${this.code}]`;
this.stack;
this.name = name;
}
}
class ERR_BUFFER_OUT_OF_BOUNDS extends NodeRangeError {
constructor(name){
super("ERR_BUFFER_OUT_OF_BOUNDS", name ? `"${name}" is outside of buffer bounds` : "Attempt to access memory outside buffer bounds");
}
}
class ERR_IPC_CHANNEL_CLOSED extends NodeError {
constructor(){
super("ERR_IPC_CHANNEL_CLOSED", `Channel closed`);
}
}
class ERR_SOCKET_BAD_PORT extends NodeRangeError {
constructor(name, port, allowZero = true){
assert(typeof allowZero === "boolean", "The 'allowZero' argument must be of type boolean.");
const operator = allowZero ? ">=" : ">";
super("ERR_SOCKET_BAD_PORT", `${name} should be ${operator} 0 and < 65536. Received ${port}.`);
}
}
class ERR_UNKNOWN_ENCODING extends NodeTypeError {
constructor(x){
super("ERR_UNKNOWN_ENCODING", `Unknown encoding: ${x}`);
}
}
codes.ERR_IPC_CHANNEL_CLOSED = ERR_IPC_CHANNEL_CLOSED;
codes.ERR_INVALID_ARG_TYPE = ERR_INVALID_ARG_TYPE;
codes.ERR_INVALID_ARG_VALUE = ERR_INVALID_ARG_VALUE;
codes.ERR_OUT_OF_RANGE = ERR_OUT_OF_RANGE;
codes.ERR_SOCKET_BAD_PORT = ERR_SOCKET_BAD_PORT;
codes.ERR_BUFFER_OUT_OF_BOUNDS = ERR_BUFFER_OUT_OF_BOUNDS;
codes.ERR_UNKNOWN_ENCODING = ERR_UNKNOWN_ENCODING;
hideStackFrames(function genericNodeError(message, errorProperties) {
const err = new Error(message);
Object.assign(err, errorProperties);
return err;
});
const { signals } = os;
Symbol.for("nodejs.util.inspect.custom");
const kEnumerableProperty = Object.create(null);
kEnumerableProperty.enumerable = true;
Object.freeze(Object.create(null));
const kCustomPromisifiedSymbol = Symbol.for("nodejs.util.promisify.custom");
const kCustomPromisifyArgsSymbol = Symbol.for("nodejs.util.promisify.customArgs");
function promisify(original) {
validateFunction(original, "original");
if (original[kCustomPromisifiedSymbol]) {
const fn = original[kCustomPromisifiedSymbol];
validateFunction(fn, "util.promisify.custom");
return Object.defineProperty(fn, kCustomPromisifiedSymbol, {
value: fn,
enumerable: false,
writable: false,
configurable: true
});
}
const argumentNames = original[kCustomPromisifyArgsSymbol];
function fn(...args) {
return new Promise((resolve, reject)=>{
args.push((err, ...values)=>{
if (err) {
return reject(err);
}
if (argumentNames !== undefined && values.length > 1) {
const obj = {};
for(let i = 0; i < argumentNames.length; i++){
obj[argumentNames[i]] = values[i];
}
resolve(obj);
} else {
resolve(values[0]);
}
});
Reflect.apply(original, this, args);
});
}
Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
Object.defineProperty(fn, kCustomPromisifiedSymbol, {
value: fn,
enumerable: false,
writable: false,
configurable: true
});
return Object.defineProperties(fn, Object.getOwnPropertyDescriptors(original));
}
promisify.custom = kCustomPromisifiedSymbol;
const utf8Encoder = new TextEncoder();
const float32Array = new Float32Array(1);
const uInt8Float32Array = new Uint8Array(float32Array.buffer);
const float64Array = new Float64Array(1);
const uInt8Float64Array = new Uint8Array(float64Array.buffer);
float32Array[0] = -1;
const bigEndian = uInt8Float32Array[3] === 0;
const kMaxLength = 2147483647;
const kStringMaxLength = 536870888;
const MAX_UINT32 = 2 ** 32;
const customInspectSymbol1 = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
const INSPECT_MAX_BYTES = 50;
const constants = {
MAX_LENGTH: 2147483647,
MAX_STRING_LENGTH: 536870888
};
Object.defineProperty(Buffer.prototype, "parent", {
enumerable: true,
get: function() {
if (!Buffer.isBuffer(this)) {
return void 0;
}
return this.buffer;
}
});
Object.defineProperty(Buffer.prototype, "offset", {
enumerable: true,
get: function() {
if (!Buffer.isBuffer(this)) {
return void 0;
}
return this.byteOffset;
}
});
function createBuffer(length) {
if (length > 2147483647) {
throw new RangeError('The value "' + length + '" is invalid for option "size"');
}
const buf = new Uint8Array(length);
Object.setPrototypeOf(buf, Buffer.prototype);
return buf;
}
function Buffer(arg, encodingOrOffset, length) {
if (typeof arg === "number") {
if (typeof encodingOrOffset === "string") {
throw new codes.ERR_INVALID_ARG_TYPE("string", "string", arg);
}
return _allocUnsafe(arg);
}
return _from(arg, encodingOrOffset, length);
}
Buffer.poolSize = 8192;
function _from(value, encodingOrOffset, length) {
if (typeof value === "string") {
return fromString(value, encodingOrOffset);
}
if (typeof value === "object" && value !== null) {
if (isAnyArrayBuffer1(value)) {
return fromArrayBuffer(value, encodingOrOffset, length);
}
const valueOf = value.valueOf && value.valueOf();
if (valueOf != null && valueOf !== value && (typeof valueOf === "string" || typeof valueOf === "object")) {
return _from(valueOf, encodingOrOffset, length);
}
const b = fromObject(value);
if (b) {
return b;
}
if (typeof value[Symbol.toPrimitive] === "function") {
const primitive = value[Symbol.toPrimitive]("string");
if (typeof primitive === "string") {
return fromString(primitive, encodingOrOffset);
}
}
}
throw new codes.ERR_INVALID_ARG_TYPE("first argument", [
"string",
"Buffer",
"ArrayBuffer",
"Array",
"Array-like Object"
], value);
}
Buffer.from = function from(value, encodingOrOffset, length) {
return _from(value, encodingOrOffset, length);
};
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
Object.setPrototypeOf(Buffer, Uint8Array);
function assertSize(size) {
validateNumber(size, "size");
if (!(size >= 0 && size <= 2147483647)) {
throw new codes.ERR_INVALID_ARG_VALUE.RangeError("size", size);
}
}
function _alloc(size, fill, encoding) {
assertSize(size);
const buffer = createBuffer(size);
if (fill !== undefined) {
if (encoding !== undefined && typeof encoding !== "string") {
throw new codes.ERR_INVALID_ARG_TYPE("encoding", "string", encoding);
}
return buffer.fill(fill, encoding);
}
return buffer;
}
Buffer.alloc = function alloc(size, fill, encoding) {
return _alloc(size, fill, encoding);
};
function _allocUnsafe(size) {
assertSize(size);
return createBuffer(size < 0 ? 0 : checked(size) | 0);
}
Buffer.allocUnsafe = function allocUnsafe(size) {
return _allocUnsafe(size);
};
Buffer.allocUnsafeSlow = function allocUnsafeSlow(size) {
return _allocUnsafe(size);
};
function fromString(string, encoding) {
if (typeof encoding !== "string" || encoding === "") {
encoding = "utf8";
}
if (!Buffer.isEncoding(encoding)) {
throw new codes.ERR_UNKNOWN_ENCODING(encoding);
}
const length = byteLength(string, encoding) | 0;
let buf = createBuffer(length);
const actual = buf.write(string, encoding);
if (actual !== length) {
buf = buf.slice(0, actual);
}
return buf;
}
function fromArrayLike(array) {
const length = array.length < 0 ? 0 : checked(array.length) | 0;
const buf = createBuffer(length);
for(let i = 0; i < length; i += 1){
buf[i] = array[i] & 255;
}
return buf;
}
function fromObject(obj) {
if (obj.length !== undefined || isAnyArrayBuffer1(obj.buffer)) {
if (typeof obj.length !== "number") {
return createBuffer(0);
}
return fromArrayLike(obj);
}
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
return fromArrayLike(obj.data);
}
}
function checked(length) {
if (length >= 2147483647) {
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + 2147483647..toString(16) + " bytes");
}
return length | 0;
}
function SlowBuffer(length) {
assertSize(length);
return Buffer.alloc(+length);
}
Object.setPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
Object.setPrototypeOf(SlowBuffer, Uint8Array);
Buffer.isBuffer = function isBuffer(b) {
return b != null && b._isBuffer === true && b !== Buffer.prototype;
};
Buffer.compare = function compare(a, b) {
if (isInstance(a, Uint8Array)) {
a = Buffer.from(a, a.offset, a.byteLength);
}
if (isInstance(b, Uint8Array)) {
b = Buffer.from(b, b.offset, b.byteLength);
}
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
}
if (a === b) {
return 0;
}
let x = a.length;
let y = b.length;
for(let i = 0, len = Math.min(x, y); i < len; ++i){
if (a[i] !== b[i]) {
x = a[i];
y = b[i];
break;
}
}
if (x < y) {
return -1;
}
if (y < x) {
return 1;
}
return 0;
};
Buffer.isEncoding = function isEncoding(encoding) {
return typeof encoding === "string" && encoding.length !== 0 && normalizeEncoding(encoding) !== undefined;
};
Buffer.concat = function concat(list, length) {
if (!Array.isArray(list)) {
throw new codes.ERR_INVALID_ARG_TYPE("list", "Array", list);
}
if (list.length === 0) {
return Buffer.alloc(0);
}
if (length === undefined) {
length = 0;
for(let i = 0; i < list.length; i++){
if (list[i].length) {
length += list[i].length;
}
}
} else {
validateOffset(length, "length");
}
const buffer = Buffer.allocUnsafe(length);
let pos = 0;
for(let i = 0; i < list.length; i++){
const buf = list[i];
if (!isUint8Array(buf)) {
throw new codes.ERR_INVALID_ARG_TYPE(`list[${i}]`, [
"Buffer",
"Uint8Array"
], list[i]);
}
pos += _copyActual(buf, buffer, pos, 0, buf.length);
}
if (pos < length) {
buffer.fill(0, pos, length);
}
return buffer;
};
function byteLength(string, encoding) {
if (typeof string !== "string") {
if (isArrayBufferView(string) || isAnyArrayBuffer1(string)) {
return string.byteLength;
}
throw new codes.ERR_INVALID_ARG_TYPE("string", [
"string",
"Buffer",
"ArrayBuffer"
], string);
}
const len = string.length;
const mustMatch = arguments.length > 2 && arguments[2] === true;
if (!mustMatch && len === 0) {
return 0;
}
if (!encoding) {
return mustMatch ? -1 : byteLengthUtf8(string);
}
const ops = getEncodingOps(encoding);
if (ops === undefined) {
return mustMatch ? -1 : byteLengthUtf8(string);
}
return ops.byteLength(string);
}
Buffer.byteLength = byteLength;
Buffer.prototype._isBuffer = true;
function swap(b, n, m) {
const i = b[n];
b[n] = b[m];
b[m] = i;
}
Buffer.prototype.swap16 = function swap16() {
const len = this.length;
if (len % 2 !== 0) {
throw new RangeError("Buffer size must be a multiple of 16-bits");
}
for(let i = 0; i < len; i += 2){
swap(this, i, i + 1);
}
return this;
};
Buffer.prototype.swap32 = function swap32() {
const len = this.length;
if (len % 4 !== 0) {
throw new RangeError("Buffer size must be a multiple of 32-bits");
}
for(let i = 0; i < len; i += 4){
swap(this, i, i + 3);
swap(this, i + 1, i + 2);
}
return this;
};
Buffer.prototype.swap64 = function swap64() {
const len = this.length;
if (len % 8 !== 0) {
throw new RangeError("Buffer size must be a multiple of 64-bits");
}
for(let i = 0; i < len; i += 8){
swap(this, i, i + 7);
swap(this, i + 1, i + 6);
swap(this, i + 2, i + 5);
swap(this, i + 3, i + 4);
}
return this;
};
Buffer.prototype.toString = function toString(encoding, start, end) {
if (arguments.length === 0) {
return this.utf8Slice(0, this.length);
}
const len = this.length;
if (start <= 0) {
start = 0;
} else if (start >= len) {
return "";
} else {
start |= 0;
}
if (end === undefined || end > len) {
end = len;
} else {
end |= 0;
}
if (end <= start) {
return "";
}
if (encoding === undefined) {
return this.utf8Slice(start, end);
}
const ops = getEncodingOps(encoding);
if (ops === undefined) {
throw new codes.ERR_UNKNOWN_ENCODING(encoding);
}
return ops.slice(this, start, end);
};
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
Buffer.prototype.equals = function equals(b) {
if (!isUint8Array(b)) {
throw new codes.ERR_INVALID_ARG_TYPE("otherBuffer", [
"Buffer",
"Uint8Array"
], b);
}
if (this === b) {
return true;
}
return Buffer.compare(this, b) === 0;
};
Buffer.prototype.inspect = function inspect() {
let str = "";
const max = INSPECT_MAX_BYTES;
str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
if (this.length > max) {
str += " ... ";
}
return "<Buffer " + str + ">";
};
if (customInspectSymbol1) {
Buffer.prototype[customInspectSymbol1] = Buffer.prototype.inspect;
}
Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
if (isInstance(target, Uint8Array)) {
target = Buffer.from(target, target.offset, target.byteLength);
}
if (!Buffer.isBuffer(target)) {
throw new codes.ERR_INVALID_ARG_TYPE("target", [
"Buffer",
"Uint8Array"
], target);
}
if (start === undefined) {
start = 0;
} else {
validateOffset(start, "targetStart", 0, kMaxLength);
}
if (end === undefined) {
end = target.length;
} else {
validateOffset(end, "targetEnd", 0, target.length);
}
if (thisStart === undefined) {
thisStart = 0;
} else {
validateOffset(start, "sourceStart", 0, kMaxLength);
}
if (thisEnd === undefined) {
thisEnd = this.length;
} else {
validateOffset(end, "sourceEnd", 0, this.length);
}
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
throw new codes.ERR_OUT_OF_RANGE("out of range index", "range");
}
if (thisStart >= thisEnd && start >= end) {
return 0;
}
if (thisStart >= thisEnd) {
return -1;
}
if (start >= end) {
return 1;
}
start >>>= 0;
end >>>= 0;
thisStart >>>= 0;
thisEnd >>>= 0;
if (this === target) {
return 0;
}
let x = thisEnd - thisStart;
let y = end - start;
const len = Math.min(x, y);
const thisCopy = this.slice(thisStart, thisEnd);
const targetCopy = target.slice(start, end);
for(let i = 0; i < len; ++i){
if (thisCopy[i] !== targetCopy[i]) {
x = thisCopy[i];
y = targetCopy[i];
break;
}
}
if (x < y) {
return -1;
}
if (y < x) {
return 1;
}
return 0;
};
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
validateBuffer(buffer);
if (typeof byteOffset === "string") {
encoding = byteOffset;
byteOffset = undefined;
} else if (byteOffset > 0x7fffffff) {
byteOffset = 0x7fffffff;
} else if (byteOffset < -0x80000000) {
byteOffset = -0x80000000;
}
byteOffset = +byteOffset;
if (Number.isNaN(byteOffset)) {
byteOffset = dir ? 0 : buffer.length || buffer.byteLength;
}
dir = !!dir;
if (typeof val === "number") {
return indexOfNumber(buffer, val >>> 0, byteOffset, dir);
}
let ops;
if (encoding === undefined) {
ops = encodingOps.utf8;
} else {
ops = getEncodingOps(encoding);
}
if (typeof val === "string") {
if (ops === undefined) {
throw new codes.ERR_UNKNOWN_ENCODING(encoding);
}
return ops.indexOf(buffer, val, byteOffset, dir);
}
if (isUint8Array(val)) {
const encodingVal = ops === undefined ? encodingsMap.utf8 : ops.encodingVal;
return indexOfBuffer(buffer, val, byteOffset, encodingVal, dir);
}
throw new codes.ERR_INVALID_ARG_TYPE("value", [
"number",
"string",
"Buffer",
"Uint8Array"
], val);
}
Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
return this.indexOf(val, byteOffset, encoding) !== -1;
};
Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
};
Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
};
Buffer.prototype.asciiSlice = function asciiSlice(offset, length) {
if (offset === 0 && length === this.length) {
return bytesToAscii(this);
} else {
return bytesToAscii(this.slice(offset, length));
}
};
Buffer.prototype.asciiWrite = function asciiWrite(string, offset, length) {
return blitBuffer(asciiToBytes(string), this, offset, length);
};
Buffer.prototype.base64Slice = function base64Slice(offset, length) {
if (offset === 0 && length === this.length) {
return encode(this);
} else {
return encode(this.slice(offset, length));
}
};
Buffer.prototype.base64Write = function base64Write(string, offset, length) {
return blitBuffer(base64ToBytes(string), this, offset, length);
};
Buffer.prototype.base64urlSlice = function base64urlSlice(offset, length) {
if (offset === 0 && length === this.length) {
return encode1(this);
} else {
return encode1(this.slice(offset, length));
}
};
Buffer.prototype.base64urlWrite = function base64urlWrite(string, offset, length) {
return blitBuffer(base64UrlToBytes(string), this, offset, length);
};
Buffer.prototype.hexWrite = function hexWrite(string, offset, length) {
return blitBuffer(hexToBytes(string, this.length - offset), this, offset, length);
};
Buffer.prototype.hexSlice = function hexSlice(string, offset, length) {
return _hexSlice(this, string, offset, length);
};
Buffer.prototype.latin1Slice = function latin1Slice(string, offset, length) {
return _latin1Slice(this, string, offset, length);
};
Buffer.prototype.latin1Write = function latin1Write(string, offset, length) {
return blitBuffer(asciiToBytes(string), this, offset, length);
};
Buffer.prototype.ucs2Slice = function ucs2Slice(offset, length) {
if (offset === 0 && length === this.length) {
return bytesToUtf16le(this);
} else {
return bytesToUtf16le(this.slice(offset, length));
}
};
Buffer.prototype.ucs2Write = function ucs2Write(string, offset, length) {
return blitBuffer(utf16leToBytes(string, this.length - offset), this, offset, length);
};
Buffer.prototype.utf8Slice = function utf8Slice(string, offset, length) {
return _utf8Slice(this, string, offset, length);
};
Buffer.prototype.utf8Write = function utf8Write(string, offset, length) {
return blitBuffer(utf8ToBytes(string, this.length - offset), this, offset, length);
};
Buffer.prototype.write = function write(string, offset, length, encoding) {
if (offset === undefined) {
return this.utf8Write(string, 0, this.length);
}
if (length === undefined && typeof offset === "string") {
encoding = offset;
length = this.length;
offset = 0;
} else {
validateOffset(offset, "offset", 0, this.length);
const remaining = this.length - offset;
if (length === undefined) {
length = remaining;
} else if (typeof length === "string") {
encoding = length;
length = remaining;
} else {
validateOffset(length, "length", 0, this.length);
if (length > remaining) {
length = remaining;
}
}
}
if (!encoding) {
return this.utf8Write(string, offset, length);
}
const ops = getEncodingOps(encoding);
if (ops === undefined) {
throw new codes.ERR_UNKNOWN_ENCODING(encoding);
}
return ops.write(this, string, offset, length);
};
Buffer.prototype.toJSON = function toJSON() {
return {
type: "Buffer",
data: Array.prototype.slice.call(this._arr || this, 0)
};
};
function fromArrayBuffer(obj, byteOffset, length) {
if (byteOffset === undefined) {
byteOffset = 0;
} else {
byteOffset = +byteOffset;
if (Number.isNaN(byteOffset)) {
byteOffset = 0;
}
}
const maxLength = obj.byteLength - byteOffset;
if (maxLength < 0) {
throw new codes.ERR_BUFFER_OUT_OF_BOUNDS("offset");
}
if (length === undefined) {
length = maxLength;
} else {
length = +length;
if (length > 0) {
if (length > maxLength) {
throw new codes.ERR_BUFFER_OUT_OF_BOUNDS("length");
}
} else {
length = 0;
}
}
const buffer = new Uint8Array(obj, byteOffset, length);
Object.setPrototypeOf(buffer, Buffer.prototype);
return buffer;
}
const decoder = new TextDecoder();
function _utf8Slice(buf, start, end) {
return decoder.decode(buf.slice(start, end));
}
function _latin1Slice(buf, start, end) {
let ret = "";
end = Math.min(buf.length, end);
for(let i = start; i < end; ++i){
ret += String.fromCharCode(buf[i]);
}
return ret;
}
function _hexSlice(buf, start, end) {
const len = buf.length;
if (!start || start < 0) {
start = 0;
}
if (!end || end < 0 || end > len) {
end = len;
}
let out = "";
for(let i = start; i < end; ++i){
out += hexSliceLookupTable[buf[i]];
}
return out;
}
Buffer.prototype.slice = function slice(start, end) {
const len = this.length;
start = ~~start;
end = end === void 0 ? len : ~~end;
if (start < 0) {
start += len;
if (start < 0) {
start = 0;
}
} else if (start > len) {
start = len;
}
if (end < 0) {
end += len;
if (end < 0) {
end = 0;
}
} else if (end > len) {
end = len;
}
if (end < start) {
end = start;
}
const newBuf = this.subarray(start, end);
Object.setPrototypeOf(newBuf, Buffer.prototype);
return newBuf;
};
Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength) {
if (offset === undefined) {
throw new codes.ERR_INVALID_ARG_TYPE("offset", "number", offset);
}
if (byteLength === 6) {
return readUInt48LE(this, offset);
}
if (byteLength === 5) {
return readUInt40LE(this, offset);
}
if (byteLength === 3) {
return readUInt24LE(this, offset);
}
if (byteLength === 4) {
return this.readUInt32LE(offset);
}
if (byteLength === 2) {
return this.readUInt16LE(offset);
}
if (byteLength === 1) {
return this.readUInt8(offset);
}
boundsError(byteLength, 6, "byteLength");
};
Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength) {
if (offset === undefined) {
throw new codes.ERR_INVALID_ARG_TYPE("offset", "number", offset);
}
if (byteLength === 6) {
return readUInt48BE(this, offset);
}
if (byteLength === 5) {
return readUInt40BE(this, offset);
}
if (byteLength === 3) {
return readUInt24BE(this, offset);
}
if (byteLength === 4) {
return this.readUInt32BE(offset);
}
if (byteLength === 2) {
return this.readUInt16BE(offset);
}
if (byteLength === 1) {
return this.readUInt8(offset);
}
boundsError(byteLength, 6, "byteLength");
};
Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset = 0) {
validateNumber(offset, "offset");
const val = this[offset];
if (val === undefined) {
boundsError(offset, this.length - 1);
}
return val;
};
Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = readUInt16BE;
Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset = 0) {
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 1];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 2);
}
return first + last * 2 ** 8;
};
Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset = 0) {
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 3];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 4);
}
return first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
};
Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = readUInt32BE;
Buffer.prototype.readBigUint64LE = Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
offset = offset >>> 0;
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 7];
if (first === void 0 || last === void 0) {
boundsError(offset, this.length - 8);
}
const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
return BigInt(lo) + (BigInt(hi) << BigInt(32));
});
Buffer.prototype.readBigUint64BE = Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
offset = offset >>> 0;
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 7];
if (first === void 0 || last === void 0) {
boundsError(offset, this.length - 8);
}
const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
return (BigInt(hi) << BigInt(32)) + BigInt(lo);
});
Buffer.prototype.readIntLE = function readIntLE(offset, byteLength) {
if (offset === undefined) {
throw new codes.ERR_INVALID_ARG_TYPE("offset", "number", offset);
}
if (byteLength === 6) {
return readInt48LE(this, offset);
}
if (byteLength === 5) {
return readInt40LE(this, offset);
}
if (byteLength === 3) {
return readInt24LE(this, offset);
}
if (byteLength === 4) {
return this.readInt32LE(offset);
}
if (byteLength === 2) {
return this.readInt16LE(offset);
}
if (byteLength === 1) {
return this.readInt8(offset);
}
boundsError(byteLength, 6, "byteLength");
};
Buffer.prototype.readIntBE = function readIntBE(offset, byteLength) {
if (offset === undefined) {
throw new codes.ERR_INVALID_ARG_TYPE("offset", "number", offset);
}
if (byteLength === 6) {
return readInt48BE(this, offset);
}
if (byteLength === 5) {
return readInt40BE(this, offset);
}
if (byteLength === 3) {
return readInt24BE(this, offset);
}
if (byteLength === 4) {
return this.readInt32BE(offset);
}
if (byteLength === 2) {
return this.readInt16BE(offset);
}
if (byteLength === 1) {
return this.readInt8(offset);
}
boundsError(byteLength, 6, "byteLength");
};
Buffer.prototype.readInt8 = function readInt8(offset = 0) {
validateNumber(offset, "offset");
const val = this[offset];
if (val === undefined) {
boundsError(offset, this.length - 1);
}
return val | (val & 2 ** 7) * 0x1fffffe;
};
Buffer.prototype.readInt16LE = function readInt16LE(offset = 0) {
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 1];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 2);
}
const val = first + last * 2 ** 8;
return val | (val & 2 ** 15) * 0x1fffe;
};
Buffer.prototype.readInt16BE = function readInt16BE(offset = 0) {
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 1];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 2);
}
const val = first * 2 ** 8 + last;
return val | (val & 2 ** 15) * 0x1fffe;
};
Buffer.prototype.readInt32LE = function readInt32LE(offset = 0) {
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 3];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 4);
}
return first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + (last << 24);
};
Buffer.prototype.readInt32BE = function readInt32BE(offset = 0) {
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 3];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 4);
}
return (first << 24) + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
};
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
offset = offset >>> 0;
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 7];
if (first === void 0 || last === void 0) {
boundsError(offset, this.length - 8);
}
const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
});
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
offset = offset >>> 0;
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 7];
if (first === void 0 || last === void 0) {
boundsError(offset, this.length - 8);
}
const val = (first << 24) + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
});
Buffer.prototype.readFloatLE = function readFloatLE(offset) {
return bigEndian ? readFloatBackwards(this, offset) : readFloatForwards(this, offset);
};
Buffer.prototype.readFloatBE = function readFloatBE(offset) {
return bigEndian ? readFloatForwards(this, offset) : readFloatBackwards(this, offset);
};
Buffer.prototype.readDoubleLE = function readDoubleLE(offset) {
return bigEndian ? readDoubleBackwards(this, offset) : readDoubleForwards(this, offset);
};
Buffer.prototype.readDoubleBE = function readDoubleBE(offset) {
return bigEndian ? readDoubleForwards(this, offset) : readDoubleBackwards(this, offset);
};
Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength) {
if (byteLength === 6) {
return writeU_Int48LE(this, value, offset, 0, 0xffffffffffff);
}
if (byteLength === 5) {
return writeU_Int40LE(this, value, offset, 0, 0xffffffffff);
}
if (byteLength === 3) {
return writeU_Int24LE(this, value, offset, 0, 0xffffff);
}
if (byteLength === 4) {
return writeU_Int32LE(this, value, offset, 0, 0xffffffff);
}
if (byteLength === 2) {
return writeU_Int16LE(this, value, offset, 0, 0xffff);
}
if (byteLength === 1) {
return writeU_Int8(this, value, offset, 0, 0xff);
}
boundsError(byteLength, 6, "byteLength");
};
Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength) {
if (byteLength === 6) {
return writeU_Int48BE(this, value, offset, 0, 0xffffffffffff);
}
if (byteLength === 5) {
return writeU_Int40BE(this, value, offset, 0, 0xffffffffff);
}
if (byteLength === 3) {
return writeU_Int24BE(this, value, offset, 0, 0xffffff);
}
if (byteLength === 4) {
return writeU_Int32BE(this, value, offset, 0, 0xffffffff);
}
if (byteLength === 2) {
return writeU_Int16BE(this, value, offset, 0, 0xffff);
}
if (byteLength === 1) {
return writeU_Int8(this, value, offset, 0, 0xff);
}
boundsError(byteLength, 6, "byteLength");
};
Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset = 0) {
return writeU_Int8(this, value, offset, 0, 0xff);
};
Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset = 0) {
return writeU_Int16LE(this, value, offset, 0, 0xffff);
};
Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset = 0) {
return writeU_Int16BE(this, value, offset, 0, 0xffff);
};
Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset = 0) {
return _writeUInt32LE(this, value, offset, 0, 0xffffffff);
};
Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset = 0) {
return _writeUInt32BE(this, value, offset, 0, 0xffffffff);
};
function wrtBigUInt64LE(buf, value, offset, min, max) {
checkIntBI(value, min, max, buf, offset, 7);
let lo = Number(value & BigInt(4294967295));
buf[offset++] = lo;
lo = lo >> 8;
buf[offset++] = lo;
lo = lo >> 8;
buf[offset++] = lo;
lo = lo >> 8;
buf[offset++] = lo;
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
buf[offset++] = hi;
hi = hi >> 8;
buf[offset++] = hi;
hi = hi >> 8;
buf[offset++] = hi;
hi = hi >> 8;
buf[offset++] = hi;
return offset;
}
function wrtBigUInt64BE(buf, value, offset, min, max) {
checkIntBI(value, min, max, buf, offset, 7);
let lo = Number(value & BigInt(4294967295));
buf[offset + 7] = lo;
lo = lo >> 8;
buf[offset + 6] = lo;
lo = lo >> 8;
buf[offset + 5] = lo;
lo = lo >> 8;
buf[offset + 4] = lo;
let hi = Number(value >> BigInt(32) & BigInt(4294967295));
buf[offset + 3] = hi;
hi = hi >> 8;
buf[offset + 2] = hi;
hi = hi >> 8;
buf[offset + 1] = hi;
hi = hi >> 8;
buf[offset] = hi;
return offset + 8;
}
Buffer.prototype.writeBigUint64LE = Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
});
Buffer.prototype.writeBigUint64BE = Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
});
Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength) {
if (byteLength === 6) {
return writeU_Int48LE(this, value, offset, -0x800000000000, 0x7fffffffffff);
}
if (byteLength === 5) {
return writeU_Int40LE(this, value, offset, -0x8000000000, 0x7fffffffff);
}
if (byteLength === 3) {
return writeU_Int24LE(this, value, offset, -0x800000, 0x7fffff);
}
if (byteLength === 4) {
return writeU_Int32LE(this, value, offset, -0x80000000, 0x7fffffff);
}
if (byteLength === 2) {
return writeU_Int16LE(this, value, offset, -0x8000, 0x7fff);
}
if (byteLength === 1) {
return writeU_Int8(this, value, offset, -0x80, 0x7f);
}
boundsError(byteLength, 6, "byteLength");
};
Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength) {
if (byteLength === 6) {
return writeU_Int48BE(this, value, offset, -0x800000000000, 0x7fffffffffff);
}
if (byteLength === 5) {
return writeU_Int40BE(this, value, offset, -0x8000000000, 0x7fffffffff);
}
if (byteLength === 3) {
return writeU_Int24BE(this, value, offset, -0x800000, 0x7fffff);
}
if (byteLength === 4) {
return writeU_Int32BE(this, value, offset, -0x80000000, 0x7fffffff);
}
if (byteLength === 2) {
return writeU_Int16BE(this, value, offset, -0x8000, 0x7fff);
}
if (byteLength === 1) {
return writeU_Int8(this, value, offset, -0x80, 0x7f);
}
boundsError(byteLength, 6, "byteLength");
};
Buffer.prototype.writeInt8 = function writeInt8(value, offset = 0) {
return writeU_Int8(this, value, offset, -0x80, 0x7f);
};
Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset = 0) {
return writeU_Int16LE(this, value, offset, -0x8000, 0x7fff);
};
Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset = 0) {
return writeU_Int16BE(this, value, offset, -0x8000, 0x7fff);
};
Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset = 0) {
return writeU_Int32LE(this, value, offset, -0x80000000, 0x7fffffff);
};
Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset = 0) {
return writeU_Int32BE(this, value, offset, -0x80000000, 0x7fffffff);
};
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
});
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
});
Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset) {
return bigEndian ? writeFloatBackwards(this, value, offset) : writeFloatForwards(this, value, offset);
};
Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset) {
return bigEndian ? writeFloatForwards(this, value, offset) : writeFloatBackwards(this, value, offset);
};
Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset) {
return bigEndian ? writeDoubleBackwards(this, value, offset) : writeDoubleForwards(this, value, offset);
};
Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset) {
return bigEndian ? writeDoubleForwards(this, value, offset) : writeDoubleBackwards(this, value, offset);
};
Buffer.prototype.copy = function copy(target, targetStart, sourceStart, sourceEnd) {
if (!isUint8Array(this)) {
throw new codes.ERR_INVALID_ARG_TYPE("source", [
"Buffer",
"Uint8Array"
], this);
}
if (!isUint8Array(target)) {
throw new codes.ERR_INVALID_ARG_TYPE("target", [
"Buffer",
"Uint8Array"
], target);
}
if (targetStart === undefined) {
targetStart = 0;
} else {
targetStart = toInteger(targetStart, 0);
if (targetStart < 0) {
throw new codes.ERR_OUT_OF_RANGE("targetStart", ">= 0", targetStart);
}
}
if (sourceStart === undefined) {
sourceStart = 0;
} else {
sourceStart = toInteger(sourceStart, 0);
if (sourceStart < 0) {
throw new codes.ERR_OUT_OF_RANGE("sourceStart", ">= 0", sourceStart);
}
if (sourceStart >= MAX_UINT32) {
throw new codes.ERR_OUT_OF_RANGE("sourceStart", `< ${MAX_UINT32}`, sourceStart);
}
}
if (sourceEnd === undefined) {
sourceEnd = this.length;
} else {
sourceEnd = toInteger(sourceEnd, 0);
if (sourceEnd < 0) {
throw new codes.ERR_OUT_OF_RANGE("sourceEnd", ">= 0", sourceEnd);
}
if (sourceEnd >= MAX_UINT32) {
throw new codes.ERR_OUT_OF_RANGE("sourceEnd", `< ${MAX_UINT32}`, sourceEnd);
}
}
if (targetStart >= target.length) {
return 0;
}
if (sourceEnd > 0 && sourceEnd < sourceStart) {
sourceEnd = sourceStart;
}
if (sourceEnd === sourceStart) {
return 0;
}
if (target.length === 0 || this.length === 0) {
return 0;
}
if (sourceEnd > this.length) {
sourceEnd = this.length;
}
if (target.length - targetStart < sourceEnd - sourceStart) {
sourceEnd = target.length - targetStart + sourceStart;
}
const len = sourceEnd - sourceStart;
if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
this.copyWithin(targetStart, sourceStart, sourceEnd);
} else {
Uint8Array.prototype.set.call(target, this.subarray(sourceStart, sourceEnd), targetStart);
}
return len;
};
Buffer.prototype.fill = function fill(val, start, end, encoding) {
if (typeof val === "string") {
if (typeof start === "string") {
encoding = start;
start = 0;
end = this.length;
} else if (typeof end === "string") {
encoding = end;
end = this.length;
}
if (encoding !== void 0 && typeof encoding !== "string") {
throw new TypeError("encoding must be a string");
}
if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) {
throw new TypeError("Unknown encoding: " + encoding);
}
if (val.length === 1) {
const code = val.charCodeAt(0);
if (encoding === "utf8" && code < 128 || encoding === "latin1") {
val = code;
}
}
} else if (typeof val === "number") {
val = val & 255;
} else if (typeof val === "boolean") {
val = Number(val);
}
if (start < 0 || this.length < start || this.length < end) {
throw new RangeError("Out of range index");
}
if (end <= start) {
return this;
}
start = start >>> 0;
end = end === void 0 ? this.length : end >>> 0;
if (!val) {
val = 0;
}
let i;
if (typeof val === "number") {
for(i = start; i < end; ++i){
this[i] = val;
}
} else {
const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding);
const len = bytes.length;
if (len === 0) {
throw new codes.ERR_INVALID_ARG_VALUE("value", val);
}
for(i = 0; i < end - start; ++i){
this[i + start] = bytes[i % len];
}
}
return this;
};
function checkBounds(buf, offset, byteLength2) {
validateNumber(offset, "offset");
if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
boundsError(offset, buf.length - (byteLength2 + 1));
}
}
function checkIntBI(value, min, max, buf, offset, byteLength2) {
if (value > max || value < min) {
const n = typeof min === "bigint" ? "n" : "";
let range;
if (byteLength2 > 3) {
if (min === 0 || min === BigInt(0)) {
range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
} else {
range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
}
} else {
range = `>= ${min}${n} and <= ${max}${n}`;
}
throw new codes.ERR_OUT_OF_RANGE("value", range, value);
}
checkBounds(buf, offset, byteLength2);
}
function utf8ToBytes(string, units) {
units = units || Infinity;
let codePoint;
const length = string.length;
let leadSurrogate = null;
const bytes = [];
for(let i = 0; i < length; ++i){
codePoint = string.charCodeAt(i);
if (codePoint > 55295 && codePoint < 57344) {
if (!leadSurrogate) {
if (codePoint > 56319) {
if ((units -= 3) > -1) {
bytes.push(239, 191, 189);
}
continue;
} else if (i + 1 === length) {
if ((units -= 3) > -1) {
bytes.push(239, 191, 189);
}
continue;
}
leadSurrogate = codePoint;
continue;
}
if (codePoint < 56320) {
if ((units -= 3) > -1) {
bytes.push(239, 191, 189);
}
leadSurrogate = codePoint;
continue;
}
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
} else if (leadSurrogate) {
if ((units -= 3) > -1) {
bytes.push(239, 191, 189);
}
}
leadSurrogate = null;
if (codePoint < 128) {
if ((units -= 1) < 0) {
break;
}
bytes.push(codePoint);
} else if (codePoint < 2048) {
if ((units -= 2) < 0) {
break;
}
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
} else if (codePoint < 65536) {
if ((units -= 3) < 0) {
break;
}
bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
} else if (codePoint < 1114112) {
if ((units -= 4) < 0) {
break;
}
bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
} else {
throw new Error("Invalid code point");
}
}
return bytes;
}
function blitBuffer(src, dst, offset, byteLength) {
let i;
const length = byteLength === undefined ? src.length : byteLength;
for(i = 0; i < length; ++i){
if (i + offset >= dst.length || i >= src.length) {
break;
}
dst[i + offset] = src[i];
}
return i;
}
function isInstance(obj, type) {
return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
}
const hexSliceLookupTable = function() {
const alphabet = "0123456789abcdef";
const table = new Array(256);
for(let i = 0; i < 16; ++i){
const i16 = i * 16;
for(let j = 0; j < 16; ++j){
table[i16 + j] = alphabet[i] + alphabet[j];
}
}
return table;
}();
function defineBigIntMethod(fn) {
return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
}
function BufferBigIntNotDefined() {
throw new Error("BigInt not supported");
}
const atob1 = globalThis.atob;
const Blob = globalThis.Blob;
const btoa = globalThis.btoa;
function readUInt48LE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 5];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 6);
}
return first + buf[++offset] * 2 ** 8 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 24 + (buf[++offset] + last * 2 ** 8) * 2 ** 32;
}
function readUInt40LE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 4];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 5);
}
return first + buf[++offset] * 2 ** 8 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 24 + last * 2 ** 32;
}
function readUInt24LE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 2];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 3);
}
return first + buf[++offset] * 2 ** 8 + last * 2 ** 16;
}
function readUInt48BE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 5];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 6);
}
return (first * 2 ** 8 + buf[++offset]) * 2 ** 32 + buf[++offset] * 2 ** 24 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 8 + last;
}
function readUInt40BE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 4];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 5);
}
return first * 2 ** 32 + buf[++offset] * 2 ** 24 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 8 + last;
}
function readUInt24BE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 2];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 3);
}
return first * 2 ** 16 + buf[++offset] * 2 ** 8 + last;
}
function readUInt16BE(offset = 0) {
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 1];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 2);
}
return first * 2 ** 8 + last;
}
function readUInt32BE(offset = 0) {
validateNumber(offset, "offset");
const first = this[offset];
const last = this[offset + 3];
if (first === undefined || last === undefined) {
boundsError(offset, this.length - 4);
}
return first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
}
function readDoubleBackwards(buffer, offset = 0) {
validateNumber(offset, "offset");
const first = buffer[offset];
const last = buffer[offset + 7];
if (first === undefined || last === undefined) {
boundsError(offset, buffer.length - 8);
}
uInt8Float64Array[7] = first;
uInt8Float64Array[6] = buffer[++offset];
uInt8Float64Array[5] = buffer[++offset];
uInt8Float64Array[4] = buffer[++offset];
uInt8Float64Array[3] = buffer[++offset];
uInt8Float64Array[2] = buffer[++offset];
uInt8Float64Array[1] = buffer[++offset];
uInt8Float64Array[0] = last;
return float64Array[0];
}
function readDoubleForwards(buffer, offset = 0) {
validateNumber(offset, "offset");
const first = buffer[offset];
const last = buffer[offset + 7];
if (first === undefined || last === undefined) {
boundsError(offset, buffer.length - 8);
}
uInt8Float64Array[0] = first;
uInt8Float64Array[1] = buffer[++offset];
uInt8Float64Array[2] = buffer[++offset];
uInt8Float64Array[3] = buffer[++offset];
uInt8Float64Array[4] = buffer[++offset];
uInt8Float64Array[5] = buffer[++offset];
uInt8Float64Array[6] = buffer[++offset];
uInt8Float64Array[7] = last;
return float64Array[0];
}
function writeDoubleForwards(buffer, val, offset = 0) {
val = +val;
checkBounds(buffer, offset, 7);
float64Array[0] = val;
buffer[offset++] = uInt8Float64Array[0];
buffer[offset++] = uInt8Float64Array[1];
buffer[offset++] = uInt8Float64Array[2];
buffer[offset++] = uInt8Float64Array[3];
buffer[offset++] = uInt8Float64Array[4];
buffer[offset++] = uInt8Float64Array[5];
buffer[offset++] = uInt8Float64Array[6];
buffer[offset++] = uInt8Float64Array[7];
return offset;
}
function writeDoubleBackwards(buffer, val, offset = 0) {
val = +val;
checkBounds(buffer, offset, 7);
float64Array[0] = val;
buffer[offset++] = uInt8Float64Array[7];
buffer[offset++] = uInt8Float64Array[6];
buffer[offset++] = uInt8Float64Array[5];
buffer[offset++] = uInt8Float64Array[4];
buffer[offset++] = uInt8Float64Array[3];
buffer[offset++] = uInt8Float64Array[2];
buffer[offset++] = uInt8Float64Array[1];
buffer[offset++] = uInt8Float64Array[0];
return offset;
}
function readFloatBackwards(buffer, offset = 0) {
validateNumber(offset, "offset");
const first = buffer[offset];
const last = buffer[offset + 3];
if (first === undefined || last === undefined) {
boundsError(offset, buffer.length - 4);
}
uInt8Float32Array[3] = first;
uInt8Float32Array[2] = buffer[++offset];
uInt8Float32Array[1] = buffer[++offset];
uInt8Float32Array[0] = last;
return float32Array[0];
}
function readFloatForwards(buffer, offset = 0) {
validateNumber(offset, "offset");
const first = buffer[offset];
const last = buffer[offset + 3];
if (first === undefined || last === undefined) {
boundsError(offset, buffer.length - 4);
}
uInt8Float32Array[0] = first;
uInt8Float32Array[1] = buffer[++offset];
uInt8Float32Array[2] = buffer[++offset];
uInt8Float32Array[3] = last;
return float32Array[0];
}
function writeFloatForwards(buffer, val, offset = 0) {
val = +val;
checkBounds(buffer, offset, 3);
float32Array[0] = val;
buffer[offset++] = uInt8Float32Array[0];
buffer[offset++] = uInt8Float32Array[1];
buffer[offset++] = uInt8Float32Array[2];
buffer[offset++] = uInt8Float32Array[3];
return offset;
}
function writeFloatBackwards(buffer, val, offset = 0) {
val = +val;
checkBounds(buffer, offset, 3);
float32Array[0] = val;
buffer[offset++] = uInt8Float32Array[3];
buffer[offset++] = uInt8Float32Array[2];
buffer[offset++] = uInt8Float32Array[1];
buffer[offset++] = uInt8Float32Array[0];
return offset;
}
function readInt24LE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 2];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 3);
}
const val = first + buf[++offset] * 2 ** 8 + last * 2 ** 16;
return val | (val & 2 ** 23) * 0x1fe;
}
function readInt40LE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 4];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 5);
}
return (last | (last & 2 ** 7) * 0x1fffffe) * 2 ** 32 + first + buf[++offset] * 2 ** 8 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 24;
}
function readInt48LE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 5];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 6);
}
const val = buf[offset + 4] + last * 2 ** 8;
return (val | (val & 2 ** 15) * 0x1fffe) * 2 ** 32 + first + buf[++offset] * 2 ** 8 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 24;
}
function readInt24BE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 2];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 3);
}
const val = first * 2 ** 16 + buf[++offset] * 2 ** 8 + last;
return val | (val & 2 ** 23) * 0x1fe;
}
function readInt48BE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 5];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 6);
}
const val = buf[++offset] + first * 2 ** 8;
return (val | (val & 2 ** 15) * 0x1fffe) * 2 ** 32 + buf[++offset] * 2 ** 24 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 8 + last;
}
function readInt40BE(buf, offset = 0) {
validateNumber(offset, "offset");
const first = buf[offset];
const last = buf[offset + 4];
if (first === undefined || last === undefined) {
boundsError(offset, buf.length - 5);
}
return (first | (first & 2 ** 7) * 0x1fffffe) * 2 ** 32 + buf[++offset] * 2 ** 24 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 8 + last;
}
function byteLengthUtf8(str) {
return utf8Encoder.encode(str).length;
}
function base64ByteLength(str, bytes) {
if (str.charCodeAt(bytes - 1) === 0x3D) {
bytes--;
}
if (bytes > 1 && str.charCodeAt(bytes - 1) === 0x3D) {
bytes--;
}
return bytes * 3 >>> 2;
}
const encodingsMap = Object.create(null);
for(let i = 0; i < encodings.length; ++i){
encodingsMap[encodings[i]] = i;
}
const encodingOps = {
ascii: {
byteLength: (string)=>string.length,
encoding: "ascii",
encodingVal: encodingsMap.ascii,
indexOf: (buf, val, byteOffset, dir)=>indexOfBuffer(buf, asciiToBytes(val), byteOffset, encodingsMap.ascii, dir),
slice: (buf, start, end)=>buf.asciiSlice(start, end),
write: (buf, string, offset, len)=>buf.asciiWrite(string, offset, len)
},
base64: {
byteLength: (string)=>base64ByteLength(string, string.length),
encoding: "base64",
encodingVal: encodingsMap.base64,
indexOf: (buf, val, byteOffset, dir)=>indexOfBuffer(buf, base64ToBytes(val), byteOffset, encodingsMap.base64, dir),
slice: (buf, start, end)=>buf.base64Slice(start, end),
write: (buf, string, offset, len)=>buf.base64Write(string, offset, len)
},
base64url: {
byteLength: (string)=>base64ByteLength(string, string.length),
encoding: "base64url",
encodingVal: encodingsMap.base64url,
indexOf: (buf, val, byteOffset, dir)=>indexOfBuffer(buf, base64UrlToBytes(val), byteOffset, encodingsMap.base64url, dir),
slice: (buf, start, end)=>buf.base64urlSlice(start, end),
write: (buf, string, offset, len)=>buf.base64urlWrite(string, offset, len)
},
hex: {
byteLength: (string)=>string.length >>> 1,
encoding: "hex",
encodingVal: encodingsMap.hex,
indexOf: (buf, val, byteOffset, dir)=>indexOfBuffer(buf, hexToBytes(val), byteOffset, encodingsMap.hex, dir),
slice: (buf, start, end)=>buf.hexSlice(start, end),
write: (buf, string, offset, len)=>buf.hexWrite(string, offset, len)
},
latin1: {
byteLength: (string)=>string.length,
encoding: "latin1",
encodingVal: encodingsMap.latin1,
indexOf: (buf, val, byteOffset, dir)=>indexOfBuffer(buf, asciiToBytes(val), byteOffset, encodingsMap.latin1, dir),
slice: (buf, start, end)=>buf.latin1Slice(start, end),
write: (buf, string, offset, len)=>buf.latin1Write(string, offset, len)
},
ucs2: {
byteLength: (string)=>string.length * 2,
encoding: "ucs2",
encodingVal: encodingsMap.utf16le,
indexOf: (buf, val, byteOffset, dir)=>indexOfBuffer(buf, utf16leToBytes(val), byteOffset, encodingsMap.utf16le, dir),
slice: (buf, start, end)=>buf.ucs2Slice(start, end),
write: (buf, string, offset, len)=>buf.ucs2Write(string, offset, len)
},
utf8: {
byteLength: byteLengthUtf8,
encoding: "utf8",
encodingVal: encodingsMap.utf8,
indexOf: (buf, val, byteOffset, dir)=>indexOfBuffer(buf, utf8Encoder.encode(val), byteOffset, encodingsMap.utf8, dir),
slice: (buf, start, end)=>buf.utf8Slice(start, end),
write: (buf, string, offset, len)=>buf.utf8Write(string, offset, len)
},
utf16le: {
byteLength: (string)=>string.length * 2,
encoding: "utf16le",
encodingVal: encodingsMap.utf16le,
indexOf: (buf, val, byteOffset, dir)=>indexOfBuffer(buf, utf16leToBytes(val), byteOffset, encodingsMap.utf16le, dir),
slice: (buf, start, end)=>buf.ucs2Slice(start, end),
write: (buf, string, offset, len)=>buf.ucs2Write(string, offset, len)
}
};
function getEncodingOps(encoding) {
encoding = String(encoding).toLowerCase();
switch(encoding.length){
case 4:
if (encoding === "utf8") return encodingOps.utf8;
if (encoding === "ucs2") return encodingOps.ucs2;
break;
case 5:
if (encoding === "utf-8") return encodingOps.utf8;
if (encoding === "ascii") return encodingOps.ascii;
if (encoding === "ucs-2") return encodingOps.ucs2;
break;
case 7:
if (encoding === "utf16le") {
return encodingOps.utf16le;
}
break;
case 8:
if (encoding === "utf-16le") {
return encodingOps.utf16le;
}
break;
case 6:
if (encoding === "latin1" || encoding === "binary") {
return encodingOps.latin1;
}
if (encoding === "base64") return encodingOps.base64;
case 3:
if (encoding === "hex") {
return encodingOps.hex;
}
break;
case 9:
if (encoding === "base64url") {
return encodingOps.base64url;
}
break;
}
}
function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
if (sourceEnd - sourceStart > target.length - targetStart) {
sourceEnd = sourceStart + target.length - targetStart;
}
let nb = sourceEnd - sourceStart;
const sourceLen = source.length - sourceStart;
if (nb > sourceLen) {
nb = sourceLen;
}
if (sourceStart !== 0 || sourceEnd < source.length) {
source = new Uint8Array(source.buffer, source.byteOffset + sourceStart, nb);
}
target.set(source, targetStart);
return nb;
}
function boundsError(value, length, type) {
if (Math.floor(value) !== value) {
validateNumber(value, type);
throw new codes.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
}
if (length < 0) {
throw new codes.ERR_BUFFER_OUT_OF_BOUNDS();
}
throw new codes.ERR_OUT_OF_RANGE(type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value);
}
function validateNumber(value, name) {
if (typeof value !== "number") {
throw new codes.ERR_INVALID_ARG_TYPE(name, "number", value);
}
}
function checkInt(value, min, max, buf, offset, byteLength) {
if (value > max || value < min) {
const n = typeof min === "bigint" ? "n" : "";
let range;
if (byteLength > 3) {
if (min === 0 || min === 0n) {
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
} else {
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and ` + `< 2${n} ** ${(byteLength + 1) * 8 - 1}${n}`;
}
} else {
range = `>= ${min}${n} and <= ${max}${n}`;
}
throw new codes.ERR_OUT_OF_RANGE("value", range, value);
}
checkBounds(buf, offset, byteLength);
}
function toInteger(n, defaultVal) {
n = +n;
if (!Number.isNaN(n) && n >= Number.MIN_SAFE_INTEGER && n <= Number.MAX_SAFE_INTEGER) {
return n % 1 === 0 ? n : Math.floor(n);
}
return defaultVal;
}
function writeU_Int8(buf, value, offset, min, max) {
value = +value;
validateNumber(offset, "offset");
if (value > max || value < min) {
throw new codes.ERR_OUT_OF_RANGE("value", `>= ${min} and <= ${max}`, value);
}
if (buf[offset] === undefined) {
boundsError(offset, buf.length - 1);
}
buf[offset] = value;
return offset + 1;
}
function writeU_Int16BE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 1);
buf[offset++] = value >>> 8;
buf[offset++] = value;
return offset;
}
function _writeUInt32LE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 3);
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
return offset;
}
function writeU_Int16LE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 1);
buf[offset++] = value;
buf[offset++] = value >>> 8;
return offset;
}
function _writeUInt32BE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 3);
buf[offset + 3] = value;
value = value >>> 8;
buf[offset + 2] = value;
value = value >>> 8;
buf[offset + 1] = value;
value = value >>> 8;
buf[offset] = value;
return offset + 4;
}
function writeU_Int48BE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 5);
const newVal = Math.floor(value * 2 ** -32);
buf[offset++] = newVal >>> 8;
buf[offset++] = newVal;
buf[offset + 3] = value;
value = value >>> 8;
buf[offset + 2] = value;
value = value >>> 8;
buf[offset + 1] = value;
value = value >>> 8;
buf[offset] = value;
return offset + 4;
}
function writeU_Int40BE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 4);
buf[offset++] = Math.floor(value * 2 ** -32);
buf[offset + 3] = value;
value = value >>> 8;
buf[offset + 2] = value;
value = value >>> 8;
buf[offset + 1] = value;
value = value >>> 8;
buf[offset] = value;
return offset + 4;
}
function writeU_Int32BE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 3);
buf[offset + 3] = value;
value = value >>> 8;
buf[offset + 2] = value;
value = value >>> 8;
buf[offset + 1] = value;
value = value >>> 8;
buf[offset] = value;
return offset + 4;
}
function writeU_Int24BE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 2);
buf[offset + 2] = value;
value = value >>> 8;
buf[offset + 1] = value;
value = value >>> 8;
buf[offset] = value;
return offset + 3;
}
function validateOffset(value, name, min = 0, max = Number.MAX_SAFE_INTEGER) {
if (typeof value !== "number") {
throw new codes.ERR_INVALID_ARG_TYPE(name, "number", value);
}
if (!Number.isInteger(value)) {
throw new codes.ERR_OUT_OF_RANGE(name, "an integer", value);
}
if (value < min || value > max) {
throw new codes.ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
}
}
function writeU_Int48LE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 5);
const newVal = Math.floor(value * 2 ** -32);
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
buf[offset++] = newVal;
buf[offset++] = newVal >>> 8;
return offset;
}
function writeU_Int40LE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 4);
const newVal = value;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
buf[offset++] = Math.floor(newVal * 2 ** -32);
return offset;
}
function writeU_Int32LE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 3);
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
return offset;
}
function writeU_Int24LE(buf, value, offset, min, max) {
value = +value;
checkInt(value, min, max, buf, offset, 2);
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
value = value >>> 8;
buf[offset++] = value;
return offset;
}
const __default1 = {
atob: atob1,
btoa,
Blob,
Buffer,
constants,
kMaxLength: 2147483647,
kStringMaxLength: 536870888,
SlowBuffer
};
export { atob1 as atob, Blob as Blob, btoa as btoa, Buffer as Buffer, constants as constants, __default1 as default, kMaxLength as kMaxLength, kStringMaxLength as kStringMaxLength, SlowBuffer as SlowBuffer };
@guest271314
Copy link
Author

const url =
  "https://gist.githubusercontent.com/guest271314/08b19ba88c98a465dd09bcd8a04606f6/raw/aac580355cfe4b4a0d6e20a493fca028dfe62dbb/buffer.js";

console.log(navigator.userAgent);

if (navigator.userAgent.includes("txiki.js")) {
  try {
    const { Buffer } = await import(url);
    console.log(Buffer.from([0]));
  } catch (e) {
    console.log(e);
  }
}

if (navigator.userAgent.includes("quickjs-ng")) {
  try {
    const { Buffer } = await import("../buffer/buffer.js");
    console.log(JSON.stringify([...Buffer.from([0])]));
  } catch (e) {
    console.log(e);
  }
}

if (navigator.userAgent.includes("Deno")) {
  const ab = new Blob([
    await (await fetch(url)).arrayBuffer(),
  ], {
    type: "text/javascript",
  });
  try {
    const { Buffer } = await import(URL.createObjectURL(ab));
  } catch (e) {
    console.log(e);
  }
}

if (navigator.userAgent.includes("Node")) {
  try {
    const text = await (await fetch(url)).text();
    const dataURL = `data:text/javascript;base64,${btoa(text)}`;
    const { Buffer } = await import(dataURL);
    console.log(Buffer.from([0]));
  } catch (e) {
    console.log(e);
  }
}

@guest271314
Copy link
Author

if (navigator.userAgent.includes("Bun")) {
  try {
    const text = await (await fetch(url)).text();
    const dataURL = `data:text/javascript;base64,${btoa(text)}`;
    const { Buffer } = await import(dataURL);
    console.log(Buffer.from([0]));
  } catch (e) {
    console.log(e);
  }
}

@guest271314
Copy link
Author

import { writeFileSync } from "node:fs";
if (navigator.userAgent.includes("Bun")) {
  const url =  "https://gist.githubusercontent.com/guest271314/08b19ba88c98a465dd09bcd8a04606f6/raw/aac580355cfe4b4a0d6e20a493fca028dfe62dbb/buffer.js";
  const text = await (await fetch(url)).text();
  writeFileSync("buffer.js", text);
  const { Buffer } = await import("./buffer.js");
  // import { Buffer } from "./buffer.js"; import statement hoists
  console.log(Buffer.from([0]));
}

@guest271314
Copy link
Author

node --experimental-default-type=module --experimental-network-imports ./test-network-imports.js

@guest271314
Copy link
Author

import { Buffer } from "https://gist.githubusercontent.com/guest271314/08b19ba88c98a465dd09bcd8a04606f6/raw/aac580355cfe4b4a0d6e20a493fca028dfe62dbb/buffer.js";
console.log(Buffer.from([0]));
tjs run test-network-imports.js
<Buffer 00>
deno run -A test-network-imports.js
<Buffer 00>
node --experimental-default-type=module --experimental-network-imports test-network-imports.js
(node:25086) ExperimentalWarning: Network Imports is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/modules/esm/load:256
  throw new ERR_UNKNOWN_MODULE_FORMAT(
        ^

RangeError [ERR_UNKNOWN_MODULE_FORMAT]: Unknown module format: null for URL https://gist.githubusercontent.com/guest271314/08b19ba88c98a465dd09bcd8a04606f6/raw/aac580355cfe4b4a0d6e20a493fca028dfe62dbb/buffer.js
    at Object.throwUnknownModuleFormat (node:internal/modules/esm/load:256:9)
    at ModuleLoader.validateLoadResult (node:internal/modules/esm/loader:428:44)
    at ModuleLoader.load (node:internal/modules/esm/loader:404:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:45) {
  code: 'ERR_UNKNOWN_MODULE_FORMAT'
}

Node.js v22.0.0-nightly2024011594f824a19d
bun run test-network-imports.js
error: FileNotFound reading "https://gist.githubusercontent.com/guest271314/08b19ba88c98a465dd09bcd8a04606f6/raw/aac580355cfe4b4a0d6e20a493fca028dfe62dbb/buffer.js"

@guest271314
Copy link
Author

node --experimental-default-type=module --experimental-network-imports --loader=./https-hooks.js ./test-network-imports.js
(node:26754) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("./https-hooks.js", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:26754) ExperimentalWarning: Network Imports is an experimental feature and might change at any time
(node:26754) ExperimentalWarning: Network Imports is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
<Buffer 00>

@guest271314
Copy link
Author

This works for Node.js https://github.com/nodejs/node/blob/main/doc/api/module.md#import-from-https

// https://github.com/nodejs/node/blob/main/doc/api/module.md#import-from-https
// https-hooks.mjs
import { get } from "node:https";

export function load(url, context, nextLoad) {
  // For JavaScript to be loaded over the network, we need to fetch and
  // return it.
  if (url.startsWith("https://")) {
    return new Promise((resolve, reject) => {
      get(url, (res) => {
        let data = "";
        res.setEncoding("utf8");
        res.on("data", (chunk) => data += chunk);
        res.on("end", () =>
          resolve({
            // This example assumes all network-provided JavaScript is ES module
            // code.
            format: "module",
            shortCircuit: true,
            source: data,
          }));
      }).on("error", (err) => reject(err));
    });
  }

  // Let Node.js handle all other URLs.
  return nextLoad(url);
}
node --experimental-default-type=module --experimental-network-imports --loader=./https-hooks.js ./test-network-imports.js
(node:26754) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("./https-hooks.js", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:26754) ExperimentalWarning: Network Imports is an experimental feature and might change at any time
(node:26754) ExperimentalWarning: Network Imports is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
<Buffer 00>

or

node --experimental-default-type=module --experimental-network-imports --import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register(pathToFileURL("./https-hooks.js"));' ./test-network-imports.js
(node:26814) ExperimentalWarning: Network Imports is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:26814) ExperimentalWarning: Network Imports is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
<Buffer 00>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment