mocha-compat 3.6.4 → 10.8.2
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/LICENSE +1 -1
- package/README.md +61 -110
- package/bin/_mocha +10 -0
- package/bin/mocha.js +142 -0
- package/browser-entry.js +61 -22
- package/lib/browser/highlight-tags.js +39 -0
- package/lib/browser/parse-query.js +24 -0
- package/lib/{template.html → browser/template.html} +7 -5
- package/lib/cli/cli.js +89 -0
- package/lib/cli/collect-files.js +137 -0
- package/lib/cli/commands.js +14 -0
- package/lib/cli/config.js +100 -0
- package/lib/cli/index.js +3 -0
- package/lib/cli/init.js +36 -0
- package/lib/cli/lookup-files.js +150 -0
- package/lib/cli/node-flags.js +85 -0
- package/lib/cli/one-and-dones.js +69 -0
- package/lib/cli/options.js +284 -0
- package/lib/cli/run-helpers.js +304 -0
- package/lib/cli/run-option-metadata.js +116 -0
- package/lib/cli/run.js +380 -0
- package/lib/cli/watch-run.js +377 -0
- package/lib/context.js +16 -42
- package/lib/errors.js +563 -0
- package/lib/hook.js +50 -9
- package/lib/interfaces/bdd.js +28 -29
- package/lib/interfaces/common.js +56 -21
- package/lib/interfaces/exports.js +4 -7
- package/lib/interfaces/qunit.js +10 -11
- package/lib/interfaces/tdd.js +15 -15
- package/lib/mocha.js +1073 -292
- package/lib/mocharc.json +10 -0
- package/lib/nodejs/buffered-worker-pool.js +188 -0
- package/lib/nodejs/esm-utils.js +106 -0
- package/lib/nodejs/file-unloader.js +15 -0
- package/lib/nodejs/parallel-buffered-runner.js +433 -0
- package/lib/nodejs/reporters/parallel-buffered.js +165 -0
- package/lib/nodejs/serializer.js +414 -0
- package/lib/nodejs/worker.js +151 -0
- package/lib/pending.js +3 -3
- package/lib/plugin-loader.js +286 -0
- package/lib/reporters/base.js +305 -205
- package/lib/reporters/doc.js +52 -21
- package/lib/reporters/dot.js +31 -18
- package/lib/reporters/html.js +153 -81
- package/lib/reporters/json-stream.js +53 -24
- package/lib/reporters/json.js +88 -18
- package/lib/reporters/landing.js +38 -16
- package/lib/reporters/list.js +34 -19
- package/lib/reporters/markdown.js +28 -15
- package/lib/reporters/min.js +22 -8
- package/lib/reporters/nyan.js +62 -58
- package/lib/reporters/progress.js +32 -19
- package/lib/reporters/spec.js +41 -23
- package/lib/reporters/tap.js +255 -32
- package/lib/reporters/xunit.js +89 -39
- package/lib/runnable.js +233 -148
- package/lib/runner.js +679 -380
- package/lib/stats-collector.js +83 -0
- package/lib/suite.js +376 -112
- package/lib/test.js +82 -21
- package/lib/utils.js +364 -477
- package/mocha.css +183 -54
- package/mocha.js +19840 -15846
- package/mocha.js.map +1 -0
- package/package.json +163 -336
- package/{lib/to-iso-string → vendor/serialize-javascript}/LICENSE +8 -6
- package/vendor/serialize-javascript/README.md +10 -0
- package/vendor/serialize-javascript/index.js +349 -0
- package/bin/_mocha-compat +0 -572
- package/bin/mocha-compat +0 -87
- package/bin/options.js +0 -41
- package/bower.json +0 -38
- package/images/error.png +0 -0
- package/images/ok.png +0 -0
- package/lib/browser/.eslintrc.yaml +0 -4
- package/lib/browser/debug.js +0 -7
- package/lib/browser/events.js +0 -195
- package/lib/browser/progress.js +0 -119
- package/lib/browser/tty.js +0 -13
- package/lib/ms.js +0 -130
- package/lib/to-iso-string/index.js +0 -37
- package/vendor/glob/LICENSE +0 -15
- package/vendor/glob/README.md +0 -399
- package/vendor/glob/common.js +0 -244
- package/vendor/glob/glob.js +0 -788
- package/vendor/glob/package.json +0 -55
- package/vendor/glob/sync.js +0 -486
- package/vendor/inflight/LICENSE +0 -15
- package/vendor/inflight/README.md +0 -37
- package/vendor/inflight/inflight.js +0 -54
- package/vendor/inflight/package.json +0 -29
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
// Vendored from serialize-javascript 7.1.1, with feature detection so it runs on the >=0.8 floor.
|
|
2
|
+
// Upstream needs Node >=20 only because it generates its UID with crypto.getRandomValues; every
|
|
3
|
+
// other 7.x change is portable, so the UID keeps using randombytes and the rest is carried over.
|
|
4
|
+
/*
|
|
5
|
+
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
|
|
6
|
+
Copyrights licensed under the New BSD License.
|
|
7
|
+
See the accompanying LICENSE file for terms.
|
|
8
|
+
*/ "use strict";
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "default", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function() {
|
|
15
|
+
return serialize;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _randombytes = /*#__PURE__*/ _interop_require_default(require("randombytes"));
|
|
19
|
+
function _instanceof(left, right) {
|
|
20
|
+
"@swc/helpers - instanceof";
|
|
21
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
22
|
+
return !!right[Symbol.hasInstance](left);
|
|
23
|
+
} else return left instanceof right;
|
|
24
|
+
}
|
|
25
|
+
function _interop_require_default(obj) {
|
|
26
|
+
return obj && obj.__esModule ? obj : {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _type_of(obj) {
|
|
31
|
+
"@swc/helpers - typeof";
|
|
32
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
33
|
+
}
|
|
34
|
+
var hasMap = typeof Map !== 'undefined';
|
|
35
|
+
var hasSet = typeof Set !== 'undefined';
|
|
36
|
+
var hasURL = typeof URL !== 'undefined';
|
|
37
|
+
var hasBigInt = typeof BigInt !== 'undefined';
|
|
38
|
+
var isArray = Array.isArray || function(x) {
|
|
39
|
+
return Object.prototype.toString.call(x) === '[object Array]';
|
|
40
|
+
};
|
|
41
|
+
// Object.assign is missing until Node 4, and only the sparse-array branch needs it
|
|
42
|
+
var assign = Object.assign || function(target, source) {
|
|
43
|
+
var keys = Object.keys(source);
|
|
44
|
+
for(var i = 0; i < keys.length; i++)target[keys[i]] = source[keys[i]];
|
|
45
|
+
return target;
|
|
46
|
+
};
|
|
47
|
+
// RegExp.prototype.flags is missing until Node 6; the individual booleans go back to ES3
|
|
48
|
+
function regexpFlags(re) {
|
|
49
|
+
if (typeof re.flags === 'string') return re.flags;
|
|
50
|
+
return (re.global ? 'g' : '') + (re.ignoreCase ? 'i' : '') + (re.multiline ? 'm' : '');
|
|
51
|
+
}
|
|
52
|
+
// Array.from is missing until Node 4, but Map/Set arrive in 0.12, so entries are collected by hand
|
|
53
|
+
function mapEntries(map) {
|
|
54
|
+
var out = [];
|
|
55
|
+
map.forEach(function(value, key) {
|
|
56
|
+
out.push([
|
|
57
|
+
key,
|
|
58
|
+
value
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
function setValues(set) {
|
|
64
|
+
var out = [];
|
|
65
|
+
set.forEach(function(value) {
|
|
66
|
+
out.push(value);
|
|
67
|
+
});
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
// Generate an internal UID to make the regexp pattern harder to guess.
|
|
71
|
+
var UID_LENGTH = 16;
|
|
72
|
+
var UID = generateUID();
|
|
73
|
+
var PLACE_HOLDER_REGEXP = new RegExp('(\\\\)?"@__(F|R|D|M|S|A|U|I|B|L)-'.concat(UID, '-(\\d+)__@"'), 'g');
|
|
74
|
+
var IS_NATIVE_CODE_REGEXP = /\{\s*\[native code\]\s*\}/g;
|
|
75
|
+
var IS_PURE_FUNCTION = /function.*?\(/;
|
|
76
|
+
var IS_ARROW_FUNCTION = /.*?=>.*?/;
|
|
77
|
+
var UNSAFE_CHARS_REGEXP = /[<>/\u2028\u2029]/g;
|
|
78
|
+
// Matches a script end tag (case-insensitive) for XSS protection: either a full `</script...>` tag,
|
|
79
|
+
// or a bare `</script` followed by a character the HTML tokenizer treats as ending the tag name.
|
|
80
|
+
var SCRIPT_CLOSE_REGEXP = /<\/script[^>]*>|<\/script(?=[\t\n\f\r /><])/gi;
|
|
81
|
+
var RESERVED_SYMBOLS = [
|
|
82
|
+
'*',
|
|
83
|
+
'async'
|
|
84
|
+
];
|
|
85
|
+
// Mapping of unsafe HTML and invalid JavaScript line terminator chars to their
|
|
86
|
+
// Unicode char counterparts which are safe to use in JavaScript strings.
|
|
87
|
+
var ESCAPED_CHARS = {
|
|
88
|
+
'<': '\\u003C',
|
|
89
|
+
'>': '\\u003E',
|
|
90
|
+
'/': '\\u002F',
|
|
91
|
+
'\u2028': '\\u2028',
|
|
92
|
+
'\u2029': '\\u2029'
|
|
93
|
+
};
|
|
94
|
+
function escapeUnsafeChars(unsafeChar) {
|
|
95
|
+
return ESCAPED_CHARS[unsafeChar];
|
|
96
|
+
}
|
|
97
|
+
// Roughly matches string literals, template literals, regex literals and comments, so a script-close
|
|
98
|
+
// sequence inside one can be escaped differently from one in plain code. A heuristic, not a parser.
|
|
99
|
+
var STRING_OR_COMMENT_REGEXP = /\/\*[\s\S]*?\*\/|\/\/[^\n]*|'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|`(?:\\.|[^`\\])*`|\/(?:\\.|\[(?:\\.|[^\]\\\n])*\]|[^/\\\n])+\//g;
|
|
100
|
+
// Escape a function body for XSS protection while preserving arrow syntax, comparison operators and
|
|
101
|
+
// regex literals: only script end tags and line terminators are escaped.
|
|
102
|
+
function escapeFunctionBody(str) {
|
|
103
|
+
var stringAndCommentSpans = [];
|
|
104
|
+
var match;
|
|
105
|
+
STRING_OR_COMMENT_REGEXP.lastIndex = 0;
|
|
106
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: exec-loop is the documented RegExp idiom
|
|
107
|
+
while(match = STRING_OR_COMMENT_REGEXP.exec(str)){
|
|
108
|
+
stringAndCommentSpans.push([
|
|
109
|
+
match.index,
|
|
110
|
+
match.index + match[0].length
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
// Matches and spans are both in increasing offset order, so one forward cursor classifies every
|
|
114
|
+
// match in O(n) instead of rescanning the spans each time.
|
|
115
|
+
var spanCursor = 0;
|
|
116
|
+
var out = str.replace(SCRIPT_CLOSE_REGEXP, function(scriptCloseMatch, offset) {
|
|
117
|
+
while(spanCursor < stringAndCommentSpans.length && stringAndCommentSpans[spanCursor][1] <= offset){
|
|
118
|
+
spanCursor++;
|
|
119
|
+
}
|
|
120
|
+
var span = stringAndCommentSpans[spanCursor];
|
|
121
|
+
var inStringOrComment = !!span && offset >= span[0] && offset < span[1];
|
|
122
|
+
if (!inStringOrComment) {
|
|
123
|
+
// In plain code `<` and `/` may be real tokens, so they cannot be rewritten as unicode escapes
|
|
124
|
+
// without breaking syntax. A space is a no-op that still breaks up the `</script` sequence.
|
|
125
|
+
return "< ".concat(scriptCloseMatch.slice(1));
|
|
126
|
+
}
|
|
127
|
+
// Inside a string/template/regex/comment the characters must survive exactly, so escape instead.
|
|
128
|
+
return scriptCloseMatch.replace(/</g, '\\u003C').replace(/\//g, '\\u002F').replace(/>/g, '\\u003E');
|
|
129
|
+
});
|
|
130
|
+
out = out.replace(/\u2028/g, '\\u2028');
|
|
131
|
+
out = out.replace(/\u2029/g, '\\u2029');
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
function generateUID() {
|
|
135
|
+
var bytes = (0, _randombytes.default)(UID_LENGTH);
|
|
136
|
+
var result = '';
|
|
137
|
+
for(var i = 0; i < UID_LENGTH; ++i){
|
|
138
|
+
result += bytes[i].toString(16);
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
function deleteFunctions(obj) {
|
|
143
|
+
var functionKeys = [];
|
|
144
|
+
for(var key in obj){
|
|
145
|
+
if (typeof obj[key] === 'function') {
|
|
146
|
+
functionKeys.push(key);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for(var i = 0; i < functionKeys.length; i++){
|
|
150
|
+
delete obj[functionKeys[i]];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function serialize(obj, options) {
|
|
154
|
+
var opts = {};
|
|
155
|
+
if (options) {
|
|
156
|
+
// Backwards-compatibility for `space` as the second argument.
|
|
157
|
+
if (typeof options === 'number' || typeof options === 'string') {
|
|
158
|
+
opts = {
|
|
159
|
+
space: options
|
|
160
|
+
};
|
|
161
|
+
} else {
|
|
162
|
+
opts = options;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
var functions = [];
|
|
166
|
+
var regexps = [];
|
|
167
|
+
var dates = [];
|
|
168
|
+
var maps = [];
|
|
169
|
+
var sets = [];
|
|
170
|
+
var arrays = [];
|
|
171
|
+
var undefs = [];
|
|
172
|
+
var infinities = [];
|
|
173
|
+
var bigInts = [];
|
|
174
|
+
var urls = [];
|
|
175
|
+
// Returns placeholders for functions and regexps (identified by index)
|
|
176
|
+
// which are later replaced by their string representation.
|
|
177
|
+
function replacer(key, value) {
|
|
178
|
+
// For nested function
|
|
179
|
+
if (opts.ignoreFunction) {
|
|
180
|
+
deleteFunctions(value);
|
|
181
|
+
}
|
|
182
|
+
if (hasBigInt && !value && value !== undefined && value !== BigInt(0)) {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
// If the value is an object w/ a toJSON method, toJSON is called before
|
|
186
|
+
// the replacer runs, so we use this[key] to get the non-toJSONed value.
|
|
187
|
+
var origValue = this[key];
|
|
188
|
+
var type = typeof origValue === "undefined" ? "undefined" : _type_of(origValue);
|
|
189
|
+
if (type === 'object') {
|
|
190
|
+
if (_instanceof(origValue, RegExp)) {
|
|
191
|
+
return "@__R-".concat(UID, "-").concat(regexps.push(origValue) - 1, "__@");
|
|
192
|
+
}
|
|
193
|
+
if (_instanceof(origValue, Date)) {
|
|
194
|
+
return "@__D-".concat(UID, "-").concat(dates.push(origValue) - 1, "__@");
|
|
195
|
+
}
|
|
196
|
+
if (hasMap && _instanceof(origValue, Map)) {
|
|
197
|
+
return "@__M-".concat(UID, "-").concat(maps.push(origValue) - 1, "__@");
|
|
198
|
+
}
|
|
199
|
+
if (hasSet && _instanceof(origValue, Set)) {
|
|
200
|
+
return "@__S-".concat(UID, "-").concat(sets.push(origValue) - 1, "__@");
|
|
201
|
+
}
|
|
202
|
+
if (isArray(origValue)) {
|
|
203
|
+
var isSparse = origValue.filter(function() {
|
|
204
|
+
return true;
|
|
205
|
+
}).length !== origValue.length;
|
|
206
|
+
if (isSparse) {
|
|
207
|
+
return "@__A-".concat(UID, "-").concat(arrays.push(origValue) - 1, "__@");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (hasURL && _instanceof(origValue, URL)) {
|
|
211
|
+
return "@__L-".concat(UID, "-").concat(urls.push(origValue) - 1, "__@");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (type === 'function') {
|
|
215
|
+
return "@__F-".concat(UID, "-").concat(functions.push(origValue) - 1, "__@");
|
|
216
|
+
}
|
|
217
|
+
if (type === 'undefined') {
|
|
218
|
+
return "@__U-".concat(UID, "-").concat(undefs.push(origValue) - 1, "__@");
|
|
219
|
+
}
|
|
220
|
+
if (type === 'number' && !Number.isNaN(origValue) && !Number.isFinite(origValue)) {
|
|
221
|
+
return "@__I-".concat(UID, "-").concat(infinities.push(origValue) - 1, "__@");
|
|
222
|
+
}
|
|
223
|
+
if (type === 'bigint') {
|
|
224
|
+
return "@__B-".concat(UID, "-").concat(bigInts.push(origValue) - 1, "__@");
|
|
225
|
+
}
|
|
226
|
+
return value;
|
|
227
|
+
}
|
|
228
|
+
function serializeFunc(fn, funcOptions) {
|
|
229
|
+
var serializedFn = fn.toString();
|
|
230
|
+
if (IS_NATIVE_CODE_REGEXP.test(serializedFn)) {
|
|
231
|
+
throw new TypeError("Serializing native function: ".concat(fn.name));
|
|
232
|
+
}
|
|
233
|
+
// Escape unsafe HTML characters in function body for XSS protection
|
|
234
|
+
if (funcOptions && funcOptions.unsafe !== true) {
|
|
235
|
+
serializedFn = escapeFunctionBody(serializedFn);
|
|
236
|
+
}
|
|
237
|
+
// pure functions, example: {key: function() {}}
|
|
238
|
+
if (IS_PURE_FUNCTION.test(serializedFn)) {
|
|
239
|
+
return serializedFn;
|
|
240
|
+
}
|
|
241
|
+
// arrow functions, example: arg1 => arg1+5
|
|
242
|
+
if (IS_ARROW_FUNCTION.test(serializedFn)) {
|
|
243
|
+
return serializedFn;
|
|
244
|
+
}
|
|
245
|
+
var argsStartsAt = serializedFn.indexOf('(');
|
|
246
|
+
var def = serializedFn.substr(0, argsStartsAt).trim().split(' ').filter(function(val) {
|
|
247
|
+
return val.length > 0;
|
|
248
|
+
});
|
|
249
|
+
var nonReservedSymbols = def.filter(function(val) {
|
|
250
|
+
return RESERVED_SYMBOLS.indexOf(val) === -1;
|
|
251
|
+
});
|
|
252
|
+
// enhanced literal objects, example: {key() {}}
|
|
253
|
+
if (nonReservedSymbols.length > 0) {
|
|
254
|
+
return "".concat(def.indexOf('async') > -1 ? 'async ' : '', "function").concat(def.join('').indexOf('*') > -1 ? '*' : '').concat(serializedFn.substr(argsStartsAt));
|
|
255
|
+
}
|
|
256
|
+
// arrow functions
|
|
257
|
+
return serializedFn;
|
|
258
|
+
}
|
|
259
|
+
// Check if the parameter is function
|
|
260
|
+
var objToSerialize = obj;
|
|
261
|
+
if (opts.ignoreFunction && typeof objToSerialize === 'function') {
|
|
262
|
+
objToSerialize = undefined;
|
|
263
|
+
}
|
|
264
|
+
// Protects against `JSON.stringify()` returning `undefined`, by serializing
|
|
265
|
+
// to the literal string: "undefined".
|
|
266
|
+
if (objToSerialize === undefined) {
|
|
267
|
+
return String(objToSerialize);
|
|
268
|
+
}
|
|
269
|
+
var str;
|
|
270
|
+
// Creates a JSON string representation of the value.
|
|
271
|
+
// NOTE: Node 0.12 goes into slow mode with extra JSON.stringify() args.
|
|
272
|
+
if (opts.isJSON && !opts.space) {
|
|
273
|
+
str = JSON.stringify(objToSerialize);
|
|
274
|
+
} else {
|
|
275
|
+
str = JSON.stringify(objToSerialize, opts.isJSON ? null : replacer, opts.space);
|
|
276
|
+
}
|
|
277
|
+
// Protects against `JSON.stringify()` returning `undefined`, by serializing
|
|
278
|
+
// to the literal string: "undefined".
|
|
279
|
+
if (typeof str !== 'string') {
|
|
280
|
+
return String(str);
|
|
281
|
+
}
|
|
282
|
+
// Replace unsafe HTML and invalid JavaScript line terminator chars with
|
|
283
|
+
// their safe Unicode char counterpart. This _must_ happen before the
|
|
284
|
+
// regexps and functions are serialized and added back to the string.
|
|
285
|
+
if (opts.unsafe !== true) {
|
|
286
|
+
str = str.replace(UNSAFE_CHARS_REGEXP, escapeUnsafeChars);
|
|
287
|
+
}
|
|
288
|
+
if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && arrays.length === 0 && undefs.length === 0 && infinities.length === 0 && bigInts.length === 0 && urls.length === 0) {
|
|
289
|
+
return str;
|
|
290
|
+
}
|
|
291
|
+
// Replaces all occurrences of function, regexp, date, map and set placeholders in the
|
|
292
|
+
// JSON string with their string representations. If the original value can
|
|
293
|
+
// not be found, then `undefined` is used.
|
|
294
|
+
return str.replace(PLACE_HOLDER_REGEXP, function(match, backSlash, type, valueIndex) {
|
|
295
|
+
// The placeholder may not be preceded by a backslash. This is to prevent
|
|
296
|
+
// replacing things like `"a\"@__R-<UID>-0__@"` and thus outputting
|
|
297
|
+
// invalid JS.
|
|
298
|
+
if (backSlash) {
|
|
299
|
+
return match;
|
|
300
|
+
}
|
|
301
|
+
if (type === 'D') {
|
|
302
|
+
// Validate the ISO string to prevent code injection through a spoofed toISOString()
|
|
303
|
+
var isoStr = String(dates[valueIndex].toISOString());
|
|
304
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/.test(isoStr)) {
|
|
305
|
+
throw new TypeError('Invalid Date ISO string');
|
|
306
|
+
}
|
|
307
|
+
return 'new Date("'.concat(isoStr, '")');
|
|
308
|
+
}
|
|
309
|
+
if (type === 'R') {
|
|
310
|
+
// Sanitize flags to prevent code injection (only valid RegExp flag characters survive)
|
|
311
|
+
var flags = String(regexpFlags(regexps[valueIndex])).replace(/[^gimsuydv]/g, '');
|
|
312
|
+
var regexpSource = regexps[valueIndex].source;
|
|
313
|
+
if (typeof regexpSource !== 'string') {
|
|
314
|
+
throw new TypeError('RegExp.source must be a string');
|
|
315
|
+
}
|
|
316
|
+
return "new RegExp(".concat(serialize(regexpSource), ', "').concat(flags, '")');
|
|
317
|
+
}
|
|
318
|
+
if (type === 'M') {
|
|
319
|
+
return "new Map(".concat(serialize(mapEntries(maps[valueIndex]), opts), ")");
|
|
320
|
+
}
|
|
321
|
+
if (type === 'S') {
|
|
322
|
+
return "new Set(".concat(serialize(setValues(sets[valueIndex]), opts), ")");
|
|
323
|
+
}
|
|
324
|
+
if (type === 'A') {
|
|
325
|
+
return "Array.prototype.slice.call(".concat(serialize(assign({
|
|
326
|
+
length: arrays[valueIndex].length
|
|
327
|
+
}, arrays[valueIndex]), opts), ")");
|
|
328
|
+
}
|
|
329
|
+
if (type === 'U') {
|
|
330
|
+
return 'undefined';
|
|
331
|
+
}
|
|
332
|
+
if (type === 'I') {
|
|
333
|
+
return String(infinities[valueIndex]);
|
|
334
|
+
}
|
|
335
|
+
if (type === 'B') {
|
|
336
|
+
return 'BigInt("'.concat(bigInts[valueIndex], '")');
|
|
337
|
+
}
|
|
338
|
+
if (type === 'L') {
|
|
339
|
+
var urlStr = urls[valueIndex].toString();
|
|
340
|
+
if (typeof urlStr !== 'string') {
|
|
341
|
+
throw new TypeError('URL.toString() must return a string');
|
|
342
|
+
}
|
|
343
|
+
return "new URL(".concat(serialize(urlStr, opts), ")");
|
|
344
|
+
}
|
|
345
|
+
var fn = functions[valueIndex];
|
|
346
|
+
return serializeFunc(fn, opts);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|