From 8f04039d2690485a02dbff09c4e148c35e56f589 Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Sat, 3 Oct 2026 09:38:03 -0500 Subject: [PATCH] Expand Node 24 callback and promise adapter compatibility --- .../node-v24-compatibility-meta.json | 2 +- .../src/generated/node-v24-compatibility.json | 4 +- internal/compatibility/dynamic-support.json | 1 + .../generated/node-v24-backlog.json | 10 +- .../generated/node-v24-internal.json | 11 +- internal/compatibility/src/generate.mjs | 3 + .../test/ts7/baselines/order-parity.json | 6 + packages/runtime/src/scr_island.c | 4126 ++++++++--------- .../npm/cases/node24-util-adapters/main.ts | 4 + .../cases/node24-util-adapters/package.json | 1 + .../node24-util-adapters-fixture/index.d.ts | 1 + .../node24-util-adapters-fixture/index.js | 78 + .../node24-util-adapters-fixture/package.json | 1 + 13 files changed, 2170 insertions(+), 2078 deletions(-) create mode 100644 tests/fixtures/npm/cases/node24-util-adapters/main.ts create mode 100644 tests/fixtures/npm/cases/node24-util-adapters/package.json create mode 100644 tests/fixtures/npm/node_modules/node24-util-adapters-fixture/index.d.ts create mode 100644 tests/fixtures/npm/node_modules/node24-util-adapters-fixture/index.js create mode 100644 tests/fixtures/npm/node_modules/node24-util-adapters-fixture/package.json diff --git a/docs/src/generated/node-v24-compatibility-meta.json b/docs/src/generated/node-v24-compatibility-meta.json index c6ec3f344..82fdd01ea 100644 --- a/docs/src/generated/node-v24-compatibility-meta.json +++ b/docs/src/generated/node-v24-compatibility-meta.json @@ -2,6 +2,6 @@ "schemaVersion": 3, "nodeVersion": "24.15.0", "nodeCommit": "848430679556aed0bd073f2bc263331ad84fa119", - "artifactVersion": "3c31fba8150926a20ac8", + "artifactVersion": "18ed68d47d451a20f50c", "rowCount": 3662 } diff --git a/docs/src/generated/node-v24-compatibility.json b/docs/src/generated/node-v24-compatibility.json index d86ffc75a..70b5ee897 100644 --- a/docs/src/generated/node-v24-compatibility.json +++ b/docs/src/generated/node-v24-compatibility.json @@ -84848,7 +84848,7 @@ }, "dynamic": { "status": "partial", - "detail": "Available through the embedded Node compatibility shim; exact member and overload coverage may be narrower.", + "detail": "Adapts callbacks and promises with receiver preservation, custom promisify hooks, function metadata, and Node-compatible argument and rejection handling; scheduling follows the island microtask queue.", "verification": "test-backed" } }, @@ -85520,7 +85520,7 @@ }, "dynamic": { "status": "partial", - "detail": "Available through the embedded Node compatibility shim; exact member and overload coverage may be narrower.", + "detail": "Adapts callbacks and promises with receiver preservation, custom promisify hooks, function metadata, and Node-compatible argument and rejection handling; scheduling follows the island microtask queue.", "verification": "test-backed" } }, diff --git a/internal/compatibility/dynamic-support.json b/internal/compatibility/dynamic-support.json index 42c5e9376..78224823c 100644 --- a/internal/compatibility/dynamic-support.json +++ b/internal/compatibility/dynamic-support.json @@ -19,6 +19,7 @@ "wasi": "by-design" }, "features": [ + { "chapter": "util", "symbols": ["util.promisify", "util.callbackify"], "status": "partial", "evidence": ["tests/fixtures/npm/cases/util-shims/main.ts", "tests/fixtures/npm/cases/node24-util-adapters/main.ts"] }, { "chapter": "util", "symbols": ["util.parseArgs", "parseArgs"], "status": "partial", "evidence": ["tests/fixtures/npm/cases/util-shims/main.ts", "tests/fixtures/npm/cases/node24-parseargs/main.ts"] }, { "chapter": "buffer", "symbols": ["buffer.isAscii", "buffer.isUtf8", "buffer.transcode"], "status": "partial", "evidence": ["tests/fixtures/npm/cases/node24-text-encoding/main.ts"] }, { "chapter": "util", "parent": "Class: `util.TextEncoder`", "signatures": ["`textEncoder.encodeInto(src, dest)`", "`encoding` Type: {string}"], "status": "partial", "evidence": ["tests/fixtures/npm/cases/node24-text-encoding/main.ts"] }, diff --git a/internal/compatibility/generated/node-v24-backlog.json b/internal/compatibility/generated/node-v24-backlog.json index e45c5bf86..d098cb59c 100644 --- a/internal/compatibility/generated/node-v24-backlog.json +++ b/internal/compatibility/generated/node-v24-backlog.json @@ -94721,9 +94721,10 @@ "action": "audit-partial", "verification": "test-backed", "confidence": "high", - "source": "island-export:node:util.callbackify", + "source": "island-feature:util.util.callbackify", "tests": [ - "tests/fixtures/npm/cases/util-shims/main.ts" + "tests/fixtures/npm/cases/util-shims/main.ts", + "tests/fixtures/npm/cases/node24-util-adapters/main.ts" ] } } @@ -95561,9 +95562,10 @@ "action": "audit-partial", "verification": "test-backed", "confidence": "high", - "source": "island-export:node:util.promisify", + "source": "island-feature:util.util.promisify", "tests": [ - "tests/fixtures/npm/cases/util-shims/main.ts" + "tests/fixtures/npm/cases/util-shims/main.ts", + "tests/fixtures/npm/cases/node24-util-adapters/main.ts" ] } } diff --git a/internal/compatibility/generated/node-v24-internal.json b/internal/compatibility/generated/node-v24-internal.json index 2ffdec739..601c98fae 100644 --- a/internal/compatibility/generated/node-v24-internal.json +++ b/internal/compatibility/generated/node-v24-internal.json @@ -111045,6 +111045,7 @@ "tests/fixtures/npm/cases/node24-env/main.ts", "tests/fixtures/npm/cases/node24-parseargs/main.ts", "tests/fixtures/npm/cases/node24-text-encoding/main.ts", + "tests/fixtures/npm/cases/node24-util-adapters/main.ts", "tests/fixtures/npm/cases/util-shims/main.ts" ] }, @@ -112010,9 +112011,10 @@ }, "dynamic": { "status": "partial", - "evidence": "island-export:node:util.callbackify", + "evidence": "island-feature:util.util.callbackify", "tests": [ - "tests/fixtures/npm/cases/util-shims/main.ts" + "tests/fixtures/npm/cases/util-shims/main.ts", + "tests/fixtures/npm/cases/node24-util-adapters/main.ts" ] }, "anchorSource": "exact" @@ -112833,9 +112835,10 @@ }, "dynamic": { "status": "partial", - "evidence": "island-export:node:util.promisify", + "evidence": "island-feature:util.util.promisify", "tests": [ - "tests/fixtures/npm/cases/util-shims/main.ts" + "tests/fixtures/npm/cases/util-shims/main.ts", + "tests/fixtures/npm/cases/node24-util-adapters/main.ts" ] }, "anchorSource": "exact" diff --git a/internal/compatibility/src/generate.mjs b/internal/compatibility/src/generate.mjs index 2d6ee1a23..7ab35ee97 100644 --- a/internal/compatibility/src/generate.mjs +++ b/internal/compatibility/src/generate.mjs @@ -678,6 +678,9 @@ function publicDetail(tier) { return "No dynamic-island implementation exists for this Node API family yet."; } if (source.startsWith("island-feature:")) { + if (/^island-feature:util\.util\.(?:promisify|callbackify)$/.test(source)) { + return "Adapts callbacks and promises with receiver preservation, custom promisify hooks, function metadata, and Node-compatible argument and rejection handling; scheduling follows the island microtask queue."; + } if (/^island-feature:util\.(?:util\.)?parseArgs$/.test(source)) { return "Parses command-line options, positionals, defaults, and tokens with Node-compatible configuration validation."; } diff --git a/packages/compiler/test/ts7/baselines/order-parity.json b/packages/compiler/test/ts7/baselines/order-parity.json index 1466c0df7..13e38c1f3 100644 --- a/packages/compiler/test/ts7/baselines/order-parity.json +++ b/packages/compiler/test/ts7/baselines/order-parity.json @@ -13408,6 +13408,12 @@ "/tests/fixtures/npm/cases/node24-parseargs/main.ts" ], "diags": [] + }, + "/tests/fixtures/npm/cases/node24-util-adapters/main.ts": { + "order": [ + "/tests/fixtures/npm/cases/node24-util-adapters/main.ts" + ], + "diags": [] } } } diff --git a/packages/runtime/src/scr_island.c b/packages/runtime/src/scr_island.c index 87ec78776..e2ff3207a 100644 --- a/packages/runtime/src/scr_island.c +++ b/packages/runtime/src/scr_island.c @@ -4342,12 +4342,12 @@ static const char isl_modules_bootstrap[] = " if (typeof f !== 'string') failType('flags', 'of type string or number', f);\n" " const c = constants, sync = c.O_SYNC || 0;\n" " const flags = { r: c.O_RDONLY, rs: c.O_RDONLY | sync, sr: c.O_RDONLY | sync, 'r+': c.O_RDWR, 'rs+': c.O_RDWR | sync, 'sr+': c.O_RDWR | sync,\n" - " w: c.O_WRONLY | c.O_CREAT | c.O_TRUNC, wx: c.O_WRONLY | c.O_CREAT | c.O_TRUNC | c.O_EXCL, xw: c.O_WRONLY | c.O_CREAT | c.O_TRUNC | c.O_EXCL,\n" - " 'w+': c.O_RDWR | c.O_CREAT | c.O_TRUNC, 'wx+': c.O_RDWR | c.O_CREAT | c.O_TRUNC | c.O_EXCL, 'xw+': c.O_RDWR | c.O_CREAT | c.O_TRUNC | c.O_EXCL,\n" - " a: c.O_WRONLY | c.O_CREAT | c.O_APPEND, ax: c.O_WRONLY | c.O_CREAT | c.O_APPEND | c.O_EXCL, xa: c.O_WRONLY | c.O_CREAT | c.O_APPEND | c.O_EXCL,\n" - " as: c.O_WRONLY | c.O_CREAT | c.O_APPEND | sync, sa: c.O_WRONLY | c.O_CREAT | c.O_APPEND | sync,\n" - " 'a+': c.O_RDWR | c.O_CREAT | c.O_APPEND, 'ax+': c.O_RDWR | c.O_CREAT | c.O_APPEND | c.O_EXCL, 'xa+': c.O_RDWR | c.O_CREAT | c.O_APPEND | c.O_EXCL,\n" - " 'as+': c.O_RDWR | c.O_CREAT | c.O_APPEND | sync, 'sa+': c.O_RDWR | c.O_CREAT | c.O_APPEND | sync };\n" + " w: c.O_WRONLY | c.O_CREAT | c.O_TRUNC, wx: c.O_WRONLY | c.O_CREAT | c.O_TRUNC | c.O_EXCL, xw: c.O_WRONLY | c.O_CREAT | c.O_TRUNC | c.O_EXCL,\n" + " 'w+': c.O_RDWR | c.O_CREAT | c.O_TRUNC, 'wx+': c.O_RDWR | c.O_CREAT | c.O_TRUNC | c.O_EXCL, 'xw+': c.O_RDWR | c.O_CREAT | c.O_TRUNC | c.O_EXCL,\n" + " a: c.O_WRONLY | c.O_CREAT | c.O_APPEND, ax: c.O_WRONLY | c.O_CREAT | c.O_APPEND | c.O_EXCL, xa: c.O_WRONLY | c.O_CREAT | c.O_APPEND | c.O_EXCL,\n" + " as: c.O_WRONLY | c.O_CREAT | c.O_APPEND | sync, sa: c.O_WRONLY | c.O_CREAT | c.O_APPEND | sync,\n" + " 'a+': c.O_RDWR | c.O_CREAT | c.O_APPEND, 'ax+': c.O_RDWR | c.O_CREAT | c.O_APPEND | c.O_EXCL, 'xa+': c.O_RDWR | c.O_CREAT | c.O_APPEND | c.O_EXCL,\n" + " 'as+': c.O_RDWR | c.O_CREAT | c.O_APPEND | sync, 'sa+': c.O_RDWR | c.O_CREAT | c.O_APPEND | sync };\n" " if (Object.prototype.hasOwnProperty.call(flags, f)) return flags[f];\n" " const e = new TypeError(\"The argument 'flags' is invalid. Received '\" + f + \"'\"); e.code = 'ERR_INVALID_ARG_VALUE'; throw e;\n" " };\n" @@ -4377,15 +4377,15 @@ static const char isl_modules_bootstrap[] = " if (length < 0 || offset + length > bytes.length) failRange('length', '<= ' + (bytes.length - offset), length);\n" " if (position == null) position = -1;\n" " else if (typeof position === 'bigint') {\n" - " if (position < -1n || position > 9007199254740991n) { const e = new Error('fs.read positions outside the safe integer range are not supported in the scriptc island'); e.code = 'SC2020'; throw e; }\n" - " position = Number(position);\n" + " if (position < -1n || position > 9007199254740991n) { const e = new Error('fs.read positions outside the safe integer range are not supported in the scriptc island'); e.code = 'SC2020'; throw e; }\n" + " position = Number(position);\n" " } else integer(position, 'position', -1);\n" " return [bytes, offset, length, position];\n" " };\n" " const readSync = function(fd, buffer, offset, length, position) {\n" " viewOf(buffer);\n" " if (arguments.length <= 3 || typeof offset === 'object') {\n" - " ({ offset = 0, length = buffer.byteLength - offset, position = null } = optionsOf(offset));\n" + " ({ offset = 0, length = buffer.byteLength - offset, position = null } = optionsOf(offset));\n" " }\n" " const a = readWindow(buffer, offset, length, position, false);\n" " if (a[2] === 0) return 0;\n" @@ -4410,8 +4410,8 @@ static const char isl_modules_bootstrap[] = " const writeSync = (fd, buffer, offset, length, position) => {\n" " let a;\n" " if (ArrayBuffer.isView(buffer)) {\n" - " if (typeof offset === 'object') { const o = optionsOf(offset); offset = o.offset; length = o.length; position = o.position; }\n" - " a = writeWindow(buffer, offset, length, position);\n" + " if (typeof offset === 'object') { const o = optionsOf(offset); offset = o.offset; length = o.length; position = o.position; }\n" + " a = writeWindow(buffer, offset, length, position);\n" " } else { const bytes = stringBytes(buffer, length); a = [bytes, 0, bytes.length, typeof offset === 'number' ? offset : -1]; }\n" " return call('write', fdOf(fd), ...a);\n" " };\n" @@ -4445,11 +4445,11 @@ static const char isl_modules_bootstrap[] = " const read = function(fd, buffer, offset, length, position, cb) {\n" " fdOf(fd);\n" " if (arguments.length <= 4) {\n" - " let o;\n" - " if (arguments.length === 4) { o = optionsOf(offset); cb = length; }\n" - " else if (arguments.length === 3) { cb = offset; if (!ArrayBuffer.isView(buffer)) { o = optionsOf(buffer); ({ buffer = Buffer.alloc(16384) } = o); } }\n" - " else { cb = buffer; buffer = Buffer.alloc(16384); }\n" - " ({ offset = 0, length = buffer.byteLength - offset, position = null } = o || {});\n" + " let o;\n" + " if (arguments.length === 4) { o = optionsOf(offset); cb = length; }\n" + " else if (arguments.length === 3) { cb = offset; if (!ArrayBuffer.isView(buffer)) { o = optionsOf(buffer); ({ buffer = Buffer.alloc(16384) } = o); } }\n" + " else { cb = buffer; buffer = Buffer.alloc(16384); }\n" + " ({ offset = 0, length = buffer.byteLength - offset, position = null } = o || {});\n" " }\n" " viewOf(buffer); cbOf(cb);\n" " const a = readWindow(buffer, offset, length, position, true);\n" @@ -4458,12 +4458,12 @@ static const char isl_modules_bootstrap[] = " const write = function(fd, buffer, offset, length, position, cb) {\n" " fdOf(fd); let a;\n" " if (ArrayBuffer.isView(buffer)) {\n" - " cb = cb || position || length || offset; cbOf(cb);\n" - " if (typeof offset === 'object') { const o = optionsOf(offset); offset = o.offset; length = o.length; position = o.position; }\n" - " a = writeWindow(buffer, offset, length, position);\n" + " cb = cb || position || length || offset; cbOf(cb);\n" + " if (typeof offset === 'object') { const o = optionsOf(offset); offset = o.offset; length = o.length; position = o.position; }\n" + " a = writeWindow(buffer, offset, length, position);\n" " } else {\n" - " if (typeof position !== 'function') { if (typeof offset === 'function') { position = offset; offset = null; } else position = length; length = 'utf8'; }\n" - " const bytes = stringBytes(buffer, length); cb = position; cbOf(cb); a = [bytes, 0, bytes.length, typeof offset === 'number' ? offset : -1];\n" + " if (typeof position !== 'function') { if (typeof offset === 'function') { position = offset; offset = null; } else position = length; length = 'utf8'; }\n" + " const bytes = stringBytes(buffer, length); cb = position; cbOf(cb); a = [bytes, 0, bytes.length, typeof offset === 'number' ? offset : -1];\n" " }\n" " callbackIO(cb, () => call('write', fd, ...a), buffer);\n" " };\n" @@ -4480,32 +4480,32 @@ static const char isl_modules_bootstrap[] = " constructor(fd) { super(); handleState.set(this, { fd }); }\n" " get fd() { return handleState.get(this).fd; }\n" " close = () => {\n" - " const state = handleState.get(this);\n" - " if (state.fd === -1) return Promise.resolve();\n" - " const fd = state.fd; state.fd = -1;\n" - " const result = Promise.resolve().then(() => closeSync(fd));\n" - " this.emit('close'); return result;\n" - " };\n" + " const state = handleState.get(this);\n" + " if (state.fd === -1) return Promise.resolve();\n" + " const fd = state.fd; state.fd = -1;\n" + " const result = Promise.resolve().then(() => closeSync(fd));\n" + " this.emit('close'); return result;\n" + " };\n" " async [Symbol.asyncDispose || Symbol.for('nodejs.asyncDispose')]() { await this.close(); }\n" " async _call(op, action) {\n" - " if (this.fd === -1) { const e = new Error('file closed'); e.code = 'EBADF'; e.syscall = op; throw e; }\n" - " return action(this.fd);\n" + " if (this.fd === -1) { const e = new Error('file closed'); e.code = 'EBADF'; e.syscall = op; throw e; }\n" + " return action(this.fd);\n" " }\n" " read(buffer, offset, length, position) {\n" - " return this._call('read', (fd) => {\n" - " if (!ArrayBuffer.isView(buffer)) { ({ buffer = Buffer.alloc(16384), offset = 0, length = buffer.byteLength - offset, position = null } = optionsOf(buffer)); }\n" - " if (offset !== null && typeof offset === 'object') { ({ offset = 0, length = buffer.byteLength - offset, position = null } = optionsOf(offset)); }\n" - " if (offset == null) offset = 0;\n" - " if (length == null) length = buffer.byteLength - offset;\n" - " const a = readWindow(buffer, offset, length, position, true, false);\n" - " return { __proto__: null, bytesRead: a[2] === 0 ? 0 : call('read', fd, ...a), buffer };\n" - " });\n" + " return this._call('read', (fd) => {\n" + " if (!ArrayBuffer.isView(buffer)) { ({ buffer = Buffer.alloc(16384), offset = 0, length = buffer.byteLength - offset, position = null } = optionsOf(buffer)); }\n" + " if (offset !== null && typeof offset === 'object') { ({ offset = 0, length = buffer.byteLength - offset, position = null } = optionsOf(offset)); }\n" + " if (offset == null) offset = 0;\n" + " if (length == null) length = buffer.byteLength - offset;\n" + " const a = readWindow(buffer, offset, length, position, true, false);\n" + " return { __proto__: null, bytesRead: a[2] === 0 ? 0 : call('read', fd, ...a), buffer };\n" + " });\n" " }\n" " write(buffer, offset, length, position) {\n" - " return this._call('write', (fd) => {\n" - " const bytesWritten = buffer && buffer.byteLength === 0 ? 0 : writeSync(fd, buffer, offset, length, position);\n" - " return { __proto__: null, bytesWritten, buffer };\n" - " });\n" + " return this._call('write', (fd) => {\n" + " const bytesWritten = buffer && buffer.byteLength === 0 ? 0 : writeSync(fd, buffer, offset, length, position);\n" + " return { __proto__: null, bytesWritten, buffer };\n" + " });\n" " }\n" " readv(buffers, position) { return this._call('readv', (fd) => ({ __proto__: null, bytesRead: readvSync(fd, buffers, position), buffers })); }\n" " writev(buffers, position) { return this._call('writev', (fd) => ({ __proto__: null, bytesWritten: writevSync(fd, buffers, position), buffers })); }\n" @@ -4527,24 +4527,24 @@ static const char isl_modules_bootstrap[] = " const callbackify = (syncFn) => (...args) => {\n" " const cb = args.pop();\n" " if (typeof cb !== \"function\") {\n" - " const e = new TypeError('The \"cb\" argument must be of type function. Received ' + (cb === undefined ? \"undefined\" : \"type \" + typeof cb));\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" + " const e = new TypeError('The \"cb\" argument must be of type function. Received ' + (cb === undefined ? \"undefined\" : \"type \" + typeof cb));\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" " }\n" " let result;\n" " try {\n" - " result = syncFn(...args);\n" + " result = syncFn(...args);\n" " } catch (err) {\n" - " env.nextTick(() => cb(err));\n" - " return;\n" + " env.nextTick(() => cb(err));\n" + " return;\n" " }\n" " env.nextTick(() => cb(null, result));\n" " };\n" " const promisify = (syncFn) => (...args) => new Promise((resolve, reject) => {\n" " try {\n" - " resolve(syncFn(...args));\n" + " resolve(syncFn(...args));\n" " } catch (err) {\n" - " reject(err);\n" + " reject(err);\n" " }\n" " });\n" " const fs = {\n" @@ -4556,7 +4556,7 @@ static const char isl_modules_bootstrap[] = " writeFile: callbackify(writeFileSync),\n" " appendFile: callbackify(appendFileSync),\n" " exists: (p, cb) => {\n" - " env.nextTick(() => cb(existsSync(p)));\n" + " env.nextTick(() => cb(existsSync(p)));\n" " },\n" " realpath: Object.assign(callbackify(realpathSync), { native: callbackify(realpathSync) }),\n" " mkdir: callbackify(mkdirSync),\n" @@ -4573,51 +4573,51 @@ static const char isl_modules_bootstrap[] = " rename: callbackify(renameSync),\n" " readlink: callbackify(readlinkSync),\n" " createReadStream: (p, options) => {\n" - " const enc = typeof options === \"string\" ? options : options && options.encoding;\n" - " const r = new env.Readable({\n" - " read() {\n" - " if (this._started) return;\n" - " this._started = true;\n" - " try {\n" - " const buf = readFileSync(p);\n" - " for (let i = 0; i < buf.length; i += 65536) this.push(buf.subarray(i, Math.min(i + 65536, buf.length)));\n" - " this.push(null);\n" - " } catch (err) {\n" - " this.destroy(err);\n" - " }\n" - " },\n" - " });\n" - " if (enc) r.setEncoding(enc);\n" - " r.path = typeof p === \"string\" ? p : pathOf(p);\n" - " return r;\n" + " const enc = typeof options === \"string\" ? options : options && options.encoding;\n" + " const r = new env.Readable({\n" + " read() {\n" + " if (this._started) return;\n" + " this._started = true;\n" + " try {\n" + " const buf = readFileSync(p);\n" + " for (let i = 0; i < buf.length; i += 65536) this.push(buf.subarray(i, Math.min(i + 65536, buf.length)));\n" + " this.push(null);\n" + " } catch (err) {\n" + " this.destroy(err);\n" + " }\n" + " },\n" + " });\n" + " if (enc) r.setEncoding(enc);\n" + " r.path = typeof p === \"string\" ? p : pathOf(p);\n" + " return r;\n" " },\n" " createWriteStream: (p, options) => {\n" - " const chunks = [];\n" - " const w = new env.Writable({\n" - " write(chunk, e, cb) {\n" - " chunks.push(chunk);\n" - " cb();\n" - " },\n" - " final(cb) {\n" - " try {\n" - " const flags = options && options.flags;\n" - " const data = Buffer.concat(chunks.map((c) => (typeof c === \"string\" ? Buffer.from(c) : c)));\n" - " if (flags === \"a\") appendFileSync(p, data);\n" - " else writeFileSync(p, data);\n" - " cb();\n" - " } catch (err) {\n" - " cb(err);\n" - " }\n" - " },\n" - " });\n" - " w.path = typeof p === \"string\" ? p : pathOf(p);\n" - " return w;\n" + " const chunks = [];\n" + " const w = new env.Writable({\n" + " write(chunk, e, cb) {\n" + " chunks.push(chunk);\n" + " cb();\n" + " },\n" + " final(cb) {\n" + " try {\n" + " const flags = options && options.flags;\n" + " const data = Buffer.concat(chunks.map((c) => (typeof c === \"string\" ? Buffer.from(c) : c)));\n" + " if (flags === \"a\") appendFileSync(p, data);\n" + " else writeFileSync(p, data);\n" + " cb();\n" + " } catch (err) {\n" + " cb(err);\n" + " }\n" + " },\n" + " });\n" + " w.path = typeof p === \"string\" ? p : pathOf(p);\n" + " return w;\n" " },\n" " watch: () => {\n" - " throw new Error(\"fs.watch is not available in the scriptc island\");\n" + " throw new Error(\"fs.watch is not available in the scriptc island\");\n" " },\n" " watchFile: () => {\n" - " throw new Error(\"fs.watchFile is not available in the scriptc island\");\n" + " throw new Error(\"fs.watchFile is not available in the scriptc island\");\n" " },\n" " open, read, write, readv: vectorCallback(false), writev: vectorCallback(true),\n" " close: controlCallback('close', () => {}),\n" @@ -4663,43 +4663,43 @@ static const char isl_modules_bootstrap[] = " builtins.os = memo(() => {\n" " const plat = host.platform();\n" " const os = {\n" - " EOL: plat === 'win32' ? '\\r\\n' : '\\n',\n" - " platform: () => plat,\n" - " arch: () => host.arch(),\n" - " hostname: () => host.hostname(),\n" - " homedir: () => host.homedir(),\n" - " tmpdir: () => host.tmpdir(),\n" - " type: () => (plat === 'darwin' ? 'Darwin' : plat === 'win32' ? 'Windows_NT' : 'Linux'),\n" - " endianness: () => 'LE',\n" - " userInfo: () => {\n" - " const ids = host.ids();\n" - " const env = builtins.process().env;\n" - " return {\n" - " uid: ids[0],\n" - " gid: ids[1],\n" - " username: env.USER || env.USERNAME || env.LOGNAME || '',\n" - " homedir: host.homedir(),\n" - " shell: plat === 'win32' ? null : env.SHELL || null,\n" - " };\n" - " },\n" + " EOL: plat === 'win32' ? '\\r\\n' : '\\n',\n" + " platform: () => plat,\n" + " arch: () => host.arch(),\n" + " hostname: () => host.hostname(),\n" + " homedir: () => host.homedir(),\n" + " tmpdir: () => host.tmpdir(),\n" + " type: () => (plat === 'darwin' ? 'Darwin' : plat === 'win32' ? 'Windows_NT' : 'Linux'),\n" + " endianness: () => 'LE',\n" + " userInfo: () => {\n" + " const ids = host.ids();\n" + " const env = builtins.process().env;\n" + " return {\n" + " uid: ids[0],\n" + " gid: ids[1],\n" + " username: env.USER || env.USERNAME || env.LOGNAME || '',\n" + " homedir: host.homedir(),\n" + " shell: plat === 'win32' ? null : env.SHELL || null,\n" + " };\n" + " },\n" /* The inert half: values Node reads from the kernel that the island * does not carry — empty-but-typed answers, never throws. */ - " release: () => '',\n" - " version: () => '',\n" - " machine: () => (host.arch() === 'arm64' ? 'arm64' : host.arch() === 'x64' ? 'x86_64' : host.arch()),\n" - " cpus: () => [],\n" - " availableParallelism: () => 1,\n" - " totalmem: () => 0,\n" - " freemem: () => 0,\n" - " loadavg: () => [0, 0, 0],\n" - " uptime: () => 0,\n" - " networkInterfaces: () => ({}),\n" - " constants: {\n" - " signals: host.signals(),\n" - " errno: {},\n" - " priority: { PRIORITY_LOW: 19, PRIORITY_BELOW_NORMAL: 10, PRIORITY_NORMAL: 0, PRIORITY_ABOVE_NORMAL: -7, PRIORITY_HIGH: -14, PRIORITY_HIGHEST: -20 },\n" - " },\n" - " };\n" + " release: () => '',\n" + " version: () => '',\n" + " machine: () => (host.arch() === 'arm64' ? 'arm64' : host.arch() === 'x64' ? 'x86_64' : host.arch()),\n" + " cpus: () => [],\n" + " availableParallelism: () => 1,\n" + " totalmem: () => 0,\n" + " freemem: () => 0,\n" + " loadavg: () => [0, 0, 0],\n" + " uptime: () => 0,\n" + " networkInterfaces: () => ({}),\n" + " constants: {\n" + " signals: host.signals(),\n" + " errno: {},\n" + " priority: { PRIORITY_LOW: 19, PRIORITY_BELOW_NORMAL: 10, PRIORITY_NORMAL: 0, PRIORITY_ABOVE_NORMAL: -7, PRIORITY_HIGH: -14, PRIORITY_HIGHEST: -20 },\n" + " },\n" + " };\n" " os.default = os;\n" " return os;\n" " });\n" @@ -4710,24 +4710,24 @@ static const char isl_modules_bootstrap[] = " builtins.tty = memo(() => {\n" " const isatty = (fd) => Number.isInteger(fd) && fd >= 0 && host.isatty(fd);\n" " class ReadStream {\n" - " constructor(fd) { this.fd = fd; this.isTTY = isatty(fd); this.isRaw = false; }\n" - " setRawMode(mode) { this.isRaw = !!mode; return this; }\n" + " constructor(fd) { this.fd = fd; this.isTTY = isatty(fd); this.isRaw = false; }\n" + " setRawMode(mode) { this.isRaw = !!mode; return this; }\n" " }\n" " class WriteStream {\n" - " constructor(fd) {\n" - " this.fd = fd;\n" - " this.isTTY = isatty(fd);\n" - " const c = host.columns(fd);\n" - " if (c > 0) this.columns = c;\n" - " }\n" - " write(s) { return host.write(this.fd, String(s)); }\n" - " getColorDepth() { return this.isTTY ? 8 : 1; }\n" - " hasColors(n) { return this.isTTY && (n === undefined || n <= 256); }\n" - " getWindowSize() { return [this.columns || 0, 0]; }\n" - " clearLine() { return true; }\n" - " clearScreenDown() { return true; }\n" - " cursorTo() { return true; }\n" - " moveCursor() { return true; }\n" + " constructor(fd) {\n" + " this.fd = fd;\n" + " this.isTTY = isatty(fd);\n" + " const c = host.columns(fd);\n" + " if (c > 0) this.columns = c;\n" + " }\n" + " write(s) { return host.write(this.fd, String(s)); }\n" + " getColorDepth() { return this.isTTY ? 8 : 1; }\n" + " hasColors(n) { return this.isTTY && (n === undefined || n <= 256); }\n" + " getWindowSize() { return [this.columns || 0, 0]; }\n" + " clearLine() { return true; }\n" + " clearScreenDown() { return true; }\n" + " cursorTo() { return true; }\n" + " moveCursor() { return true; }\n" " }\n" " const tty = { isatty, ReadStream, WriteStream };\n" " tty.default = tty;\n" @@ -4742,37 +4742,37 @@ static const char isl_modules_bootstrap[] = * subscribed. */ " const channels = Object.create(null);\n" " class Channel {\n" - " constructor(name) { this.name = name; this._subs = []; }\n" - " get hasSubscribers() { return this._subs.length > 0; }\n" - " subscribe(fn) { this._subs.push(fn); }\n" - " unsubscribe(fn) {\n" - " const i = this._subs.indexOf(fn);\n" - " if (i < 0) return false;\n" - " this._subs.splice(i, 1);\n" - " return true;\n" - " }\n" - " publish(msg) { for (const f of this._subs.slice()) f(msg, this.name); }\n" + " constructor(name) { this.name = name; this._subs = []; }\n" + " get hasSubscribers() { return this._subs.length > 0; }\n" + " subscribe(fn) { this._subs.push(fn); }\n" + " unsubscribe(fn) {\n" + " const i = this._subs.indexOf(fn);\n" + " if (i < 0) return false;\n" + " this._subs.splice(i, 1);\n" + " return true;\n" + " }\n" + " publish(msg) { for (const f of this._subs.slice()) f(msg, this.name); }\n" " }\n" " const channel = (name) => channels[name] || (channels[name] = new Channel(name));\n" " const tracingChannel = (name) => ({\n" - " get hasSubscribers() {\n" - " if (typeof name !== 'string') return false;\n" - " for (const s of ['start', 'end', 'asyncStart', 'asyncEnd', 'error']) {\n" - " if (channel('tracing:' + name + ':' + s).hasSubscribers) return true;\n" - " }\n" - " return false;\n" - " },\n" - " traceSync(fn, ctx, thisArg, ...args) { return fn.apply(thisArg, args); },\n" - " tracePromise(fn, ctx, thisArg, ...args) { return fn.apply(thisArg, args); },\n" - " traceCallback(fn, position, ctx, thisArg, ...args) { return fn.apply(thisArg, args); },\n" + " get hasSubscribers() {\n" + " if (typeof name !== 'string') return false;\n" + " for (const s of ['start', 'end', 'asyncStart', 'asyncEnd', 'error']) {\n" + " if (channel('tracing:' + name + ':' + s).hasSubscribers) return true;\n" + " }\n" + " return false;\n" + " },\n" + " traceSync(fn, ctx, thisArg, ...args) { return fn.apply(thisArg, args); },\n" + " tracePromise(fn, ctx, thisArg, ...args) { return fn.apply(thisArg, args); },\n" + " traceCallback(fn, position, ctx, thisArg, ...args) { return fn.apply(thisArg, args); },\n" " });\n" " const dc = {\n" - " channel,\n" - " subscribe: (name, fn) => { channel(name).subscribe(fn); },\n" - " unsubscribe: (name, fn) => channel(name).unsubscribe(fn),\n" - " hasSubscribers: (name) => channel(name).hasSubscribers,\n" - " tracingChannel,\n" - " };\n" + " channel,\n" + " subscribe: (name, fn) => { channel(name).subscribe(fn); },\n" + " unsubscribe: (name, fn) => channel(name).unsubscribe(fn),\n" + " hasSubscribers: (name) => channel(name).hasSubscribers,\n" + " tracingChannel,\n" + " };\n" " dc.default = dc;\n" " return dc;\n" " });\n" @@ -4785,30 +4785,30 @@ static const char isl_modules_bootstrap[] = * (createRequire(import.meta.url) then require("node:fs")) works * end-to-end. */ " const createRequire = (base) => {\n" - " let key = String(base);\n" - " if (key.startsWith('file://')) key = decodeURIComponent(key.slice(7));\n" + " let key = String(base);\n" + " if (key.startsWith('file://')) key = decodeURIComponent(key.slice(7));\n" /* The base file is the created require's parent, like Node: modules * it loads report it in their require stacks. */ - " return decorateRequire((spec) => requireKey(spec.startsWith('node:') ? spec : resolveFrom(key, spec), key), key);\n" - " };\n" + " return decorateRequire((spec) => requireKey(spec.startsWith('node:') ? spec : resolveFrom(key, spec), key), key);\n" + " };\n" /* builtinModules/isBuiltin answer Node's QUESTION ("is this name a * Node builtin?") with Node's full list — resolution of unshimmed * ones still fails lazily at the call, the island's documented * shape. */ " const isBuiltin = (name) => {\n" - " const n = String(name);\n" - " return n.startsWith('node:') ? builtinModules.includes(n.slice(5)) : builtinModules.includes(n);\n" - " };\n" + " const n = String(name);\n" + " return n.startsWith('node:') ? builtinModules.includes(n.slice(5)) : builtinModules.includes(n);\n" + " };\n" " const m = {\n" - " createRequire,\n" - " builtinModules,\n" - " isBuiltin,\n" - " syncBuiltinESMExports: () => {},\n" - " register: () => {\n" - " throw new Error('module.register is not available in the scriptc island');\n" - " },\n" - " findSourceMap: () => undefined,\n" - " };\n" + " createRequire,\n" + " builtinModules,\n" + " isBuiltin,\n" + " syncBuiltinESMExports: () => {},\n" + " register: () => {\n" + " throw new Error('module.register is not available in the scriptc island');\n" + " },\n" + " findSourceMap: () => undefined,\n" + " };\n" " m.default = m;\n" " return m;\n" " });\n" @@ -4818,78 +4818,78 @@ static const char isl_modules_bootstrap[] = * exact rules), and the legacy parse/format/resolve trio over the * WHATWG parser. */ " const fileURLToPath = (u) => {\n" - " const s = typeof u === 'object' && u !== null && 'href' in u ? String(u.href) : String(u);\n" - " return host.urlToPath(s);\n" - " };\n" + " const s = typeof u === 'object' && u !== null && 'href' in u ? String(u.href) : String(u);\n" + " return host.urlToPath(s);\n" + " };\n" " const pathToFileURL = (p) => new globalThis.URL(host.urlFromPath(String(p)));\n" " const parse = (input, parseQuery) => {\n" - " const out = { protocol: null, slashes: null, auth: null, host: null, port: null,\n" - " hostname: null, hash: null, search: null, query: null, pathname: null, path: null, href: String(input) };\n" - " let u = null;\n" - " try { u = new globalThis.URL(String(input)); } catch (e) { u = null; }\n" - " if (u !== null) {\n" - " out.protocol = u.protocol || null;\n" - " out.slashes = u.href.startsWith(u.protocol + '//') ? true : null;\n" - " out.auth = u.username !== '' ? (u.password !== '' ? u.username + ':' + u.password : u.username) : null;\n" - " out.host = u.host || null;\n" - " out.port = u.port !== '' ? u.port : null;\n" - " out.hostname = u.hostname || null;\n" - " out.hash = u.hash !== '' ? u.hash : null;\n" - " out.search = u.search !== '' ? u.search : null;\n" - " out.query = u.search !== '' ? u.search.slice(1) : null;\n" - " out.pathname = u.pathname || null;\n" - " out.path = (u.pathname || '') + (u.search || '') || null;\n" - " out.href = u.href;\n" - " } else {\n" - " let rest = String(input);\n" - " const hashAt = rest.indexOf('#');\n" - " if (hashAt >= 0) { out.hash = rest.slice(hashAt); rest = rest.slice(0, hashAt); }\n" - " const qAt = rest.indexOf('?');\n" - " if (qAt >= 0) { out.search = rest.slice(qAt); out.query = rest.slice(qAt + 1); rest = rest.slice(0, qAt); }\n" - " out.pathname = rest || null;\n" - " out.path = (rest || '') + (out.search || '') || null;\n" + " const out = { protocol: null, slashes: null, auth: null, host: null, port: null,\n" + " hostname: null, hash: null, search: null, query: null, pathname: null, path: null, href: String(input) };\n" + " let u = null;\n" + " try { u = new globalThis.URL(String(input)); } catch (e) { u = null; }\n" + " if (u !== null) {\n" + " out.protocol = u.protocol || null;\n" + " out.slashes = u.href.startsWith(u.protocol + '//') ? true : null;\n" + " out.auth = u.username !== '' ? (u.password !== '' ? u.username + ':' + u.password : u.username) : null;\n" + " out.host = u.host || null;\n" + " out.port = u.port !== '' ? u.port : null;\n" + " out.hostname = u.hostname || null;\n" + " out.hash = u.hash !== '' ? u.hash : null;\n" + " out.search = u.search !== '' ? u.search : null;\n" + " out.query = u.search !== '' ? u.search.slice(1) : null;\n" + " out.pathname = u.pathname || null;\n" + " out.path = (u.pathname || '') + (u.search || '') || null;\n" + " out.href = u.href;\n" + " } else {\n" + " let rest = String(input);\n" + " const hashAt = rest.indexOf('#');\n" + " if (hashAt >= 0) { out.hash = rest.slice(hashAt); rest = rest.slice(0, hashAt); }\n" + " const qAt = rest.indexOf('?');\n" + " if (qAt >= 0) { out.search = rest.slice(qAt); out.query = rest.slice(qAt + 1); rest = rest.slice(0, qAt); }\n" + " out.pathname = rest || null;\n" + " out.path = (rest || '') + (out.search || '') || null;\n" + " }\n" + " if (parseQuery) {\n" + " const q = {};\n" + " for (const [k, v] of new globalThis.URLSearchParams(out.query || '')) {\n" + " if (k in q) { if (Array.isArray(q[k])) q[k].push(v); else q[k] = [q[k], v]; }\n" + " else q[k] = v;\n" " }\n" - " if (parseQuery) {\n" - " const q = {};\n" - " for (const [k, v] of new globalThis.URLSearchParams(out.query || '')) {\n" - " if (k in q) { if (Array.isArray(q[k])) q[k].push(v); else q[k] = [q[k], v]; }\n" - " else q[k] = v;\n" - " }\n" - " out.query = q;\n" - " }\n" - " return out;\n" - " };\n" + " out.query = q;\n" + " }\n" + " return out;\n" + " };\n" " const format = (obj) => {\n" - " if (typeof obj === 'string') return obj;\n" - " if (obj !== null && typeof obj === 'object' && typeof obj.href === 'string' && obj instanceof globalThis.URL) return obj.href;\n" - " const protocol = obj.protocol ? (obj.protocol.endsWith(':') ? obj.protocol : obj.protocol + ':') : '';\n" - " const host = obj.host !== undefined && obj.host !== null ? obj.host\n" - " : obj.hostname ? obj.hostname + (obj.port ? ':' + obj.port : '') : '';\n" - " const auth = obj.auth ? obj.auth + '@' : '';\n" - " const slashes = obj.slashes || host !== '' ? '//' : '';\n" - " let pathname = obj.pathname || '';\n" - " if (pathname !== '' && !pathname.startsWith('/') && host !== '') pathname = '/' + pathname;\n" - " let search = obj.search || (obj.query && typeof obj.query === 'object' ? '?' + new globalThis.URLSearchParams(obj.query).toString() : obj.query ? '?' + obj.query : '');\n" - " if (search !== '' && !search.startsWith('?')) search = '?' + search;\n" - " let hash = obj.hash || '';\n" - " if (hash !== '' && !hash.startsWith('#')) hash = '#' + hash;\n" - " return protocol + slashes + auth + host + pathname + search + hash;\n" - " };\n" + " if (typeof obj === 'string') return obj;\n" + " if (obj !== null && typeof obj === 'object' && typeof obj.href === 'string' && obj instanceof globalThis.URL) return obj.href;\n" + " const protocol = obj.protocol ? (obj.protocol.endsWith(':') ? obj.protocol : obj.protocol + ':') : '';\n" + " const host = obj.host !== undefined && obj.host !== null ? obj.host\n" + " : obj.hostname ? obj.hostname + (obj.port ? ':' + obj.port : '') : '';\n" + " const auth = obj.auth ? obj.auth + '@' : '';\n" + " const slashes = obj.slashes || host !== '' ? '//' : '';\n" + " let pathname = obj.pathname || '';\n" + " if (pathname !== '' && !pathname.startsWith('/') && host !== '') pathname = '/' + pathname;\n" + " let search = obj.search || (obj.query && typeof obj.query === 'object' ? '?' + new globalThis.URLSearchParams(obj.query).toString() : obj.query ? '?' + obj.query : '');\n" + " if (search !== '' && !search.startsWith('?')) search = '?' + search;\n" + " let hash = obj.hash || '';\n" + " if (hash !== '' && !hash.startsWith('#')) hash = '#' + hash;\n" + " return protocol + slashes + auth + host + pathname + search + hash;\n" + " };\n" " const resolve = (from, to) => {\n" - " const u = new globalThis.URL(String(to), new globalThis.URL(String(from), 'resolve://'));\n" - " if (u.protocol === 'resolve:') return u.pathname + u.search + u.hash;\n" - " return u.href;\n" - " };\n" + " const u = new globalThis.URL(String(to), new globalThis.URL(String(from), 'resolve://'));\n" + " if (u.protocol === 'resolve:') return u.pathname + u.search + u.hash;\n" + " return u.href;\n" + " };\n" " const u = {\n" - " URL: globalThis.URL,\n" - " URLSearchParams: globalThis.URLSearchParams,\n" - " fileURLToPath, pathToFileURL, parse, format, resolve,\n" + " URL: globalThis.URL,\n" + " URLSearchParams: globalThis.URLSearchParams,\n" + " fileURLToPath, pathToFileURL, parse, format, resolve,\n" /* IDNA is not carried: ASCII hostnames pass through lowercased * (documented divergence for internationalized domains). */ - " domainToASCII: (d) => String(d).toLowerCase(),\n" - " domainToUnicode: (d) => String(d).toLowerCase(),\n" - " urlToHttpOptions: (u2) => ({ protocol: u2.protocol, hostname: u2.hostname, hash: u2.hash, search: u2.search, pathname: u2.pathname, path: u2.pathname + (u2.search || ''), href: u2.href, port: u2.port !== '' ? Number(u2.port) : undefined, host: u2.host }),\n" - " };\n" + " domainToASCII: (d) => String(d).toLowerCase(),\n" + " domainToUnicode: (d) => String(d).toLowerCase(),\n" + " urlToHttpOptions: (u2) => ({ protocol: u2.protocol, hostname: u2.hostname, hash: u2.hash, search: u2.search, pathname: u2.pathname, path: u2.pathname + (u2.search || ''), href: u2.href, port: u2.port !== '' ? Number(u2.port) : undefined, host: u2.host }),\n" + " };\n" " u.default = u;\n" " return u;\n" " });\n" @@ -4960,9 +4960,9 @@ static const char isl_modules_bootstrap[] = " const out = new Uint8Array(n);\n" " let i = 0;\n" " for (; i < n; i++) {\n" - " const b = parseInt(s.substr(i * 2, 2), 16);\n" - " if (Number.isNaN(b) || !/^[0-9a-fA-F]{2}$/.test(s.substr(i * 2, 2))) break;\n" - " out[i] = b;\n" + " const b = parseInt(s.substr(i * 2, 2), 16);\n" + " if (Number.isNaN(b) || !/^[0-9a-fA-F]{2}$/.test(s.substr(i * 2, 2))) break;\n" + " out[i] = b;\n" " }\n" " return i === n ? out : out.subarray(0, i);\n" " };\n" @@ -4970,9 +4970,9 @@ static const char isl_modules_bootstrap[] = " const str = String(s);\n" " const vals = [];\n" " for (let i = 0; i < str.length; i++) {\n" - " if (str[i] === \"=\") break;\n" - " const v = b64Val[str.charCodeAt(i)];\n" - " if (v >= 0) vals.push(v);\n" + " if (str[i] === \"=\") break;\n" + " const v = b64Val[str.charCodeAt(i)];\n" + " if (v >= 0) vals.push(v);\n" " }\n" " const n = Math.floor((vals.length * 6) / 8);\n" " const out = new Uint8Array(n);\n" @@ -4980,45 +4980,45 @@ static const char isl_modules_bootstrap[] = " let bits = 0;\n" " let o = 0;\n" " for (let i = 0; i < vals.length; i++) {\n" - " buf = (buf << 6) | vals[i];\n" - " bits += 6;\n" - " if (bits >= 8) {\n" - " bits -= 8;\n" - " out[o++] = (buf >> bits) & 0xff;\n" - " }\n" + " buf = (buf << 6) | vals[i];\n" + " bits += 6;\n" + " if (bits >= 8) {\n" + " bits -= 8;\n" + " out[o++] = (buf >> bits) & 0xff;\n" + " }\n" " }\n" " return out;\n" " };\n" " const encUtf16 = (s) => {\n" " const out = new Uint8Array(s.length * 2);\n" " for (let i = 0; i < s.length; i++) {\n" - " const c = s.charCodeAt(i);\n" - " out[i * 2] = c & 0xff;\n" - " out[i * 2 + 1] = c >>> 8;\n" + " const c = s.charCodeAt(i);\n" + " out[i * 2] = c & 0xff;\n" + " out[i * 2 + 1] = c >>> 8;\n" " }\n" " return out;\n" " };\n" " const encodeStr = (s, enc) => {\n" " switch (enc) {\n" - " case \"utf8\": return encUtf8(s);\n" - " case \"latin1\": case \"ascii\": return encLatin1(s);\n" - " case \"hex\": return encHex(s);\n" - " case \"base64\": case \"base64url\": return encB64(s);\n" - " case \"utf16le\": return encUtf16(s);\n" + " case \"utf8\": return encUtf8(s);\n" + " case \"latin1\": case \"ascii\": return encLatin1(s);\n" + " case \"hex\": return encHex(s);\n" + " case \"base64\": case \"base64url\": return encB64(s);\n" + " case \"utf16le\": return encUtf16(s);\n" " }\n" " };\n" " const hexChars = \"0123456789abcdef\";\n" " const decHex = (u8, start, end) => {\n" " let out = \"\";\n" " for (let i = start; i < end; i++) {\n" - " out += hexChars[u8[i] >> 4] + hexChars[u8[i] & 0x0f];\n" + " out += hexChars[u8[i] >> 4] + hexChars[u8[i] & 0x0f];\n" " }\n" " return out;\n" " };\n" " const decLatin1 = (u8, start, end) => {\n" " let out = \"\";\n" " for (let i = start; i < end; i += 4096) {\n" - " out += String.fromCharCode.apply(null, u8.subarray(i, Math.min(i + 4096, end)));\n" + " out += String.fromCharCode.apply(null, u8.subarray(i, Math.min(i + 4096, end)));\n" " }\n" " return out;\n" " };\n" @@ -5031,18 +5031,18 @@ static const char isl_modules_bootstrap[] = " const alpha = url ? B64U : B64;\n" " let out = \"\";\n" " for (let i = start; i < end; i += 3) {\n" - " const b0 = u8[i];\n" - " const has1 = i + 1 < end;\n" - " const has2 = i + 2 < end;\n" - " const b1 = has1 ? u8[i + 1] : 0;\n" - " const b2 = has2 ? u8[i + 2] : 0;\n" - " const v = (b0 << 16) | (b1 << 8) | b2;\n" - " out += alpha[(v >> 18) & 63];\n" - " out += alpha[(v >> 12) & 63];\n" - " if (has1) out += alpha[(v >> 6) & 63];\n" - " else if (!url) out += \"=\";\n" - " if (has2) out += alpha[v & 63];\n" - " else if (!url) out += \"=\";\n" + " const b0 = u8[i];\n" + " const has1 = i + 1 < end;\n" + " const has2 = i + 2 < end;\n" + " const b1 = has1 ? u8[i + 1] : 0;\n" + " const b2 = has2 ? u8[i + 2] : 0;\n" + " const v = (b0 << 16) | (b1 << 8) | b2;\n" + " out += alpha[(v >> 18) & 63];\n" + " out += alpha[(v >> 12) & 63];\n" + " if (has1) out += alpha[(v >> 6) & 63];\n" + " else if (!url) out += \"=\";\n" + " if (has2) out += alpha[v & 63];\n" + " else if (!url) out += \"=\";\n" " }\n" " return out;\n" " };\n" @@ -5050,7 +5050,7 @@ static const char isl_modules_bootstrap[] = " let out = \"\";\n" " const n = start + ((end - start) & ~1);\n" " for (let i = start; i < n; i += 2) {\n" - " out += String.fromCharCode(u8[i] | (u8[i + 1] << 8));\n" + " out += String.fromCharCode(u8[i] | (u8[i + 1] << 8));\n" " }\n" " return out;\n" " };\n" @@ -5059,293 +5059,293 @@ static const char isl_modules_bootstrap[] = " if (end > u8.length) end = u8.length;\n" " if (end <= start) return \"\";\n" " switch (enc) {\n" - " case \"utf8\": return utf8Dec.decode(u8.subarray(start, end));\n" - " case \"latin1\": return decLatin1(u8, start, end);\n" - " case \"ascii\": return decAscii(u8, start, end);\n" - " case \"hex\": return decHex(u8, start, end);\n" - " case \"base64\": return decB64(u8, start, end, false);\n" - " case \"base64url\": return decB64(u8, start, end, true);\n" - " case \"utf16le\": return decUtf16(u8, start, end);\n" + " case \"utf8\": return utf8Dec.decode(u8.subarray(start, end));\n" + " case \"latin1\": return decLatin1(u8, start, end);\n" + " case \"ascii\": return decAscii(u8, start, end);\n" + " case \"hex\": return decHex(u8, start, end);\n" + " case \"base64\": return decB64(u8, start, end, false);\n" + " case \"base64url\": return decB64(u8, start, end, true);\n" + " case \"utf16le\": return decUtf16(u8, start, end);\n" " }\n" " };\n" " const checkOffset = (buf, offset, ext) => {\n" " if (!Number.isInteger(offset)) throw outOfRange(\"offset\", \"an integer\", offset);\n" " if (offset < 0 || offset + ext > buf.length) {\n" - " if (buf.length - ext < 0) {\n" - " const e = new RangeError(\"Attempt to access memory outside buffer bounds\");\n" - " e.code = \"ERR_BUFFER_OUT_OF_BOUNDS\";\n" - " throw e;\n" - " }\n" - " throw outOfRange(\"offset\", \">= 0 and <= \" + (buf.length - ext), offset);\n" + " if (buf.length - ext < 0) {\n" + " const e = new RangeError(\"Attempt to access memory outside buffer bounds\");\n" + " e.code = \"ERR_BUFFER_OUT_OF_BOUNDS\";\n" + " throw e;\n" + " }\n" + " throw outOfRange(\"offset\", \">= 0 and <= \" + (buf.length - ext), offset);\n" " }\n" " };\n" " const checkValue = (value, min, max, name) => {\n" " if (value < min || value > max) {\n" - " throw outOfRange(name, \">= \" + min + \" and <= \" + max, value);\n" + " throw outOfRange(name, \">= \" + min + \" and <= \" + max, value);\n" " }\n" " };\n" " class Buffer extends Uint8Array {\n" " static alloc(size, fill, encoding) {\n" - " if (typeof size !== \"number\" || Number.isNaN(size)) throw invalidArg(\"size\", \"of type number\", size);\n" - " if (size < 0 || size > K_MAX_LENGTH) throw outOfRange(\"size\", \">= 0 && <= \" + K_MAX_LENGTH, size);\n" - " const b = new Buffer(size);\n" - " if (fill !== undefined && fill !== 0) b.fill(fill, 0, b.length, encoding);\n" - " return b;\n" + " if (typeof size !== \"number\" || Number.isNaN(size)) throw invalidArg(\"size\", \"of type number\", size);\n" + " if (size < 0 || size > K_MAX_LENGTH) throw outOfRange(\"size\", \">= 0 && <= \" + K_MAX_LENGTH, size);\n" + " const b = new Buffer(size);\n" + " if (fill !== undefined && fill !== 0) b.fill(fill, 0, b.length, encoding);\n" + " return b;\n" " }\n" " static allocUnsafe(size) {\n" - " return Buffer.alloc(size);\n" + " return Buffer.alloc(size);\n" " }\n" " static allocUnsafeSlow(size) {\n" - " return Buffer.alloc(size);\n" + " return Buffer.alloc(size);\n" " }\n" " static from(value, encodingOrOffset, length) {\n" - " if (typeof value === \"string\") {\n" - " const enc = normEnc(encodingOrOffset);\n" - " if (enc === null) throw badEnc(encodingOrOffset);\n" - " const u8 = encodeStr(value, enc);\n" - " return new Buffer(u8.buffer, u8.byteOffset, u8.length);\n" + " if (typeof value === \"string\") {\n" + " const enc = normEnc(encodingOrOffset);\n" + " if (enc === null) throw badEnc(encodingOrOffset);\n" + " const u8 = encodeStr(value, enc);\n" + " return new Buffer(u8.buffer, u8.byteOffset, u8.length);\n" + " }\n" + " if (value instanceof ArrayBuffer || (typeof SharedArrayBuffer !== \"undefined\" && value instanceof SharedArrayBuffer)) {\n" + " return new Buffer(value, encodingOrOffset, length);\n" + " }\n" + " if (ArrayBuffer.isView(value)) {\n" + " if (value instanceof Uint8Array) {\n" + " const copy = new Buffer(value.length);\n" + " copy.set(value);\n" + " return copy;\n" " }\n" - " if (value instanceof ArrayBuffer || (typeof SharedArrayBuffer !== \"undefined\" && value instanceof SharedArrayBuffer)) {\n" - " return new Buffer(value, encodingOrOffset, length);\n" + " return new Buffer(Uint8Array.from(value).buffer);\n" + " }\n" + " if (value === null || value === undefined) throw invalidArg(\"first argument\", \"of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object\", value);\n" + " if (typeof value === \"object\") {\n" + " if (typeof value.length === \"number\") {\n" + " const n = Math.max(0, Math.floor(value.length) || 0);\n" + " const b = new Buffer(n);\n" + " for (let i = 0; i < n; i++) b[i] = value[i] & 0xff;\n" + " return b;\n" " }\n" - " if (ArrayBuffer.isView(value)) {\n" - " if (value instanceof Uint8Array) {\n" - " const copy = new Buffer(value.length);\n" - " copy.set(value);\n" - " return copy;\n" - " }\n" - " return new Buffer(Uint8Array.from(value).buffer);\n" + " if (value.type === \"Buffer\" && Array.isArray(value.data)) {\n" + " return Buffer.from(value.data);\n" " }\n" - " if (value === null || value === undefined) throw invalidArg(\"first argument\", \"of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object\", value);\n" - " if (typeof value === \"object\") {\n" - " if (typeof value.length === \"number\") {\n" - " const n = Math.max(0, Math.floor(value.length) || 0);\n" - " const b = new Buffer(n);\n" - " for (let i = 0; i < n; i++) b[i] = value[i] & 0xff;\n" - " return b;\n" - " }\n" - " if (value.type === \"Buffer\" && Array.isArray(value.data)) {\n" - " return Buffer.from(value.data);\n" - " }\n" - " const prim = value.valueOf && value.valueOf();\n" - " if (prim !== null && prim !== undefined && prim !== value) return Buffer.from(prim, encodingOrOffset, length);\n" - " }\n" - " throw invalidArg(\"first argument\", \"of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object\", value);\n" + " const prim = value.valueOf && value.valueOf();\n" + " if (prim !== null && prim !== undefined && prim !== value) return Buffer.from(prim, encodingOrOffset, length);\n" + " }\n" + " throw invalidArg(\"first argument\", \"of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object\", value);\n" " }\n" " static isBuffer(b) {\n" - " return b instanceof Buffer;\n" + " return b instanceof Buffer;\n" " }\n" " static isEncoding(enc) {\n" - " return typeof enc === \"string\" && normEnc(enc) !== null;\n" + " return typeof enc === \"string\" && normEnc(enc) !== null;\n" " }\n" " static byteLength(value, encoding) {\n" - " if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) return value.byteLength;\n" - " if (typeof value !== \"string\") throw invalidArg(\"string\", \"of type string or an instance of Buffer or ArrayBuffer\", value);\n" - " const enc = normEnc(encoding);\n" - " switch (enc) {\n" - " case \"latin1\": case \"ascii\": return value.length;\n" - " case \"utf16le\": return value.length * 2;\n" - " case \"hex\": return value.length >>> 1;\n" - " case \"base64\": case \"base64url\": {\n" - " let n = value.length;\n" - " while (n > 0 && (value[n - 1] === \"=\" || value[n - 1] === \" \" || value[n - 1] === \"\\n\" || value[n - 1] === \"\\r\")) n--;\n" - " return Math.floor((n * 6) / 8);\n" - " }\n" - " default: return encUtf8(value).length;\n" + " if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) return value.byteLength;\n" + " if (typeof value !== \"string\") throw invalidArg(\"string\", \"of type string or an instance of Buffer or ArrayBuffer\", value);\n" + " const enc = normEnc(encoding);\n" + " switch (enc) {\n" + " case \"latin1\": case \"ascii\": return value.length;\n" + " case \"utf16le\": return value.length * 2;\n" + " case \"hex\": return value.length >>> 1;\n" + " case \"base64\": case \"base64url\": {\n" + " let n = value.length;\n" + " while (n > 0 && (value[n - 1] === \"=\" || value[n - 1] === \" \" || value[n - 1] === \"\\n\" || value[n - 1] === \"\\r\")) n--;\n" + " return Math.floor((n * 6) / 8);\n" " }\n" + " default: return encUtf8(value).length;\n" + " }\n" " }\n" " static concat(list, totalLength) {\n" - " if (!Array.isArray(list)) throw invalidArg(\"list\", \"an instance of Array\", list);\n" - " if (list.length === 0) return new Buffer(0);\n" - " let total = totalLength;\n" - " if (total === undefined) {\n" - " total = 0;\n" - " for (const b of list) total += b.length;\n" - " }\n" - " const out = new Buffer(total);\n" - " let o = 0;\n" - " for (const b of list) {\n" - " if (o >= total) break;\n" - " const chunk = b.length + o > total ? b.subarray(0, total - o) : b;\n" - " out.set(chunk, o);\n" - " o += chunk.length;\n" - " }\n" - " return out;\n" + " if (!Array.isArray(list)) throw invalidArg(\"list\", \"an instance of Array\", list);\n" + " if (list.length === 0) return new Buffer(0);\n" + " let total = totalLength;\n" + " if (total === undefined) {\n" + " total = 0;\n" + " for (const b of list) total += b.length;\n" + " }\n" + " const out = new Buffer(total);\n" + " let o = 0;\n" + " for (const b of list) {\n" + " if (o >= total) break;\n" + " const chunk = b.length + o > total ? b.subarray(0, total - o) : b;\n" + " out.set(chunk, o);\n" + " o += chunk.length;\n" + " }\n" + " return out;\n" " }\n" " static compare(a, b) {\n" - " return a.compare(b);\n" + " return a.compare(b);\n" " }\n" " toString(encoding, start, end) {\n" - " const enc = normEnc(encoding);\n" - " if (enc === null) throw badEnc(encoding);\n" - " return decodeBytes(this, enc, start === undefined ? 0 : Math.floor(start), end === undefined ? this.length : Math.min(Math.floor(end), this.length));\n" + " const enc = normEnc(encoding);\n" + " if (enc === null) throw badEnc(encoding);\n" + " return decodeBytes(this, enc, start === undefined ? 0 : Math.floor(start), end === undefined ? this.length : Math.min(Math.floor(end), this.length));\n" " }\n" " toJSON() {\n" - " return { type: \"Buffer\", data: Array.prototype.slice.call(this) };\n" + " return { type: \"Buffer\", data: Array.prototype.slice.call(this) };\n" " }\n" " equals(other) {\n" - " if (!(other instanceof Uint8Array)) throw invalidArg(\"otherBuffer\", \"an instance of Buffer or Uint8Array\", other);\n" - " if (this === other) return true;\n" - " if (this.length !== other.length) return false;\n" - " for (let i = 0; i < this.length; i++) {\n" - " if (this[i] !== other[i]) return false;\n" - " }\n" - " return true;\n" + " if (!(other instanceof Uint8Array)) throw invalidArg(\"otherBuffer\", \"an instance of Buffer or Uint8Array\", other);\n" + " if (this === other) return true;\n" + " if (this.length !== other.length) return false;\n" + " for (let i = 0; i < this.length; i++) {\n" + " if (this[i] !== other[i]) return false;\n" + " }\n" + " return true;\n" " }\n" " compare(target, targetStart, targetEnd, sourceStart, sourceEnd) {\n" - " if (!(target instanceof Uint8Array)) throw invalidArg(\"target\", \"an instance of Buffer or Uint8Array\", target);\n" - " const ts = targetStart === undefined ? 0 : targetStart;\n" - " const te = targetEnd === undefined ? target.length : targetEnd;\n" - " const ss = sourceStart === undefined ? 0 : sourceStart;\n" - " const se = sourceEnd === undefined ? this.length : sourceEnd;\n" - " const a = this.subarray(ss, se);\n" - " const b = target.subarray(ts, te);\n" - " const n = Math.min(a.length, b.length);\n" - " for (let i = 0; i < n; i++) {\n" - " if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1;\n" - " }\n" - " return a.length === b.length ? 0 : a.length < b.length ? -1 : 1;\n" + " if (!(target instanceof Uint8Array)) throw invalidArg(\"target\", \"an instance of Buffer or Uint8Array\", target);\n" + " const ts = targetStart === undefined ? 0 : targetStart;\n" + " const te = targetEnd === undefined ? target.length : targetEnd;\n" + " const ss = sourceStart === undefined ? 0 : sourceStart;\n" + " const se = sourceEnd === undefined ? this.length : sourceEnd;\n" + " const a = this.subarray(ss, se);\n" + " const b = target.subarray(ts, te);\n" + " const n = Math.min(a.length, b.length);\n" + " for (let i = 0; i < n; i++) {\n" + " if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1;\n" + " }\n" + " return a.length === b.length ? 0 : a.length < b.length ? -1 : 1;\n" " }\n" " copy(target, targetStart, sourceStart, sourceEnd) {\n" - " const ts = targetStart === undefined ? 0 : targetStart;\n" - " const ss = sourceStart === undefined ? 0 : sourceStart;\n" - " let se = sourceEnd === undefined ? this.length : sourceEnd;\n" - " if (se > this.length) se = this.length;\n" - " const n = Math.min(se - ss, target.length - ts);\n" - " if (n <= 0) return 0;\n" - " target.set(this.subarray(ss, ss + n), ts);\n" - " return n;\n" + " const ts = targetStart === undefined ? 0 : targetStart;\n" + " const ss = sourceStart === undefined ? 0 : sourceStart;\n" + " let se = sourceEnd === undefined ? this.length : sourceEnd;\n" + " if (se > this.length) se = this.length;\n" + " const n = Math.min(se - ss, target.length - ts);\n" + " if (n <= 0) return 0;\n" + " target.set(this.subarray(ss, ss + n), ts);\n" + " return n;\n" " }\n" " fill(value, start, end, encoding) {\n" - " let s = 0;\n" - " let e = this.length;\n" - " let enc = encoding;\n" - " if (typeof start === \"string\") {\n" - " enc = start;\n" - " } else {\n" - " if (start !== undefined) s = start;\n" - " if (typeof end === \"string\") enc = end;\n" - " else if (end !== undefined) e = end;\n" - " }\n" - " if (typeof value === \"number\") {\n" - " Uint8Array.prototype.fill.call(this, value & 0xff, s, e);\n" - " return this;\n" - " }\n" - " let pattern;\n" - " if (typeof value === \"string\") {\n" - " const ne = normEnc(enc);\n" - " if (ne === null) throw badEnc(enc);\n" - " pattern = encodeStr(value, ne);\n" - " } else if (value instanceof Uint8Array) {\n" - " pattern = value;\n" - " } else {\n" - " throw invalidArg(\"value\", \"of type string or number or an instance of Buffer or Uint8Array\", value);\n" - " }\n" - " if (pattern.length === 0) {\n" - " Uint8Array.prototype.fill.call(this, 0, s, e);\n" - " return this;\n" - " }\n" - " for (let i = s; i < e; i++) this[i] = pattern[(i - s) % pattern.length];\n" + " let s = 0;\n" + " let e = this.length;\n" + " let enc = encoding;\n" + " if (typeof start === \"string\") {\n" + " enc = start;\n" + " } else {\n" + " if (start !== undefined) s = start;\n" + " if (typeof end === \"string\") enc = end;\n" + " else if (end !== undefined) e = end;\n" + " }\n" + " if (typeof value === \"number\") {\n" + " Uint8Array.prototype.fill.call(this, value & 0xff, s, e);\n" " return this;\n" " }\n" + " let pattern;\n" + " if (typeof value === \"string\") {\n" + " const ne = normEnc(enc);\n" + " if (ne === null) throw badEnc(enc);\n" + " pattern = encodeStr(value, ne);\n" + " } else if (value instanceof Uint8Array) {\n" + " pattern = value;\n" + " } else {\n" + " throw invalidArg(\"value\", \"of type string or number or an instance of Buffer or Uint8Array\", value);\n" + " }\n" + " if (pattern.length === 0) {\n" + " Uint8Array.prototype.fill.call(this, 0, s, e);\n" + " return this;\n" + " }\n" + " for (let i = s; i < e; i++) this[i] = pattern[(i - s) % pattern.length];\n" + " return this;\n" + " }\n" " write(string, offset, length, encoding) {\n" - " if (typeof string !== \"string\") throw invalidArg(\"string\", \"of type string\", string);\n" - " let off = 0;\n" - " let len;\n" - " let enc = \"utf8\";\n" - " if (offset === undefined) {\n" - " len = this.length;\n" - " } else if (typeof offset === \"string\") {\n" - " enc = normEnc(offset);\n" - " if (enc === null) throw badEnc(offset);\n" - " len = this.length;\n" + " if (typeof string !== \"string\") throw invalidArg(\"string\", \"of type string\", string);\n" + " let off = 0;\n" + " let len;\n" + " let enc = \"utf8\";\n" + " if (offset === undefined) {\n" + " len = this.length;\n" + " } else if (typeof offset === \"string\") {\n" + " enc = normEnc(offset);\n" + " if (enc === null) throw badEnc(offset);\n" + " len = this.length;\n" + " } else {\n" + " off = offset;\n" + " if (length === undefined) {\n" + " len = this.length - off;\n" + " } else if (typeof length === \"string\") {\n" + " enc = normEnc(length);\n" + " if (enc === null) throw badEnc(length);\n" + " len = this.length - off;\n" " } else {\n" - " off = offset;\n" - " if (length === undefined) {\n" - " len = this.length - off;\n" - " } else if (typeof length === \"string\") {\n" - " enc = normEnc(length);\n" - " if (enc === null) throw badEnc(length);\n" - " len = this.length - off;\n" - " } else {\n" - " len = length;\n" - " if (encoding !== undefined) {\n" - " enc = normEnc(encoding);\n" - " if (enc === null) throw badEnc(encoding);\n" - " }\n" - " }\n" + " len = length;\n" + " if (encoding !== undefined) {\n" + " enc = normEnc(encoding);\n" + " if (enc === null) throw badEnc(encoding);\n" " }\n" - " if (off < 0 || off > this.length) throw outOfRange(\"offset\", \">= 0 and <= \" + this.length, off);\n" - " const bytes = encodeStr(string, enc);\n" - " let n = Math.min(bytes.length, len, this.length - off);\n" - " if (enc === \"utf16le\") n &= ~1;\n" - " if (enc === \"utf8\" && n < bytes.length) {\n" - " while (n > 0 && (bytes[n] & 0xc0) === 0x80) n--;\n" " }\n" - " this.set(bytes.subarray(0, n), off);\n" - " return n;\n" + " }\n" + " if (off < 0 || off > this.length) throw outOfRange(\"offset\", \">= 0 and <= \" + this.length, off);\n" + " const bytes = encodeStr(string, enc);\n" + " let n = Math.min(bytes.length, len, this.length - off);\n" + " if (enc === \"utf16le\") n &= ~1;\n" + " if (enc === \"utf8\" && n < bytes.length) {\n" + " while (n > 0 && (bytes[n] & 0xc0) === 0x80) n--;\n" + " }\n" + " this.set(bytes.subarray(0, n), off);\n" + " return n;\n" " }\n" " slice(start, end) {\n" - " return this.subarray(start, end);\n" + " return this.subarray(start, end);\n" " }\n" " toLocaleString(...args) {\n" - " return this.toString(...args);\n" + " return this.toString(...args);\n" " }\n" " inspect() {\n" - " return this[Symbol.for(\"nodejs.util.inspect.custom\")]();\n" + " return this[Symbol.for(\"nodejs.util.inspect.custom\")]();\n" " }\n" " [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n" - " const max = Math.min(this.length, INSPECT_MAX_BYTES);\n" - " let out = \"> 4] + hexChars[this[i] & 0x0f];\n" - " }\n" - " if (this.length > max) {\n" - " const rest = this.length - max;\n" - " out += \" ... \" + rest + \" more byte\" + (rest > 1 ? \"s\" : \"\");\n" - " }\n" - " return out + \">\";\n" + " const max = Math.min(this.length, INSPECT_MAX_BYTES);\n" + " let out = \"> 4] + hexChars[this[i] & 0x0f];\n" + " }\n" + " if (this.length > max) {\n" + " const rest = this.length - max;\n" + " out += \" ... \" + rest + \" more byte\" + (rest > 1 ? \"s\" : \"\");\n" + " }\n" + " return out + \">\";\n" " }\n" " indexOf(needle, byteOffset, encoding) {\n" - " return bufIndexOf(this, needle, byteOffset, encoding, true);\n" + " return bufIndexOf(this, needle, byteOffset, encoding, true);\n" " }\n" " lastIndexOf(needle, byteOffset, encoding) {\n" - " return bufIndexOf(this, needle, byteOffset, encoding, false);\n" + " return bufIndexOf(this, needle, byteOffset, encoding, false);\n" " }\n" " includes(needle, byteOffset, encoding) {\n" - " return this.indexOf(needle, byteOffset, encoding) !== -1;\n" + " return this.indexOf(needle, byteOffset, encoding) !== -1;\n" " }\n" " swap16() {\n" - " if (this.length % 2 !== 0) throw invalidBufferSize(\"16\");\n" - " for (let i = 0; i < this.length; i += 2) {\n" - " const t = this[i];\n" - " this[i] = this[i + 1];\n" - " this[i + 1] = t;\n" - " }\n" - " return this;\n" + " if (this.length % 2 !== 0) throw invalidBufferSize(\"16\");\n" + " for (let i = 0; i < this.length; i += 2) {\n" + " const t = this[i];\n" + " this[i] = this[i + 1];\n" + " this[i + 1] = t;\n" + " }\n" + " return this;\n" " }\n" " swap32() {\n" - " if (this.length % 4 !== 0) throw invalidBufferSize(\"32\");\n" - " for (let i = 0; i < this.length; i += 4) {\n" - " let t = this[i];\n" - " this[i] = this[i + 3];\n" - " this[i + 3] = t;\n" - " t = this[i + 1];\n" - " this[i + 1] = this[i + 2];\n" - " this[i + 2] = t;\n" - " }\n" - " return this;\n" + " if (this.length % 4 !== 0) throw invalidBufferSize(\"32\");\n" + " for (let i = 0; i < this.length; i += 4) {\n" + " let t = this[i];\n" + " this[i] = this[i + 3];\n" + " this[i + 3] = t;\n" + " t = this[i + 1];\n" + " this[i + 1] = this[i + 2];\n" + " this[i + 2] = t;\n" + " }\n" + " return this;\n" " }\n" " swap64() {\n" - " if (this.length % 8 !== 0) throw invalidBufferSize(\"64\");\n" - " for (let i = 0; i < this.length; i += 8) {\n" - " for (let j = 0; j < 4; j++) {\n" - " const t = this[i + j];\n" - " this[i + j] = this[i + 7 - j];\n" - " this[i + 7 - j] = t;\n" - " }\n" + " if (this.length % 8 !== 0) throw invalidBufferSize(\"64\");\n" + " for (let i = 0; i < this.length; i += 8) {\n" + " for (let j = 0; j < 4; j++) {\n" + " const t = this[i + j];\n" + " this[i + j] = this[i + 7 - j];\n" + " this[i + 7 - j] = t;\n" " }\n" - " return this;\n" + " }\n" + " return this;\n" " }\n" " readUInt8(offset = 0) { checkOffset(this, offset, 1); return this[offset]; }\n" " readUInt16LE(offset = 0) { checkOffset(this, offset, 2); return this[offset] | (this[offset + 1] << 8); }\n" @@ -5358,196 +5358,196 @@ static const char isl_modules_bootstrap[] = " readInt32LE(offset = 0) { checkOffset(this, offset, 4); return this[offset] | (this[offset + 1] << 8) | (this[offset + 2] << 16) | (this[offset + 3] << 24); }\n" " readInt32BE(offset = 0) { checkOffset(this, offset, 4); return (this[offset] << 24) | (this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]; }\n" " readUIntLE(offset, byteLength) {\n" - " checkOffset(this, offset, byteLength);\n" - " let v = 0;\n" - " let mul = 1;\n" - " for (let i = 0; i < byteLength; i++) {\n" - " v += this[offset + i] * mul;\n" - " mul *= 0x100;\n" - " }\n" - " return v;\n" + " checkOffset(this, offset, byteLength);\n" + " let v = 0;\n" + " let mul = 1;\n" + " for (let i = 0; i < byteLength; i++) {\n" + " v += this[offset + i] * mul;\n" + " mul *= 0x100;\n" + " }\n" + " return v;\n" " }\n" " readUIntBE(offset, byteLength) {\n" - " checkOffset(this, offset, byteLength);\n" - " let v = 0;\n" - " for (let i = 0; i < byteLength; i++) v = v * 0x100 + this[offset + i];\n" - " return v;\n" + " checkOffset(this, offset, byteLength);\n" + " let v = 0;\n" + " for (let i = 0; i < byteLength; i++) v = v * 0x100 + this[offset + i];\n" + " return v;\n" " }\n" " readIntLE(offset, byteLength) {\n" - " const v = this.readUIntLE(offset, byteLength);\n" - " const limit = Math.pow(2, 8 * byteLength - 1);\n" - " return v >= limit ? v - limit * 2 : v;\n" + " const v = this.readUIntLE(offset, byteLength);\n" + " const limit = Math.pow(2, 8 * byteLength - 1);\n" + " return v >= limit ? v - limit * 2 : v;\n" " }\n" " readIntBE(offset, byteLength) {\n" - " const v = this.readUIntBE(offset, byteLength);\n" - " const limit = Math.pow(2, 8 * byteLength - 1);\n" - " return v >= limit ? v - limit * 2 : v;\n" + " const v = this.readUIntBE(offset, byteLength);\n" + " const limit = Math.pow(2, 8 * byteLength - 1);\n" + " return v >= limit ? v - limit * 2 : v;\n" " }\n" " readBigUInt64LE(offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigUint64(offset, true);\n" + " checkOffset(this, offset, 8);\n" + " return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigUint64(offset, true);\n" " }\n" " readBigUInt64BE(offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigUint64(offset, false);\n" + " checkOffset(this, offset, 8);\n" + " return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigUint64(offset, false);\n" " }\n" " readBigInt64LE(offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigInt64(offset, true);\n" + " checkOffset(this, offset, 8);\n" + " return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigInt64(offset, true);\n" " }\n" " readBigInt64BE(offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigInt64(offset, false);\n" + " checkOffset(this, offset, 8);\n" + " return new DataView(this.buffer, this.byteOffset, this.byteLength).getBigInt64(offset, false);\n" " }\n" " readFloatLE(offset = 0) {\n" - " checkOffset(this, offset, 4);\n" - " return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat32(offset, true);\n" + " checkOffset(this, offset, 4);\n" + " return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat32(offset, true);\n" " }\n" " readFloatBE(offset = 0) {\n" - " checkOffset(this, offset, 4);\n" - " return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat32(offset, false);\n" + " checkOffset(this, offset, 4);\n" + " return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat32(offset, false);\n" " }\n" " readDoubleLE(offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat64(offset, true);\n" + " checkOffset(this, offset, 8);\n" + " return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat64(offset, true);\n" " }\n" " readDoubleBE(offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat64(offset, false);\n" + " checkOffset(this, offset, 8);\n" + " return new DataView(this.buffer, this.byteOffset, this.byteLength).getFloat64(offset, false);\n" " }\n" " writeUInt8(value, offset = 0) {\n" - " checkOffset(this, offset, 1);\n" - " checkValue(value, 0, 0xff, \"value\");\n" - " this[offset] = value;\n" - " return offset + 1;\n" + " checkOffset(this, offset, 1);\n" + " checkValue(value, 0, 0xff, \"value\");\n" + " this[offset] = value;\n" + " return offset + 1;\n" " }\n" " writeUInt16LE(value, offset = 0) {\n" - " checkOffset(this, offset, 2);\n" - " checkValue(value, 0, 0xffff, \"value\");\n" - " this[offset] = value & 0xff;\n" - " this[offset + 1] = value >>> 8;\n" - " return offset + 2;\n" + " checkOffset(this, offset, 2);\n" + " checkValue(value, 0, 0xffff, \"value\");\n" + " this[offset] = value & 0xff;\n" + " this[offset + 1] = value >>> 8;\n" + " return offset + 2;\n" " }\n" " writeUInt16BE(value, offset = 0) {\n" - " checkOffset(this, offset, 2);\n" - " checkValue(value, 0, 0xffff, \"value\");\n" - " this[offset] = value >>> 8;\n" - " this[offset + 1] = value & 0xff;\n" - " return offset + 2;\n" + " checkOffset(this, offset, 2);\n" + " checkValue(value, 0, 0xffff, \"value\");\n" + " this[offset] = value >>> 8;\n" + " this[offset + 1] = value & 0xff;\n" + " return offset + 2;\n" " }\n" " writeUInt32LE(value, offset = 0) {\n" - " checkOffset(this, offset, 4);\n" - " checkValue(value, 0, 0xffffffff, \"value\");\n" - " this[offset] = value & 0xff;\n" - " this[offset + 1] = (value >>> 8) & 0xff;\n" - " this[offset + 2] = (value >>> 16) & 0xff;\n" - " this[offset + 3] = (value >>> 24) & 0xff;\n" - " return offset + 4;\n" + " checkOffset(this, offset, 4);\n" + " checkValue(value, 0, 0xffffffff, \"value\");\n" + " this[offset] = value & 0xff;\n" + " this[offset + 1] = (value >>> 8) & 0xff;\n" + " this[offset + 2] = (value >>> 16) & 0xff;\n" + " this[offset + 3] = (value >>> 24) & 0xff;\n" + " return offset + 4;\n" " }\n" " writeUInt32BE(value, offset = 0) {\n" - " checkOffset(this, offset, 4);\n" - " checkValue(value, 0, 0xffffffff, \"value\");\n" - " this[offset] = (value >>> 24) & 0xff;\n" - " this[offset + 1] = (value >>> 16) & 0xff;\n" - " this[offset + 2] = (value >>> 8) & 0xff;\n" - " this[offset + 3] = value & 0xff;\n" - " return offset + 4;\n" + " checkOffset(this, offset, 4);\n" + " checkValue(value, 0, 0xffffffff, \"value\");\n" + " this[offset] = (value >>> 24) & 0xff;\n" + " this[offset + 1] = (value >>> 16) & 0xff;\n" + " this[offset + 2] = (value >>> 8) & 0xff;\n" + " this[offset + 3] = value & 0xff;\n" + " return offset + 4;\n" " }\n" " writeInt8(value, offset = 0) {\n" - " checkOffset(this, offset, 1);\n" - " checkValue(value, -0x80, 0x7f, \"value\");\n" - " this[offset] = value & 0xff;\n" - " return offset + 1;\n" + " checkOffset(this, offset, 1);\n" + " checkValue(value, -0x80, 0x7f, \"value\");\n" + " this[offset] = value & 0xff;\n" + " return offset + 1;\n" " }\n" " writeInt16LE(value, offset = 0) {\n" - " checkOffset(this, offset, 2);\n" - " checkValue(value, -0x8000, 0x7fff, \"value\");\n" - " this[offset] = value & 0xff;\n" - " this[offset + 1] = (value >>> 8) & 0xff;\n" - " return offset + 2;\n" + " checkOffset(this, offset, 2);\n" + " checkValue(value, -0x8000, 0x7fff, \"value\");\n" + " this[offset] = value & 0xff;\n" + " this[offset + 1] = (value >>> 8) & 0xff;\n" + " return offset + 2;\n" " }\n" " writeInt16BE(value, offset = 0) {\n" - " checkOffset(this, offset, 2);\n" - " checkValue(value, -0x8000, 0x7fff, \"value\");\n" - " this[offset] = (value >>> 8) & 0xff;\n" - " this[offset + 1] = value & 0xff;\n" - " return offset + 2;\n" + " checkOffset(this, offset, 2);\n" + " checkValue(value, -0x8000, 0x7fff, \"value\");\n" + " this[offset] = (value >>> 8) & 0xff;\n" + " this[offset + 1] = value & 0xff;\n" + " return offset + 2;\n" " }\n" " writeInt32LE(value, offset = 0) {\n" - " checkOffset(this, offset, 4);\n" - " checkValue(value, -0x80000000, 0x7fffffff, \"value\");\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setInt32(offset, value, true);\n" - " return offset + 4;\n" + " checkOffset(this, offset, 4);\n" + " checkValue(value, -0x80000000, 0x7fffffff, \"value\");\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setInt32(offset, value, true);\n" + " return offset + 4;\n" " }\n" " writeInt32BE(value, offset = 0) {\n" - " checkOffset(this, offset, 4);\n" - " checkValue(value, -0x80000000, 0x7fffffff, \"value\");\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setInt32(offset, value, false);\n" - " return offset + 4;\n" + " checkOffset(this, offset, 4);\n" + " checkValue(value, -0x80000000, 0x7fffffff, \"value\");\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setInt32(offset, value, false);\n" + " return offset + 4;\n" " }\n" " writeBigUInt64LE(value, offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setBigUint64(offset, value, true);\n" - " return offset + 8;\n" + " checkOffset(this, offset, 8);\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setBigUint64(offset, value, true);\n" + " return offset + 8;\n" " }\n" " writeBigUInt64BE(value, offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setBigUint64(offset, value, false);\n" - " return offset + 8;\n" + " checkOffset(this, offset, 8);\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setBigUint64(offset, value, false);\n" + " return offset + 8;\n" " }\n" " writeBigInt64LE(value, offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setBigInt64(offset, value, true);\n" - " return offset + 8;\n" + " checkOffset(this, offset, 8);\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setBigInt64(offset, value, true);\n" + " return offset + 8;\n" " }\n" " writeBigInt64BE(value, offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setBigInt64(offset, value, false);\n" - " return offset + 8;\n" + " checkOffset(this, offset, 8);\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setBigInt64(offset, value, false);\n" + " return offset + 8;\n" " }\n" " writeFloatLE(value, offset = 0) {\n" - " checkOffset(this, offset, 4);\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat32(offset, value, true);\n" - " return offset + 4;\n" + " checkOffset(this, offset, 4);\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat32(offset, value, true);\n" + " return offset + 4;\n" " }\n" " writeFloatBE(value, offset = 0) {\n" - " checkOffset(this, offset, 4);\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat32(offset, value, false);\n" - " return offset + 4;\n" + " checkOffset(this, offset, 4);\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat32(offset, value, false);\n" + " return offset + 4;\n" " }\n" " writeDoubleLE(value, offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat64(offset, value, true);\n" - " return offset + 8;\n" + " checkOffset(this, offset, 8);\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat64(offset, value, true);\n" + " return offset + 8;\n" " }\n" " writeDoubleBE(value, offset = 0) {\n" - " checkOffset(this, offset, 8);\n" - " new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat64(offset, value, false);\n" - " return offset + 8;\n" + " checkOffset(this, offset, 8);\n" + " new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat64(offset, value, false);\n" + " return offset + 8;\n" " }\n" " writeUIntLE(value, offset, byteLength) {\n" - " checkOffset(this, offset, byteLength);\n" - " let v = value;\n" - " for (let i = 0; i < byteLength; i++) {\n" - " this[offset + i] = v & 0xff;\n" - " v = Math.floor(v / 0x100);\n" - " }\n" - " return offset + byteLength;\n" + " checkOffset(this, offset, byteLength);\n" + " let v = value;\n" + " for (let i = 0; i < byteLength; i++) {\n" + " this[offset + i] = v & 0xff;\n" + " v = Math.floor(v / 0x100);\n" + " }\n" + " return offset + byteLength;\n" " }\n" " writeUIntBE(value, offset, byteLength) {\n" - " checkOffset(this, offset, byteLength);\n" - " let v = value;\n" - " for (let i = byteLength - 1; i >= 0; i--) {\n" - " this[offset + i] = v & 0xff;\n" - " v = Math.floor(v / 0x100);\n" - " }\n" - " return offset + byteLength;\n" + " checkOffset(this, offset, byteLength);\n" + " let v = value;\n" + " for (let i = byteLength - 1; i >= 0; i--) {\n" + " this[offset + i] = v & 0xff;\n" + " v = Math.floor(v / 0x100);\n" + " }\n" + " return offset + byteLength;\n" " }\n" " writeIntLE(value, offset, byteLength) {\n" - " return this.writeUIntLE(value < 0 ? value + Math.pow(2, 8 * byteLength) : value, offset, byteLength);\n" + " return this.writeUIntLE(value < 0 ? value + Math.pow(2, 8 * byteLength) : value, offset, byteLength);\n" " }\n" " writeIntBE(value, offset, byteLength) {\n" - " return this.writeUIntBE(value < 0 ? value + Math.pow(2, 8 * byteLength) : value, offset, byteLength);\n" + " return this.writeUIntBE(value < 0 ? value + Math.pow(2, 8 * byteLength) : value, offset, byteLength);\n" " }\n" " }\n" " Buffer.poolSize = 8192;\n" @@ -5555,52 +5555,52 @@ static const char isl_modules_bootstrap[] = " let enc = \"utf8\";\n" " let start = first ? 0 : buf.length - 1;\n" " if (typeof byteOffset === \"string\") {\n" - " enc = normEnc(byteOffset);\n" - " if (enc === null) throw badEnc(byteOffset);\n" + " enc = normEnc(byteOffset);\n" + " if (enc === null) throw badEnc(byteOffset);\n" " } else if (byteOffset !== undefined) {\n" - " start = Math.trunc(byteOffset);\n" - " if (Number.isNaN(start)) start = first ? 0 : buf.length - 1;\n" - " if (start < 0) start = buf.length + start;\n" - " if (encoding !== undefined) {\n" - " enc = normEnc(encoding);\n" - " if (enc === null) throw badEnc(encoding);\n" - " }\n" + " start = Math.trunc(byteOffset);\n" + " if (Number.isNaN(start)) start = first ? 0 : buf.length - 1;\n" + " if (start < 0) start = buf.length + start;\n" + " if (encoding !== undefined) {\n" + " enc = normEnc(encoding);\n" + " if (enc === null) throw badEnc(encoding);\n" + " }\n" " }\n" " let pat;\n" " if (typeof needle === \"number\") {\n" - " const b = needle & 0xff;\n" - " if (first) {\n" - " for (let i = Math.max(0, start); i < buf.length; i++) {\n" - " if (buf[i] === b) return i;\n" - " }\n" - " } else {\n" - " for (let i = Math.min(start, buf.length - 1); i >= 0; i--) {\n" - " if (buf[i] === b) return i;\n" - " }\n" + " const b = needle & 0xff;\n" + " if (first) {\n" + " for (let i = Math.max(0, start); i < buf.length; i++) {\n" + " if (buf[i] === b) return i;\n" " }\n" - " return -1;\n" + " } else {\n" + " for (let i = Math.min(start, buf.length - 1); i >= 0; i--) {\n" + " if (buf[i] === b) return i;\n" + " }\n" + " }\n" + " return -1;\n" " }\n" " if (typeof needle === \"string\") pat = encodeStr(needle, enc);\n" " else if (needle instanceof Uint8Array) pat = needle;\n" " else throw invalidArg(\"value\", \"of type string or an instance of Buffer or Uint8Array\", needle);\n" " if (pat.length === 0) {\n" - " if (first) return start < 0 ? 0 : start > buf.length ? buf.length : start;\n" - " return start < 0 ? 0 : Math.min(start, buf.length);\n" + " if (first) return start < 0 ? 0 : start > buf.length ? buf.length : start;\n" + " return start < 0 ? 0 : Math.min(start, buf.length);\n" " }\n" " const match = (i) => {\n" - " for (let j = 0; j < pat.length; j++) {\n" - " if (buf[i + j] !== pat[j]) return false;\n" - " }\n" - " return true;\n" - " };\n" + " for (let j = 0; j < pat.length; j++) {\n" + " if (buf[i + j] !== pat[j]) return false;\n" + " }\n" + " return true;\n" + " };\n" " if (first) {\n" - " for (let i = Math.max(0, start); i <= buf.length - pat.length; i++) {\n" - " if (match(i)) return i;\n" - " }\n" + " for (let i = Math.max(0, start); i <= buf.length - pat.length; i++) {\n" + " if (match(i)) return i;\n" + " }\n" " } else {\n" - " for (let i = Math.min(start, buf.length - pat.length); i >= 0; i--) {\n" - " if (match(i)) return i;\n" - " }\n" + " for (let i = Math.min(start, buf.length - pat.length); i >= 0; i--) {\n" + " if (match(i)) return i;\n" + " }\n" " }\n" " return -1;\n" " };\n" @@ -5613,7 +5613,7 @@ static const char isl_modules_bootstrap[] = " const isAscii = (input) => {\n" " const u8 = validationBytes(input);\n" " for (let i = 0; i < u8.length; i++) {\n" - " if (u8[i] > 0x7f) return false;\n" + " if (u8[i] > 0x7f) return false;\n" " }\n" " return true;\n" " };\n" @@ -5621,22 +5621,22 @@ static const char isl_modules_bootstrap[] = " const u8 = validationBytes(input);\n" " let i = 0;\n" " while (i < u8.length) {\n" - " const b = u8[i];\n" - " let n = 0;\n" - " let min = 0;\n" - " let cp = 0;\n" - " if (b < 0x80) { i++; continue; }\n" - " else if ((b & 0xe0) === 0xc0) { n = 1; min = 0x80; cp = b & 0x1f; }\n" - " else if ((b & 0xf0) === 0xe0) { n = 2; min = 0x800; cp = b & 0x0f; }\n" - " else if ((b & 0xf8) === 0xf0) { n = 3; min = 0x10000; cp = b & 0x07; }\n" - " else return false;\n" - " if (i + n >= u8.length + 1 && i + n > u8.length) return false;\n" - " for (let j = 1; j <= n; j++) {\n" - " if (i + j >= u8.length || (u8[i + j] & 0xc0) !== 0x80) return false;\n" - " cp = (cp << 6) | (u8[i + j] & 0x3f);\n" - " }\n" - " if (cp < min || cp > 0x10ffff || (cp >= 0xd800 && cp <= 0xdfff)) return false;\n" - " i += n + 1;\n" + " const b = u8[i];\n" + " let n = 0;\n" + " let min = 0;\n" + " let cp = 0;\n" + " if (b < 0x80) { i++; continue; }\n" + " else if ((b & 0xe0) === 0xc0) { n = 1; min = 0x80; cp = b & 0x1f; }\n" + " else if ((b & 0xf0) === 0xe0) { n = 2; min = 0x800; cp = b & 0x0f; }\n" + " else if ((b & 0xf8) === 0xf0) { n = 3; min = 0x10000; cp = b & 0x07; }\n" + " else return false;\n" + " if (i + n >= u8.length + 1 && i + n > u8.length) return false;\n" + " for (let j = 1; j <= n; j++) {\n" + " if (i + j >= u8.length || (u8[i + j] & 0xc0) !== 0x80) return false;\n" + " cp = (cp << 6) | (u8[i + j] & 0x3f);\n" + " }\n" + " if (cp < min || cp > 0x10ffff || (cp >= 0xd800 && cp <= 0xdfff)) return false;\n" + " i += n + 1;\n" " }\n" " return true;\n" " };\n" @@ -5657,8 +5657,8 @@ static const char isl_modules_bootstrap[] = " Blob: globalThis.Blob,\n" " File: globalThis.File,\n" " transcode: (source, from, to) => {\n" - " if (!(source instanceof Uint8Array)) throw invalidArg('source', 'an instance of Buffer or Uint8Array', source);\n" - " return Buffer.from(host.transcode(source, from, to));\n" + " if (!(source instanceof Uint8Array)) throw invalidArg('source', 'an instance of Buffer or Uint8Array', source);\n" + " return Buffer.from(host.transcode(source, from, to));\n" " },\n" " resolveObjectURL: () => undefined,\n" " };\n" @@ -5685,71 +5685,71 @@ static const char isl_modules_bootstrap[] = " };\n" " class StringDecoder {\n" " constructor(encoding) {\n" - " this.encoding = normEnc(encoding);\n" - " this._encoding = this.encoding;\n" - " this._pending = new Uint8Array(0);\n" - " this._missing = 0;\n" + " this.encoding = normEnc(encoding);\n" + " this._encoding = this.encoding;\n" + " this._pending = new Uint8Array(0);\n" + " this._missing = 0;\n" " }\n" " write(buf) {\n" - " if (typeof buf === 'string') return buf;\n" - " if (!ArrayBuffer.isView(buf)) {\n" - " const received = buf === null ? 'null' : buf === undefined ? 'undefined' : typeof buf === 'object' ? 'an instance of ' + (buf.constructor && buf.constructor.name || 'Object') : 'type ' + typeof buf + ' (' + String(buf) + ')';\n" - " const err = new TypeError('The \"buf\" argument must be an instance of Buffer, TypedArray, or DataView. Received ' + received);\n" - " err.code = 'ERR_INVALID_ARG_TYPE';\n" - " throw err;\n" - " }\n" - " const bytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n" - " const enc = this._encoding;\n" - " let offset = 0;\n" - " let out = '';\n" - " if (this._missing > 0) {\n" - " let take = Math.min(bytes.length, this._missing);\n" - " if (enc === 'utf8') {\n" - " for (let i = 0; i < take; i++) {\n" - " if ((bytes[i] & 0xc0) !== 0x80) { take = i; this._missing = i; break; }\n" - " }\n" - " }\n" - " const pending = new Uint8Array(this._pending.length + take);\n" - " pending.set(this._pending);\n" - " pending.set(bytes.subarray(0, take), this._pending.length);\n" - " this._pending = pending;\n" - " this._missing -= take;\n" - " offset = take;\n" - " if (this._missing === 0) {\n" - " out = Buffer.from(pending).toString(enc);\n" - " this._pending = new Uint8Array(0);\n" - " }\n" - " if (offset === bytes.length) return out;\n" - " }\n" - " const n = bytes.length - offset;\n" - " let held = 0;\n" - " let total = 0;\n" + " if (typeof buf === 'string') return buf;\n" + " if (!ArrayBuffer.isView(buf)) {\n" + " const received = buf === null ? 'null' : buf === undefined ? 'undefined' : typeof buf === 'object' ? 'an instance of ' + (buf.constructor && buf.constructor.name || 'Object') : 'type ' + typeof buf + ' (' + String(buf) + ')';\n" + " const err = new TypeError('The \"buf\" argument must be an instance of Buffer, TypedArray, or DataView. Received ' + received);\n" + " err.code = 'ERR_INVALID_ARG_TYPE';\n" + " throw err;\n" + " }\n" + " const bytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n" + " const enc = this._encoding;\n" + " let offset = 0;\n" + " let out = '';\n" + " if (this._missing > 0) {\n" + " let take = Math.min(bytes.length, this._missing);\n" " if (enc === 'utf8') {\n" - " for (let back = 1; back <= Math.min(n, 3); back++) {\n" - " const b = bytes[bytes.length - back];\n" - " if ((b & 0xc0) === 0x80) continue;\n" - " total = (b & 0xe0) === 0xc0 ? 2 : (b & 0xf0) === 0xe0 ? 3 : (b & 0xf8) === 0xf0 ? 4 : 0;\n" - " if (back < total) held = back;\n" - " break;\n" - " }\n" - " } else if (enc === 'utf16le') {\n" - " if (n % 2) { held = 1; total = 2; }\n" - " else if (n >= 2 && (bytes[bytes.length - 1] & 0xfc) === 0xd8) { held = 2; total = 4; }\n" - " } else if (enc === 'base64' || enc === 'base64url') {\n" - " held = n % 3;\n" - " total = 3;\n" + " for (let i = 0; i < take; i++) {\n" + " if ((bytes[i] & 0xc0) !== 0x80) { take = i; this._missing = i; break; }\n" " }\n" - " const end = bytes.length - held;\n" - " this._pending = bytes.slice(end);\n" - " this._missing = held ? total - held : 0;\n" - " return out + Buffer.from(bytes.subarray(offset, end)).toString(enc);\n" + " }\n" + " const pending = new Uint8Array(this._pending.length + take);\n" + " pending.set(this._pending);\n" + " pending.set(bytes.subarray(0, take), this._pending.length);\n" + " this._pending = pending;\n" + " this._missing -= take;\n" + " offset = take;\n" + " if (this._missing === 0) {\n" + " out = Buffer.from(pending).toString(enc);\n" + " this._pending = new Uint8Array(0);\n" + " }\n" + " if (offset === bytes.length) return out;\n" + " }\n" + " const n = bytes.length - offset;\n" + " let held = 0;\n" + " let total = 0;\n" + " if (enc === 'utf8') {\n" + " for (let back = 1; back <= Math.min(n, 3); back++) {\n" + " const b = bytes[bytes.length - back];\n" + " if ((b & 0xc0) === 0x80) continue;\n" + " total = (b & 0xe0) === 0xc0 ? 2 : (b & 0xf0) === 0xe0 ? 3 : (b & 0xf8) === 0xf0 ? 4 : 0;\n" + " if (back < total) held = back;\n" + " break;\n" + " }\n" + " } else if (enc === 'utf16le') {\n" + " if (n % 2) { held = 1; total = 2; }\n" + " else if (n >= 2 && (bytes[bytes.length - 1] & 0xfc) === 0xd8) { held = 2; total = 4; }\n" + " } else if (enc === 'base64' || enc === 'base64url') {\n" + " held = n % 3;\n" + " total = 3;\n" + " }\n" + " const end = bytes.length - held;\n" + " this._pending = bytes.slice(end);\n" + " this._missing = held ? total - held : 0;\n" + " return out + Buffer.from(bytes.subarray(offset, end)).toString(enc);\n" " }\n" " end(buf) {\n" - " const out = buf === undefined ? '' : this.write(buf);\n" - " const tail = Buffer.from(this._pending).toString(this._encoding);\n" - " this._pending = new Uint8Array(0);\n" - " this._missing = 0;\n" - " return out + tail;\n" + " const out = buf === undefined ? '' : this.write(buf);\n" + " const tail = Buffer.from(this._pending).toString(this._encoding);\n" + " this._pending = new Uint8Array(0);\n" + " this._missing = 0;\n" + " return out + tail;\n" " }\n" " }\n" " return { StringDecoder };\n" @@ -5786,66 +5786,66 @@ static const char isl_modules_bootstrap[] = " const out = new Uint8Array(total);\n" " let o = 0;\n" " for (const c of chunks) {\n" - " out.set(c, o);\n" - " o += c.length;\n" + " out.set(c, o);\n" + " o += c.length;\n" " }\n" " return out;\n" " };\n" " class Hash {\n" " constructor(algorithm, from) {\n" - " if (from === undefined) {\n" - " const alg = String(algorithm).toLowerCase();\n" - " if (env.digest(alg, new Uint8Array(0)) === undefined) throw unsupportedDigest();\n" - " this._alg = alg;\n" - " this._chunks = [];\n" - " } else {\n" - " this._alg = from._alg;\n" - " this._chunks = from._chunks.slice();\n" - " }\n" - " this._done = false;\n" + " if (from === undefined) {\n" + " const alg = String(algorithm).toLowerCase();\n" + " if (env.digest(alg, new Uint8Array(0)) === undefined) throw unsupportedDigest();\n" + " this._alg = alg;\n" + " this._chunks = [];\n" + " } else {\n" + " this._alg = from._alg;\n" + " this._chunks = from._chunks.slice();\n" + " }\n" + " this._done = false;\n" " }\n" " update(data, inputEncoding) {\n" - " if (this._done) {\n" - " const e = new Error(\"Digest already called\");\n" - " e.code = \"ERR_CRYPTO_HASH_FINALIZED\";\n" - " throw e;\n" - " }\n" - " this._chunks.push(toU8(data, inputEncoding, \"data\"));\n" - " return this;\n" + " if (this._done) {\n" + " const e = new Error(\"Digest already called\");\n" + " e.code = \"ERR_CRYPTO_HASH_FINALIZED\";\n" + " throw e;\n" + " }\n" + " this._chunks.push(toU8(data, inputEncoding, \"data\"));\n" + " return this;\n" " }\n" " copy() {\n" - " return new Hash(this._alg, this);\n" + " return new Hash(this._alg, this);\n" " }\n" " digest(outputEncoding) {\n" - " if (this._done) {\n" - " const e = new Error(\"Digest already called\");\n" - " e.code = \"ERR_CRYPTO_HASH_FINALIZED\";\n" - " throw e;\n" - " }\n" - " this._done = true;\n" - " const raw = env.digest(this._alg, concatChunks(this._chunks));\n" - " const buf = Buffer.from(raw.buffer, raw.byteOffset, raw.length);\n" - " return outputEncoding === undefined || outputEncoding === \"buffer\" ? buf : buf.toString(outputEncoding);\n" + " if (this._done) {\n" + " const e = new Error(\"Digest already called\");\n" + " e.code = \"ERR_CRYPTO_HASH_FINALIZED\";\n" + " throw e;\n" + " }\n" + " this._done = true;\n" + " const raw = env.digest(this._alg, concatChunks(this._chunks));\n" + " const buf = Buffer.from(raw.buffer, raw.byteOffset, raw.length);\n" + " return outputEncoding === undefined || outputEncoding === \"buffer\" ? buf : buf.toString(outputEncoding);\n" " }\n" " }\n" " class Hmac {\n" " constructor(algorithm, key) {\n" - " const alg = String(algorithm).toLowerCase();\n" - " if (env.digest(alg, new Uint8Array(0)) === undefined) throw unsupportedDigest();\n" - " this._alg = alg;\n" - " this._key = toU8(key, \"utf8\", \"key\");\n" - " this._chunks = [];\n" - " this._done = false;\n" + " const alg = String(algorithm).toLowerCase();\n" + " if (env.digest(alg, new Uint8Array(0)) === undefined) throw unsupportedDigest();\n" + " this._alg = alg;\n" + " this._key = toU8(key, \"utf8\", \"key\");\n" + " this._chunks = [];\n" + " this._done = false;\n" " }\n" " update(data, inputEncoding) {\n" - " this._chunks.push(toU8(data, inputEncoding, \"data\"));\n" - " return this;\n" + " this._chunks.push(toU8(data, inputEncoding, \"data\"));\n" + " return this;\n" " }\n" " digest(outputEncoding) {\n" - " this._done = true;\n" - " const raw = env.hmac(this._alg, this._key, concatChunks(this._chunks));\n" - " const buf = Buffer.from(raw.buffer, raw.byteOffset, raw.length);\n" - " return outputEncoding === undefined || outputEncoding === \"buffer\" ? buf : buf.toString(outputEncoding);\n" + " this._done = true;\n" + " const raw = env.hmac(this._alg, this._key, concatChunks(this._chunks));\n" + " const buf = Buffer.from(raw.buffer, raw.byteOffset, raw.length);\n" + " return outputEncoding === undefined || outputEncoding === \"buffer\" ? buf : buf.toString(outputEncoding);\n" " }\n" " }\n" " const createHash = (algorithm) => new Hash(algorithm);\n" @@ -5857,20 +5857,20 @@ static const char isl_modules_bootstrap[] = " };\n" " const fillRandom = (u8) => {\n" " for (let i = 0; i < u8.length; i += 65536) {\n" - " webcrypto.getRandomValues(u8.subarray(i, Math.min(i + 65536, u8.length)));\n" + " webcrypto.getRandomValues(u8.subarray(i, Math.min(i + 65536, u8.length)));\n" " }\n" " return u8;\n" " };\n" " const randomBytes = (size, callback) => {\n" " if (typeof size !== \"number\" || Number.isNaN(size) || size < 0) {\n" - " const e = new RangeError('The value of \"size\" is out of range. It must be >= 0 && <= 2147483647. Received ' + size);\n" - " e.code = \"ERR_OUT_OF_RANGE\";\n" - " throw e;\n" + " const e = new RangeError('The value of \"size\" is out of range. It must be >= 0 && <= 2147483647. Received ' + size);\n" + " e.code = \"ERR_OUT_OF_RANGE\";\n" + " throw e;\n" " }\n" " const buf = fillRandom(Buffer.alloc(size));\n" " if (typeof callback === \"function\") {\n" - " queueMicrotask(() => callback(null, buf));\n" - " return undefined;\n" + " queueMicrotask(() => callback(null, buf));\n" + " return undefined;\n" " }\n" " return buf;\n" " };\n" @@ -5884,43 +5884,43 @@ static const char isl_modules_bootstrap[] = " const randomFill = (buf, ...rest) => {\n" " const callback = rest.pop();\n" " if (typeof callback !== \"function\") {\n" - " const e = new TypeError('The \"callback\" argument must be of type function. Received ' + (callback === undefined ? \"undefined\" : \"type \" + typeof callback));\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" + " const e = new TypeError('The \"callback\" argument must be of type function. Received ' + (callback === undefined ? \"undefined\" : \"type \" + typeof callback));\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" " }\n" " randomFillSync(buf, ...rest);\n" " queueMicrotask(() => callback(null, buf));\n" " };\n" " const randomInt = (min, max, callback) => {\n" " if (max === undefined || typeof max === \"function\") {\n" - " callback = max;\n" - " max = min;\n" - " min = 0;\n" + " callback = max;\n" + " max = min;\n" + " min = 0;\n" " }\n" " if (!Number.isSafeInteger(min)) {\n" - " const e = new TypeError('The \"min\" argument must be a safe integer. Received ' + min);\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" + " const e = new TypeError('The \"min\" argument must be a safe integer. Received ' + min);\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" " }\n" " if (max <= min) {\n" - " const e = new RangeError('The value of \"max\" is out of range. It must be greater than the value of \"min\" (' + min + \"). Received \" + max);\n" - " e.code = \"ERR_OUT_OF_RANGE\";\n" - " throw e;\n" + " const e = new RangeError('The value of \"max\" is out of range. It must be greater than the value of \"min\" (' + min + \"). Received \" + max);\n" + " e.code = \"ERR_OUT_OF_RANGE\";\n" + " throw e;\n" " }\n" " const range = max - min;\n" " const draw = () => {\n" - " const bytes = fillRandom(new Uint8Array(6));\n" - " let v = 0;\n" - " for (let i = 0; i < 6; i++) v = v * 256 + bytes[i];\n" - " return v;\n" - " };\n" + " const bytes = fillRandom(new Uint8Array(6));\n" + " let v = 0;\n" + " for (let i = 0; i < 6; i++) v = v * 256 + bytes[i];\n" + " return v;\n" + " };\n" " const limit = Math.floor(Math.pow(2, 48) / range) * range;\n" " let v = draw();\n" " while (v >= limit) v = draw();\n" " const result = min + (v % range);\n" " if (typeof callback === \"function\") {\n" - " queueMicrotask(() => callback(null, result));\n" - " return undefined;\n" + " queueMicrotask(() => callback(null, result));\n" + " return undefined;\n" " }\n" " return result;\n" " };\n" @@ -5929,9 +5929,9 @@ static const char isl_modules_bootstrap[] = " const ua = toU8(a, undefined, \"buf1\");\n" " const ub = toU8(b, undefined, \"buf2\");\n" " if (ua.byteLength !== ub.byteLength) {\n" - " const e = new RangeError(\"Input buffers must have the same byte length\");\n" - " e.code = \"ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH\";\n" - " throw e;\n" + " const e = new RangeError(\"Input buffers must have the same byte length\");\n" + " e.code = \"ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH\";\n" + " throw e;\n" " }\n" " let diff = 0;\n" " for (let i = 0; i < ua.length; i++) diff |= ua[i] ^ ub[i];\n" @@ -5946,34 +5946,34 @@ static const char isl_modules_bootstrap[] = " const blocks = Math.ceil(keylen / hLen);\n" " const dk = new Uint8Array(blocks * hLen);\n" " for (let i = 1; i <= blocks; i++) {\n" - " const block = new Uint8Array(st.length + 4);\n" - " block.set(st, 0);\n" - " block[st.length] = (i >>> 24) & 0xff;\n" - " block[st.length + 1] = (i >>> 16) & 0xff;\n" - " block[st.length + 2] = (i >>> 8) & 0xff;\n" - " block[st.length + 3] = i & 0xff;\n" - " let u = env.hmac(alg, pw, block);\n" - " const t = new Uint8Array(u);\n" - " for (let j = 1; j < iterations; j++) {\n" - " u = env.hmac(alg, pw, u);\n" - " for (let k = 0; k < hLen; k++) t[k] ^= u[k];\n" - " }\n" - " dk.set(t, (i - 1) * hLen);\n" + " const block = new Uint8Array(st.length + 4);\n" + " block.set(st, 0);\n" + " block[st.length] = (i >>> 24) & 0xff;\n" + " block[st.length + 1] = (i >>> 16) & 0xff;\n" + " block[st.length + 2] = (i >>> 8) & 0xff;\n" + " block[st.length + 3] = i & 0xff;\n" + " let u = env.hmac(alg, pw, block);\n" + " const t = new Uint8Array(u);\n" + " for (let j = 1; j < iterations; j++) {\n" + " u = env.hmac(alg, pw, u);\n" + " for (let k = 0; k < hLen; k++) t[k] ^= u[k];\n" + " }\n" + " dk.set(t, (i - 1) * hLen);\n" " }\n" " return Buffer.from(dk.buffer, 0, keylen);\n" " };\n" " const pbkdf2 = (password, salt, iterations, keylen, digestAlg, callback) => {\n" " if (typeof callback !== \"function\") {\n" - " const e = new TypeError('The \"callback\" argument must be of type function. Received undefined');\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" + " const e = new TypeError('The \"callback\" argument must be of type function. Received undefined');\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" " }\n" " let derived;\n" " try {\n" - " derived = pbkdf2Sync(password, salt, iterations, keylen, digestAlg);\n" + " derived = pbkdf2Sync(password, salt, iterations, keylen, digestAlg);\n" " } catch (err) {\n" - " queueMicrotask(() => callback(err));\n" - " return;\n" + " queueMicrotask(() => callback(err));\n" + " return;\n" " }\n" " queueMicrotask(() => callback(null, derived));\n" " };\n" @@ -5985,12 +5985,12 @@ static const char isl_modules_bootstrap[] = " const kdfNumber = (value) => Number.isInteger(value) && Math.abs(value) > 4294967296 ? String(value).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \"_\") : String(value);\n" " const kdfInteger = (value, name, max) => {\n" " if (typeof value !== \"number\") {\n" - " const received = value === null ? \"null\" : value === undefined ? \"undefined\" : typeof value === \"object\" ? \"an instance of \" + ((value.constructor && value.constructor.name) || \"Object\") : \"type \" + typeof value + \" (\" + (typeof value === \"string\" ? \"'\" + value + \"'\" : String(value)) + \")\";\n" - " throw kdfError(TypeError, \"ERR_INVALID_ARG_TYPE\", 'The \"' + name + '\" argument must be of type number. Received ' + received);\n" + " const received = value === null ? \"null\" : value === undefined ? \"undefined\" : typeof value === \"object\" ? \"an instance of \" + ((value.constructor && value.constructor.name) || \"Object\") : \"type \" + typeof value + \" (\" + (typeof value === \"string\" ? \"'\" + value + \"'\" : String(value)) + \")\";\n" + " throw kdfError(TypeError, \"ERR_INVALID_ARG_TYPE\", 'The \"' + name + '\" argument must be of type number. Received ' + received);\n" " }\n" " if (!Number.isInteger(value) || value < 0 || value > max) {\n" - " const range = Number.isInteger(value) ? \">= 0 && <= \" + max : \"an integer\";\n" - " throw kdfError(RangeError, \"ERR_OUT_OF_RANGE\", 'The value of \"' + name + '\" is out of range. It must be ' + range + '. Received ' + kdfNumber(value));\n" + " const range = Number.isInteger(value) ? \">= 0 && <= \" + max : \"an integer\";\n" + " throw kdfError(RangeError, \"ERR_OUT_OF_RANGE\", 'The value of \"' + name + '\" is out of range. It must be ' + range + '. Received ' + kdfNumber(value));\n" " }\n" " return value;\n" " };\n" @@ -6004,14 +6004,14 @@ static const char isl_modules_bootstrap[] = " };\n" " const kdfCallback = (callback) => {\n" " if (typeof callback !== \"function\") {\n" - " const received = callback === undefined ? \"undefined\" : callback === null ? \"null\" : typeof callback === \"object\" ? \"an instance of \" + ((callback.constructor && callback.constructor.name) || \"Object\") : \"type \" + typeof callback + \" (\" + String(callback) + \")\";\n" - " throw kdfError(TypeError, \"ERR_INVALID_ARG_TYPE\", 'The \"callback\" argument must be of type function. Received ' + received);\n" + " const received = callback === undefined ? \"undefined\" : callback === null ? \"null\" : typeof callback === \"object\" ? \"an instance of \" + ((callback.constructor && callback.constructor.name) || \"Object\") : \"type \" + typeof callback + \" (\" + String(callback) + \")\";\n" + " throw kdfError(TypeError, \"ERR_INVALID_ARG_TYPE\", 'The \"callback\" argument must be of type function. Received ' + received);\n" " }\n" " };\n" " const hkdfParameters = (digest, ikm, salt, info, keylen) => {\n" " if (typeof digest !== \"string\") {\n" - " const received = digest === undefined ? \"undefined\" : digest === null ? \"null\" : \"type \" + typeof digest + \" (\" + String(digest) + \")\";\n" - " throw kdfError(TypeError, \"ERR_INVALID_ARG_TYPE\", 'The \"digest\" argument must be of type string. Received ' + received);\n" + " const received = digest === undefined ? \"undefined\" : digest === null ? \"null\" : \"type \" + typeof digest + \" (\" + String(digest) + \")\";\n" + " throw kdfError(TypeError, \"ERR_INVALID_ARG_TYPE\", 'The \"digest\" argument must be of type string. Received ' + received);\n" " }\n" " ikm = kdfInput(ikm, \"ikm\", true);\n" " salt = kdfInput(salt, \"salt\", false, true);\n" @@ -6024,23 +6024,23 @@ static const char isl_modules_bootstrap[] = " const prk = env.hmac(digest.toLowerCase(), salt, ikm);\n" " if (prk === undefined) throw kdfError(TypeError, \"ERR_CRYPTO_INVALID_DIGEST\", \"Invalid digest: \" + digest);\n" " if (keylen > 255 * prk.length) {\n" - " prk.fill(0);\n" - " throw kdfError(RangeError, \"ERR_CRYPTO_INVALID_KEYLEN\", \"Invalid key length\");\n" + " prk.fill(0);\n" + " throw kdfError(RangeError, \"ERR_CRYPTO_INVALID_KEYLEN\", \"Invalid key length\");\n" " }\n" " const result = new Uint8Array(keylen);\n" " let previous = new Uint8Array(0), offset = 0;\n" " for (let counter = 1; offset < keylen; counter++) {\n" - " const block = new Uint8Array(previous.length + info.length + 1);\n" - " block.set(previous);\n" - " block.set(info, previous.length);\n" - " block[block.length - 1] = counter;\n" - " const next = env.hmac(digest.toLowerCase(), prk, block);\n" - " previous.fill(0);\n" - " block.fill(0);\n" - " previous = next;\n" - " const take = Math.min(next.length, keylen - offset);\n" - " result.set(next.subarray(0, take), offset);\n" - " offset += take;\n" + " const block = new Uint8Array(previous.length + info.length + 1);\n" + " block.set(previous);\n" + " block.set(info, previous.length);\n" + " block[block.length - 1] = counter;\n" + " const next = env.hmac(digest.toLowerCase(), prk, block);\n" + " previous.fill(0);\n" + " block.fill(0);\n" + " previous = next;\n" + " const take = Math.min(next.length, keylen - offset);\n" + " result.set(next.subarray(0, take), offset);\n" + " offset += take;\n" " }\n" " prk.fill(0);\n" " previous.fill(0);\n" @@ -6063,16 +6063,16 @@ static const char isl_modules_bootstrap[] = " kdfInteger(keylen, \"keylen\", 2147483647);\n" " const values = [16384, 8, 1, 33554432];\n" " if (options) {\n" - " const names = [\"N\", \"r\", \"p\"], aliases = [\"cost\", \"blockSize\", \"parallelization\"];\n" - " for (let i = 0; i < 3; i++) {\n" - " const name = names[i], alias = aliases[i], present = options[name] !== undefined;\n" - " if (present) values[i] = kdfInteger(options[name], name, 4294967295);\n" - " if (options[alias] !== undefined) {\n" - " if (present) throw kdfError(TypeError, \"ERR_INCOMPATIBLE_OPTION_PAIR\", 'Option \"' + name + '\" cannot be used in combination with option \"' + alias + '\"');\n" - " values[i] = kdfInteger(options[alias], alias, 4294967295);\n" - " }\n" + " const names = [\"N\", \"r\", \"p\"], aliases = [\"cost\", \"blockSize\", \"parallelization\"];\n" + " for (let i = 0; i < 3; i++) {\n" + " const name = names[i], alias = aliases[i], present = options[name] !== undefined;\n" + " if (present) values[i] = kdfInteger(options[name], name, 4294967295);\n" + " if (options[alias] !== undefined) {\n" + " if (present) throw kdfError(TypeError, \"ERR_INCOMPATIBLE_OPTION_PAIR\", 'Option \"' + name + '\" cannot be used in combination with option \"' + alias + '\"');\n" + " values[i] = kdfInteger(options[alias], alias, 4294967295);\n" " }\n" - " if (options.maxmem !== undefined) values[3] = kdfInteger(options.maxmem, \"maxmem\", Number.MAX_SAFE_INTEGER);\n" + " }\n" + " if (options.maxmem !== undefined) values[3] = kdfInteger(options.maxmem, \"maxmem\", Number.MAX_SAFE_INTEGER);\n" " }\n" " return [password, salt, keylen, ...values];\n" " };\n" @@ -6089,7 +6089,7 @@ static const char isl_modules_bootstrap[] = " };\n" " class KeyObject {\n" " constructor() {\n" - " throw new Error(\"crypto.KeyObject is not available in the scriptc island (the embedded runtime carries the hashing/random/KDF slice only)\");\n" + " throw new Error(\"crypto.KeyObject is not available in the scriptc island (the embedded runtime carries the hashing/random/KDF slice only)\");\n" " }\n" " }\n" " const constants = {\n" @@ -6191,11 +6191,11 @@ static const char isl_modules_bootstrap[] = " };\n" " class Stream extends EventEmitter {\n" " constructor(opts) {\n" - " super();\n" - " void opts;\n" + " super();\n" + " void opts;\n" " }\n" " pipe(dest, options) {\n" - " return pipeImpl(this, dest, options);\n" + " return pipeImpl(this, dest, options);\n" " }\n" " }\n" " const chunkOf = (stream, chunk, encoding) => {\n" @@ -6205,36 +6205,36 @@ static const char isl_modules_bootstrap[] = " };\n" " class Readable extends Stream {\n" " constructor(options) {\n" - " super();\n" - " const opts = options || {};\n" - " this._objectMode = !!(opts.objectMode || opts.readableObjectMode);\n" - " this._hwm = opts.highWaterMark !== undefined ? opts.highWaterMark\n" - " : opts.readableHighWaterMark !== undefined ? opts.readableHighWaterMark\n" - " : this._objectMode ? 16 : " ISL_STREAM_DEFAULT_HWM ";\n" - " if (typeof opts.read === \"function\") this._read = opts.read;\n" - " if (typeof opts.destroy === \"function\") this._destroy = opts.destroy;\n" - " this._rBuf = [];\n" - " this._rLen = 0;\n" - " this._sync = true; /* Node's state.sync: true at start and during _read */\n" - " this._flowing = null;\n" - " this._rEnded = false; /* push(null) seen */\n" - " this._rEmittedEnd = false;\n" - " this._reading = false;\n" - " this._readRequested = false;\n" - " this.destroyed = false;\n" - " this._rErrored = null;\n" - " this._decoder = null;\n" - " this._encoding = null;\n" - " this._closeEmitted = false;\n" - " if (opts.encoding) this.setEncoding(opts.encoding);\n" - " if (typeof opts.signal === \"object\" && opts.signal !== null && typeof opts.signal.addEventListener === \"function\") {\n" - " opts.signal.addEventListener(\"abort\", () => {\n" - " const e = new Error(\"The operation was aborted\");\n" - " e.code = \"ABORT_ERR\";\n" - " e.name = \"AbortError\";\n" - " this.destroy(e);\n" - " });\n" - " }\n" + " super();\n" + " const opts = options || {};\n" + " this._objectMode = !!(opts.objectMode || opts.readableObjectMode);\n" + " this._hwm = opts.highWaterMark !== undefined ? opts.highWaterMark\n" + " : opts.readableHighWaterMark !== undefined ? opts.readableHighWaterMark\n" + " : this._objectMode ? 16 : " ISL_STREAM_DEFAULT_HWM ";\n" + " if (typeof opts.read === \"function\") this._read = opts.read;\n" + " if (typeof opts.destroy === \"function\") this._destroy = opts.destroy;\n" + " this._rBuf = [];\n" + " this._rLen = 0;\n" + " this._sync = true; /* Node's state.sync: true at start and during _read */\n" + " this._flowing = null;\n" + " this._rEnded = false; /* push(null) seen */\n" + " this._rEmittedEnd = false;\n" + " this._reading = false;\n" + " this._readRequested = false;\n" + " this.destroyed = false;\n" + " this._rErrored = null;\n" + " this._decoder = null;\n" + " this._encoding = null;\n" + " this._closeEmitted = false;\n" + " if (opts.encoding) this.setEncoding(opts.encoding);\n" + " if (typeof opts.signal === \"object\" && opts.signal !== null && typeof opts.signal.addEventListener === \"function\") {\n" + " opts.signal.addEventListener(\"abort\", () => {\n" + " const e = new Error(\"The operation was aborted\");\n" + " e.code = \"ABORT_ERR\";\n" + " e.name = \"AbortError\";\n" + " this.destroy(e);\n" + " });\n" + " }\n" " }\n" " get readableEnded() { return this._rEmittedEnd; }\n" " get readableFlowing() { return this._flowing; }\n" @@ -6242,325 +6242,325 @@ static const char isl_modules_bootstrap[] = " get readableHighWaterMark() { return this._hwm; }\n" " get readableObjectMode() { return this._objectMode; }\n" " get readable() {\n" - " return !this._rEmittedEnd && !this.destroyed && this._rErrored === null;\n" + " return !this._rEmittedEnd && !this.destroyed && this._rErrored === null;\n" " }\n" " get errored() { return this._rErrored; }\n" " get closed() { return this._closeEmitted; }\n" " _read() {\n" - " throw ERR_METHOD_NOT_IMPLEMENTED(\"_read()\");\n" + " throw ERR_METHOD_NOT_IMPLEMENTED(\"_read()\");\n" " }\n" " setEncoding(enc) {\n" - " this._decoder = new StringDecoder(enc);\n" - " this._encoding = this._decoder.encoding;\n" - " if (this._rBuf.length) {\n" - " const chunks = this._rBuf;\n" - " this._rBuf = [];\n" - " this._rLen = 0;\n" - " for (const c of chunks) {\n" - " const s = typeof c === \"string\" ? c : this._decoder.write(c);\n" - " if (s.length) {\n" - " this._rBuf.push(s);\n" - " this._rLen += s.length;\n" - " }\n" - " }\n" + " this._decoder = new StringDecoder(enc);\n" + " this._encoding = this._decoder.encoding;\n" + " if (this._rBuf.length) {\n" + " const chunks = this._rBuf;\n" + " this._rBuf = [];\n" + " this._rLen = 0;\n" + " for (const c of chunks) {\n" + " const s = typeof c === \"string\" ? c : this._decoder.write(c);\n" + " if (s.length) {\n" + " this._rBuf.push(s);\n" + " this._rLen += s.length;\n" " }\n" - " return this;\n" + " }\n" + " }\n" + " return this;\n" " }\n" " push(chunk, encoding) {\n" - " if (chunk === null) {\n" - " this._rEnded = true;\n" - " this._maybeEmitEnd();\n" - " return false;\n" - " }\n" - " if (this._rEmittedEnd || (this._rEnded && !this._objectMode)) {\n" - " this.emit(\"error\", ERR_PUSH_AFTER_EOF());\n" - " return false;\n" - " }\n" - " let c = chunkOf(this, chunk, encoding);\n" - " if (this._decoder && typeof c !== \"string\") {\n" - " c = this._decoder.write(c);\n" - " if (c.length === 0) return !this._rEnded && this._rLen < this._hwm;\n" - " }\n" - " this._rBuf.push(c);\n" - " this._rLen += this._objectMode ? 1 : c.length;\n" - " this._pushed = true;\n" - " if (this._flowing === true && this._rLen === (this._objectMode ? 1 : c.length) && !this._sync && !this._reading) {\n" - " this._takeChunk();\n" - " this.emit(\"data\", c);\n" - " } else if (this._flowing === true) {\n" - " if (!this._reading) nextTick(() => this._emitData());\n" - " } else {\n" - " nextTick(() => this.emit(\"readable\"));\n" - " }\n" - " return !this._rEnded && this._rLen < this._hwm;\n" + " if (chunk === null) {\n" + " this._rEnded = true;\n" + " this._maybeEmitEnd();\n" + " return false;\n" + " }\n" + " if (this._rEmittedEnd || (this._rEnded && !this._objectMode)) {\n" + " this.emit(\"error\", ERR_PUSH_AFTER_EOF());\n" + " return false;\n" + " }\n" + " let c = chunkOf(this, chunk, encoding);\n" + " if (this._decoder && typeof c !== \"string\") {\n" + " c = this._decoder.write(c);\n" + " if (c.length === 0) return !this._rEnded && this._rLen < this._hwm;\n" + " }\n" + " this._rBuf.push(c);\n" + " this._rLen += this._objectMode ? 1 : c.length;\n" + " this._pushed = true;\n" + " if (this._flowing === true && this._rLen === (this._objectMode ? 1 : c.length) && !this._sync && !this._reading) {\n" + " this._takeChunk();\n" + " this.emit(\"data\", c);\n" + " } else if (this._flowing === true) {\n" + " if (!this._reading) nextTick(() => this._emitData());\n" + " } else {\n" + " nextTick(() => this.emit(\"readable\"));\n" + " }\n" + " return !this._rEnded && this._rLen < this._hwm;\n" " }\n" " unshift(chunk, encoding) {\n" - " if (chunk === null || chunk === undefined) return;\n" - " let c = chunkOf(this, chunk, encoding);\n" - " if (this._decoder && typeof c !== \"string\") c = this._decoder.write(c);\n" - " this._rBuf.unshift(c);\n" - " this._rLen += this._objectMode ? 1 : c.length;\n" + " if (chunk === null || chunk === undefined) return;\n" + " let c = chunkOf(this, chunk, encoding);\n" + " if (this._decoder && typeof c !== \"string\") c = this._decoder.write(c);\n" + " this._rBuf.unshift(c);\n" + " this._rLen += this._objectMode ? 1 : c.length;\n" " }\n" " _callRead() {\n" - " while (!this._reading && !this._rEnded && !this.destroyed) {\n" - " this._reading = true;\n" - " this._pushed = false;\n" - " this._sync = true;\n" - " try {\n" - " this._read(this._hwm);\n" - " } catch (err) {\n" - " this.destroy(err);\n" - " }\n" - " this._sync = false;\n" - " this._reading = false;\n" - " if (this._flowing === true) this._drainData();\n" - " else this._maybeEmitEnd();\n" - " if (!(this._flowing === true && this._pushed && !this._rEnded && !this.destroyed)) break;\n" + " while (!this._reading && !this._rEnded && !this.destroyed) {\n" + " this._reading = true;\n" + " this._pushed = false;\n" + " this._sync = true;\n" + " try {\n" + " this._read(this._hwm);\n" + " } catch (err) {\n" + " this.destroy(err);\n" " }\n" + " this._sync = false;\n" + " this._reading = false;\n" + " if (this._flowing === true) this._drainData();\n" + " else this._maybeEmitEnd();\n" + " if (!(this._flowing === true && this._pushed && !this._rEnded && !this.destroyed)) break;\n" + " }\n" " }\n" " _drainData() {\n" - " while (this._flowing === true && this._rBuf.length > 0 && !this.destroyed) {\n" - " const c = this._takeChunk();\n" - " this.emit(\"data\", c);\n" - " }\n" - " this._maybeEmitEnd();\n" + " while (this._flowing === true && this._rBuf.length > 0 && !this.destroyed) {\n" + " const c = this._takeChunk();\n" + " this.emit(\"data\", c);\n" + " }\n" + " this._maybeEmitEnd();\n" " }\n" " _emitData() {\n" - " this._drainData();\n" - " if (this._flowing === true && !this._rEnded && !this.destroyed) {\n" - " this._callRead();\n" - " }\n" + " this._drainData();\n" + " if (this._flowing === true && !this._rEnded && !this.destroyed) {\n" + " this._callRead();\n" + " }\n" " }\n" " _takeChunk() {\n" - " const c = this._rBuf.shift();\n" - " this._rLen -= this._objectMode ? 1 : c.length;\n" - " return c;\n" + " const c = this._rBuf.shift();\n" + " this._rLen -= this._objectMode ? 1 : c.length;\n" + " return c;\n" " }\n" " _maybeEmitEnd() {\n" - " if (this._rEnded && this._rBuf.length === 0 && !this._rEmittedEnd && !this.destroyed) {\n" - " this._rEmittedEnd = true;\n" - " if (this._decoder) {\n" - " const tail = this._decoder.end();\n" - " if (tail.length) {\n" - " this._rEmittedEnd = false;\n" - " this._rBuf.push(tail);\n" - " this._rLen += tail.length;\n" - " if (this._flowing === true) this._emitData();\n" - " return;\n" - " }\n" - " }\n" - " nextTick(() => {\n" - " this.emit(\"end\");\n" - " this._maybeClose();\n" - " });\n" + " if (this._rEnded && this._rBuf.length === 0 && !this._rEmittedEnd && !this.destroyed) {\n" + " this._rEmittedEnd = true;\n" + " if (this._decoder) {\n" + " const tail = this._decoder.end();\n" + " if (tail.length) {\n" + " this._rEmittedEnd = false;\n" + " this._rBuf.push(tail);\n" + " this._rLen += tail.length;\n" + " if (this._flowing === true) this._emitData();\n" + " return;\n" " }\n" + " }\n" + " nextTick(() => {\n" + " this.emit(\"end\");\n" + " this._maybeClose();\n" + " });\n" + " }\n" " }\n" " _maybeClose() {\n" - " if (this._closeEmitted || this.destroyed) return;\n" - " this._closeEmitted = true;\n" - " nextTick(() => this.emit(\"close\"));\n" + " if (this._closeEmitted || this.destroyed) return;\n" + " this._closeEmitted = true;\n" + " nextTick(() => this.emit(\"close\"));\n" " }\n" " read(n) {\n" - " if (this._rBuf.length === 0) {\n" - " this._callRead();\n" - " }\n" - " if (this._rBuf.length === 0) {\n" - " this._maybeEmitEnd();\n" - " return null;\n" - " }\n" - " if (n === undefined || n === null) {\n" - " if (this._objectMode) return this._takeChunk();\n" - " let out;\n" - " if (typeof this._rBuf[0] === \"string\") {\n" - " out = this._rBuf.join(\"\");\n" - " } else {\n" - " out = Buffer.concat(this._rBuf);\n" - " }\n" - " this._rBuf = [];\n" - " this._rLen = 0;\n" - " this._maybeEmitEnd();\n" - " return out;\n" - " }\n" + " if (this._rBuf.length === 0) {\n" + " this._callRead();\n" + " }\n" + " if (this._rBuf.length === 0) {\n" + " this._maybeEmitEnd();\n" + " return null;\n" + " }\n" + " if (n === undefined || n === null) {\n" " if (this._objectMode) return this._takeChunk();\n" - " if (n <= 0) return null;\n" - " if (this._rLen === 0) return null;\n" - " if (n >= this._rLen) return this.read();\n" " let out;\n" " if (typeof this._rBuf[0] === \"string\") {\n" - " let s = \"\";\n" - " while (s.length < n && this._rBuf.length) {\n" - " const c = this._takeChunk();\n" - " if (s.length + c.length <= n) {\n" - " s += c;\n" - " } else {\n" - " const take = n - s.length;\n" - " s += c.slice(0, take);\n" - " this._rBuf.unshift(c.slice(take));\n" - " this._rLen += c.length - take;\n" - " }\n" - " }\n" - " out = s;\n" + " out = this._rBuf.join(\"\");\n" " } else {\n" - " const parts = [];\n" - " let got = 0;\n" - " while (got < n && this._rBuf.length) {\n" - " const c = this._takeChunk();\n" - " if (got + c.length <= n) {\n" - " parts.push(c);\n" - " got += c.length;\n" - " } else {\n" - " const take = n - got;\n" - " parts.push(c.subarray(0, take));\n" - " this._rBuf.unshift(c.subarray(take));\n" - " this._rLen += c.length - take;\n" - " got = n;\n" - " }\n" - " }\n" - " out = Buffer.concat(parts);\n" + " out = Buffer.concat(this._rBuf);\n" " }\n" + " this._rBuf = [];\n" + " this._rLen = 0;\n" " this._maybeEmitEnd();\n" " return out;\n" " }\n" - " on(name, fn) {\n" - " super.on(name, fn);\n" - " if (name === \"data\") {\n" - " if (this._flowing !== false) {\n" - " this._flowing = true;\n" - " nextTick(() => this._emitData());\n" - " }\n" - " } else if (name === \"readable\") {\n" - " if (this._rBuf.length > 0 || this._rEnded) {\n" - " nextTick(() => this.emit(\"readable\"));\n" - " } else {\n" - " nextTick(() => this._callRead());\n" - " }\n" + " if (this._objectMode) return this._takeChunk();\n" + " if (n <= 0) return null;\n" + " if (this._rLen === 0) return null;\n" + " if (n >= this._rLen) return this.read();\n" + " let out;\n" + " if (typeof this._rBuf[0] === \"string\") {\n" + " let s = \"\";\n" + " while (s.length < n && this._rBuf.length) {\n" + " const c = this._takeChunk();\n" + " if (s.length + c.length <= n) {\n" + " s += c;\n" + " } else {\n" + " const take = n - s.length;\n" + " s += c.slice(0, take);\n" + " this._rBuf.unshift(c.slice(take));\n" + " this._rLen += c.length - take;\n" " }\n" - " return this;\n" + " }\n" + " out = s;\n" + " } else {\n" + " const parts = [];\n" + " let got = 0;\n" + " while (got < n && this._rBuf.length) {\n" + " const c = this._takeChunk();\n" + " if (got + c.length <= n) {\n" + " parts.push(c);\n" + " got += c.length;\n" + " } else {\n" + " const take = n - got;\n" + " parts.push(c.subarray(0, take));\n" + " this._rBuf.unshift(c.subarray(take));\n" + " this._rLen += c.length - take;\n" + " got = n;\n" + " }\n" + " }\n" + " out = Buffer.concat(parts);\n" + " }\n" + " this._maybeEmitEnd();\n" + " return out;\n" + " }\n" + " on(name, fn) {\n" + " super.on(name, fn);\n" + " if (name === \"data\") {\n" + " if (this._flowing !== false) {\n" + " this._flowing = true;\n" + " nextTick(() => this._emitData());\n" + " }\n" + " } else if (name === \"readable\") {\n" + " if (this._rBuf.length > 0 || this._rEnded) {\n" + " nextTick(() => this.emit(\"readable\"));\n" + " } else {\n" + " nextTick(() => this._callRead());\n" + " }\n" + " }\n" + " return this;\n" " }\n" " addListener(name, fn) { return this.on(name, fn); }\n" " pause() {\n" - " this._flowing = false;\n" - " return this;\n" + " this._flowing = false;\n" + " return this;\n" " }\n" " resume() {\n" - " if (this._flowing !== true) {\n" - " this._flowing = true;\n" - " nextTick(() => this._emitData());\n" - " }\n" - " return this;\n" + " if (this._flowing !== true) {\n" + " this._flowing = true;\n" + " nextTick(() => this._emitData());\n" + " }\n" + " return this;\n" " }\n" " isPaused() { return this._flowing === false; }\n" " _destroy(err, cb) { cb(err); }\n" " destroy(err) {\n" - " if (this.destroyed) return this;\n" - " this.destroyed = true;\n" - " this._rErrored = err || null;\n" - " this._destroy(err || null, (er) => {\n" - " if (er) nextTick(() => this.emit(\"error\", er));\n" - " else if (err) nextTick(() => this.emit(\"error\", err));\n" - " if (!this._closeEmitted) {\n" - " this._closeEmitted = true;\n" - " nextTick(() => this.emit(\"close\"));\n" - " }\n" - " });\n" - " return this;\n" + " if (this.destroyed) return this;\n" + " this.destroyed = true;\n" + " this._rErrored = err || null;\n" + " this._destroy(err || null, (er) => {\n" + " if (er) nextTick(() => this.emit(\"error\", er));\n" + " else if (err) nextTick(() => this.emit(\"error\", err));\n" + " if (!this._closeEmitted) {\n" + " this._closeEmitted = true;\n" + " nextTick(() => this.emit(\"close\"));\n" + " }\n" + " });\n" + " return this;\n" " }\n" " unpipe(dest) {\n" - " unpipeImpl(this, dest);\n" - " return this;\n" + " unpipeImpl(this, dest);\n" + " return this;\n" " }\n" " wrap() { throw ERR_METHOD_NOT_IMPLEMENTED(\"wrap()\"); }\n" " [Symbol.asyncIterator]() {\n" - " const stream = this;\n" - " let done = false;\n" - " return {\n" - " next() {\n" - " return new Promise((resolve, reject) => {\n" - " if (done || stream._rEmittedEnd) {\n" - " done = true;\n" - " resolve({ value: undefined, done: true });\n" - " return;\n" - " }\n" - " const tryRead = () => {\n" - " const c = stream.read();\n" - " if (c !== null) {\n" - " cleanup();\n" - " resolve({ value: c, done: false });\n" - " return true;\n" - " }\n" - " if (stream._rEmittedEnd || (stream._rEnded && stream._rBuf.length === 0)) {\n" - " cleanup();\n" - " done = true;\n" - " resolve({ value: undefined, done: true });\n" - " return true;\n" - " }\n" - " return false;\n" - " };\n" - " const onReadable = () => { tryRead(); };\n" - " const onEnd = () => {\n" - " cleanup();\n" - " done = true;\n" - " resolve({ value: undefined, done: true });\n" - " };\n" - " const onError = (err) => {\n" - " cleanup();\n" - " done = true;\n" - " reject(err);\n" - " };\n" - " const cleanup = () => {\n" - " stream.removeListener(\"readable\", onReadable);\n" - " stream.removeListener(\"end\", onEnd);\n" - " stream.removeListener(\"error\", onError);\n" - " };\n" - " if (tryRead()) return;\n" - " stream.on(\"readable\", onReadable);\n" - " stream.on(\"end\", onEnd);\n" - " stream.on(\"error\", onError);\n" - " });\n" - " },\n" - " return() {\n" + " const stream = this;\n" + " let done = false;\n" + " return {\n" + " next() {\n" + " return new Promise((resolve, reject) => {\n" + " if (done || stream._rEmittedEnd) {\n" " done = true;\n" - " stream.destroy();\n" - " return Promise.resolve({ value: undefined, done: true });\n" - " },\n" - " [Symbol.asyncIterator]() { return this; },\n" - " };\n" + " resolve({ value: undefined, done: true });\n" + " return;\n" + " }\n" + " const tryRead = () => {\n" + " const c = stream.read();\n" + " if (c !== null) {\n" + " cleanup();\n" + " resolve({ value: c, done: false });\n" + " return true;\n" + " }\n" + " if (stream._rEmittedEnd || (stream._rEnded && stream._rBuf.length === 0)) {\n" + " cleanup();\n" + " done = true;\n" + " resolve({ value: undefined, done: true });\n" + " return true;\n" + " }\n" + " return false;\n" + " };\n" + " const onReadable = () => { tryRead(); };\n" + " const onEnd = () => {\n" + " cleanup();\n" + " done = true;\n" + " resolve({ value: undefined, done: true });\n" + " };\n" + " const onError = (err) => {\n" + " cleanup();\n" + " done = true;\n" + " reject(err);\n" + " };\n" + " const cleanup = () => {\n" + " stream.removeListener(\"readable\", onReadable);\n" + " stream.removeListener(\"end\", onEnd);\n" + " stream.removeListener(\"error\", onError);\n" + " };\n" + " if (tryRead()) return;\n" + " stream.on(\"readable\", onReadable);\n" + " stream.on(\"end\", onEnd);\n" + " stream.on(\"error\", onError);\n" + " });\n" + " },\n" + " return() {\n" + " done = true;\n" + " stream.destroy();\n" + " return Promise.resolve({ value: undefined, done: true });\n" + " },\n" + " [Symbol.asyncIterator]() { return this; },\n" + " };\n" " }\n" " static from(iterable) {\n" - " const r = new Readable({ objectMode: true, read() {} });\n" - " (async () => {\n" - " try {\n" - " if (typeof iterable === \"string\" || iterable instanceof Buffer || iterable instanceof Uint8Array) {\n" - " r.push(iterable);\n" - " } else {\n" - " for await (const chunk of iterable) r.push(chunk);\n" - " }\n" - " r.push(null);\n" - " } catch (err) {\n" - " r.destroy(err);\n" - " }\n" - " })();\n" - " return r;\n" + " const r = new Readable({ objectMode: true, read() {} });\n" + " (async () => {\n" + " try {\n" + " if (typeof iterable === \"string\" || iterable instanceof Buffer || iterable instanceof Uint8Array) {\n" + " r.push(iterable);\n" + " } else {\n" + " for await (const chunk of iterable) r.push(chunk);\n" + " }\n" + " r.push(null);\n" + " } catch (err) {\n" + " r.destroy(err);\n" + " }\n" + " })();\n" + " return r;\n" " }\n" " }\n" " const pipeImpl = (src, dest, options) => {\n" " const endOnFinish = !options || options.end !== false;\n" " const onData = (chunk) => {\n" - " const ok = dest.write(chunk);\n" - " if (ok === false) src.pause();\n" - " };\n" + " const ok = dest.write(chunk);\n" + " if (ok === false) src.pause();\n" + " };\n" " const onDrain = () => src.resume();\n" " const onEnd = () => {\n" - " if (endOnFinish) dest.end();\n" - " };\n" + " if (endOnFinish) dest.end();\n" + " };\n" " src.on(\"data\", onData);\n" " dest.on(\"drain\", onDrain);\n" " src.on(\"end\", onEnd);\n" " const cleanup = () => {\n" - " src.removeListener(\"data\", onData);\n" - " dest.removeListener(\"drain\", onDrain);\n" - " src.removeListener(\"end\", onEnd);\n" - " };\n" + " src.removeListener(\"data\", onData);\n" + " dest.removeListener(\"drain\", onDrain);\n" + " src.removeListener(\"end\", onEnd);\n" + " };\n" " if (!src._pipes) src._pipes = [];\n" " src._pipes.push({ dest, cleanup });\n" " dest.emit(\"pipe\", src);\n" @@ -6569,38 +6569,38 @@ static const char isl_modules_bootstrap[] = " const unpipeImpl = (src, dest) => {\n" " if (!src._pipes) return;\n" " for (let i = src._pipes.length - 1; i >= 0; i--) {\n" - " if (dest === undefined || src._pipes[i].dest === dest) {\n" - " src._pipes[i].cleanup();\n" - " const d = src._pipes[i].dest;\n" - " src._pipes.splice(i, 1);\n" - " d.emit(\"unpipe\", src);\n" - " }\n" + " if (dest === undefined || src._pipes[i].dest === dest) {\n" + " src._pipes[i].cleanup();\n" + " const d = src._pipes[i].dest;\n" + " src._pipes.splice(i, 1);\n" + " d.emit(\"unpipe\", src);\n" + " }\n" " }\n" " };\n" " class Writable extends Stream {\n" " constructor(options) {\n" - " super();\n" - " const opts = options || {};\n" - " this._objectMode = !!(opts.objectMode || opts.writableObjectMode);\n" - " this._wom = this._objectMode;\n" - " this._whwm = opts.highWaterMark !== undefined ? opts.highWaterMark\n" - " : opts.writableHighWaterMark !== undefined ? opts.writableHighWaterMark\n" - " : this._wom ? 16 : " ISL_STREAM_DEFAULT_HWM ";\n" - " if (typeof opts.write === \"function\") this._write = opts.write;\n" - " if (typeof opts.writev === \"function\") this._writev = opts.writev;\n" - " if (typeof opts.final === \"function\") this._final = opts.final;\n" - " if (typeof opts.destroy === \"function\") this._destroy = opts.destroy;\n" - " this._decodeStrings = opts.decodeStrings !== false;\n" - " this._wQueue = [];\n" - " this._wLen = 0;\n" - " this._writing = false;\n" - " this._wEnded = false;\n" - " this._wFinished = false;\n" - " this._needDrain = false;\n" - " this.destroyed = false;\n" - " this._wErrored = null;\n" - " this._wCloseEmitted = false;\n" - " this._defaultEncoding = opts.defaultEncoding || \"utf8\";\n" + " super();\n" + " const opts = options || {};\n" + " this._objectMode = !!(opts.objectMode || opts.writableObjectMode);\n" + " this._wom = this._objectMode;\n" + " this._whwm = opts.highWaterMark !== undefined ? opts.highWaterMark\n" + " : opts.writableHighWaterMark !== undefined ? opts.writableHighWaterMark\n" + " : this._wom ? 16 : " ISL_STREAM_DEFAULT_HWM ";\n" + " if (typeof opts.write === \"function\") this._write = opts.write;\n" + " if (typeof opts.writev === \"function\") this._writev = opts.writev;\n" + " if (typeof opts.final === \"function\") this._final = opts.final;\n" + " if (typeof opts.destroy === \"function\") this._destroy = opts.destroy;\n" + " this._decodeStrings = opts.decodeStrings !== false;\n" + " this._wQueue = [];\n" + " this._wLen = 0;\n" + " this._writing = false;\n" + " this._wEnded = false;\n" + " this._wFinished = false;\n" + " this._needDrain = false;\n" + " this.destroyed = false;\n" + " this._wErrored = null;\n" + " this._wCloseEmitted = false;\n" + " this._defaultEncoding = opts.defaultEncoding || \"utf8\";\n" " }\n" " get writableEnded() { return this._wEnded; }\n" " get writableFinished() { return this._wFinished; }\n" @@ -6608,178 +6608,178 @@ static const char isl_modules_bootstrap[] = " get writableHighWaterMark() { return this._whwm; }\n" " get writableObjectMode() { return this._wom; }\n" " get writable() {\n" - " return !this._wEnded && !this.destroyed && this._wErrored === null;\n" + " return !this._wEnded && !this.destroyed && this._wErrored === null;\n" " }\n" " get errored() { return this._wErrored; }\n" " get closed() { return this._wCloseEmitted; }\n" " _write(chunk, encoding, callback) {\n" - " if (this._writev) {\n" - " this._writev([{ chunk, encoding }], callback);\n" - " return;\n" - " }\n" - " throw ERR_METHOD_NOT_IMPLEMENTED(\"_write()\");\n" + " if (this._writev) {\n" + " this._writev([{ chunk, encoding }], callback);\n" + " return;\n" + " }\n" + " throw ERR_METHOD_NOT_IMPLEMENTED(\"_write()\");\n" " }\n" " write(chunk, encoding, callback) {\n" - " if (typeof encoding === \"function\") {\n" - " callback = encoding;\n" - " encoding = null;\n" - " }\n" - " if (this._wEnded) {\n" - " const err = ERR_WRITE_AFTER_END();\n" - " nextTick(() => {\n" - " if (typeof callback === \"function\") callback(err);\n" - " this.emit(\"error\", err);\n" - " });\n" - " return false;\n" - " }\n" - " if (this.destroyed) {\n" - " const err = ERR_DESTROYED(\"write\");\n" - " nextTick(() => {\n" - " if (typeof callback === \"function\") callback(err);\n" - " this.emit(\"error\", err);\n" - " });\n" - " return false;\n" - " }\n" - " let c = chunk;\n" - " let enc = encoding || this._defaultEncoding;\n" - " if (!this._wom && typeof chunk === \"string\" && this._decodeStrings) {\n" - " c = Buffer.from(chunk, enc);\n" - " enc = \"buffer\";\n" - " } else if (!this._wom && typeof chunk !== \"string\") {\n" - " enc = \"buffer\";\n" - " }\n" - " this._wQueue.push({ chunk: c, encoding: enc, callback });\n" - " this._wLen += this._wom ? 1 : (c.length !== undefined ? c.length : 1);\n" - " const ret = this._wLen < this._whwm;\n" - " if (!ret) this._needDrain = true;\n" - " this._processWrites();\n" - " return ret;\n" + " if (typeof encoding === \"function\") {\n" + " callback = encoding;\n" + " encoding = null;\n" + " }\n" + " if (this._wEnded) {\n" + " const err = ERR_WRITE_AFTER_END();\n" + " nextTick(() => {\n" + " if (typeof callback === \"function\") callback(err);\n" + " this.emit(\"error\", err);\n" + " });\n" + " return false;\n" + " }\n" + " if (this.destroyed) {\n" + " const err = ERR_DESTROYED(\"write\");\n" + " nextTick(() => {\n" + " if (typeof callback === \"function\") callback(err);\n" + " this.emit(\"error\", err);\n" + " });\n" + " return false;\n" + " }\n" + " let c = chunk;\n" + " let enc = encoding || this._defaultEncoding;\n" + " if (!this._wom && typeof chunk === \"string\" && this._decodeStrings) {\n" + " c = Buffer.from(chunk, enc);\n" + " enc = \"buffer\";\n" + " } else if (!this._wom && typeof chunk !== \"string\") {\n" + " enc = \"buffer\";\n" + " }\n" + " this._wQueue.push({ chunk: c, encoding: enc, callback });\n" + " this._wLen += this._wom ? 1 : (c.length !== undefined ? c.length : 1);\n" + " const ret = this._wLen < this._whwm;\n" + " if (!ret) this._needDrain = true;\n" + " this._processWrites();\n" + " return ret;\n" " }\n" " _processWrites() {\n" - " if (this._writing || this.destroyed) return;\n" - " const entry = this._wQueue.shift();\n" - " if (entry === undefined) {\n" - " if (this._wEnded && !this._wFinished && !this._finalCalled) {\n" - " this._finalCalled = true;\n" - " if (this._final) nextTick(() => this._runFinal());\n" - " else this._runFinal();\n" - " }\n" - " if (this._needDrain && !this._wEnded) {\n" - " this._needDrain = false;\n" - " nextTick(() => this.emit(\"drain\"));\n" - " }\n" - " return;\n" + " if (this._writing || this.destroyed) return;\n" + " const entry = this._wQueue.shift();\n" + " if (entry === undefined) {\n" + " if (this._wEnded && !this._wFinished && !this._finalCalled) {\n" + " this._finalCalled = true;\n" + " if (this._final) nextTick(() => this._runFinal());\n" + " else this._runFinal();\n" " }\n" - " this._runWrite(entry);\n" + " if (this._needDrain && !this._wEnded) {\n" + " this._needDrain = false;\n" + " nextTick(() => this.emit(\"drain\"));\n" + " }\n" + " return;\n" + " }\n" + " this._runWrite(entry);\n" " }\n" " _runFinal() {\n" - " const finish = (err) => {\n" - " if (err) {\n" - " this.destroy(err);\n" - " return;\n" - " }\n" - " this._wFinished = true;\n" - " nextTick(() => {\n" - " this.emit(\"finish\");\n" - " this._maybeCloseW();\n" - " });\n" - " };\n" - " if (this._final) {\n" - " try {\n" - " this._final.call(this, finish);\n" - " } catch (err) {\n" - " finish(err);\n" - " }\n" - " } else {\n" - " finish();\n" + " const finish = (err) => {\n" + " if (err) {\n" + " this.destroy(err);\n" + " return;\n" " }\n" + " this._wFinished = true;\n" + " nextTick(() => {\n" + " this.emit(\"finish\");\n" + " this._maybeCloseW();\n" + " });\n" + " };\n" + " if (this._final) {\n" + " try {\n" + " this._final.call(this, finish);\n" + " } catch (err) {\n" + " finish(err);\n" + " }\n" + " } else {\n" + " finish();\n" + " }\n" " }\n" " _runWrite(entry) {\n" - " this._writing = true;\n" - " const done = (err) => {\n" - " this._writing = false;\n" - " this._wLen -= this._wom ? 1 : (entry.chunk.length !== undefined ? entry.chunk.length : 1);\n" - " if (typeof entry.callback === \"function\") {\n" - " nextTick(() => entry.callback(err || null));\n" - " }\n" - " if (err) {\n" - " this.destroy(err);\n" - " return;\n" - " }\n" - " nextTick(() => this._processWrites());\n" - " };\n" - " try {\n" - " this._write.call(this, entry.chunk, entry.encoding, done);\n" - " } catch (err) {\n" - " done(err);\n" + " this._writing = true;\n" + " const done = (err) => {\n" + " this._writing = false;\n" + " this._wLen -= this._wom ? 1 : (entry.chunk.length !== undefined ? entry.chunk.length : 1);\n" + " if (typeof entry.callback === \"function\") {\n" + " nextTick(() => entry.callback(err || null));\n" " }\n" + " if (err) {\n" + " this.destroy(err);\n" + " return;\n" + " }\n" + " nextTick(() => this._processWrites());\n" + " };\n" + " try {\n" + " this._write.call(this, entry.chunk, entry.encoding, done);\n" + " } catch (err) {\n" + " done(err);\n" + " }\n" " }\n" " end(chunk, encoding, callback) {\n" - " if (typeof chunk === \"function\") {\n" - " callback = chunk;\n" - " chunk = null;\n" - " encoding = null;\n" - " } else if (typeof encoding === \"function\") {\n" - " callback = encoding;\n" - " encoding = null;\n" - " }\n" - " if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n" - " this._wEnded = true;\n" - " if (typeof callback === \"function\") {\n" - " if (this._wFinished) nextTick(callback);\n" - " else if (typeof this.prependOnceListener === \"function\") this.prependOnceListener(\"finish\", () => callback());\n" - " else this.once(\"finish\", () => callback());\n" - " }\n" - " this._processWrites();\n" - " return this;\n" + " if (typeof chunk === \"function\") {\n" + " callback = chunk;\n" + " chunk = null;\n" + " encoding = null;\n" + " } else if (typeof encoding === \"function\") {\n" + " callback = encoding;\n" + " encoding = null;\n" + " }\n" + " if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n" + " this._wEnded = true;\n" + " if (typeof callback === \"function\") {\n" + " if (this._wFinished) nextTick(callback);\n" + " else if (typeof this.prependOnceListener === \"function\") this.prependOnceListener(\"finish\", () => callback());\n" + " else this.once(\"finish\", () => callback());\n" + " }\n" + " this._processWrites();\n" + " return this;\n" " }\n" " cork() {}\n" " uncork() {}\n" " setDefaultEncoding(enc) {\n" - " this._defaultEncoding = enc;\n" - " return this;\n" + " this._defaultEncoding = enc;\n" + " return this;\n" " }\n" " _destroy(err, cb) { cb(err); }\n" " destroy(err) {\n" - " if (this.destroyed) return this;\n" - " this.destroyed = true;\n" - " this._wErrored = err || null;\n" - " this._destroy(err || null, (er) => {\n" - " const finalErr = er || err;\n" - " if (finalErr) nextTick(() => this.emit(\"error\", finalErr));\n" - " this._maybeCloseW();\n" - " });\n" - " return this;\n" + " if (this.destroyed) return this;\n" + " this.destroyed = true;\n" + " this._wErrored = err || null;\n" + " this._destroy(err || null, (er) => {\n" + " const finalErr = er || err;\n" + " if (finalErr) nextTick(() => this.emit(\"error\", finalErr));\n" + " this._maybeCloseW();\n" + " });\n" + " return this;\n" " }\n" " _maybeCloseW() {\n" - " if (this._wCloseEmitted) return;\n" - " this._wCloseEmitted = true;\n" - " nextTick(() => this.emit(\"close\"));\n" + " if (this._wCloseEmitted) return;\n" + " this._wCloseEmitted = true;\n" + " nextTick(() => this.emit(\"close\"));\n" " }\n" " }\n" " class Duplex extends Readable {\n" " constructor(options) {\n" - " super(options);\n" - " const opts = options || {};\n" - " const w = new Writable(opts);\n" - " this._wSide = w;\n" - " this._whwm = w._whwm;\n" - " this._wQueue = w._wQueue;\n" - " if (typeof opts.write === \"function\") this._write = opts.write;\n" - " if (typeof opts.writev === \"function\") this._writev = opts.writev;\n" - " if (typeof opts.final === \"function\") this._final = opts.final;\n" - " this._wObjectMode = !!(opts.objectMode || opts.writableObjectMode);\n" - " this._decodeStrings = opts.decodeStrings !== false;\n" - " this._wLen = 0;\n" - " this._writing = false;\n" - " this._wEnded = false;\n" - " this._wFinished = false;\n" - " this._needDrain = false;\n" - " this._wErrored = null;\n" - " this._wCloseEmitted = false;\n" - " this._finalCalled = false;\n" - " this._defaultEncoding = opts.defaultEncoding || \"utf8\";\n" - " this.allowHalfOpen = opts.allowHalfOpen !== false;\n" + " super(options);\n" + " const opts = options || {};\n" + " const w = new Writable(opts);\n" + " this._wSide = w;\n" + " this._whwm = w._whwm;\n" + " this._wQueue = w._wQueue;\n" + " if (typeof opts.write === \"function\") this._write = opts.write;\n" + " if (typeof opts.writev === \"function\") this._writev = opts.writev;\n" + " if (typeof opts.final === \"function\") this._final = opts.final;\n" + " this._wObjectMode = !!(opts.objectMode || opts.writableObjectMode);\n" + " this._decodeStrings = opts.decodeStrings !== false;\n" + " this._wLen = 0;\n" + " this._writing = false;\n" + " this._wEnded = false;\n" + " this._wFinished = false;\n" + " this._needDrain = false;\n" + " this._wErrored = null;\n" + " this._wCloseEmitted = false;\n" + " this._finalCalled = false;\n" + " this._defaultEncoding = opts.defaultEncoding || \"utf8\";\n" + " this.allowHalfOpen = opts.allowHalfOpen !== false;\n" " }\n" " get writableEnded() { return this._wEnded; }\n" " get writableFinished() { return this._wFinished; }\n" @@ -6787,7 +6787,7 @@ static const char isl_modules_bootstrap[] = " get writableHighWaterMark() { return this._whwm; }\n" " get writableObjectMode() { return this._wom; }\n" " get writable() {\n" - " return !this._wEnded && !this.destroyed && this._wErrored === null;\n" + " return !this._wEnded && !this.destroyed && this._wErrored === null;\n" " }\n" " }\n" " for (const m of [\"_write\", \"write\", \"_processWrites\", \"_runFinal\", \"_runWrite\", \"end\", \"cork\", \"uncork\", \"setDefaultEncoding\", \"_maybeCloseW\"]) {\n" @@ -6798,108 +6798,108 @@ static const char isl_modules_bootstrap[] = " };\n" " class Transform extends Duplex {\n" " constructor(options) {\n" - " super(options);\n" - " const opts = options || {};\n" - " if (typeof opts.transform === \"function\") this._transform = opts.transform;\n" - " if (typeof opts.flush === \"function\") this._flush = opts.flush;\n" + " super(options);\n" + " const opts = options || {};\n" + " if (typeof opts.transform === \"function\") this._transform = opts.transform;\n" + " if (typeof opts.flush === \"function\") this._flush = opts.flush;\n" " }\n" " _read() {}\n" " _transform() {\n" - " throw ERR_METHOD_NOT_IMPLEMENTED(\"_transform()\");\n" + " throw ERR_METHOD_NOT_IMPLEMENTED(\"_transform()\");\n" " }\n" " _write(chunk, encoding, callback) {\n" - " try {\n" - " this._transform.call(this, chunk, encoding, (err, data) => {\n" - " if (err) {\n" - " callback(err);\n" - " return;\n" - " }\n" - " if (data !== undefined && data !== null) this.push(data);\n" - " callback();\n" - " });\n" - " } catch (err) {\n" + " try {\n" + " this._transform.call(this, chunk, encoding, (err, data) => {\n" + " if (err) {\n" " callback(err);\n" - " }\n" - " }\n" - " _final(callback) {\n" - " if (this._flushCalled) {\n" - " callback();\n" " return;\n" " }\n" - " this._flushCalled = true;\n" - " if (this._flush) {\n" - " try {\n" - " this._flush.call(this, (err, data) => {\n" - " if (err) {\n" - " callback(err);\n" - " return;\n" - " }\n" - " if (data !== undefined && data !== null) this.push(data);\n" - " this.push(null);\n" - " callback();\n" - " });\n" - " } catch (err) {\n" + " if (data !== undefined && data !== null) this.push(data);\n" + " callback();\n" + " });\n" + " } catch (err) {\n" + " callback(err);\n" + " }\n" + " }\n" + " _final(callback) {\n" + " if (this._flushCalled) {\n" + " callback();\n" + " return;\n" + " }\n" + " this._flushCalled = true;\n" + " if (this._flush) {\n" + " try {\n" + " this._flush.call(this, (err, data) => {\n" + " if (err) {\n" " callback(err);\n" + " return;\n" " }\n" - " } else {\n" + " if (data !== undefined && data !== null) this.push(data);\n" " this.push(null);\n" " callback();\n" + " });\n" + " } catch (err) {\n" + " callback(err);\n" " }\n" + " } else {\n" + " this.push(null);\n" + " callback();\n" + " }\n" " }\n" " }\n" " class PassThrough extends Transform {\n" " _transform(chunk, encoding, callback) {\n" - " callback(null, chunk);\n" + " callback(null, chunk);\n" " }\n" " }\n" " const isReadableLike = (s) => s instanceof Readable || (s && typeof s.on === \"function\" && typeof s.read === \"function\" && typeof s.write !== \"function\");\n" " const finished = (stream, opts, callback) => {\n" " if (typeof opts === \"function\") {\n" - " callback = opts;\n" - " opts = {};\n" + " callback = opts;\n" + " opts = {};\n" " }\n" " let called = false;\n" " const done = (err) => {\n" - " if (called) return;\n" - " called = true;\n" - " cleanup();\n" - " callback.call(stream, err);\n" - " };\n" + " if (called) return;\n" + " called = true;\n" + " cleanup();\n" + " callback.call(stream, err);\n" + " };\n" " const readable = typeof stream.push === \"function\" || typeof stream.read === \"function\";\n" " const writable = typeof stream.write === \"function\";\n" " let readableEnded = !readable || stream._rEmittedEnd === true;\n" " let writableFinished = !writable || stream._wFinished === true;\n" " const onEnd = () => {\n" - " readableEnded = true;\n" - " if (writableFinished) done(null);\n" - " };\n" + " readableEnded = true;\n" + " if (writableFinished) done(null);\n" + " };\n" " const onFinish = () => {\n" - " writableFinished = true;\n" - " if (readableEnded) done(null);\n" - " };\n" + " writableFinished = true;\n" + " if (readableEnded) done(null);\n" + " };\n" " const onError = (err) => done(err);\n" " const onClose = () => {\n" - " if (readableEnded && writableFinished) {\n" - " done(null);\n" - " } else if (stream.destroyed && stream.errored) {\n" - " done(stream.errored);\n" - " } else {\n" - " done(ERR_PREMATURE());\n" - " }\n" - " };\n" - " const cleanup = () => {\n" - " stream.removeListener(\"end\", onEnd);\n" - " stream.removeListener(\"finish\", onFinish);\n" - " stream.removeListener(\"error\", onError);\n" - " stream.removeListener(\"close\", onClose);\n" - " };\n" " if (readableEnded && writableFinished) {\n" - " nextTick(() => done(null));\n" - " return () => {};\n" + " done(null);\n" + " } else if (stream.destroyed && stream.errored) {\n" + " done(stream.errored);\n" + " } else {\n" + " done(ERR_PREMATURE());\n" + " }\n" + " };\n" + " const cleanup = () => {\n" + " stream.removeListener(\"end\", onEnd);\n" + " stream.removeListener(\"finish\", onFinish);\n" + " stream.removeListener(\"error\", onError);\n" + " stream.removeListener(\"close\", onClose);\n" + " };\n" + " if (readableEnded && writableFinished) {\n" + " nextTick(() => done(null));\n" + " return () => {};\n" " }\n" " if (stream.destroyed) {\n" - " nextTick(() => onClose());\n" - " return () => {};\n" + " nextTick(() => onClose());\n" + " return () => {};\n" " }\n" " stream.on(\"end\", onEnd);\n" " stream.on(\"finish\", onFinish);\n" @@ -6910,84 +6910,84 @@ static const char isl_modules_bootstrap[] = " const pipeline = (...args) => {\n" " const callback = args.pop();\n" " if (typeof callback !== \"function\") {\n" - " const e = new TypeError('The \"callback\" argument must be of type function');\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" + " const e = new TypeError('The \"callback\" argument must be of type function');\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" " }\n" " let streams = Array.isArray(args[0]) && args.length === 1 ? args[0] : args;\n" " if (streams.length < 2) {\n" - " const e = new TypeError(\"The `streams` argument must be specified\");\n" - " e.code = \"ERR_MISSING_ARGS\";\n" - " throw e;\n" + " const e = new TypeError(\"The `streams` argument must be specified\");\n" + " e.code = \"ERR_MISSING_ARGS\";\n" + " throw e;\n" " }\n" " if (typeof streams[0][Symbol.asyncIterator] === \"function\" && typeof streams[0].pipe !== \"function\") {\n" - " streams = [Readable.from(streams[0]), ...streams.slice(1)];\n" + " streams = [Readable.from(streams[0]), ...streams.slice(1)];\n" " } else if (typeof streams[0][Symbol.iterator] === \"function\" && typeof streams[0].pipe !== \"function\" && typeof streams[0] !== \"string\") {\n" - " streams = [Readable.from(streams[0]), ...streams.slice(1)];\n" + " streams = [Readable.from(streams[0]), ...streams.slice(1)];\n" " }\n" " let settled = false;\n" " const tail = streams[streams.length - 1];\n" " const settle = (err) => {\n" - " if (settled) return;\n" - " settled = true;\n" - " if (err) {\n" - " for (const s of streams) {\n" - " if (typeof s.destroy === \"function\" && !s.destroyed) s.destroy(err);\n" - " }\n" + " if (settled) return;\n" + " settled = true;\n" + " if (err) {\n" + " for (const s of streams) {\n" + " if (typeof s.destroy === \"function\" && !s.destroyed) s.destroy(err);\n" " }\n" - " callback(err || null);\n" - " };\n" + " }\n" + " callback(err || null);\n" + " };\n" " for (let i = 0; i < streams.length; i++) {\n" - " streams[i].on(\"error\", (err) => settle(err));\n" + " streams[i].on(\"error\", (err) => settle(err));\n" " }\n" " finished(tail, (err) => settle(err));\n" " for (let i = 0; i < streams.length - 1; i++) {\n" - " streams[i].pipe(streams[i + 1]);\n" + " streams[i].pipe(streams[i + 1]);\n" " }\n" " return tail;\n" " };\n" " const promises = {\n" " pipeline: (...streams) => new Promise((resolve, reject) => {\n" - " pipeline(...streams, (err) => (err ? reject(err) : resolve()));\n" + " pipeline(...streams, (err) => (err ? reject(err) : resolve()));\n" " }),\n" " finished: (stream, opts) => new Promise((resolve, reject) => {\n" - " finished(stream, opts || {}, (err) => (err ? reject(err) : resolve()));\n" + " finished(stream, opts || {}, (err) => (err ? reject(err) : resolve()));\n" " }),\n" " };\n" " const consumers = {\n" " text: async (stream) => {\n" - " let out = \"\";\n" - " const dec = new StringDecoder(\"utf8\");\n" - " for await (const chunk of stream) {\n" - " out += typeof chunk === \"string\" ? chunk : dec.write(chunk);\n" - " }\n" - " out += dec.end();\n" - " return out;\n" + " let out = \"\";\n" + " const dec = new StringDecoder(\"utf8\");\n" + " for await (const chunk of stream) {\n" + " out += typeof chunk === \"string\" ? chunk : dec.write(chunk);\n" + " }\n" + " out += dec.end();\n" + " return out;\n" " },\n" " buffer: async (stream) => {\n" - " const parts = [];\n" - " for await (const chunk of stream) {\n" - " parts.push(typeof chunk === \"string\" ? Buffer.from(chunk) : Buffer.from(chunk.buffer === undefined ? chunk : chunk));\n" - " }\n" - " return Buffer.concat(parts);\n" + " const parts = [];\n" + " for await (const chunk of stream) {\n" + " parts.push(typeof chunk === \"string\" ? Buffer.from(chunk) : Buffer.from(chunk.buffer === undefined ? chunk : chunk));\n" + " }\n" + " return Buffer.concat(parts);\n" " },\n" " arrayBuffer: async (stream) => {\n" - " const buf = await consumers.buffer(stream);\n" - " return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n" + " const buf = await consumers.buffer(stream);\n" + " return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n" " },\n" " json: async (stream) => JSON.parse(await consumers.text(stream)),\n" " blob: async () => {\n" - " throw new Error(\"stream.consumers.blob is not available in the scriptc island\");\n" + " throw new Error(\"stream.consumers.blob is not available in the scriptc island\");\n" " },\n" " };\n" " const addAbortSignal = (signal, stream) => {\n" " if (signal && typeof signal.addEventListener === \"function\") {\n" - " signal.addEventListener(\"abort\", () => {\n" - " const e = new Error(\"The operation was aborted\");\n" - " e.code = \"ABORT_ERR\";\n" - " e.name = \"AbortError\";\n" - " stream.destroy(e);\n" - " });\n" + " signal.addEventListener(\"abort\", () => {\n" + " const e = new Error(\"The operation was aborted\");\n" + " e.code = \"ABORT_ERR\";\n" + " e.name = \"AbortError\";\n" + " stream.destroy(e);\n" + " });\n" " }\n" " return stream;\n" " };\n" @@ -7024,20 +7024,20 @@ static const char isl_modules_bootstrap[] = " const Buffer = builtins.buffer().Buffer;\n" " const SD = builtins.string_decoder().StringDecoder;\n" " const text = async (stream) => {\n" - " let out = '';\n" - " const d = new SD('utf8');\n" - " for await (const chunk of stream) out += typeof chunk === 'string' ? chunk : d.write(chunk);\n" - " return out + d.end();\n" - " };\n" + " let out = '';\n" + " const d = new SD('utf8');\n" + " for await (const chunk of stream) out += typeof chunk === 'string' ? chunk : d.write(chunk);\n" + " return out + d.end();\n" + " };\n" " const buffer = async (stream) => {\n" - " const parts = [];\n" - " for await (const chunk of stream) parts.push(typeof chunk === 'string' ? Buffer.from(chunk) : Buffer.from(chunk));\n" - " return Buffer.concat(parts);\n" - " };\n" + " const parts = [];\n" + " for await (const chunk of stream) parts.push(typeof chunk === 'string' ? Buffer.from(chunk) : Buffer.from(chunk));\n" + " return Buffer.concat(parts);\n" + " };\n" " const arrayBuffer = async (stream) => {\n" - " const b = await buffer(stream);\n" - " return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);\n" - " };\n" + " const b = await buffer(stream);\n" + " return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);\n" + " };\n" " const json = async (stream) => JSON.parse(await text(stream));\n" " const blob = async () => { throw new Error('stream.consumers.blob is not available in the scriptc island'); };\n" " const c = { text, buffer, arrayBuffer, json, blob };\n" @@ -7048,9 +7048,9 @@ static const char isl_modules_bootstrap[] = " builtins['stream/web'] = memo(() => {\n" " const g = globalThis;\n" " const w = {\n" - " ReadableStream: g.ReadableStream, TransformStream: g.TransformStream,\n" - " TextDecoderStream: g.TextDecoderStream,\n" - " };\n" + " ReadableStream: g.ReadableStream, TransformStream: g.TransformStream,\n" + " TextDecoderStream: g.TextDecoderStream,\n" + " };\n" " w.default = w;\n" " return w;\n" " });\n" @@ -7065,72 +7065,72 @@ static const char isl_modules_bootstrap[] = " const inspect = env.inspect;\n" " class AssertionError extends Error {\n" " constructor(options) {\n" - " const opts = options || {};\n" - " let message = opts.message;\n" - " let generated = false;\n" - " if (message === undefined || message === null) {\n" - " generated = true;\n" - " const a = inspect(opts.actual, { depth: 2 });\n" - " const b = inspect(opts.expected, { depth: 2 });\n" - " switch (opts.operator) {\n" - " case \"strictEqual\":\n" - " message = \"Expected values to be strictly equal:\\n\\n\" + a + \" !== \" + b + \"\\n\";\n" - " break;\n" - " case \"notStrictEqual\":\n" - " message = \"Expected \\\"actual\\\" to be strictly unequal to: \" + b;\n" - " break;\n" - " case \"deepStrictEqual\":\n" - " message = \"Expected values to be strictly deep-equal:\\n\\n\" + a + \" !== \" + b + \"\\n\";\n" - " break;\n" - " case \"notDeepStrictEqual\":\n" - " message = \"Expected \\\"actual\\\" not to be strictly deep-equal to:\\n\\n\" + b + \"\\n\";\n" - " break;\n" - " case \"==\":\n" - " message = \"Expected values to be loosely equal:\\n\\n\" + a + \" != \" + b + \"\\n\";\n" - " break;\n" - " case \"!=\":\n" - " message = \"Expected \\\"actual\\\" to be loosely unequal to:\\n\\n\" + b + \"\\n\";\n" - " break;\n" - " case \"fail\":\n" - " message = \"Failed\";\n" - " break;\n" - " default:\n" - " message = a + \" \" + (opts.operator || \"==\") + \" \" + b;\n" - " }\n" - " } else if (message instanceof Error) {\n" - " throw message;\n" + " const opts = options || {};\n" + " let message = opts.message;\n" + " let generated = false;\n" + " if (message === undefined || message === null) {\n" + " generated = true;\n" + " const a = inspect(opts.actual, { depth: 2 });\n" + " const b = inspect(opts.expected, { depth: 2 });\n" + " switch (opts.operator) {\n" + " case \"strictEqual\":\n" + " message = \"Expected values to be strictly equal:\\n\\n\" + a + \" !== \" + b + \"\\n\";\n" + " break;\n" + " case \"notStrictEqual\":\n" + " message = \"Expected \\\"actual\\\" to be strictly unequal to: \" + b;\n" + " break;\n" + " case \"deepStrictEqual\":\n" + " message = \"Expected values to be strictly deep-equal:\\n\\n\" + a + \" !== \" + b + \"\\n\";\n" + " break;\n" + " case \"notDeepStrictEqual\":\n" + " message = \"Expected \\\"actual\\\" not to be strictly deep-equal to:\\n\\n\" + b + \"\\n\";\n" + " break;\n" + " case \"==\":\n" + " message = \"Expected values to be loosely equal:\\n\\n\" + a + \" != \" + b + \"\\n\";\n" + " break;\n" + " case \"!=\":\n" + " message = \"Expected \\\"actual\\\" to be loosely unequal to:\\n\\n\" + b + \"\\n\";\n" + " break;\n" + " case \"fail\":\n" + " message = \"Failed\";\n" + " break;\n" + " default:\n" + " message = a + \" \" + (opts.operator || \"==\") + \" \" + b;\n" " }\n" - " super(String(message));\n" - " this.name = \"AssertionError\";\n" - " this.code = \"ERR_ASSERTION\";\n" - " this.actual = opts.actual;\n" - " this.expected = opts.expected;\n" - " this.operator = opts.operator;\n" - " this.generatedMessage = opts.generatedMessage !== undefined ? opts.generatedMessage : generated;\n" + " } else if (message instanceof Error) {\n" + " throw message;\n" + " }\n" + " super(String(message));\n" + " this.name = \"AssertionError\";\n" + " this.code = \"ERR_ASSERTION\";\n" + " this.actual = opts.actual;\n" + " this.expected = opts.expected;\n" + " this.operator = opts.operator;\n" + " this.generatedMessage = opts.generatedMessage !== undefined ? opts.generatedMessage : generated;\n" " }\n" " }\n" " function fail(actual, expected, message, operator) {\n" " const argsLen = arguments.length;\n" " if (argsLen === 0) {\n" - " throw new AssertionError({ message: \"Failed\", operator: \"fail\", generatedMessage: true });\n" + " throw new AssertionError({ message: \"Failed\", operator: \"fail\", generatedMessage: true });\n" " }\n" " if (argsLen === 1) {\n" - " throw new AssertionError({ message: actual === undefined ? \"Failed\" : actual, operator: \"fail\", generatedMessage: actual === undefined });\n" + " throw new AssertionError({ message: actual === undefined ? \"Failed\" : actual, operator: \"fail\", generatedMessage: actual === undefined });\n" " }\n" " if (argsLen === 2) operator = \"!=\";\n" " throw new AssertionError({ message, actual, expected, operator: operator || \"fail\" });\n" " }\n" " const innerOk = (value, message) => {\n" " if (!value) {\n" - " if (message instanceof Error) throw message;\n" - " throw new AssertionError({\n" - " message: message !== undefined ? message\n" - " : \"The expression evaluated to a falsy value\",\n" - " actual: value,\n" - " expected: true,\n" - " operator: \"==\",\n" - " generatedMessage: message === undefined,\n" - " });\n" + " if (message instanceof Error) throw message;\n" + " throw new AssertionError({\n" + " message: message !== undefined ? message\n" + " : \"The expression evaluated to a falsy value\",\n" + " actual: value,\n" + " expected: true,\n" + " operator: \"==\",\n" + " generatedMessage: message === undefined,\n" + " });\n" " }\n" " };\n" " function ok(value, message) {\n" @@ -7150,58 +7150,58 @@ static const char isl_modules_bootstrap[] = " if (seen.has(a)) return true;\n" " seen.add(a);\n" " if (Array.isArray(a)) {\n" - " if (!Array.isArray(b) || a.length !== b.length) return false;\n" - " for (let i = 0; i < a.length; i++) {\n" - " if (!looseDeep(a[i], b[i], seen)) return false;\n" - " }\n" - " return true;\n" + " if (!Array.isArray(b) || a.length !== b.length) return false;\n" + " for (let i = 0; i < a.length; i++) {\n" + " if (!looseDeep(a[i], b[i], seen)) return false;\n" + " }\n" + " return true;\n" " }\n" " if (a instanceof Map) {\n" - " if (a.size !== b.size) return false;\n" - " for (const [k, v] of a) {\n" - " if (!b.has(k) || !looseDeep(v, b.get(k), seen)) return false;\n" - " }\n" - " return true;\n" + " if (a.size !== b.size) return false;\n" + " for (const [k, v] of a) {\n" + " if (!b.has(k) || !looseDeep(v, b.get(k), seen)) return false;\n" + " }\n" + " return true;\n" " }\n" " if (a instanceof Set) {\n" - " if (a.size !== b.size) return false;\n" - " for (const v of a) {\n" - " if (!b.has(v)) return false;\n" - " }\n" - " return true;\n" + " if (a.size !== b.size) return false;\n" + " for (const v of a) {\n" + " if (!b.has(v)) return false;\n" + " }\n" + " return true;\n" " }\n" " const ka = Object.keys(a);\n" " const kb = Object.keys(b);\n" " if (ka.length !== kb.length) return false;\n" " for (const k of ka) {\n" - " if (!Object.prototype.hasOwnProperty.call(b, k)) return false;\n" - " if (!looseDeep(a[k], b[k], seen)) return false;\n" + " if (!Object.prototype.hasOwnProperty.call(b, k)) return false;\n" + " if (!looseDeep(a[k], b[k], seen)) return false;\n" " }\n" " return true;\n" " };\n" " const checkExpected = (actual, expected, message, fnName) => {\n" " if (typeof expected === \"function\") {\n" - " if (expected.prototype !== undefined && actual instanceof expected) return true;\n" - " if (Error.isPrototypeOf ? Object.getPrototypeOf(expected) === null : false) return false;\n" - " if (!(expected === Error || Error.prototype.isPrototypeOf(expected.prototype || {}))) {\n" - " return expected(actual) === true;\n" - " }\n" - " return actual instanceof expected;\n" + " if (expected.prototype !== undefined && actual instanceof expected) return true;\n" + " if (Error.isPrototypeOf ? Object.getPrototypeOf(expected) === null : false) return false;\n" + " if (!(expected === Error || Error.prototype.isPrototypeOf(expected.prototype || {}))) {\n" + " return expected(actual) === true;\n" + " }\n" + " return actual instanceof expected;\n" " }\n" " if (expected instanceof RegExp) {\n" - " return expected.test(actual instanceof Error ? actual.message : String(actual));\n" + " return expected.test(actual instanceof Error ? actual.message : String(actual));\n" " }\n" " if (expected !== null && typeof expected === \"object\") {\n" - " for (const k of Object.keys(expected)) {\n" - " const want = expected[k];\n" - " const got = actual[k];\n" - " if (want instanceof RegExp) {\n" - " if (!want.test(got)) return false;\n" - " } else if (!isDeepStrictEqual(got, want)) {\n" - " return false;\n" - " }\n" + " for (const k of Object.keys(expected)) {\n" + " const want = expected[k];\n" + " const got = actual[k];\n" + " if (want instanceof RegExp) {\n" + " if (!want.test(got)) return false;\n" + " } else if (!isDeepStrictEqual(got, want)) {\n" + " return false;\n" " }\n" - " return true;\n" + " }\n" + " return true;\n" " }\n" " void message;\n" " void fnName;\n" @@ -7209,213 +7209,213 @@ static const char isl_modules_bootstrap[] = " };\n" " const mismatchError = (thrown, expected, operator) => {\n" " if (typeof expected === \"function\" && (expected === Error || Error.prototype.isPrototypeOf(expected.prototype || {}))) {\n" - " return new AssertionError({\n" - " message: 'The error is expected to be an instance of \"' + expected.name + '\". Received \"' + (thrown && thrown.constructor && thrown.constructor.name) + '\"\\n\\nError message:\\n\\n' + (thrown && thrown.message),\n" - " actual: thrown,\n" - " expected,\n" - " operator,\n" - " generatedMessage: true,\n" - " });\n" - " }\n" - " if (expected instanceof RegExp) {\n" - " return new AssertionError({\n" - " message: \"The input did not match the regular expression \" + expected + \". Input:\\n\\n\" + inspect(thrown instanceof Error ? String(thrown) : thrown) + \"\\n\",\n" - " actual: thrown,\n" - " expected,\n" - " operator,\n" - " generatedMessage: true,\n" - " });\n" - " }\n" " return new AssertionError({\n" - " message: \"Expected values to be strictly deep-equal:\\n+ actual - expected\\n\",\n" + " message: 'The error is expected to be an instance of \"' + expected.name + '\". Received \"' + (thrown && thrown.constructor && thrown.constructor.name) + '\"\\n\\nError message:\\n\\n' + (thrown && thrown.message),\n" " actual: thrown,\n" " expected,\n" " operator,\n" " generatedMessage: true,\n" " });\n" + " }\n" + " if (expected instanceof RegExp) {\n" + " return new AssertionError({\n" + " message: \"The input did not match the regular expression \" + expected + \". Input:\\n\\n\" + inspect(thrown instanceof Error ? String(thrown) : thrown) + \"\\n\",\n" + " actual: thrown,\n" + " expected,\n" + " operator,\n" + " generatedMessage: true,\n" + " });\n" + " }\n" + " return new AssertionError({\n" + " message: \"Expected values to be strictly deep-equal:\\n+ actual - expected\\n\",\n" + " actual: thrown,\n" + " expected,\n" + " operator,\n" + " generatedMessage: true,\n" + " });\n" " };\n" " const assert = Object.assign(ok, {\n" " AssertionError,\n" " ok,\n" " fail,\n" " equal(actual, expected, message) {\n" - " if (actual != expected && !(Number.isNaN(actual) && Number.isNaN(expected))) {\n" - " throw new AssertionError({ message, actual, expected, operator: \"==\" });\n" - " }\n" + " if (actual != expected && !(Number.isNaN(actual) && Number.isNaN(expected))) {\n" + " throw new AssertionError({ message, actual, expected, operator: \"==\" });\n" + " }\n" " },\n" " notEqual(actual, expected, message) {\n" - " if (actual == expected || (Number.isNaN(actual) && Number.isNaN(expected))) {\n" - " throw new AssertionError({ message, actual, expected, operator: \"!=\" });\n" - " }\n" + " if (actual == expected || (Number.isNaN(actual) && Number.isNaN(expected))) {\n" + " throw new AssertionError({ message, actual, expected, operator: \"!=\" });\n" + " }\n" " },\n" " strictEqual(actual, expected, message) {\n" - " if (!Object.is(actual, expected)) {\n" - " throw new AssertionError({ message, actual, expected, operator: \"strictEqual\" });\n" - " }\n" + " if (!Object.is(actual, expected)) {\n" + " throw new AssertionError({ message, actual, expected, operator: \"strictEqual\" });\n" + " }\n" " },\n" " notStrictEqual(actual, expected, message) {\n" - " if (Object.is(actual, expected)) {\n" - " throw new AssertionError({ message, actual, expected, operator: \"notStrictEqual\" });\n" - " }\n" + " if (Object.is(actual, expected)) {\n" + " throw new AssertionError({ message, actual, expected, operator: \"notStrictEqual\" });\n" + " }\n" " },\n" " deepEqual(actual, expected, message) {\n" - " if (!looseDeep(actual, expected)) {\n" - " throw new AssertionError({ message, actual, expected, operator: \"deepEqual\" });\n" - " }\n" + " if (!looseDeep(actual, expected)) {\n" + " throw new AssertionError({ message, actual, expected, operator: \"deepEqual\" });\n" + " }\n" " },\n" " notDeepEqual(actual, expected, message) {\n" - " if (looseDeep(actual, expected)) {\n" - " throw new AssertionError({ message, actual, expected, operator: \"notDeepEqual\" });\n" - " }\n" + " if (looseDeep(actual, expected)) {\n" + " throw new AssertionError({ message, actual, expected, operator: \"notDeepEqual\" });\n" + " }\n" " },\n" " deepStrictEqual(actual, expected, message) {\n" - " if (!isDeepStrictEqual(actual, expected)) {\n" - " throw new AssertionError({ message, actual, expected, operator: \"deepStrictEqual\" });\n" - " }\n" + " if (!isDeepStrictEqual(actual, expected)) {\n" + " throw new AssertionError({ message, actual, expected, operator: \"deepStrictEqual\" });\n" + " }\n" " },\n" " notDeepStrictEqual(actual, expected, message) {\n" - " if (isDeepStrictEqual(actual, expected)) {\n" - " throw new AssertionError({ message, actual, expected, operator: \"notDeepStrictEqual\" });\n" - " }\n" + " if (isDeepStrictEqual(actual, expected)) {\n" + " throw new AssertionError({ message, actual, expected, operator: \"notDeepStrictEqual\" });\n" + " }\n" " },\n" " throws(fn, expected, message) {\n" - " if (typeof expected === \"string\") {\n" - " message = expected;\n" - " expected = undefined;\n" - " }\n" - " let thrown = null;\n" - " let did = false;\n" - " try {\n" - " fn();\n" - " } catch (e) {\n" - " did = true;\n" - " thrown = e;\n" - " }\n" - " if (!did) {\n" - " throw new AssertionError({\n" - " message: \"Missing expected exception\" + (message ? \": \" + message : \".\"),\n" - " operator: \"throws\",\n" - " });\n" - " }\n" - " if (expected !== undefined && !checkExpected(thrown, expected, message, \"throws\")) {\n" - " throw mismatchError(thrown, expected, \"throws\");\n" - " }\n" + " if (typeof expected === \"string\") {\n" + " message = expected;\n" + " expected = undefined;\n" + " }\n" + " let thrown = null;\n" + " let did = false;\n" + " try {\n" + " fn();\n" + " } catch (e) {\n" + " did = true;\n" + " thrown = e;\n" + " }\n" + " if (!did) {\n" + " throw new AssertionError({\n" + " message: \"Missing expected exception\" + (message ? \": \" + message : \".\"),\n" + " operator: \"throws\",\n" + " });\n" + " }\n" + " if (expected !== undefined && !checkExpected(thrown, expected, message, \"throws\")) {\n" + " throw mismatchError(thrown, expected, \"throws\");\n" + " }\n" " },\n" " doesNotThrow(fn, expected, message) {\n" - " if (typeof expected === \"string\") {\n" - " message = expected;\n" - " expected = undefined;\n" - " }\n" - " try {\n" - " fn();\n" - " } catch (e) {\n" - " if (expected === undefined || checkExpected(e, expected, message, \"doesNotThrow\")) {\n" - " throw new AssertionError({\n" - " message: \"Got unwanted exception\" + (message ? \": \" + message : \".\") + \"\\nActual message: \\\"\" + (e && e.message) + \"\\\"\",\n" - " operator: \"doesNotThrow\",\n" - " });\n" - " }\n" - " throw e;\n" + " if (typeof expected === \"string\") {\n" + " message = expected;\n" + " expected = undefined;\n" + " }\n" + " try {\n" + " fn();\n" + " } catch (e) {\n" + " if (expected === undefined || checkExpected(e, expected, message, \"doesNotThrow\")) {\n" + " throw new AssertionError({\n" + " message: \"Got unwanted exception\" + (message ? \": \" + message : \".\") + \"\\nActual message: \\\"\" + (e && e.message) + \"\\\"\",\n" + " operator: \"doesNotThrow\",\n" + " });\n" " }\n" + " throw e;\n" + " }\n" " },\n" " async rejects(promiseOrFn, expected, message) {\n" - " if (typeof expected === \"string\") {\n" - " message = expected;\n" - " expected = undefined;\n" - " }\n" - " let rejection = null;\n" - " let did = false;\n" - " try {\n" - " await (typeof promiseOrFn === \"function\" ? promiseOrFn() : promiseOrFn);\n" - " } catch (e) {\n" - " did = true;\n" - " rejection = e;\n" - " }\n" - " if (!did) {\n" - " throw new AssertionError({\n" - " message: \"Missing expected rejection\" + (message ? \": \" + message : \".\"),\n" - " operator: \"rejects\",\n" - " });\n" - " }\n" - " if (expected !== undefined && !checkExpected(rejection, expected, message, \"rejects\")) {\n" - " throw mismatchError(rejection, expected, \"rejects\");\n" - " }\n" + " if (typeof expected === \"string\") {\n" + " message = expected;\n" + " expected = undefined;\n" + " }\n" + " let rejection = null;\n" + " let did = false;\n" + " try {\n" + " await (typeof promiseOrFn === \"function\" ? promiseOrFn() : promiseOrFn);\n" + " } catch (e) {\n" + " did = true;\n" + " rejection = e;\n" + " }\n" + " if (!did) {\n" + " throw new AssertionError({\n" + " message: \"Missing expected rejection\" + (message ? \": \" + message : \".\"),\n" + " operator: \"rejects\",\n" + " });\n" + " }\n" + " if (expected !== undefined && !checkExpected(rejection, expected, message, \"rejects\")) {\n" + " throw mismatchError(rejection, expected, \"rejects\");\n" + " }\n" " },\n" " async doesNotReject(promiseOrFn, expected, message) {\n" - " if (typeof expected === \"string\") {\n" - " message = expected;\n" - " expected = undefined;\n" - " }\n" - " try {\n" - " await (typeof promiseOrFn === \"function\" ? promiseOrFn() : promiseOrFn);\n" - " } catch (e) {\n" - " if (expected === undefined || checkExpected(e, expected, message, \"doesNotReject\")) {\n" - " throw new AssertionError({\n" - " message: \"Got unwanted rejection\" + (message ? \": \" + message : \".\") + \"\\nActual message: \\\"\" + (e && e.message) + \"\\\"\",\n" - " operator: \"doesNotReject\",\n" - " });\n" - " }\n" - " throw e;\n" + " if (typeof expected === \"string\") {\n" + " message = expected;\n" + " expected = undefined;\n" + " }\n" + " try {\n" + " await (typeof promiseOrFn === \"function\" ? promiseOrFn() : promiseOrFn);\n" + " } catch (e) {\n" + " if (expected === undefined || checkExpected(e, expected, message, \"doesNotReject\")) {\n" + " throw new AssertionError({\n" + " message: \"Got unwanted rejection\" + (message ? \": \" + message : \".\") + \"\\nActual message: \\\"\" + (e && e.message) + \"\\\"\",\n" + " operator: \"doesNotReject\",\n" + " });\n" " }\n" + " throw e;\n" + " }\n" " },\n" " match(string, regexp, message) {\n" - " if (!(regexp instanceof RegExp)) {\n" - " const e = new TypeError('The \"regexp\" argument must be an instance of RegExp. Received ' + (regexp === null ? \"null\" : \"type \" + typeof regexp + \" ('\" + String(regexp) + \"')\"));\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" - " }\n" - " if (typeof string !== \"string\" || !regexp.test(string)) {\n" - " throw new AssertionError({\n" - " message: message !== undefined ? message\n" - " : typeof string !== \"string\"\n" - " ? 'The \"string\" argument must be of type string. Received type ' + typeof string + \" (\" + inspect(string) + \")\"\n" - " : \"The input did not match the regular expression \" + regexp + \". Input:\\n\\n\" + inspect(string) + \"\\n\",\n" - " actual: string,\n" - " expected: regexp,\n" - " operator: \"match\",\n" - " generatedMessage: message === undefined,\n" - " });\n" - " }\n" + " if (!(regexp instanceof RegExp)) {\n" + " const e = new TypeError('The \"regexp\" argument must be an instance of RegExp. Received ' + (regexp === null ? \"null\" : \"type \" + typeof regexp + \" ('\" + String(regexp) + \"')\"));\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" + " }\n" + " if (typeof string !== \"string\" || !regexp.test(string)) {\n" + " throw new AssertionError({\n" + " message: message !== undefined ? message\n" + " : typeof string !== \"string\"\n" + " ? 'The \"string\" argument must be of type string. Received type ' + typeof string + \" (\" + inspect(string) + \")\"\n" + " : \"The input did not match the regular expression \" + regexp + \". Input:\\n\\n\" + inspect(string) + \"\\n\",\n" + " actual: string,\n" + " expected: regexp,\n" + " operator: \"match\",\n" + " generatedMessage: message === undefined,\n" + " });\n" + " }\n" " },\n" " doesNotMatch(string, regexp, message) {\n" - " if (!(regexp instanceof RegExp)) {\n" - " const e = new TypeError('The \"regexp\" argument must be an instance of RegExp. Received ' + (regexp === null ? \"null\" : \"type \" + typeof regexp + \" ('\" + String(regexp) + \"')\"));\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" - " }\n" - " if (typeof string === \"string\" && regexp.test(string)) {\n" - " throw new AssertionError({\n" - " message: message !== undefined ? message\n" - " : \"The input was expected to not match the regular expression \" + regexp + \". Input:\\n\\n\" + inspect(string) + \"\\n\",\n" - " actual: string,\n" - " expected: regexp,\n" - " operator: \"doesNotMatch\",\n" - " generatedMessage: message === undefined,\n" - " });\n" - " }\n" + " if (!(regexp instanceof RegExp)) {\n" + " const e = new TypeError('The \"regexp\" argument must be an instance of RegExp. Received ' + (regexp === null ? \"null\" : \"type \" + typeof regexp + \" ('\" + String(regexp) + \"')\"));\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" + " }\n" + " if (typeof string === \"string\" && regexp.test(string)) {\n" + " throw new AssertionError({\n" + " message: message !== undefined ? message\n" + " : \"The input was expected to not match the regular expression \" + regexp + \". Input:\\n\\n\" + inspect(string) + \"\\n\",\n" + " actual: string,\n" + " expected: regexp,\n" + " operator: \"doesNotMatch\",\n" + " generatedMessage: message === undefined,\n" + " });\n" + " }\n" " },\n" " ifError(value) {\n" - " if (value !== null && value !== undefined) {\n" - " const e = new AssertionError({\n" - " message: \"ifError got unwanted exception: \" + (value instanceof Error && typeof value.message === \"string\" ? (value.message === \"\" ? value.constructor.name : value.message) : inspect(value)),\n" - " actual: value,\n" - " expected: null,\n" - " operator: \"ifError\",\n" - " });\n" - " throw e;\n" - " }\n" + " if (value !== null && value !== undefined) {\n" + " const e = new AssertionError({\n" + " message: \"ifError got unwanted exception: \" + (value instanceof Error && typeof value.message === \"string\" ? (value.message === \"\" ? value.constructor.name : value.message) : inspect(value)),\n" + " actual: value,\n" + " expected: null,\n" + " operator: \"ifError\",\n" + " });\n" + " throw e;\n" + " }\n" " },\n" " });\n" " const strict = Object.assign(\n" " function strictOk(...args) {\n" - " return ok(...args);\n" + " return ok(...args);\n" " },\n" " assert,\n" " {\n" - " equal: assert.strictEqual,\n" - " notEqual: assert.notStrictEqual,\n" - " deepEqual: assert.deepStrictEqual,\n" - " notDeepEqual: assert.notDeepStrictEqual,\n" + " equal: assert.strictEqual,\n" + " notEqual: assert.notStrictEqual,\n" + " deepEqual: assert.deepStrictEqual,\n" + " notDeepEqual: assert.notDeepStrictEqual,\n" " },\n" " );\n" " strict.strict = strict;\n" @@ -7456,17 +7456,17 @@ static const char isl_modules_bootstrap[] = " const strEsc = (s, q) => {\n" " let out = \"\";\n" " for (let i = 0; i < s.length; i++) {\n" - " const c = s.charCodeAt(i);\n" - " const ch = s[i];\n" - " if (ch === q || ch === \"\\\\\") out += \"\\\\\" + ch;\n" - " else if (c === 10) out += \"\\\\n\";\n" - " else if (c === 9) out += \"\\\\t\";\n" - " else if (c === 13) out += \"\\\\r\";\n" - " else if (c === 8) out += \"\\\\b\";\n" - " else if (c === 12) out += \"\\\\f\";\n" - " else if (c === 11) out += \"\\\\v\";\n" - " else if (c < 32 || c === 127) out += \"\\\\x\" + c.toString(16).toUpperCase().padStart(2, \"0\");\n" - " else out += ch;\n" + " const c = s.charCodeAt(i);\n" + " const ch = s[i];\n" + " if (ch === q || ch === \"\\\\\") out += \"\\\\\" + ch;\n" + " else if (c === 10) out += \"\\\\n\";\n" + " else if (c === 9) out += \"\\\\t\";\n" + " else if (c === 13) out += \"\\\\r\";\n" + " else if (c === 8) out += \"\\\\b\";\n" + " else if (c === 12) out += \"\\\\f\";\n" + " else if (c === 11) out += \"\\\\v\";\n" + " else if (c < 32 || c === 127) out += \"\\\\x\" + c.toString(16).toUpperCase().padStart(2, \"0\");\n" + " else out += ch;\n" " }\n" " return out;\n" " };\n" @@ -7481,12 +7481,12 @@ static const char isl_modules_bootstrap[] = " const fmtPrimitive = (ctx, v) => {\n" " const t = typeof v;\n" " if (t === \"string\") {\n" - " if (v.length > ctx.maxStringLength) {\n" - " const rest = v.length - ctx.maxStringLength;\n" - " return quoteStr(v.slice(0, ctx.maxStringLength)) +\n" - " \"... \" + rest + \" more character\" + (rest > 1 ? \"s\" : \"\");\n" - " }\n" - " return quoteStr(v);\n" + " if (v.length > ctx.maxStringLength) {\n" + " const rest = v.length - ctx.maxStringLength;\n" + " return quoteStr(v.slice(0, ctx.maxStringLength)) +\n" + " \"... \" + rest + \" more character\" + (rest > 1 ? \"s\" : \"\");\n" + " }\n" + " return quoteStr(v);\n" " }\n" " if (t === \"number\") return fmtNumber(v);\n" " if (t === \"bigint\") return fmtBigInt(v);\n" @@ -7497,11 +7497,11 @@ static const char isl_modules_bootstrap[] = " const constructorNameOf = (v) => {\n" " let p = v;\n" " while (p !== null) {\n" - " const d = Object.getOwnPropertyDescriptor(p, \"constructor\");\n" - " if (d !== undefined && typeof d.value === \"function\" && d.value.name !== \"\") {\n" - " return d.value.name;\n" - " }\n" - " p = Object.getPrototypeOf(p);\n" + " const d = Object.getOwnPropertyDescriptor(p, \"constructor\");\n" + " if (d !== undefined && typeof d.value === \"function\" && d.value.name !== \"\") {\n" + " return d.value.name;\n" + " }\n" + " p = Object.getPrototypeOf(p);\n" " }\n" " return null;\n" " };\n" @@ -7509,10 +7509,10 @@ static const char isl_modules_bootstrap[] = " const s = Function.prototype.toString.call(v);\n" " let kind = \"Function\";\n" " if (s.startsWith(\"class\")) {\n" - " let base = \"class \" + (v.name || \"(anonymous)\");\n" - " const proto = Object.getPrototypeOf(v);\n" - " if (typeof proto === \"function\" && proto.name !== \"\") base += \" extends \" + proto.name;\n" - " return \"[\" + base + \"]\";\n" + " let base = \"class \" + (v.name || \"(anonymous)\");\n" + " const proto = Object.getPrototypeOf(v);\n" + " if (typeof proto === \"function\" && proto.name !== \"\") base += \" extends \" + proto.name;\n" + " return \"[\" + base + \"]\";\n" " }\n" " if (s.startsWith(\"async function\") || (s.startsWith(\"async\") && !s.startsWith(\"async function*\"))) kind = \"AsyncFunction\";\n" " if (s.startsWith(\"function*\") || /^async function\\*/.test(s)) kind = s.startsWith(\"async\") ? \"AsyncGeneratorFunction\" : \"GeneratorFunction\";\n" @@ -7531,23 +7531,23 @@ static const char isl_modules_bootstrap[] = " const keys = [];\n" " for (const k of Object.keys(v)) keys.push(k);\n" " for (const s of Object.getOwnPropertySymbols(v)) {\n" - " const d = Object.getOwnPropertyDescriptor(v, s);\n" - " if (d && d.enumerable) keys.push(s);\n" + " const d = Object.getOwnPropertyDescriptor(v, s);\n" + " if (d && d.enumerable) keys.push(s);\n" " }\n" " return keys;\n" " };\n" " const fmtProperty = (ctx, v, k, depth) => {\n" " const d = Object.getOwnPropertyDescriptor(v, k) ||\n" - " { value: v[k], enumerable: true };\n" + " { value: v[k], enumerable: true };\n" " let val;\n" " if (d.value !== undefined || (\"value\" in d)) {\n" - " val = fmtValue(ctx, d.value, depth + 1);\n" + " val = fmtValue(ctx, d.value, depth + 1);\n" " } else if (d.get !== undefined) {\n" - " val = d.set !== undefined ? \"[Getter/Setter]\" : \"[Getter]\";\n" + " val = d.set !== undefined ? \"[Getter/Setter]\" : \"[Getter]\";\n" " } else if (d.set !== undefined) {\n" - " val = \"[Setter]\";\n" + " val = \"[Setter]\";\n" " } else {\n" - " val = \"undefined\";\n" + " val = \"undefined\";\n" " }\n" " return keyOf(k) + \": \" + val;\n" " };\n" @@ -7565,100 +7565,100 @@ static const char isl_modules_bootstrap[] = " if (ctx.maxArrayLength < output.length) outputLength = output.length - 1;\n" " const dataLen = new Array(outputLength);\n" " for (; i < outputLength; i++) {\n" - " const len = output[i].length;\n" - " dataLen[i] = len;\n" - " totalLength += len + 2;\n" - " if (maxLength < len) maxLength = len;\n" + " const len = output[i].length;\n" + " dataLen[i] = len;\n" + " totalLength += len + 2;\n" + " if (maxLength < len) maxLength = len;\n" " }\n" " const actualMax = maxLength + 2;\n" " if (actualMax * 3 + ctx.indentationLvl < ctx.breakLength &&\n" - " (totalLength / actualMax > 5 || maxLength <= 6)) {\n" - " const approxCharHeights = 2.5;\n" - " const averageBias = Math.sqrt(actualMax - totalLength / output.length);\n" - " const biasedMax = Math.max(actualMax - 3 - averageBias, 1);\n" - " const columns = Math.min(\n" - " Math.round(Math.sqrt(approxCharHeights * biasedMax * outputLength) / biasedMax),\n" - " Math.floor((ctx.breakLength - ctx.indentationLvl) / actualMax),\n" - " ctx.compact * 4,\n" - " 15,\n" - " );\n" - " if (columns <= 1) return output;\n" - " const tmp = [];\n" - " const maxLineLength = [];\n" - " for (let ii = 0; ii < columns; ii++) {\n" - " let lineLength = 0;\n" - " for (let j = ii; j < output.length; j += columns) {\n" - " if (dataLen[j] > lineLength) lineLength = dataLen[j];\n" - " }\n" - " maxLineLength[ii] = lineLength + 2;\n" + " (totalLength / actualMax > 5 || maxLength <= 6)) {\n" + " const approxCharHeights = 2.5;\n" + " const averageBias = Math.sqrt(actualMax - totalLength / output.length);\n" + " const biasedMax = Math.max(actualMax - 3 - averageBias, 1);\n" + " const columns = Math.min(\n" + " Math.round(Math.sqrt(approxCharHeights * biasedMax * outputLength) / biasedMax),\n" + " Math.floor((ctx.breakLength - ctx.indentationLvl) / actualMax),\n" + " ctx.compact * 4,\n" + " 15,\n" + " );\n" + " if (columns <= 1) return output;\n" + " const tmp = [];\n" + " const maxLineLength = [];\n" + " for (let ii = 0; ii < columns; ii++) {\n" + " let lineLength = 0;\n" + " for (let j = ii; j < output.length; j += columns) {\n" + " if (dataLen[j] > lineLength) lineLength = dataLen[j];\n" " }\n" - " let order = String.prototype.padStart;\n" - " if (value !== undefined) {\n" - " for (let ii = 0; ii < output.length; ii++) {\n" - " if (typeof value[ii] !== \"number\" && typeof value[ii] !== \"bigint\") {\n" - " order = String.prototype.padEnd;\n" - " break;\n" - " }\n" - " }\n" + " maxLineLength[ii] = lineLength + 2;\n" + " }\n" + " let order = String.prototype.padStart;\n" + " if (value !== undefined) {\n" + " for (let ii = 0; ii < output.length; ii++) {\n" + " if (typeof value[ii] !== \"number\" && typeof value[ii] !== \"bigint\") {\n" + " order = String.prototype.padEnd;\n" + " break;\n" " }\n" - " for (let ii = 0; ii < outputLength; ii += columns) {\n" - " const max = Math.min(ii + columns, outputLength);\n" - " let str = \"\";\n" - " let j = ii;\n" - " for (; j < max - 1; j++) {\n" - " const padding = maxLineLength[j - ii] + output[j].length - dataLen[j];\n" - " str += order.call(output[j] + \", \", padding, \" \");\n" - " }\n" - " if (order === String.prototype.padStart) {\n" - " const padding = maxLineLength[j - ii] + output[j].length - dataLen[j] - 2;\n" - " str += output[j].padStart(padding, \" \");\n" - " } else {\n" - " str += output[j];\n" - " }\n" - " tmp.push(str);\n" " }\n" - " if (ctx.maxArrayLength < output.length) tmp.push(output[outputLength]);\n" - " output = tmp;\n" + " }\n" + " for (let ii = 0; ii < outputLength; ii += columns) {\n" + " const max = Math.min(ii + columns, outputLength);\n" + " let str = \"\";\n" + " let j = ii;\n" + " for (; j < max - 1; j++) {\n" + " const padding = maxLineLength[j - ii] + output[j].length - dataLen[j];\n" + " str += order.call(output[j] + \", \", padding, \" \");\n" + " }\n" + " if (order === String.prototype.padStart) {\n" + " const padding = maxLineLength[j - ii] + output[j].length - dataLen[j] - 2;\n" + " str += output[j].padStart(padding, \" \");\n" + " } else {\n" + " str += output[j];\n" + " }\n" + " tmp.push(str);\n" + " }\n" + " if (ctx.maxArrayLength < output.length) tmp.push(output[outputLength]);\n" + " output = tmp;\n" " }\n" " return output;\n" " };\n" " const reduceToSingleString = (ctx, output, base, braces, isArrayLike, depth, value) => {\n" " if (ctx.compact >= 1 && typeof ctx.compact === \"number\") {\n" - " const entries = output.length;\n" - " if (isArrayLike && entries > 6) output = groupArrayElements(ctx, output, value);\n" - " if (ctx.currentDepth - depth < ctx.compact && entries === output.length) {\n" - " const start = output.length + ctx.indentationLvl + braces[0].length + base.length + 10;\n" - " if (belowBreakLength(ctx, output, start, base)) {\n" - " const joined = output.join(\", \");\n" - " if (!joined.includes(\"\\n\")) {\n" - " return (base ? base + \" \" : \"\") + braces[0] + \" \" + joined + \" \" + braces[1];\n" - " }\n" - " }\n" + " const entries = output.length;\n" + " if (isArrayLike && entries > 6) output = groupArrayElements(ctx, output, value);\n" + " if (ctx.currentDepth - depth < ctx.compact && entries === output.length) {\n" + " const start = output.length + ctx.indentationLvl + braces[0].length + base.length + 10;\n" + " if (belowBreakLength(ctx, output, start, base)) {\n" + " const joined = output.join(\", \");\n" + " if (!joined.includes(\"\\n\")) {\n" + " return (base ? base + \" \" : \"\") + braces[0] + \" \" + joined + \" \" + braces[1];\n" " }\n" + " }\n" + " }\n" " }\n" " const indentation = \"\\n\" + \" \".repeat(ctx.indentationLvl);\n" " return (base ? base + \" \" : \"\") + braces[0] + indentation + \" \" +\n" - " output.join(\",\" + indentation + \" \") + indentation + braces[1];\n" + " output.join(\",\" + indentation + \" \") + indentation + braces[1];\n" " };\n" " const fmtList = (ctx, v, depth) => {\n" " const output = [];\n" " const max = Math.min(ctx.maxArrayLength, v.length);\n" " let i = 0;\n" " while (i < max) {\n" - " if (!Object.prototype.hasOwnProperty.call(v, i)) {\n" - " let j = i;\n" - " while (j < v.length && !Object.prototype.hasOwnProperty.call(v, j)) j++;\n" - " const n = Math.min(j, max) === j ? j - i : j - i;\n" - " output.push(\"<\" + n + \" empty item\" + (n > 1 ? \"s\" : \"\") + \">\");\n" - " i = j;\n" - " continue;\n" - " }\n" - " output.push(fmtValue(ctx, v[i], depth + 1));\n" - " i++;\n" + " if (!Object.prototype.hasOwnProperty.call(v, i)) {\n" + " let j = i;\n" + " while (j < v.length && !Object.prototype.hasOwnProperty.call(v, j)) j++;\n" + " const n = Math.min(j, max) === j ? j - i : j - i;\n" + " output.push(\"<\" + n + \" empty item\" + (n > 1 ? \"s\" : \"\") + \">\");\n" + " i = j;\n" + " continue;\n" + " }\n" + " output.push(fmtValue(ctx, v[i], depth + 1));\n" + " i++;\n" " }\n" " if (v.length > max) {\n" - " const rest = v.length - max;\n" - " output.push(\"... \" + rest + \" more item\" + (rest > 1 ? \"s\" : \"\"));\n" + " const rest = v.length - max;\n" + " output.push(\"... \" + rest + \" more item\" + (rest > 1 ? \"s\" : \"\"));\n" " }\n" " return output;\n" " };\n" @@ -7666,11 +7666,11 @@ static const char isl_modules_bootstrap[] = " const max = Math.min(ctx.maxArrayLength, v.length);\n" " const output = new Array(max);\n" " for (let i = 0; i < max; i++) {\n" - " output[i] = typeof v[i] === \"bigint\" ? fmtBigInt(v[i]) : fmtNumber(v[i]);\n" + " output[i] = typeof v[i] === \"bigint\" ? fmtBigInt(v[i]) : fmtNumber(v[i]);\n" " }\n" " if (v.length > max) {\n" - " const rest = v.length - max;\n" - " output.push(\"... \" + rest + \" more item\" + (rest > 1 ? \"s\" : \"\"));\n" + " const rest = v.length - max;\n" + " output.push(\"... \" + rest + \" more item\" + (rest > 1 ? \"s\" : \"\"));\n" " }\n" " return output;\n" " };\n" @@ -7681,42 +7681,42 @@ static const char isl_modules_bootstrap[] = " };\n" " const fmtValue = (ctx, value, depth, typedArray) => {\n" " if (typeof value !== \"object\" && typeof value !== \"function\") {\n" - " return fmtPrimitive(ctx, value);\n" + " return fmtPrimitive(ctx, value);\n" " }\n" " if (value === null) return \"null\";\n" " if (ctx.customInspect) {\n" - " const maybe = value[inspectCustom];\n" - " if (typeof maybe === \"function\" && maybe !== inspect &&\n" - " !(value.constructor && value.constructor.prototype === value)) {\n" - " const depthRemaining = ctx.depth === null ? null : ctx.depth - depth;\n" - " const opts = {\n" - " depth: ctx.depth, colors: ctx.colors, showHidden: ctx.showHidden,\n" - " breakLength: ctx.breakLength, compact: ctx.compact,\n" - " maxArrayLength: ctx.maxArrayLength, maxStringLength: ctx.maxStringLength,\n" - " customInspect: ctx.customInspect, sorted: ctx.sorted, getters: ctx.getters,\n" - " numericSeparator: ctx.numericSeparator, stylize: (s) => s,\n" - " };\n" - " const ret = maybe.call(value, depthRemaining, opts, inspect);\n" - " if (ret !== value) {\n" - " return typeof ret !== \"string\" ? fmtValue(ctx, ret, depth) : ret;\n" - " }\n" + " const maybe = value[inspectCustom];\n" + " if (typeof maybe === \"function\" && maybe !== inspect &&\n" + " !(value.constructor && value.constructor.prototype === value)) {\n" + " const depthRemaining = ctx.depth === null ? null : ctx.depth - depth;\n" + " const opts = {\n" + " depth: ctx.depth, colors: ctx.colors, showHidden: ctx.showHidden,\n" + " breakLength: ctx.breakLength, compact: ctx.compact,\n" + " maxArrayLength: ctx.maxArrayLength, maxStringLength: ctx.maxStringLength,\n" + " customInspect: ctx.customInspect, sorted: ctx.sorted, getters: ctx.getters,\n" + " numericSeparator: ctx.numericSeparator, stylize: (s) => s,\n" + " };\n" + " const ret = maybe.call(value, depthRemaining, opts, inspect);\n" + " if (ret !== value) {\n" + " return typeof ret !== \"string\" ? fmtValue(ctx, ret, depth) : ret;\n" " }\n" " }\n" + " }\n" " if (ctx.seen.includes(value)) {\n" - " let index = 1;\n" - " if (ctx.circular === undefined) {\n" - " ctx.circular = new Map();\n" - " ctx.circular.set(value, index);\n" + " let index = 1;\n" + " if (ctx.circular === undefined) {\n" + " ctx.circular = new Map();\n" + " ctx.circular.set(value, index);\n" + " } else {\n" + " const seenIndex = ctx.circular.get(value);\n" + " if (seenIndex === undefined) {\n" + " index = ctx.circular.size + 1;\n" + " ctx.circular.set(value, index);\n" " } else {\n" - " const seenIndex = ctx.circular.get(value);\n" - " if (seenIndex === undefined) {\n" - " index = ctx.circular.size + 1;\n" - " ctx.circular.set(value, index);\n" - " } else {\n" - " index = seenIndex;\n" - " }\n" + " index = seenIndex;\n" " }\n" - " return \"[Circular *\" + index + \"]\";\n" + " }\n" + " return \"[Circular *\" + index + \"]\";\n" " }\n" " return fmtRaw(ctx, value, depth, typedArray);\n" " };\n" @@ -7730,175 +7730,175 @@ static const char isl_modules_bootstrap[] = " let isArrayLike = false;\n" " const taKind = kindTA(value);\n" " if (Array.isArray(value)) {\n" - " if (depth > ctx.depth && ctx.depth !== null) return \"[Array]\";\n" - " const prefix = ctorName !== \"Array\" || protoOf === null\n" - " ? (ctorName === null ? \"[Array(\" + value.length + \"): null prototype] \" : ctorName + \"(\" + value.length + \") \")\n" - " : \"\";\n" - " keys = keys.filter((k) => !(typeof k === \"string\" && /^\\d+$/.test(k) && +k < value.length));\n" - " braces = [prefix + \"[\", \"]\"];\n" - " if (value.length === 0 && keys.length === 0) return braces[0] + \"]\";\n" - " formatter = fmtList;\n" - " isArrayLike = true;\n" + " if (depth > ctx.depth && ctx.depth !== null) return \"[Array]\";\n" + " const prefix = ctorName !== \"Array\" || protoOf === null\n" + " ? (ctorName === null ? \"[Array(\" + value.length + \"): null prototype] \" : ctorName + \"(\" + value.length + \") \")\n" + " : \"\";\n" + " keys = keys.filter((k) => !(typeof k === \"string\" && /^\\d+$/.test(k) && +k < value.length));\n" + " braces = [prefix + \"[\", \"]\"];\n" + " if (value.length === 0 && keys.length === 0) return braces[0] + \"]\";\n" + " formatter = fmtList;\n" + " isArrayLike = true;\n" " } else if (value instanceof Map) {\n" - " if (depth > ctx.depth && ctx.depth !== null) return \"[Map]\";\n" - " const size = value.size;\n" - " const prefix = (ctorName !== \"Map\" ? ctorName + \" [Map]\" : \"Map\") + \"(\" + size + \") \";\n" - " if (size === 0 && keys.length === 0) return prefix + \"{}\";\n" - " braces = [prefix + \"{\", \"}\"];\n" - " formatter = (c, v, d) => {\n" - " const out = [];\n" - " for (const [k, val] of v) {\n" - " out.push(fmtValue(c, k, d + 1) + \" => \" + fmtValue(c, val, d + 1));\n" - " }\n" - " return out;\n" - " };\n" + " if (depth > ctx.depth && ctx.depth !== null) return \"[Map]\";\n" + " const size = value.size;\n" + " const prefix = (ctorName !== \"Map\" ? ctorName + \" [Map]\" : \"Map\") + \"(\" + size + \") \";\n" + " if (size === 0 && keys.length === 0) return prefix + \"{}\";\n" + " braces = [prefix + \"{\", \"}\"];\n" + " formatter = (c, v, d) => {\n" + " const out = [];\n" + " for (const [k, val] of v) {\n" + " out.push(fmtValue(c, k, d + 1) + \" => \" + fmtValue(c, val, d + 1));\n" + " }\n" + " return out;\n" + " };\n" " } else if (value instanceof Set) {\n" - " if (depth > ctx.depth && ctx.depth !== null) return \"[Set]\";\n" - " const size = value.size;\n" - " const prefix = (ctorName !== \"Set\" ? ctorName + \" [Set]\" : \"Set\") + \"(\" + size + \") \";\n" - " if (size === 0 && keys.length === 0) return prefix + \"{}\";\n" - " braces = [prefix + \"{\", \"}\"];\n" - " formatter = (c, v, d) => {\n" - " const out = [];\n" - " for (const val of v) out.push(fmtValue(c, val, d + 1));\n" - " return out;\n" - " };\n" + " if (depth > ctx.depth && ctx.depth !== null) return \"[Set]\";\n" + " const size = value.size;\n" + " const prefix = (ctorName !== \"Set\" ? ctorName + \" [Set]\" : \"Set\") + \"(\" + size + \") \";\n" + " if (size === 0 && keys.length === 0) return prefix + \"{}\";\n" + " braces = [prefix + \"{\", \"}\"];\n" + " formatter = (c, v, d) => {\n" + " const out = [];\n" + " for (const val of v) out.push(fmtValue(c, val, d + 1));\n" + " return out;\n" + " };\n" " } else if (taKind !== null) {\n" - " if (depth > ctx.depth && ctx.depth !== null) return \"[\" + taKind + \"]\";\n" - " const prefix = (ctorName !== taKind && ctorName !== null ? ctorName + \"(\" + value.length + \") [\" + taKind + \"] \" : taKind + \"(\" + value.length + \") \");\n" - " braces = [prefix + \"[\", \"]\"];\n" - " if (value.length === 0 && keys.length === 0) return braces[0] + \"]\";\n" - " keys = keys.filter((k) => !(typeof k === \"string\" && /^\\d+$/.test(k) && +k < value.length));\n" - " formatter = fmtTypedArray;\n" - " isArrayLike = true;\n" + " if (depth > ctx.depth && ctx.depth !== null) return \"[\" + taKind + \"]\";\n" + " const prefix = (ctorName !== taKind && ctorName !== null ? ctorName + \"(\" + value.length + \") [\" + taKind + \"] \" : taKind + \"(\" + value.length + \") \");\n" + " braces = [prefix + \"[\", \"]\"];\n" + " if (value.length === 0 && keys.length === 0) return braces[0] + \"]\";\n" + " keys = keys.filter((k) => !(typeof k === \"string\" && /^\\d+$/.test(k) && +k < value.length));\n" + " formatter = fmtTypedArray;\n" + " isArrayLike = true;\n" " } else if (typeof value === \"function\") {\n" - " base = fnBase(value);\n" - " if (keys.length === 0) return base;\n" - " if (depth > ctx.depth && ctx.depth !== null) return base;\n" - " braces = [\"{\", \"}\"];\n" - " formatter = () => [];\n" + " base = fnBase(value);\n" + " if (keys.length === 0) return base;\n" + " if (depth > ctx.depth && ctx.depth !== null) return base;\n" + " braces = [\"{\", \"}\"];\n" + " formatter = () => [];\n" " } else if (value instanceof RegExp) {\n" - " base = RegExp.prototype.toString.call(value);\n" - " if (keys.length === 0) return base;\n" - " if (depth > ctx.depth && ctx.depth !== null) return base;\n" - " braces = [\"{\", \"}\"];\n" - " formatter = () => [];\n" + " base = RegExp.prototype.toString.call(value);\n" + " if (keys.length === 0) return base;\n" + " if (depth > ctx.depth && ctx.depth !== null) return base;\n" + " braces = [\"{\", \"}\"];\n" + " formatter = () => [];\n" " } else if (value instanceof Date) {\n" - " const t = Date.prototype.getTime.call(value);\n" - " base = Number.isNaN(t) ? \"Invalid Date\" : Date.prototype.toISOString.call(value);\n" - " if (keys.length === 0) return base;\n" - " if (depth > ctx.depth && ctx.depth !== null) return base;\n" - " braces = [\"{\", \"}\"];\n" - " formatter = () => [];\n" + " const t = Date.prototype.getTime.call(value);\n" + " base = Number.isNaN(t) ? \"Invalid Date\" : Date.prototype.toISOString.call(value);\n" + " if (keys.length === 0) return base;\n" + " if (depth > ctx.depth && ctx.depth !== null) return base;\n" + " braces = [\"{\", \"}\"];\n" + " formatter = () => [];\n" " } else if (value instanceof Error) {\n" - " base = value.stack;\n" - " if (typeof base !== \"string\" || base === \"\") {\n" - " const name = value.name === undefined ? \"Error\" : String(value.name);\n" - " const msg = value.message === undefined || value.message === \"\" ? \"\" : \": \" + String(value.message);\n" - " base = \"[\" + name + msg + \"]\";\n" + " base = value.stack;\n" + " if (typeof base !== \"string\" || base === \"\") {\n" + " const name = value.name === undefined ? \"Error\" : String(value.name);\n" + " const msg = value.message === undefined || value.message === \"\" ? \"\" : \": \" + String(value.message);\n" + " base = \"[\" + name + msg + \"]\";\n" + " }\n" + " keys = keys.filter((k) => k !== \"message\" && k !== \"stack\");\n" + " if (keys.length === 0) return base;\n" + " if (depth > ctx.depth && ctx.depth !== null) return base;\n" + " braces = [\"{\", \"}\"];\n" + " formatter = () => [];\n" + " } else if (value instanceof Promise) {\n" + " if (depth > ctx.depth && ctx.depth !== null) return \"[Promise]\";\n" + " const st = env.promiseState(value);\n" + " braces = [\"Promise {\", \"}\"];\n" + " formatter = (c, v, d) => {\n" + " if (st === undefined || st[0] === 0) return [\"\"];\n" + " if (st[0] === 1) return [fmtValue(c, st[1], d + 1)];\n" + " return [\" \" + fmtValue(c, st[1], d + 1)];\n" + " };\n" + " } else if (value instanceof ArrayBuffer) {\n" + " if (depth > ctx.depth && ctx.depth !== null) return \"[ArrayBuffer]\";\n" + " const u8 = new Uint8Array(value);\n" + " const n = Math.min(ctx.maxArrayLength, u8.length);\n" + " let contents = \"<\" + hexSlice(u8, n);\n" + " if (u8.length > n) {\n" + " const rest = u8.length - n;\n" + " contents += (n > 0 ? \" \" : \"\") + \"... \" + rest + \" more byte\" + (rest > 1 ? \"s\" : \"\");\n" + " }\n" + " contents += \">\";\n" + " braces = [\"ArrayBuffer {\", \"}\"];\n" + " const bl = value.byteLength;\n" + " formatter = () => [\"[Uint8Contents]: \" + contents, \"[byteLength]: \" + fmtNumber(bl)];\n" + " } else {\n" + " const boxed = (() => {\n" + " const tag = Object.prototype.toString.call(value).slice(8, -1);\n" + " if (tag === \"String\") return \"[String: \" + quoteStr(String.prototype.valueOf.call(value)) + \"]\";\n" + " if (tag === \"Number\") return \"[Number: \" + fmtNumber(Number.prototype.valueOf.call(value)) + \"]\";\n" + " if (tag === \"Boolean\") return \"[Boolean: \" + Boolean.prototype.valueOf.call(value) + \"]\";\n" + " if (tag === \"Symbol\") return \"[Symbol: \" + String(Symbol.prototype.valueOf.call(value)) + \"]\";\n" + " if (tag === \"BigInt\") return \"[BigInt: \" + fmtBigInt(BigInt.prototype.valueOf.call(value)) + \"]\";\n" + " return null;\n" + " })();\n" + " if (boxed !== null) {\n" + " base = boxed;\n" + " if (Object.prototype.toString.call(value).slice(8, -1) === \"String\") {\n" + " const len = String.prototype.valueOf.call(value).length;\n" + " keys = keys.filter((k) => !(typeof k === \"string\" && /^\\d+$/.test(k) && +k < len));\n" " }\n" - " keys = keys.filter((k) => k !== \"message\" && k !== \"stack\");\n" " if (keys.length === 0) return base;\n" - " if (depth > ctx.depth && ctx.depth !== null) return base;\n" " braces = [\"{\", \"}\"];\n" " formatter = () => [];\n" - " } else if (value instanceof Promise) {\n" - " if (depth > ctx.depth && ctx.depth !== null) return \"[Promise]\";\n" - " const st = env.promiseState(value);\n" - " braces = [\"Promise {\", \"}\"];\n" - " formatter = (c, v, d) => {\n" - " if (st === undefined || st[0] === 0) return [\"\"];\n" - " if (st[0] === 1) return [fmtValue(c, st[1], d + 1)];\n" - " return [\" \" + fmtValue(c, st[1], d + 1)];\n" - " };\n" - " } else if (value instanceof ArrayBuffer) {\n" - " if (depth > ctx.depth && ctx.depth !== null) return \"[ArrayBuffer]\";\n" - " const u8 = new Uint8Array(value);\n" - " const n = Math.min(ctx.maxArrayLength, u8.length);\n" - " let contents = \"<\" + hexSlice(u8, n);\n" - " if (u8.length > n) {\n" - " const rest = u8.length - n;\n" - " contents += (n > 0 ? \" \" : \"\") + \"... \" + rest + \" more byte\" + (rest > 1 ? \"s\" : \"\");\n" - " }\n" - " contents += \">\";\n" - " braces = [\"ArrayBuffer {\", \"}\"];\n" - " const bl = value.byteLength;\n" - " formatter = () => [\"[Uint8Contents]: \" + contents, \"[byteLength]: \" + fmtNumber(bl)];\n" " } else {\n" - " const boxed = (() => {\n" - " const tag = Object.prototype.toString.call(value).slice(8, -1);\n" - " if (tag === \"String\") return \"[String: \" + quoteStr(String.prototype.valueOf.call(value)) + \"]\";\n" - " if (tag === \"Number\") return \"[Number: \" + fmtNumber(Number.prototype.valueOf.call(value)) + \"]\";\n" - " if (tag === \"Boolean\") return \"[Boolean: \" + Boolean.prototype.valueOf.call(value) + \"]\";\n" - " if (tag === \"Symbol\") return \"[Symbol: \" + String(Symbol.prototype.valueOf.call(value)) + \"]\";\n" - " if (tag === \"BigInt\") return \"[BigInt: \" + fmtBigInt(BigInt.prototype.valueOf.call(value)) + \"]\";\n" - " return null;\n" - " })();\n" - " if (boxed !== null) {\n" - " base = boxed;\n" - " if (Object.prototype.toString.call(value).slice(8, -1) === \"String\") {\n" - " const len = String.prototype.valueOf.call(value).length;\n" - " keys = keys.filter((k) => !(typeof k === \"string\" && /^\\d+$/.test(k) && +k < len));\n" - " }\n" - " if (keys.length === 0) return base;\n" - " braces = [\"{\", \"}\"];\n" - " formatter = () => [];\n" - " } else {\n" - " if (keys.length > 0 && depth > ctx.depth && ctx.depth !== null) {\n" - " return \"[\" + (ctorName === null ? \"Object: null prototype\" : ctorName) + \"]\";\n" - " }\n" - " if (protoOf === null) {\n" - " base = \"[Object: null prototype]\";\n" - " braces = [\"{\", \"}\"];\n" - " } else if (ctorName !== \"Object\" && ctorName !== null) {\n" - " braces = [ctorName + \" {\", \"}\"];\n" - " } else {\n" - " braces = [\"{\", \"}\"];\n" - " }\n" - " if (keys.length === 0) {\n" - " if (base !== \"\") return base + \" {}\";\n" - " return braces[0] === \"{\" ? \"{}\" : braces[0] + \"}\";\n" - " }\n" - " formatter = () => [];\n" + " if (keys.length > 0 && depth > ctx.depth && ctx.depth !== null) {\n" + " return \"[\" + (ctorName === null ? \"Object: null prototype\" : ctorName) + \"]\";\n" " }\n" + " if (protoOf === null) {\n" + " base = \"[Object: null prototype]\";\n" + " braces = [\"{\", \"}\"];\n" + " } else if (ctorName !== \"Object\" && ctorName !== null) {\n" + " braces = [ctorName + \" {\", \"}\"];\n" + " } else {\n" + " braces = [\"{\", \"}\"];\n" + " }\n" + " if (keys.length === 0) {\n" + " if (base !== \"\") return base + \" {}\";\n" + " return braces[0] === \"{\" ? \"{}\" : braces[0] + \"}\";\n" + " }\n" + " formatter = () => [];\n" + " }\n" " }\n" " ctx.seen.push(value);\n" " ctx.currentDepth = depth;\n" " let output;\n" " try {\n" - " output = formatter(ctx, value, depth);\n" - " for (const k of keys) {\n" - " output.push(fmtProperty(ctx, value, k, depth));\n" - " }\n" + " output = formatter(ctx, value, depth);\n" + " for (const k of keys) {\n" + " output.push(fmtProperty(ctx, value, k, depth));\n" + " }\n" " } finally {\n" - " ctx.seen.pop();\n" + " ctx.seen.pop();\n" " }\n" " if (ctx.sorted) output.sort();\n" " const res = reduceToSingleString(ctx, output, base, braces, isArrayLike, depth, value);\n" " if (ctx.circular !== undefined) {\n" - " const index = ctx.circular.get(value);\n" - " if (index !== undefined) return \" \" + res;\n" + " const index = ctx.circular.get(value);\n" + " if (index !== undefined) return \" \" + res;\n" " }\n" " return res;\n" " };\n" " function inspect(value, showHiddenOrOpts, depthArg, colorsArg) {\n" " const ctx = {\n" - " showHidden: false, depth: 2, colors: false, customInspect: true,\n" - " maxArrayLength: 100, maxStringLength: 10000, breakLength: 128,\n" - " compact: 3, sorted: false, getters: false, numericSeparator: false,\n" - " seen: [], circular: undefined, indentationLvl: 0, currentDepth: 0,\n" - " };\n" + " showHidden: false, depth: 2, colors: false, customInspect: true,\n" + " maxArrayLength: 100, maxStringLength: 10000, breakLength: 128,\n" + " compact: 3, sorted: false, getters: false, numericSeparator: false,\n" + " seen: [], circular: undefined, indentationLvl: 0, currentDepth: 0,\n" + " };\n" " if (arguments.length > 1) {\n" - " if (typeof showHiddenOrOpts === \"boolean\") {\n" - " ctx.showHidden = showHiddenOrOpts;\n" - " if (depthArg !== undefined) ctx.depth = depthArg;\n" - " if (colorsArg !== undefined) ctx.colors = colorsArg;\n" - " } else if (showHiddenOrOpts !== null && typeof showHiddenOrOpts === \"object\") {\n" - " for (const k of Object.keys(showHiddenOrOpts)) {\n" - " if (showHiddenOrOpts[k] !== undefined || k in ctx) ctx[k] = showHiddenOrOpts[k];\n" - " }\n" + " if (typeof showHiddenOrOpts === \"boolean\") {\n" + " ctx.showHidden = showHiddenOrOpts;\n" + " if (depthArg !== undefined) ctx.depth = depthArg;\n" + " if (colorsArg !== undefined) ctx.colors = colorsArg;\n" + " } else if (showHiddenOrOpts !== null && typeof showHiddenOrOpts === \"object\") {\n" + " for (const k of Object.keys(showHiddenOrOpts)) {\n" + " if (showHiddenOrOpts[k] !== undefined || k in ctx) ctx[k] = showHiddenOrOpts[k];\n" " }\n" " }\n" + " }\n" " if (ctx.maxArrayLength === null) ctx.maxArrayLength = Infinity;\n" " if (ctx.maxStringLength === null) ctx.maxStringLength = Infinity;\n" " if (ctx.breakLength === null) ctx.breakLength = Infinity;\n" @@ -7933,122 +7933,134 @@ static const char isl_modules_bootstrap[] = " let str = \"\";\n" " let joined = \"\";\n" " if (typeof first === \"string\" && first.includes(\"%\")) {\n" - " a = 1;\n" - " let lastPos = 0;\n" - " for (let i = 0; i < first.length - 1; i++) {\n" - " if (first[i] !== \"%\") continue;\n" - " const next = first[++i];\n" - " let tempStr;\n" - " if (next === \"%\") {\n" - " str += first.slice(lastPos, i - 1) + \"%\";\n" - " lastPos = i + 1;\n" - " continue;\n" - " }\n" - " if (a >= args.length) continue;\n" - " switch (next) {\n" - " case \"s\": {\n" - " const arg = args[a];\n" - " if (typeof arg === \"number\") tempStr = fmtNumber(arg);\n" - " else if (typeof arg === \"bigint\") tempStr = fmtBigInt(arg);\n" - " else if (typeof arg !== \"object\" || arg === null) tempStr = String(arg);\n" - " else tempStr = inspect(arg, { ...opts, compact: 3, colors: false, depth: 0 });\n" - " break;\n" - " }\n" - " case \"j\":\n" - " try { tempStr = JSON.stringify(args[a]); }\n" - " catch (e) { tempStr = \"[Circular]\"; }\n" - " break;\n" - " case \"d\": {\n" - " const arg = args[a];\n" - " if (typeof arg === \"bigint\") tempStr = fmtBigInt(arg);\n" - " else if (typeof arg === \"symbol\") tempStr = \"NaN\";\n" - " else tempStr = fmtNumber(Number(arg));\n" - " break;\n" - " }\n" - " case \"O\":\n" - " tempStr = inspect(args[a], { ...opts });\n" - " break;\n" - " case \"o\":\n" - " tempStr = inspect(args[a], { ...opts, showHidden: true, showProxy: true, depth: 4 });\n" - " break;\n" - " case \"i\": {\n" - " const arg = args[a];\n" - " if (typeof arg === \"bigint\") tempStr = fmtBigInt(arg);\n" - " else if (typeof arg === \"symbol\") tempStr = \"NaN\";\n" - " else tempStr = fmtNumber(parseInt(arg));\n" - " break;\n" - " }\n" - " case \"f\": {\n" - " const arg = args[a];\n" - " if (typeof arg === \"symbol\") tempStr = \"NaN\";\n" - " else tempStr = fmtNumber(parseFloat(arg));\n" - " break;\n" - " }\n" - " case \"c\":\n" - " a += 1;\n" - " lastPos = i + 1;\n" - " continue;\n" - " default:\n" - " continue;\n" - " }\n" - " if (lastPos !== i - 1) str += first.slice(lastPos, i - 1);\n" - " str += tempStr;\n" + " a = 1;\n" + " let lastPos = 0;\n" + " for (let i = 0; i < first.length - 1; i++) {\n" + " if (first[i] !== \"%\") continue;\n" + " const next = first[++i];\n" + " let tempStr;\n" + " if (next === \"%\") {\n" + " str += first.slice(lastPos, i - 1) + \"%\";\n" + " lastPos = i + 1;\n" + " continue;\n" + " }\n" + " if (a >= args.length) continue;\n" + " switch (next) {\n" + " case \"s\": {\n" + " const arg = args[a];\n" + " if (typeof arg === \"number\") tempStr = fmtNumber(arg);\n" + " else if (typeof arg === \"bigint\") tempStr = fmtBigInt(arg);\n" + " else if (typeof arg !== \"object\" || arg === null) tempStr = String(arg);\n" + " else tempStr = inspect(arg, { ...opts, compact: 3, colors: false, depth: 0 });\n" + " break;\n" + " }\n" + " case \"j\":\n" + " try { tempStr = JSON.stringify(args[a]); }\n" + " catch (e) { tempStr = \"[Circular]\"; }\n" + " break;\n" + " case \"d\": {\n" + " const arg = args[a];\n" + " if (typeof arg === \"bigint\") tempStr = fmtBigInt(arg);\n" + " else if (typeof arg === \"symbol\") tempStr = \"NaN\";\n" + " else tempStr = fmtNumber(Number(arg));\n" + " break;\n" + " }\n" + " case \"O\":\n" + " tempStr = inspect(args[a], { ...opts });\n" + " break;\n" + " case \"o\":\n" + " tempStr = inspect(args[a], { ...opts, showHidden: true, showProxy: true, depth: 4 });\n" + " break;\n" + " case \"i\": {\n" + " const arg = args[a];\n" + " if (typeof arg === \"bigint\") tempStr = fmtBigInt(arg);\n" + " else if (typeof arg === \"symbol\") tempStr = \"NaN\";\n" + " else tempStr = fmtNumber(parseInt(arg));\n" + " break;\n" + " }\n" + " case \"f\": {\n" + " const arg = args[a];\n" + " if (typeof arg === \"symbol\") tempStr = \"NaN\";\n" + " else tempStr = fmtNumber(parseFloat(arg));\n" + " break;\n" + " }\n" + " case \"c\":\n" + " a += 1;\n" " lastPos = i + 1;\n" - " a++;\n" + " continue;\n" + " default:\n" + " continue;\n" " }\n" - " if (lastPos !== 0) {\n" - " if (lastPos < first.length) str += first.slice(lastPos);\n" - " first = str;\n" - " str = \"\";\n" - " } else {\n" - " str = \"\";\n" - " }\n" - " joined = first;\n" + " if (lastPos !== i - 1) str += first.slice(lastPos, i - 1);\n" + " str += tempStr;\n" + " lastPos = i + 1;\n" + " a++;\n" + " }\n" + " if (lastPos !== 0) {\n" + " if (lastPos < first.length) str += first.slice(lastPos);\n" + " first = str;\n" + " str = \"\";\n" + " } else {\n" + " str = \"\";\n" + " }\n" + " joined = first;\n" " }\n" " while (a < args.length) {\n" - " const value = args[a];\n" - " joined += a > 0 || typeof first !== \"string\" && a === 0 ? \"\" : \"\";\n" - " if (joined !== \"\" || a > 0) joined += \" \";\n" - " joined += typeof value !== \"string\" ? inspect(value, opts) : value;\n" - " a++;\n" + " const value = args[a];\n" + " joined += a > 0 || typeof first !== \"string\" && a === 0 ? \"\" : \"\";\n" + " if (joined !== \"\" || a > 0) joined += \" \";\n" + " joined += typeof value !== \"string\" ? inspect(value, opts) : value;\n" + " a++;\n" " }\n" " return joined;\n" " };\n" " const format = (...args) => formatWithOptions({}, ...args);\n" " const inherits = (ctor, superCtor) => {\n" " if (ctor === undefined || ctor === null) {\n" - " const e = new TypeError('The \"ctor\" argument must be of type function. Received ' + (ctor === null ? \"null\" : \"undefined\"));\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" + " const e = new TypeError('The \"ctor\" argument must be of type function. Received ' + (ctor === null ? \"null\" : \"undefined\"));\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" " }\n" " if (superCtor === undefined || superCtor === null) {\n" - " const e = new TypeError('The \"superCtor\" argument must be of type function. Received ' + (superCtor === null ? \"null\" : \"undefined\"));\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" + " const e = new TypeError('The \"superCtor\" argument must be of type function. Received ' + (superCtor === null ? \"null\" : \"undefined\"));\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" " }\n" " if (superCtor.prototype === undefined) {\n" - " const e = new TypeError('The \"superCtor.prototype\" argument must be of type object. Received undefined');\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" + " const e = new TypeError('The \"superCtor.prototype\" argument must be of type object. Received undefined');\n" + " e.code = \"ERR_INVALID_ARG_TYPE\";\n" + " throw e;\n" " }\n" " Object.defineProperty(ctor, \"super_\", { value: superCtor, writable: true, configurable: true });\n" " Object.setPrototypeOf(ctor.prototype, superCtor.prototype);\n" " };\n" + " const received = (v) => {\n" + " if (v === null || v === undefined) return String(v);\n" + " if (typeof v === 'object') return v.constructor && 'name' in v.constructor ? 'an instance of ' + v.constructor.name : inspect(v, { depth: -1 });\n" + " if (typeof v === 'function') return 'function ' + v.name;\n" + " if (typeof v === 'string') {\n" + " if (v.length > 28) v = v.slice(0, 25) + '...';\n" + " return 'type string (' + (v.includes(\"'\") ? JSON.stringify(v) : \"'\" + v + \"'\") + ')';\n" + " }\n" + " if (typeof v === 'number') return 'type number (' + (Object.is(v, -0) ? '-0' : String(v)) + ')';\n" + " if (typeof v === 'bigint') return 'type bigint (' + v + 'n)';\n" + " if (typeof v === 'symbol') return 'type symbol (' + String(v) + ')';\n" + " return 'type ' + typeof v + ' (' + String(v) + ')';\n" + " };\n" + " const validateAdapterFunction = (value, name) => {\n" + " if (typeof value !== 'function') {\n" + " const e = new TypeError('The ' + (name === 'last argument' ? name : '\"' + name + '\" ' + (name.includes('.') ? 'property' : 'argument')) + ' must be of type function. Received ' + received(value));\n" + " e.code = 'ERR_INVALID_ARG_TYPE';\n" + " throw e;\n" + " }\n" + " };\n" " const kCustomPromisified = Symbol.for(\"nodejs.util.promisify.custom\");\n" " const kCustomPromisifyArgs = Symbol(\"customPromisifyArgs\");\n" " const promisify = (original) => {\n" - " if (typeof original !== \"function\") {\n" - " const e = new TypeError('The \"original\" argument must be of type function. Received ' + (original === null ? \"null\" : typeof original === \"object\" ? \"an instance of Object\" : typeof original === \"undefined\" ? \"undefined\" : \"type \" + typeof original + \" (\" + JSON.stringify(original) + \")\"));\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" - " }\n" + " validateAdapterFunction(original, 'original');\n" " if (original[kCustomPromisified]) {\n" " const fn = original[kCustomPromisified];\n" - " if (typeof fn !== \"function\") {\n" - " const e = new TypeError('The \"util.promisify.custom\" property must be of type function');\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" - " }\n" + " validateAdapterFunction(fn, 'util.promisify.custom');\n" " return Object.defineProperty(fn, kCustomPromisified, { value: fn, enumerable: false, writable: false, configurable: true });\n" " }\n" " const argumentNames = original[kCustomPromisifyArgs];\n" @@ -8070,30 +8082,21 @@ static const char isl_modules_bootstrap[] = " Object.setPrototypeOf(fn, Object.getPrototypeOf(original));\n" " Object.defineProperty(fn, kCustomPromisified, { value: fn, enumerable: false, writable: false, configurable: true });\n" " const descriptors = Object.getOwnPropertyDescriptors(original);\n" - " delete descriptors.name;\n" - " delete descriptors.length;\n" + " for (const descriptor of Object.values(descriptors)) Object.setPrototypeOf(descriptor, null);\n" " return Object.defineProperties(fn, descriptors);\n" " };\n" " promisify.custom = kCustomPromisified;\n" " const callbackify = (original) => {\n" - " if (typeof original !== \"function\") {\n" - " const e = new TypeError('The \"original\" argument must be of type function');\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" - " }\n" + " validateAdapterFunction(original, 'original');\n" " function callbackified(...args) {\n" " const maybeCb = args.pop();\n" - " if (typeof maybeCb !== \"function\") {\n" - " const e = new TypeError(\"The last argument must be of type function\");\n" - " e.code = \"ERR_INVALID_ARG_TYPE\";\n" - " throw e;\n" - " }\n" + " validateAdapterFunction(maybeCb, 'last argument');\n" " const cb = (...cbArgs) => Reflect.apply(maybeCb, this, cbArgs);\n" " Reflect.apply(original, this, args).then(\n" " (ret) => queueMicrotask(() => cb(null, ret)),\n" " (rej) => queueMicrotask(() => {\n" - " if (rej === null || (typeof rej !== \"object\" && typeof rej !== \"function\")) {\n" - " const wrapped = new Error(\"Promise was rejected with a falsy value\");\n" + " if (!rej) {\n" + " const wrapped = new Error(\"Promise was rejected with falsy value\");\n" " wrapped.code = \"ERR_FALSY_VALUE_REJECTION\";\n" " wrapped.reason = rej;\n" " return cb(wrapped);\n" @@ -8102,8 +8105,10 @@ static const char isl_modules_bootstrap[] = " }),\n" " );\n" " }\n" - " Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));\n" " const descriptors = Object.getOwnPropertyDescriptors(original);\n" + " if (typeof descriptors.length.value === 'number') descriptors.length.value++;\n" + " if (typeof descriptors.name.value === 'string') descriptors.name.value += 'Callbackified';\n" + " for (const descriptor of Object.values(descriptors)) Object.setPrototypeOf(descriptor, null);\n" " Object.defineProperties(callbackified, descriptors);\n" " return callbackified;\n" " };\n" @@ -8385,19 +8390,6 @@ static const char isl_modules_bootstrap[] = " const allowNegative = get(config, 'allowNegative') ?? false;\n" " const options = get(config, 'options') ?? Object.create(null);\n" " const fail = (code, message) => { const e = new TypeError(message); e.code = code; throw e; };\n" - " const received = (v) => {\n" - " if (v === null || v === undefined) return String(v);\n" - " if (typeof v === 'object') return v.constructor && 'name' in v.constructor ? 'an instance of ' + v.constructor.name : inspect(v, { depth: -1 });\n" - " if (typeof v === 'function') return 'function ' + v.name;\n" - " if (typeof v === 'string') {\n" - " if (v.length > 28) v = v.slice(0, 25) + '...';\n" - " return 'type string (' + (v.includes(\"'\") ? JSON.stringify(v) : \"'\" + v + \"'\") + ')';\n" - " }\n" - " if (typeof v === 'number') return 'type number (' + (Object.is(v, -0) ? '-0' : String(v)) + ')';\n" - " if (typeof v === 'bigint') return 'type bigint (' + v + 'n)';\n" - " if (typeof v === 'symbol') return 'type symbol (' + String(v) + ')';\n" - " return 'type ' + typeof v + ' (' + String(v) + ')';\n" - " };\n" " const validate = (v, name, expected, ok) => {\n" " if (!ok) fail('ERR_INVALID_ARG_TYPE', 'The \"' + name + '\" ' + (name.startsWith('options.') ? 'property' : 'argument') + ' must be ' + expected + '. Received ' + received(v));\n" " };\n" diff --git a/tests/fixtures/npm/cases/node24-util-adapters/main.ts b/tests/fixtures/npm/cases/node24-util-adapters/main.ts new file mode 100644 index 000000000..0881f23b1 --- /dev/null +++ b/tests/fixtures/npm/cases/node24-util-adapters/main.ts @@ -0,0 +1,4 @@ +// @dynamic +// @stderr +import { report } from "node24-util-adapters-fixture"; +report(); diff --git a/tests/fixtures/npm/cases/node24-util-adapters/package.json b/tests/fixtures/npm/cases/node24-util-adapters/package.json new file mode 100644 index 000000000..089153bcb --- /dev/null +++ b/tests/fixtures/npm/cases/node24-util-adapters/package.json @@ -0,0 +1 @@ +{"type":"module"} diff --git a/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/index.d.ts b/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/index.d.ts new file mode 100644 index 000000000..601984b08 --- /dev/null +++ b/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/index.d.ts @@ -0,0 +1 @@ +export function report(): Promise; diff --git a/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/index.js b/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/index.js new file mode 100644 index 000000000..1cc2ee882 --- /dev/null +++ b/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/index.js @@ -0,0 +1,78 @@ +import { promisify, callbackify } from 'node:util'; + +export async function report() { + const line = (name, value) => console.log(name, JSON.stringify(value)); + const error = (name, fn) => { + try { fn(); line(name, 'no error'); } + catch (e) { line(name, [e.name, e.code, e.message]); } + }; + const descriptor = (fn, key) => { + const d = Object.getOwnPropertyDescriptor(fn, key); + return [d.value, d.writable, d.enumerable, d.configurable]; + }; + for (const value of [undefined, null, false, 42, -0, 2n, Symbol('x'), 'no', "can't", 'a'.repeat(29), {}, [], Object.create(null)]) { + error('promisify invalid', () => promisify(value)); + error('callbackify invalid', () => callbackify(value)); + } + const metadata = Symbol('metadata'); + function sum(a, b, cb) { cb(null, this.base + a + b, 'ignored'); } + Object.defineProperty(sum, 'detail', { get() { return 17; }, enumerable: true }); + sum[metadata] = 'symbol'; + const customPrototype = Object.create(Function.prototype); + Object.setPrototypeOf(sum, customPrototype); + const wrapped = promisify(sum); + line('promisify metadata', [descriptor(wrapped, 'name'), descriptor(wrapped, 'length'), wrapped.detail, wrapped[metadata], Object.getPrototypeOf(wrapped) === customPrototype]); + line('promisify identity', [promisify(wrapped) === wrapped, wrapped[promisify.custom] === wrapped, Symbol.for('nodejs.util.promisify.custom') === promisify.custom]); + line('promisify receiver', await wrapped.call({ base: 10 }, 2, 3)); + line('promisify no result', await promisify(cb => cb(null))() === undefined); + line('promisify falsy error', await promisify(cb => cb(0, 'ok'))()); + line('promisify first settlement', await promisify(cb => { cb(null, 1); cb(new Error('late')); throw new Error('later'); })()); + const boom = new Error('sync'); + line('promisify sync throw', await promisify(() => { throw boom; })().catch(e => e === boom)); + function custom() {} + custom[promisify.custom] = function chosen() { return this.value; }; + const chosen = promisify(custom); + line('custom', [chosen === custom[promisify.custom], promisify(chosen) === chosen, chosen.call({ value: 23 })]); + for (const value of [true, 'wrong', {}, 5, 3n, Symbol('bad')]) { + custom[promisify.custom] = value; + error('invalid custom', () => promisify(custom)); + } + custom[promisify.custom] = false; + line('falsy custom ignored', typeof promisify(custom)); + + async function add(a, b) { return this.base + a + b; } + Object.setPrototypeOf(add, customPrototype); + add[metadata] = 'async symbol'; + const callback = callbackify(add); + line('callbackify metadata', [descriptor(callback, 'name'), descriptor(callback, 'length'), callback[metadata], Object.getPrototypeOf(callback) === Function.prototype]); + await new Promise(resolve => { + let synchronous = true; + const receiver = { base: 20 }; + const returned = callback.call(receiver, 2, 3, function(err, result) { + line('callbackify success', [err, result, this === receiver, synchronous, arguments.length]); resolve(); + }); + line('callbackify return', returned === undefined); + synchronous = false; + }); + for (const value of [undefined, null, 1, 'callback', {}, Symbol('cb')]) error('invalid callback', () => callback(value)); + for (const reason of [undefined, null, false, 0, -0, NaN, '', 0n, 1, true, 'failure', 2n, Symbol('failure'), {}, new Error('failure')]) { + await new Promise(resolve => callbackify(() => Promise.reject(reason))(function(err, result) { + line('callbackify rejection', [typeof reason, !reason, err === reason, err?.code ?? null, Object.is(err?.reason, reason), arguments.length, result === undefined, err instanceof Error, err?.message ?? null, Object.hasOwn(Object(err), 'reason')]); resolve(); + })); + } + await new Promise(resolve => { + const order = []; + callbackify(() => ({ then(fulfilled) { order.push('then'); fulfilled(8); } }))(function(err, value) { + order.push('callback'); line('thenable asynchronous', [order, err, value]); resolve(); + }); + order.push('returned'); + }); + error('callbackify sync throw', () => callbackify(() => { throw new Error('sync failure'); })(() => {})); + for (const values of [[7, 'renamed'], ['strange', 12], [NaN, '']]) { + function altered() { return Promise.resolve(1); } + Object.defineProperty(altered, 'length', { value: values[0] }); + Object.defineProperty(altered, 'name', { value: values[1] }); + const p = promisify(altered), c = callbackify(altered); + line('altered metadata', [descriptor(p, 'name'), descriptor(p, 'length'), descriptor(c, 'name'), descriptor(c, 'length')]); + } +} diff --git a/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/package.json b/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/package.json new file mode 100644 index 000000000..65c3891c9 --- /dev/null +++ b/tests/fixtures/npm/node_modules/node24-util-adapters-fixture/package.json @@ -0,0 +1 @@ +{"name":"node24-util-adapters-fixture","version":"1.0.0","type":"module","main":"index.js","types":"index.d.ts"}