@gjsify/util 0.3.13 → 0.3.14
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/_virtual/_rolldown/runtime.js +18 -0
- package/lib/esm/errors.js +251 -251
- package/lib/esm/index.js +519 -554
- package/lib/esm/types/index.js +156 -203
- package/lib/esm/types.js +51 -5
- package/package.json +3 -3
package/lib/esm/index.js
CHANGED
|
@@ -1,624 +1,589 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
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");
|
|
4
6
|
function inspectValue(value, opts, depth) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return inspectObject(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
72
|
}
|
|
73
73
|
function inspectArray(arr, opts, depth) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
${rows.join(",\n")}
|
|
109
|
-
]`;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const singleLine = `[ ${items.join(", ")} ]`;
|
|
113
|
-
if (singleLine.length <= breakLength) return singleLine;
|
|
114
|
-
return `[
|
|
115
|
-
${items.map((i) => " " + i).join(",\n")}
|
|
116
|
-
]`;
|
|
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]`;
|
|
117
108
|
}
|
|
118
109
|
function inspectObject(obj, opts, depth) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
${items.map((i) => " " + i).join(",\n")}
|
|
135
|
-
}`;
|
|
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}`;
|
|
136
125
|
}
|
|
137
126
|
function inspect(value, opts) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
127
|
+
const options = typeof opts === "boolean" ? { showHidden: opts } : { ...opts };
|
|
128
|
+
if (options.colors === undefined) options.colors = false;
|
|
129
|
+
return inspectValue(value, options, 0);
|
|
141
130
|
}
|
|
142
131
|
inspect.custom = kCustomInspect;
|
|
143
132
|
inspect.defaultOptions = {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
133
|
+
showHidden: false,
|
|
134
|
+
depth: 2,
|
|
135
|
+
colors: false,
|
|
136
|
+
maxArrayLength: 100,
|
|
137
|
+
maxStringLength: 1e4,
|
|
138
|
+
breakLength: 72,
|
|
139
|
+
compact: 3,
|
|
140
|
+
sorted: false
|
|
152
141
|
};
|
|
142
|
+
/** ANSI color code pairs [open, close] for terminal coloring. */
|
|
153
143
|
inspect.colors = {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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]
|
|
199
189
|
};
|
|
190
|
+
/** Maps type names to color names for util.inspect output styling. */
|
|
200
191
|
inspect.styles = {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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"
|
|
212
203
|
};
|
|
213
204
|
function format(fmt, ...args) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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;
|
|
344
338
|
}
|
|
345
339
|
function formatWithOptions(inspectOptions, fmt, ...args) {
|
|
346
|
-
|
|
340
|
+
return format(fmt, ...args);
|
|
347
341
|
}
|
|
348
|
-
const ANSI_REGEX = new RegExp(
|
|
349
|
-
"[\\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=><~]))",
|
|
350
|
-
"g"
|
|
351
|
-
);
|
|
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");
|
|
352
343
|
function stripVTControlCharacters(str) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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, "");
|
|
358
349
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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}`;
|
|
381
378
|
}
|
|
382
|
-
const kCustomPromisify =
|
|
379
|
+
const kCustomPromisify = Symbol.for("nodejs.util.promisify.custom");
|
|
383
380
|
function promisify(fn) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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;
|
|
405
402
|
}
|
|
406
403
|
promisify.custom = kCustomPromisify;
|
|
407
404
|
function callbackify(fn) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
(err) => Promise.resolve().then(() => callback(err || new Error()))
|
|
419
|
-
);
|
|
420
|
-
};
|
|
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
|
+
};
|
|
421
415
|
}
|
|
422
416
|
function deprecate(fn, msg, code) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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;
|
|
434
428
|
}
|
|
435
429
|
function debuglog(section) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
};
|
|
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
|
+
};
|
|
453
446
|
}
|
|
454
447
|
function inherits(ctor, superCtor) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
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);
|
|
472
469
|
}
|
|
473
470
|
function isBoolean(value) {
|
|
474
|
-
|
|
471
|
+
return typeof value === "boolean";
|
|
475
472
|
}
|
|
476
473
|
function isNull(value) {
|
|
477
|
-
|
|
474
|
+
return value === null;
|
|
478
475
|
}
|
|
479
476
|
function isNullOrUndefined(value) {
|
|
480
|
-
|
|
477
|
+
return value == null;
|
|
481
478
|
}
|
|
482
479
|
function isNumber(value) {
|
|
483
|
-
|
|
480
|
+
return typeof value === "number";
|
|
484
481
|
}
|
|
485
482
|
function isString(value) {
|
|
486
|
-
|
|
483
|
+
return typeof value === "string";
|
|
487
484
|
}
|
|
488
485
|
function isSymbol(value) {
|
|
489
|
-
|
|
486
|
+
return typeof value === "symbol";
|
|
490
487
|
}
|
|
491
488
|
function isUndefined(value) {
|
|
492
|
-
|
|
489
|
+
return value === undefined;
|
|
493
490
|
}
|
|
494
491
|
function isObject(value) {
|
|
495
|
-
|
|
492
|
+
return value !== null && typeof value === "object";
|
|
496
493
|
}
|
|
497
494
|
function isError(value) {
|
|
498
|
-
|
|
495
|
+
return value instanceof Error;
|
|
499
496
|
}
|
|
500
497
|
function isFunction(value) {
|
|
501
|
-
|
|
498
|
+
return typeof value === "function";
|
|
502
499
|
}
|
|
503
500
|
function isRegExp(value) {
|
|
504
|
-
|
|
501
|
+
return value instanceof RegExp;
|
|
505
502
|
}
|
|
506
503
|
function isArray(value) {
|
|
507
|
-
|
|
504
|
+
return Array.isArray(value);
|
|
508
505
|
}
|
|
509
506
|
function isPrimitive(value) {
|
|
510
|
-
|
|
507
|
+
return value === null || typeof value !== "object" && typeof value !== "function";
|
|
511
508
|
}
|
|
512
509
|
function isDate(value) {
|
|
513
|
-
|
|
510
|
+
return value instanceof Date;
|
|
514
511
|
}
|
|
515
512
|
function isBuffer(value) {
|
|
516
|
-
|
|
513
|
+
return value instanceof Uint8Array && value.constructor?.name === "Buffer";
|
|
517
514
|
}
|
|
518
515
|
const TextDecoder = globalThis.TextDecoder;
|
|
519
516
|
const TextEncoder = globalThis.TextEncoder;
|
|
520
517
|
function isDeepStrictEqual(a, b) {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
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;
|
|
549
546
|
}
|
|
550
547
|
function toUSVString(string) {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
548
|
+
if (typeof string.toWellFormed === "function") {
|
|
549
|
+
return string.toWellFormed();
|
|
550
|
+
}
|
|
551
|
+
return string.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "�");
|
|
555
552
|
}
|
|
556
|
-
var
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
};
|
|
590
|
-
export {
|
|
591
|
-
TextDecoder,
|
|
592
|
-
TextEncoder,
|
|
593
|
-
callbackify,
|
|
594
|
-
debuglog,
|
|
595
|
-
index_default as default,
|
|
596
|
-
deprecate,
|
|
597
|
-
format,
|
|
598
|
-
formatWithOptions,
|
|
599
|
-
getSystemErrorMap,
|
|
600
|
-
getSystemErrorName,
|
|
601
|
-
inherits,
|
|
602
|
-
inspect,
|
|
603
|
-
isArray,
|
|
604
|
-
isBoolean,
|
|
605
|
-
isBuffer,
|
|
606
|
-
isDate,
|
|
607
|
-
isDeepStrictEqual,
|
|
608
|
-
isError,
|
|
609
|
-
isFunction,
|
|
610
|
-
isNull,
|
|
611
|
-
isNullOrUndefined,
|
|
612
|
-
isNumber,
|
|
613
|
-
isObject,
|
|
614
|
-
isPrimitive,
|
|
615
|
-
isRegExp,
|
|
616
|
-
isString,
|
|
617
|
-
isSymbol,
|
|
618
|
-
isUndefined,
|
|
619
|
-
promisify,
|
|
620
|
-
stripVTControlCharacters,
|
|
621
|
-
styleText,
|
|
622
|
-
toUSVString,
|
|
623
|
-
types
|
|
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
|
|
624
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 };
|