@gjsify/util 0.3.16 → 0.3.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/esm/index.js CHANGED
@@ -1,589 +1,4 @@
1
- import { getSystemErrorMap, getSystemErrorName } from "./errors.js";
2
- import { types_exports } from "./types.js";
3
-
4
- //#region src/index.ts
5
- const kCustomInspect = Symbol.for("nodejs.util.inspect.custom");
6
- function inspectValue(value, opts, depth) {
7
- if (value === null) return opts.colors ? "\x1B[1mnull\x1B[22m" : "null";
8
- if (value === undefined) return opts.colors ? "\x1B[90mundefined\x1B[39m" : "undefined";
9
- const maxDepth = opts.depth ?? 2;
10
- if (typeof value === "string") {
11
- const escaped = value.replace(/\\/g, "\\\\");
12
- if (value.includes("'") && !value.includes("\"")) {
13
- const dq = escaped.replace(/"/g, "\\\"");
14
- return opts.colors ? `\x1b[32m"${dq}"\x1b[39m` : `"${dq}"`;
15
- }
16
- const sq = escaped.replace(/'/g, "\\'");
17
- return opts.colors ? `\x1b[32m'${sq}'\x1b[39m` : `'${sq}'`;
18
- }
19
- if (typeof value === "number") {
20
- return opts.colors ? `\x1b[33m${value}\x1b[39m` : String(value);
21
- }
22
- if (typeof value === "bigint") {
23
- return opts.colors ? `\x1b[33m${value}n\x1b[39m` : `${value}n`;
24
- }
25
- if (typeof value === "boolean") {
26
- return opts.colors ? `\x1b[33m${value}\x1b[39m` : String(value);
27
- }
28
- if (typeof value === "symbol") {
29
- return opts.colors ? `\x1b[32m${value.toString()}\x1b[39m` : value.toString();
30
- }
31
- if (typeof value === "function") {
32
- const name = value.name ? `: ${value.name}` : "";
33
- return opts.colors ? `\x1b[36m[Function${name}]\x1b[39m` : `[Function${name}]`;
34
- }
35
- if (value !== null && typeof value === "object" && kCustomInspect in value) {
36
- const custom = value[kCustomInspect];
37
- if (typeof custom === "function") {
38
- const result = custom.call(value, depth, opts);
39
- if (typeof result === "string") return result;
40
- return inspectValue(result, opts, depth);
41
- }
42
- }
43
- if (value instanceof Date) {
44
- return value.toISOString();
45
- }
46
- if (value instanceof RegExp) {
47
- return opts.colors ? `\x1b[31m${value.toString()}\x1b[39m` : value.toString();
48
- }
49
- if (value instanceof Error) {
50
- return value.stack || value.toString();
51
- }
52
- if (depth > maxDepth) {
53
- return Array.isArray(value) ? "[Array]" : "[Object]";
54
- }
55
- if (Array.isArray(value)) {
56
- return inspectArray(value, opts, depth);
57
- }
58
- if (value instanceof Map) {
59
- const entries = [...value.entries()].map(([k, v]) => `${inspectValue(k, opts, depth + 1)} => ${inspectValue(v, opts, depth + 1)}`);
60
- return `Map(${value.size}) { ${entries.join(", ")} }`;
61
- }
62
- if (value instanceof Set) {
63
- const entries = [...value].map((v) => inspectValue(v, opts, depth + 1));
64
- return `Set(${value.size}) { ${entries.join(", ")} }`;
65
- }
66
- if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
67
- const name = value.constructor?.name || "TypedArray";
68
- const arr = Array.from(value);
69
- return `${name}(${arr.length}) [ ${arr.join(", ")} ]`;
70
- }
71
- return inspectObject(value, opts, depth);
72
- }
73
- function inspectArray(arr, opts, depth) {
74
- const maxLen = opts.maxArrayLength ?? 100;
75
- const len = Math.min(arr.length, maxLen);
76
- const items = [];
77
- for (let i = 0; i < len; i++) {
78
- items.push(inspectValue(arr[i], opts, depth + 1));
79
- }
80
- if (arr.length > maxLen) {
81
- items.push(`... ${arr.length - maxLen} more items`);
82
- }
83
- if (opts.showHidden) {
84
- items.push(`[length]: ${arr.length}`);
85
- }
86
- const breakLength = opts.breakLength ?? 72;
87
- const compact = opts.compact ?? 3;
88
- if (typeof compact === "number" && compact > 0 && arr.length > compact) {
89
- const indent = " ";
90
- const indentLen = indent.length;
91
- const stripAnsi = (s) => s.replace(/\x1b\[[0-9;]*m/g, "");
92
- const maxItemLen = Math.max(...items.map((item) => stripAnsi(item).length));
93
- const biasedMax = Math.max(maxItemLen - 2, 1);
94
- const numItems = items.length;
95
- const approxCharHeights = 2.5;
96
- const columns = Math.min(Math.round(Math.sqrt(approxCharHeights * biasedMax * numItems) / biasedMax), Math.floor((breakLength - indentLen) / biasedMax), Math.floor((2.5 + numItems - 1) / 2), 15);
97
- if (columns > 1) {
98
- const rows = [];
99
- for (let i = 0; i < numItems; i += columns) {
100
- rows.push(indent + items.slice(i, Math.min(i + columns, numItems)).join(", "));
101
- }
102
- return `[\n${rows.join(",\n")}\n]`;
103
- }
104
- }
105
- const singleLine = `[ ${items.join(", ")} ]`;
106
- if (singleLine.length <= breakLength) return singleLine;
107
- return `[\n${items.map((i) => " " + i).join(",\n")}\n]`;
108
- }
109
- function inspectObject(obj, opts, depth) {
110
- const keys = opts.showHidden ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
111
- if (opts.sorted) keys.sort();
112
- if (keys.length === 0) {
113
- const tag = Object.prototype.toString.call(obj);
114
- if (tag !== "[object Object]") return tag;
115
- return "{}";
116
- }
117
- const items = keys.map((key) => {
118
- const val = inspectValue(obj[key], opts, depth + 1);
119
- return `${key}: ${val}`;
120
- });
121
- const breakLength = opts.breakLength ?? 72;
122
- const singleLine = `{ ${items.join(", ")} }`;
123
- if (singleLine.length <= breakLength) return singleLine;
124
- return `{\n${items.map((i) => " " + i).join(",\n")}\n}`;
125
- }
126
- function inspect(value, opts) {
127
- const options = typeof opts === "boolean" ? { showHidden: opts } : { ...opts };
128
- if (options.colors === undefined) options.colors = false;
129
- return inspectValue(value, options, 0);
130
- }
131
- inspect.custom = kCustomInspect;
132
- inspect.defaultOptions = {
133
- showHidden: false,
134
- depth: 2,
135
- colors: false,
136
- maxArrayLength: 100,
137
- maxStringLength: 1e4,
138
- breakLength: 72,
139
- compact: 3,
140
- sorted: false
141
- };
142
- /** ANSI color code pairs [open, close] for terminal coloring. */
143
- inspect.colors = {
144
- reset: [0, 0],
145
- bold: [1, 22],
146
- dim: [2, 22],
147
- italic: [3, 23],
148
- underline: [4, 24],
149
- blink: [5, 25],
150
- inverse: [7, 27],
151
- hidden: [8, 28],
152
- strikethrough: [9, 29],
153
- doubleunderline: [21, 24],
154
- black: [30, 39],
155
- red: [31, 39],
156
- green: [32, 39],
157
- yellow: [33, 39],
158
- blue: [34, 39],
159
- magenta: [35, 39],
160
- cyan: [36, 39],
161
- white: [37, 39],
162
- bgBlack: [40, 49],
163
- bgRed: [41, 49],
164
- bgGreen: [42, 49],
165
- bgYellow: [43, 49],
166
- bgBlue: [44, 49],
167
- bgMagenta: [45, 49],
168
- bgCyan: [46, 49],
169
- bgWhite: [47, 49],
170
- framed: [51, 54],
171
- overlined: [53, 55],
172
- gray: [90, 39],
173
- grey: [90, 39],
174
- redBright: [91, 39],
175
- greenBright: [92, 39],
176
- yellowBright: [93, 39],
177
- blueBright: [94, 39],
178
- magentaBright: [95, 39],
179
- cyanBright: [96, 39],
180
- whiteBright: [97, 39],
181
- bgBlackBright: [100, 49],
182
- bgRedBright: [101, 49],
183
- bgGreenBright: [102, 49],
184
- bgYellowBright: [103, 49],
185
- bgBlueBright: [104, 49],
186
- bgMagentaBright: [105, 49],
187
- bgCyanBright: [106, 49],
188
- bgWhiteBright: [107, 49]
189
- };
190
- /** Maps type names to color names for util.inspect output styling. */
191
- inspect.styles = {
192
- special: "cyan",
193
- number: "yellow",
194
- bigint: "yellow",
195
- boolean: "yellow",
196
- undefined: "grey",
197
- null: "bold",
198
- string: "green",
199
- symbol: "green",
200
- date: "magenta",
201
- regexp: "red",
202
- module: "underline"
203
- };
204
- function format(fmt, ...args) {
205
- if (fmt === undefined && args.length === 0) return "";
206
- if (typeof fmt !== "string") {
207
- if (args.length === 0) return inspect(fmt);
208
- const parts = [inspect(fmt)];
209
- for (const arg of args) parts.push(inspect(arg));
210
- return parts.join(" ");
211
- }
212
- let i = 0;
213
- let result = "";
214
- let lastIdx = 0;
215
- for (let p = 0; p < fmt.length - 1; p++) {
216
- if (fmt[p] !== "%") continue;
217
- if (p > lastIdx) result += fmt.slice(lastIdx, p);
218
- const next = fmt[p + 1];
219
- if (next === "%") {
220
- result += "%";
221
- lastIdx = p + 2;
222
- p++;
223
- continue;
224
- }
225
- if (i >= args.length) {
226
- result += "%" + next;
227
- lastIdx = p + 2;
228
- p++;
229
- continue;
230
- }
231
- const arg = args[i];
232
- switch (next) {
233
- case "s": {
234
- if (typeof arg === "bigint") {
235
- result += `${arg}n`;
236
- } else if (typeof arg === "symbol") {
237
- result += arg.toString();
238
- } else if (typeof arg === "number" && Object.is(arg, -0)) {
239
- result += "-0";
240
- } else if (typeof arg === "object" && arg !== null) {
241
- const proto = Object.getPrototypeOf(arg);
242
- if (proto === null || typeof arg.toString === "function" && arg.toString !== Object.prototype.toString && arg.toString !== Array.prototype.toString) {
243
- try {
244
- const str = arg.toString();
245
- if (typeof str === "string" && str !== "[object Object]") {
246
- result += str;
247
- } else {
248
- result += inspect(arg, { depth: 0 });
249
- }
250
- } catch {
251
- result += inspect(arg, { depth: 0 });
252
- }
253
- } else {
254
- result += inspect(arg, { depth: 0 });
255
- }
256
- } else {
257
- result += String(arg);
258
- }
259
- i++;
260
- break;
261
- }
262
- case "d": {
263
- if (typeof arg === "bigint") {
264
- result += `${arg}n`;
265
- } else if (typeof arg === "symbol") {
266
- result += "NaN";
267
- } else {
268
- const n = Number(arg);
269
- result += Object.is(n, -0) ? "-0" : String(n);
270
- }
271
- i++;
272
- break;
273
- }
274
- case "i": {
275
- if (typeof arg === "bigint") {
276
- result += `${arg}n`;
277
- } else if (typeof arg === "symbol") {
278
- result += "NaN";
279
- } else {
280
- const n = Number(arg);
281
- if (!isFinite(n)) {
282
- result += "NaN";
283
- } else {
284
- const truncated = Math.trunc(n);
285
- result += Object.is(truncated, -0) ? "-0" : String(truncated);
286
- }
287
- }
288
- i++;
289
- break;
290
- }
291
- case "f": {
292
- if (typeof arg === "bigint") {
293
- result += Number(arg).toString();
294
- } else if (typeof arg === "symbol") {
295
- result += "NaN";
296
- } else {
297
- const n = parseFloat(String(arg));
298
- result += Object.is(n, -0) ? "-0" : String(n);
299
- }
300
- i++;
301
- break;
302
- }
303
- case "j":
304
- try {
305
- result += JSON.stringify(args[i++]);
306
- } catch {
307
- result += "[Circular]";
308
- }
309
- break;
310
- case "o":
311
- result += inspect(args[i++], {
312
- showHidden: true,
313
- depth: 4
314
- });
315
- break;
316
- case "O":
317
- result += inspect(args[i++], { depth: 4 });
318
- break;
319
- default:
320
- result += "%" + next;
321
- break;
322
- }
323
- lastIdx = p + 2;
324
- p++;
325
- }
326
- if (lastIdx < fmt.length) {
327
- result += fmt.slice(lastIdx);
328
- }
329
- for (; i < args.length; i++) {
330
- const arg = args[i];
331
- if (typeof arg === "string") {
332
- result += " " + arg;
333
- } else {
334
- result += " " + inspect(arg);
335
- }
336
- }
337
- return result;
338
- }
339
- function formatWithOptions(inspectOptions, fmt, ...args) {
340
- return format(fmt, ...args);
341
- }
342
- const ANSI_REGEX = new RegExp("[\\u001B\\u009B][[\\]()#;?]*" + "(?:(?:(?:(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]+)*" + "|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]*)*)?" + "(?:\\u0007|\\u001B\\u005C|\\u009C))" + "|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?" + "[\\dA-PR-TZcf-nq-uy=><~]))", "g");
343
- function stripVTControlCharacters(str) {
344
- if (typeof str !== "string") {
345
- throw new TypeError("The \"str\" argument must be of type string. Received " + typeof str);
346
- }
347
- if (str.indexOf("\x1B") === -1 && str.indexOf("›") === -1) return str;
348
- return str.replace(ANSI_REGEX, "");
349
- }
350
- /**
351
- * Apply ANSI styling to text, using the format names from `inspect.colors`.
352
- * Per Node's spec, when `validateStream` is true (default) and the target
353
- * stream is not a TTY, return the unstyled text. We use `process.stdout` as
354
- * the default stream — the same as Node.
355
- */
356
- function styleText(format, text, options) {
357
- if (typeof text !== "string") {
358
- throw new TypeError("The \"text\" argument must be of type string. Received " + typeof text);
359
- }
360
- const validateStream = options?.validateStream ?? true;
361
- if (validateStream) {
362
- const stream = options?.stream ?? globalThis.process?.stdout;
363
- if (!stream?.isTTY) return text;
364
- }
365
- const formats = Array.isArray(format) ? format : [format];
366
- let openCodes = "";
367
- let closeCodes = "";
368
- for (const key of formats) {
369
- if (key === "none") continue;
370
- const style = inspect.colors[key];
371
- if (style === undefined) {
372
- throw new TypeError(`The "format" argument must be one of: ${Object.keys(inspect.colors).join(", ")}. Received '${key}'`);
373
- }
374
- openCodes += `[${style[0]}m`;
375
- closeCodes = `[${style[1]}m` + closeCodes;
376
- }
377
- return `${openCodes}${text}${closeCodes}`;
378
- }
379
- const kCustomPromisify = Symbol.for("nodejs.util.promisify.custom");
380
- function promisify(fn) {
381
- if (typeof fn !== "function") {
382
- throw new TypeError("The \"original\" argument must be of type Function");
383
- }
384
- const custom = fn[kCustomPromisify];
385
- if (typeof custom === "function") return custom;
386
- function promisified(...args) {
387
- return new Promise((resolve, reject) => {
388
- fn.call(this, ...args, (err, ...values) => {
389
- if (err) {
390
- reject(err);
391
- } else if (values.length <= 1) {
392
- resolve(values[0]);
393
- } else {
394
- resolve(values);
395
- }
396
- });
397
- });
398
- }
399
- Object.setPrototypeOf(promisified, Object.getPrototypeOf(fn));
400
- Object.defineProperty(promisified, kCustomPromisify, { value: promisified });
401
- return promisified;
402
- }
403
- promisify.custom = kCustomPromisify;
404
- function callbackify(fn) {
405
- if (typeof fn !== "function") {
406
- throw new TypeError("The \"original\" argument must be of type Function");
407
- }
408
- return function(...args) {
409
- const callback = args.pop();
410
- if (typeof callback !== "function") {
411
- throw new TypeError("The last argument must be of type Function");
412
- }
413
- fn.apply(this, args).then((result) => Promise.resolve().then(() => callback(null, result)), (err) => Promise.resolve().then(() => callback(err || new Error())));
414
- };
415
- }
416
- function deprecate(fn, msg, code) {
417
- let warned = false;
418
- function deprecated(...args) {
419
- if (!warned) {
420
- warned = true;
421
- const warning = code ? `[${code}] ${msg}` : msg;
422
- console.warn(`DeprecationWarning: ${warning}`);
423
- }
424
- return fn.apply(this, args);
425
- }
426
- Object.setPrototypeOf(deprecated, fn);
427
- return deprecated;
428
- }
429
- function debuglog(section) {
430
- let debug;
431
- return (...args) => {
432
- if (debug === undefined) {
433
- const nodeDebug = typeof globalThis.process?.env?.NODE_DEBUG === "string" ? globalThis.process.env.NODE_DEBUG : "";
434
- const regex = new RegExp(`\\b${section}\\b`, "i");
435
- if (regex.test(nodeDebug)) {
436
- const pid = typeof globalThis.process?.pid === "number" ? globalThis.process.pid : 0;
437
- debug = (...a) => {
438
- console.error(`${section.toUpperCase()} ${pid}:`, ...a);
439
- };
440
- } else {
441
- debug = () => {};
442
- }
443
- }
444
- debug(...args);
445
- };
446
- }
447
- function inherits(ctor, superCtor) {
448
- if (ctor === undefined || ctor === null) {
449
- const err = new TypeError("The \"ctor\" argument must be of type Function. Received " + String(ctor));
450
- err.code = "ERR_INVALID_ARG_TYPE";
451
- throw err;
452
- }
453
- if (superCtor === undefined || superCtor === null) {
454
- const err = new TypeError("The \"superCtor\" argument must be of type Function. Received " + String(superCtor));
455
- err.code = "ERR_INVALID_ARG_TYPE";
456
- throw err;
457
- }
458
- if (superCtor.prototype === undefined) {
459
- const err = new TypeError("The \"superCtor.prototype\" property must not be undefined");
460
- err.code = "ERR_INVALID_ARG_TYPE";
461
- throw err;
462
- }
463
- Object.defineProperty(ctor, "super_", {
464
- value: superCtor,
465
- writable: true,
466
- configurable: true
467
- });
468
- Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
469
- }
470
- function isBoolean(value) {
471
- return typeof value === "boolean";
472
- }
473
- function isNull(value) {
474
- return value === null;
475
- }
476
- function isNullOrUndefined(value) {
477
- return value == null;
478
- }
479
- function isNumber(value) {
480
- return typeof value === "number";
481
- }
482
- function isString(value) {
483
- return typeof value === "string";
484
- }
485
- function isSymbol(value) {
486
- return typeof value === "symbol";
487
- }
488
- function isUndefined(value) {
489
- return value === undefined;
490
- }
491
- function isObject(value) {
492
- return value !== null && typeof value === "object";
493
- }
494
- function isError(value) {
495
- return value instanceof Error;
496
- }
497
- function isFunction(value) {
498
- return typeof value === "function";
499
- }
500
- function isRegExp(value) {
501
- return value instanceof RegExp;
502
- }
503
- function isArray(value) {
504
- return Array.isArray(value);
505
- }
506
- function isPrimitive(value) {
507
- return value === null || typeof value !== "object" && typeof value !== "function";
508
- }
509
- function isDate(value) {
510
- return value instanceof Date;
511
- }
512
- function isBuffer(value) {
513
- return value instanceof Uint8Array && value.constructor?.name === "Buffer";
514
- }
515
- const TextDecoder = globalThis.TextDecoder;
516
- const TextEncoder = globalThis.TextEncoder;
517
- function isDeepStrictEqual(a, b) {
518
- if (Object.is(a, b)) return true;
519
- if (typeof a !== typeof b) return false;
520
- if (a === null || b === null) return false;
521
- if (typeof a !== "object") return false;
522
- const aObj = a;
523
- const bObj = b;
524
- if (Array.isArray(aObj) && Array.isArray(bObj)) {
525
- if (aObj.length !== bObj.length) return false;
526
- for (let i = 0; i < aObj.length; i++) {
527
- if (!isDeepStrictEqual(aObj[i], bObj[i])) return false;
528
- }
529
- return true;
530
- }
531
- if (Array.isArray(aObj) !== Array.isArray(bObj)) return false;
532
- if (aObj instanceof Date && bObj instanceof Date) {
533
- return aObj.getTime() === bObj.getTime();
534
- }
535
- if (aObj instanceof RegExp && bObj instanceof RegExp) {
536
- return aObj.source === bObj.source && aObj.flags === bObj.flags;
537
- }
538
- const aKeys = Object.keys(aObj);
539
- const bKeys = Object.keys(bObj);
540
- if (aKeys.length !== bKeys.length) return false;
541
- for (const key of aKeys) {
542
- if (!Object.prototype.hasOwnProperty.call(bObj, key)) return false;
543
- if (!isDeepStrictEqual(aObj[key], bObj[key])) return false;
544
- }
545
- return true;
546
- }
547
- function toUSVString(string) {
548
- if (typeof string.toWellFormed === "function") {
549
- return string.toWellFormed();
550
- }
551
- return string.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "�");
552
- }
553
- var src_default = {
554
- format,
555
- formatWithOptions,
556
- styleText,
557
- stripVTControlCharacters,
558
- inspect,
559
- promisify,
560
- callbackify,
561
- deprecate,
562
- debuglog,
563
- inherits,
564
- types: types_exports,
565
- isBoolean,
566
- isNull,
567
- isNullOrUndefined,
568
- isNumber,
569
- isString,
570
- isSymbol,
571
- isUndefined,
572
- isObject,
573
- isError,
574
- isFunction,
575
- isRegExp,
576
- isArray,
577
- isPrimitive,
578
- isDate,
579
- isBuffer,
580
- isDeepStrictEqual,
581
- toUSVString,
582
- TextDecoder: globalThis.TextDecoder,
583
- TextEncoder: globalThis.TextEncoder,
584
- getSystemErrorName,
585
- getSystemErrorMap
586
- };
587
-
588
- //#endregion
589
- export { TextDecoder, TextEncoder, callbackify, debuglog, src_default as default, deprecate, format, formatWithOptions, getSystemErrorMap, getSystemErrorName, inherits, inspect, isArray, isBoolean, isBuffer, isDate, isDeepStrictEqual, isError, isFunction, isNull, isNullOrUndefined, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, promisify, stripVTControlCharacters, styleText, toUSVString, types_exports as types };
1
+ import{getSystemErrorMap as e,getSystemErrorName as t}from"./errors.js";import{types_exports as n}from"./types.js";const r=Symbol.for(`nodejs.util.inspect.custom`);function i(e,t,n){if(e===null)return t.colors?`\x1B[1mnull\x1B[22m`:`null`;if(e===void 0)return t.colors?`\x1B[90mundefined\x1B[39m`:`undefined`;let s=t.depth??2;if(typeof e==`string`){let n=e.replace(/\\/g,`\\\\`);if(e.includes(`'`)&&!e.includes(`"`)){let e=n.replace(/"/g,`\\"`);return t.colors?`\x1b[32m"${e}"\x1b[39m`:`"${e}"`}let r=n.replace(/'/g,`\\'`);return t.colors?`\x1b[32m'${r}'\x1b[39m`:`'${r}'`}if(typeof e==`number`)return t.colors?`\x1b[33m${e}\x1b[39m`:String(e);if(typeof e==`bigint`)return t.colors?`\x1b[33m${e}n\x1b[39m`:`${e}n`;if(typeof e==`boolean`)return t.colors?`\x1b[33m${e}\x1b[39m`:String(e);if(typeof e==`symbol`)return t.colors?`\x1b[32m${e.toString()}\x1b[39m`:e.toString();if(typeof e==`function`){let n=e.name?`: ${e.name}`:``;return t.colors?`\x1b[36m[Function${n}]\x1b[39m`:`[Function${n}]`}if(typeof e==`object`&&e&&r in e){let a=e[r];if(typeof a==`function`){let r=a.call(e,n,t);return typeof r==`string`?r:i(r,t,n)}}if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return t.colors?`\x1b[31m${e.toString()}\x1b[39m`:e.toString();if(e instanceof Error)return e.stack||e.toString();if(n>s)return Array.isArray(e)?`[Array]`:`[Object]`;if(Array.isArray(e))return a(e,t,n);if(e instanceof Map){let r=[...e.entries()].map(([e,r])=>`${i(e,t,n+1)} => ${i(r,t,n+1)}`);return`Map(${e.size}) { ${r.join(`, `)} }`}if(e instanceof Set){let r=[...e].map(e=>i(e,t,n+1));return`Set(${e.size}) { ${r.join(`, `)} }`}if(ArrayBuffer.isView(e)&&!(e instanceof DataView)){let t=e.constructor?.name||`TypedArray`,n=Array.from(e);return`${t}(${n.length}) [ ${n.join(`, `)} ]`}return o(e,t,n)}function a(e,t,n){let r=t.maxArrayLength??100,a=Math.min(e.length,r),o=[];for(let r=0;r<a;r++)o.push(i(e[r],t,n+1));e.length>r&&o.push(`... ${e.length-r} more items`),t.showHidden&&o.push(`[length]: ${e.length}`);let s=t.breakLength??72,c=t.compact??3;if(typeof c==`number`&&c>0&&e.length>c){let e=e=>e.replace(/\x1b\[[0-9;]*m/g,``),t=Math.max(...o.map(t=>e(t).length)),n=Math.max(t-2,1),r=o.length,i=Math.min(Math.round(Math.sqrt(2.5*n*r)/n),Math.floor((s-2)/n),Math.floor((2.5+r-1)/2),15);if(i>1){let e=[];for(let t=0;t<r;t+=i)e.push(` `+o.slice(t,Math.min(t+i,r)).join(`, `));return`[\n${e.join(`,
2
+ `)}\n]`}}let l=`[ ${o.join(`, `)} ]`;return l.length<=s?l:`[\n${o.map(e=>` `+e).join(`,
3
+ `)}\n]`}function o(e,t,n){let r=t.showHidden?Object.getOwnPropertyNames(e):Object.keys(e);if(t.sorted&&r.sort(),r.length===0){let t=Object.prototype.toString.call(e);return t===`[object Object]`?`{}`:t}let a=r.map(r=>`${r}: ${i(e[r],t,n+1)}`),o=t.breakLength??72,s=`{ ${a.join(`, `)} }`;return s.length<=o?s:`{\n${a.map(e=>` `+e).join(`,
4
+ `)}\n}`}function s(e,t){let n=typeof t==`boolean`?{showHidden:t}:{...t};return n.colors===void 0&&(n.colors=!1),i(e,n,0)}s.custom=r,s.defaultOptions={showHidden:!1,depth:2,colors:!1,maxArrayLength:100,maxStringLength:1e4,breakLength:72,compact:3,sorted:!1},s.colors={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],blink:[5,25],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],doubleunderline:[21,24],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],framed:[51,54],overlined:[53,55],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},s.styles={special:`cyan`,number:`yellow`,bigint:`yellow`,boolean:`yellow`,undefined:`grey`,null:`bold`,string:`green`,symbol:`green`,date:`magenta`,regexp:`red`,module:`underline`};function c(e,...t){if(e===void 0&&t.length===0)return``;if(typeof e!=`string`){if(t.length===0)return s(e);let n=[s(e)];for(let e of t)n.push(s(e));return n.join(` `)}let n=0,r=``,i=0;for(let a=0;a<e.length-1;a++){if(e[a]!==`%`)continue;a>i&&(r+=e.slice(i,a));let o=e[a+1];if(o===`%`){r+=`%`,i=a+2,a++;continue}if(n>=t.length){r+=`%`+o,i=a+2,a++;continue}let c=t[n];switch(o){case`s`:if(typeof c==`bigint`)r+=`${c}n`;else if(typeof c==`symbol`)r+=c.toString();else if(typeof c==`number`&&Object.is(c,-0))r+=`-0`;else if(typeof c==`object`&&c)if(Object.getPrototypeOf(c)===null||typeof c.toString==`function`&&c.toString!==Object.prototype.toString&&c.toString!==Array.prototype.toString)try{let e=c.toString();typeof e==`string`&&e!==`[object Object]`?r+=e:r+=s(c,{depth:0})}catch{r+=s(c,{depth:0})}else r+=s(c,{depth:0});else r+=String(c);n++;break;case`d`:if(typeof c==`bigint`)r+=`${c}n`;else if(typeof c==`symbol`)r+=`NaN`;else{let e=Number(c);r+=Object.is(e,-0)?`-0`:String(e)}n++;break;case`i`:if(typeof c==`bigint`)r+=`${c}n`;else if(typeof c==`symbol`)r+=`NaN`;else{let e=Number(c);if(!isFinite(e))r+=`NaN`;else{let t=Math.trunc(e);r+=Object.is(t,-0)?`-0`:String(t)}}n++;break;case`f`:if(typeof c==`bigint`)r+=Number(c).toString();else if(typeof c==`symbol`)r+=`NaN`;else{let e=parseFloat(String(c));r+=Object.is(e,-0)?`-0`:String(e)}n++;break;case`j`:try{r+=JSON.stringify(t[n++])}catch{r+=`[Circular]`}break;case`o`:r+=s(t[n++],{showHidden:!0,depth:4});break;case`O`:r+=s(t[n++],{depth:4});break;default:r+=`%`+o;break}i=a+2,a++}for(i<e.length&&(r+=e.slice(i));n<t.length;n++){let e=t[n];typeof e==`string`?r+=` `+e:r+=` `+s(e)}return r}function l(e,t,...n){return c(t,...n)}const u=RegExp(`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`,`g`);function d(e){if(typeof e!=`string`)throw TypeError(`The "str" argument must be of type string. Received `+typeof e);return e.indexOf(`\x1B`)===-1&&e.indexOf(`›`)===-1?e:e.replace(u,``)}function f(e,t,n){if(typeof t!=`string`)throw TypeError(`The "text" argument must be of type string. Received `+typeof t);if((n?.validateStream??!0)&&!(n?.stream??globalThis.process?.stdout)?.isTTY)return t;let r=Array.isArray(e)?e:[e],i=``,a=``;for(let e of r){if(e===`none`)continue;let t=s.colors[e];if(t===void 0)throw TypeError(`The "format" argument must be one of: ${Object.keys(s.colors).join(`, `)}. Received '${e}'`);i+=`[${t[0]}m`,a=`[${t[1]}m`+a}return`${i}${t}${a}`}const p=Symbol.for(`nodejs.util.promisify.custom`);function m(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type Function`);let t=e[p];if(typeof t==`function`)return t;function n(...t){return new Promise((n,r)=>{e.call(this,...t,(e,...t)=>{e?r(e):t.length<=1?n(t[0]):n(t)})})}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperty(n,p,{value:n}),n}m.custom=p;function h(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type Function`);return function(...t){let n=t.pop();if(typeof n!=`function`)throw TypeError(`The last argument must be of type Function`);e.apply(this,t).then(e=>Promise.resolve().then(()=>n(null,e)),e=>Promise.resolve().then(()=>n(e||Error())))}}function g(e,t,n){let r=!1;function i(...i){if(!r){r=!0;let e=n?`[${n}] ${t}`:t;console.warn(`DeprecationWarning: ${e}`)}return e.apply(this,i)}return Object.setPrototypeOf(i,e),i}function _(e){let t;return(...n)=>{if(t===void 0){let n=typeof globalThis.process?.env?.NODE_DEBUG==`string`?globalThis.process.env.NODE_DEBUG:``;if(RegExp(`\\b${e}\\b`,`i`).test(n)){let n=typeof globalThis.process?.pid==`number`?globalThis.process.pid:0;t=(...t)=>{console.error(`${e.toUpperCase()} ${n}:`,...t)}}else t=()=>{}}t(...n)}}function v(e,t){if(e==null){let t=TypeError(`The "ctor" argument must be of type Function. Received `+String(e));throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(t==null){let e=TypeError(`The "superCtor" argument must be of type Function. Received `+String(t));throw e.code=`ERR_INVALID_ARG_TYPE`,e}if(t.prototype===void 0){let e=TypeError(`The "superCtor.prototype" property must not be undefined`);throw e.code=`ERR_INVALID_ARG_TYPE`,e}Object.defineProperty(e,`super_`,{value:t,writable:!0,configurable:!0}),Object.setPrototypeOf(e.prototype,t.prototype)}function y(e){return typeof e==`boolean`}function b(e){return e===null}function x(e){return e==null}function S(e){return typeof e==`number`}function C(e){return typeof e==`string`}function w(e){return typeof e==`symbol`}function T(e){return e===void 0}function E(e){return typeof e==`object`&&!!e}function D(e){return e instanceof Error}function O(e){return typeof e==`function`}function k(e){return e instanceof RegExp}function A(e){return Array.isArray(e)}function j(e){return e===null||typeof e!=`object`&&typeof e!=`function`}function M(e){return e instanceof Date}function N(e){return e instanceof Uint8Array&&e.constructor?.name===`Buffer`}const P=globalThis.TextDecoder,F=globalThis.TextEncoder;function I(e,t){if(Object.is(e,t))return!0;if(typeof e!=typeof t||e===null||t===null||typeof e!=`object`)return!1;let n=e,r=t;if(Array.isArray(n)&&Array.isArray(r)){if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(!I(n[e],r[e]))return!1;return!0}if(Array.isArray(n)!==Array.isArray(r))return!1;if(n instanceof Date&&r instanceof Date)return n.getTime()===r.getTime();if(n instanceof RegExp&&r instanceof RegExp)return n.source===r.source&&n.flags===r.flags;let i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e of i)if(!Object.prototype.hasOwnProperty.call(r,e)||!I(n[e],r[e]))return!1;return!0}function L(e){return typeof e.toWellFormed==`function`?e.toWellFormed():e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,`�`)}var R={format:c,formatWithOptions:l,styleText:f,stripVTControlCharacters:d,inspect:s,promisify:m,callbackify:h,deprecate:g,debuglog:_,inherits:v,types:n,isBoolean:y,isNull:b,isNullOrUndefined:x,isNumber:S,isString:C,isSymbol:w,isUndefined:T,isObject:E,isError:D,isFunction:O,isRegExp:k,isArray:A,isPrimitive:j,isDate:M,isBuffer:N,isDeepStrictEqual:I,toUSVString:L,TextDecoder:globalThis.TextDecoder,TextEncoder:globalThis.TextEncoder,getSystemErrorName:t,getSystemErrorMap:e};export{P as TextDecoder,F as TextEncoder,h as callbackify,_ as debuglog,R as default,g as deprecate,c as format,l as formatWithOptions,e as getSystemErrorMap,t as getSystemErrorName,v as inherits,s as inspect,A as isArray,y as isBoolean,N as isBuffer,M as isDate,I as isDeepStrictEqual,D as isError,O as isFunction,b as isNull,x as isNullOrUndefined,S as isNumber,E as isObject,j as isPrimitive,k as isRegExp,C as isString,w as isSymbol,T as isUndefined,m as promisify,d as stripVTControlCharacters,f as styleText,L as toUSVString,n as types};