@eggjs/mock 6.1.0-beta.9 → 7.0.0-beta.13

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.
Files changed (102) hide show
  1. package/README.md +1 -1
  2. package/README.zh_CN.md +1 -1
  3. package/dist/_virtual/rolldown_runtime.js +1 -24
  4. package/dist/inject_mocha.d.ts +1 -1
  5. package/dist/inject_mocha.js +2 -3
  6. package/dist/lib/context.js +1 -3
  7. package/package.json +8 -11
  8. package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +0 -142
  9. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +0 -157
  10. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +0 -97
  11. package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +0 -40
  12. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +0 -814
  13. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +0 -50
  14. package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +0 -68
  15. package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +0 -752
  16. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +0 -203
  17. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +0 -209
  18. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +0 -18
  19. package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +0 -215
  20. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +0 -24
  21. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +0 -33
  22. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +0 -29
  23. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +0 -185
  24. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +0 -23
  25. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +0 -26
  26. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +0 -83
  27. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +0 -51
  28. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +0 -26
  29. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +0 -151
  30. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +0 -178
  31. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +0 -168
  32. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +0 -301
  33. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +0 -137
  34. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +0 -367
  35. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +0 -91
  36. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +0 -99
  37. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +0 -23
  38. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +0 -30
  39. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +0 -22
  40. package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +0 -97
  41. package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +0 -14
  42. package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +0 -16
  43. package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +0 -4093
  44. package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +0 -14
  45. package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +0 -27
  46. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +0 -12
  47. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +0 -83
  48. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +0 -35
  49. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +0 -392
  50. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +0 -86
  51. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +0 -104
  52. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +0 -99
  53. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +0 -65
  54. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +0 -18
  55. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +0 -95
  56. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +0 -105
  57. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +0 -1037
  58. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +0 -24
  59. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +0 -152
  60. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +0 -74
  61. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +0 -22
  62. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +0 -329
  63. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +0 -314
  64. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +0 -22
  65. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +0 -417
  66. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +0 -79
  67. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +0 -75
  68. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +0 -283
  69. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +0 -40
  70. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +0 -90
  71. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +0 -145
  72. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +0 -107
  73. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +0 -77
  74. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +0 -106
  75. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +0 -57
  76. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +0 -233
  77. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +0 -92
  78. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +0 -91
  79. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +0 -261
  80. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +0 -166
  81. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +0 -346
  82. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +0 -922
  83. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +0 -72
  84. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +0 -517
  85. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +0 -105
  86. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +0 -505
  87. package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +0 -225
  88. package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +0 -124
  89. package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +0 -11
  90. package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +0 -114
  91. package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +0 -76
  92. package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +0 -89
  93. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +0 -366
  94. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +0 -248
  95. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +0 -419
  96. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +0 -27
  97. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +0 -18
  98. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +0 -16
  99. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +0 -63
  100. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +0 -21
  101. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +0 -9
  102. package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +0 -277
@@ -1,505 +0,0 @@
1
- import { __commonJS, __require } from "../../../../../../_virtual/rolldown_runtime.js";
2
- import { require_he } from "../../../../he@1.2.0/node_modules/he/he.js";
3
-
4
- //#region ../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js
5
- var require_utils = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js": ((exports) => {
6
- /**
7
- * Various utility functions used throughout Mocha's codebase.
8
- * @module utils
9
- */
10
- /**
11
- * Module dependencies.
12
- */
13
- var path = __require("node:path");
14
- var util = __require("node:util");
15
- var he = require_he();
16
- const MOCHA_ID_PROP_NAME = "__mocha_id__";
17
- /**
18
- * Inherit the prototype methods from one constructor into another.
19
- *
20
- * @param {function} ctor - Constructor function which needs to inherit the
21
- * prototype.
22
- * @param {function} superCtor - Constructor function to inherit prototype from.
23
- * @throws {TypeError} if either constructor is null, or if super constructor
24
- * lacks a prototype.
25
- */
26
- exports.inherits = util.inherits;
27
- /**
28
- * Escape special characters in the given string of html.
29
- *
30
- * @private
31
- * @param {string} html
32
- * @return {string}
33
- */
34
- exports.escape = function(html) {
35
- return he.encode(String(html), { useNamedReferences: false });
36
- };
37
- /**
38
- * Test if the given obj is type of string.
39
- *
40
- * @private
41
- * @param {Object} obj
42
- * @return {boolean}
43
- */
44
- exports.isString = function(obj) {
45
- return typeof obj === "string";
46
- };
47
- /**
48
- * Compute a slug from the given `str`.
49
- *
50
- * @private
51
- * @param {string} str
52
- * @return {string}
53
- */
54
- exports.slug = function(str) {
55
- return str.toLowerCase().replace(/\s+/g, "-").replace(/[^-\w]/g, "").replace(/-{2,}/g, "-");
56
- };
57
- /**
58
- * Strip the function definition from `str`, and re-indent for pre whitespace.
59
- *
60
- * @param {string} str
61
- * @return {string}
62
- */
63
- exports.clean = function(str) {
64
- str = str.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, "").replace(/^function(?:\s*|\s[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\}|((?:.|\n)*))$/, "$1$2$3");
65
- var spaces = str.match(/^\n?( *)/)[1].length;
66
- var tabs = str.match(/^\n?(\t*)/)[1].length;
67
- var re = new RegExp("^\n?" + (tabs ? " " : " ") + "{" + (tabs || spaces) + "}", "gm");
68
- str = str.replace(re, "");
69
- return str.trim();
70
- };
71
- /**
72
- * If a value could have properties, and has none, this function is called,
73
- * which returns a string representation of the empty value.
74
- *
75
- * Functions w/ no properties return `'[Function]'`
76
- * Arrays w/ length === 0 return `'[]'`
77
- * Objects w/ no properties return `'{}'`
78
- * All else: return result of `value.toString()`
79
- *
80
- * @private
81
- * @param {*} value The value to inspect.
82
- * @param {string} typeHint The type of the value
83
- * @returns {string}
84
- */
85
- function emptyRepresentation(value, typeHint) {
86
- switch (typeHint) {
87
- case "function": return "[Function]";
88
- case "object": return "{}";
89
- case "array": return "[]";
90
- default: return value.toString();
91
- }
92
- }
93
- /**
94
- * Takes some variable and asks `Object.prototype.toString()` what it thinks it
95
- * is.
96
- *
97
- * @private
98
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
99
- * @param {*} value The value to test.
100
- * @returns {string} Computed type
101
- * @example
102
- * canonicalType({}) // 'object'
103
- * canonicalType([]) // 'array'
104
- * canonicalType(1) // 'number'
105
- * canonicalType(false) // 'boolean'
106
- * canonicalType(Infinity) // 'number'
107
- * canonicalType(null) // 'null'
108
- * canonicalType(new Date()) // 'date'
109
- * canonicalType(/foo/) // 'regexp'
110
- * canonicalType('type') // 'string'
111
- * canonicalType(global) // 'global'
112
- * canonicalType(new String('foo') // 'object'
113
- * canonicalType(async function() {}) // 'asyncfunction'
114
- * canonicalType(Object.create(null)) // 'null-prototype'
115
- */
116
- var canonicalType = exports.canonicalType = function canonicalType$1(value) {
117
- if (value === void 0) return "undefined";
118
- else if (value === null) return "null";
119
- else if (Buffer.isBuffer(value)) return "buffer";
120
- else if (Object.getPrototypeOf(value) === null) return "null-prototype";
121
- return Object.prototype.toString.call(value).replace(/^\[.+\s(.+?)]$/, "$1").toLowerCase();
122
- };
123
- /**
124
- *
125
- * Returns a general type or data structure of a variable
126
- * @private
127
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures
128
- * @param {*} value The value to test.
129
- * @returns {string} One of undefined, boolean, number, string, bigint, symbol, object
130
- * @example
131
- * type({}) // 'object'
132
- * type([]) // 'array'
133
- * type(1) // 'number'
134
- * type(false) // 'boolean'
135
- * type(Infinity) // 'number'
136
- * type(null) // 'null'
137
- * type(new Date()) // 'object'
138
- * type(/foo/) // 'object'
139
- * type('type') // 'string'
140
- * type(global) // 'object'
141
- * type(new String('foo') // 'string'
142
- */
143
- exports.type = function type(value) {
144
- if (value === null) return "null";
145
- const primitives = new Set([
146
- "undefined",
147
- "boolean",
148
- "number",
149
- "string",
150
- "bigint",
151
- "symbol"
152
- ]);
153
- const _type = typeof value;
154
- if (_type === "function") return _type;
155
- if (primitives.has(_type)) return _type;
156
- if (value instanceof String) return "string";
157
- if (value instanceof Error) return "error";
158
- if (Array.isArray(value)) return "array";
159
- return _type;
160
- };
161
- /**
162
- * Stringify `value`. Different behavior depending on type of value:
163
- *
164
- * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
165
- * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
166
- * - If `value` is an *empty* object, function, or array, return result of function
167
- * {@link emptyRepresentation}.
168
- * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of
169
- * JSON.stringify().
170
- *
171
- * @private
172
- * @see exports.type
173
- * @param {*} value
174
- * @return {string}
175
- */
176
- exports.stringify = function(value) {
177
- var typeHint = canonicalType(value);
178
- if (!~[
179
- "object",
180
- "array",
181
- "function",
182
- "null-prototype"
183
- ].indexOf(typeHint)) {
184
- if (typeHint === "buffer") {
185
- var json = Buffer.prototype.toJSON.call(value);
186
- return jsonStringify(json.data && json.type ? json.data : json, 2).replace(/,(\n|$)/g, "$1");
187
- }
188
- if (typeHint === "string" && typeof value === "object") {
189
- value = value.split("").reduce(function(acc, char, idx) {
190
- acc[idx] = char;
191
- return acc;
192
- }, {});
193
- typeHint = "object";
194
- } else return jsonStringify(value);
195
- }
196
- for (var prop in value) if (Object.prototype.hasOwnProperty.call(value, prop)) return jsonStringify(exports.canonicalize(value, null, typeHint), 2).replace(/,(\n|$)/g, "$1");
197
- return emptyRepresentation(value, typeHint);
198
- };
199
- /**
200
- * like JSON.stringify but more sense.
201
- *
202
- * @private
203
- * @param {Object} object
204
- * @param {number=} spaces
205
- * @param {number=} depth
206
- * @returns {*}
207
- */
208
- function jsonStringify(object, spaces, depth) {
209
- if (typeof spaces === "undefined") return _stringify(object);
210
- depth = depth || 1;
211
- var space = spaces * depth;
212
- var str = Array.isArray(object) ? "[" : "{";
213
- var end = Array.isArray(object) ? "]" : "}";
214
- var length = typeof object.length === "number" ? object.length : Object.keys(object).length;
215
- function repeat(s, n) {
216
- return new Array(n).join(s);
217
- }
218
- function _stringify(val) {
219
- switch (canonicalType(val)) {
220
- case "null":
221
- case "undefined":
222
- val = "[" + val + "]";
223
- break;
224
- case "array":
225
- case "object":
226
- val = jsonStringify(val, spaces, depth + 1);
227
- break;
228
- case "boolean":
229
- case "regexp":
230
- case "symbol":
231
- case "number":
232
- val = val === 0 && 1 / val === -Infinity ? "-0" : val.toString();
233
- break;
234
- case "bigint":
235
- val = val.toString() + "n";
236
- break;
237
- case "date":
238
- val = "[Date: " + (isNaN(val.getTime()) ? val.toString() : val.toISOString()) + "]";
239
- break;
240
- case "buffer":
241
- var json = val.toJSON();
242
- json = json.data && json.type ? json.data : json;
243
- val = "[Buffer: " + jsonStringify(json, 2, depth + 1) + "]";
244
- break;
245
- default: val = val === "[Function]" || val === "[Circular]" ? val : JSON.stringify(val);
246
- }
247
- return val;
248
- }
249
- for (var i in object) {
250
- if (!Object.prototype.hasOwnProperty.call(object, i)) continue;
251
- --length;
252
- str += "\n " + repeat(" ", space) + (Array.isArray(object) ? "" : "\"" + i + "\": ") + _stringify(object[i]) + (length ? "," : "");
253
- }
254
- return str + (str.length !== 1 ? "\n" + repeat(" ", --space) + end : end);
255
- }
256
- /**
257
- * Return a new Thing that has the keys in sorted order. Recursive.
258
- *
259
- * If the Thing...
260
- * - has already been seen, return string `'[Circular]'`
261
- * - is `undefined`, return string `'[undefined]'`
262
- * - is `null`, return value `null`
263
- * - is some other primitive, return the value
264
- * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method
265
- * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again.
266
- * - is an empty `Array`, `Object`, or `Function`, return the result of calling `emptyRepresentation()`
267
- *
268
- * @private
269
- * @see {@link exports.stringify}
270
- * @param {*} value Thing to inspect. May or may not have properties.
271
- * @param {Array} [stack=[]] Stack of seen values
272
- * @param {string} [typeHint] Type hint
273
- * @return {(Object|Array|Function|string|undefined)}
274
- */
275
- exports.canonicalize = function canonicalize(value, stack, typeHint) {
276
- var canonicalizedObj;
277
- var prop;
278
- typeHint = typeHint || canonicalType(value);
279
- function withStack(value$1, fn) {
280
- stack.push(value$1);
281
- fn();
282
- stack.pop();
283
- }
284
- stack = stack || [];
285
- if (stack.indexOf(value) !== -1) return "[Circular]";
286
- switch (typeHint) {
287
- case "undefined":
288
- case "buffer":
289
- case "null":
290
- canonicalizedObj = value;
291
- break;
292
- case "array":
293
- withStack(value, function() {
294
- canonicalizedObj = value.map(function(item) {
295
- return exports.canonicalize(item, stack);
296
- });
297
- });
298
- break;
299
- case "function":
300
- for (prop in value) {
301
- canonicalizedObj = {};
302
- break;
303
- }
304
- if (!canonicalizedObj) {
305
- canonicalizedObj = emptyRepresentation(value, typeHint);
306
- break;
307
- }
308
- case "null-prototype":
309
- case "object":
310
- canonicalizedObj = canonicalizedObj || {};
311
- if (typeHint === "null-prototype" && Symbol.toStringTag in value) canonicalizedObj["[Symbol.toStringTag]"] = value[Symbol.toStringTag];
312
- withStack(value, function() {
313
- Object.keys(value).sort().forEach(function(key) {
314
- canonicalizedObj[key] = exports.canonicalize(value[key], stack);
315
- });
316
- });
317
- break;
318
- case "date":
319
- case "number":
320
- case "regexp":
321
- case "boolean":
322
- case "symbol":
323
- canonicalizedObj = value;
324
- break;
325
- default: canonicalizedObj = value + "";
326
- }
327
- return canonicalizedObj;
328
- };
329
- /**
330
- * @summary
331
- * This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`)
332
- * @description
333
- * When invoking this function you get a filter function that get the Error.stack as an input,
334
- * and return a prettify output.
335
- * (i.e: strip Mocha and internal node functions from stack trace).
336
- * @returns {Function}
337
- */
338
- exports.stackTraceFilter = function() {
339
- var is = typeof document === "undefined" ? { node: true } : { browser: true };
340
- var slash = path.sep;
341
- var cwd;
342
- if (is.node) cwd = exports.cwd() + slash;
343
- else {
344
- cwd = (typeof location === "undefined" ? window.location : location).href.replace(/\/[^/]*$/, "/");
345
- slash = "/";
346
- }
347
- function isMochaInternal(line) {
348
- return ~line.indexOf("node_modules" + slash + "mocha" + slash) || ~line.indexOf(slash + "mocha.js") || ~line.indexOf(slash + "mocha.min.js");
349
- }
350
- function isNodeInternal(line) {
351
- return ~line.indexOf("(timers.js:") || ~line.indexOf("(events.js:") || ~line.indexOf("(node.js:") || ~line.indexOf("(module.js:") || ~line.indexOf("GeneratorFunctionPrototype.next (native)") || false;
352
- }
353
- return function(stack) {
354
- stack = stack.split("\n");
355
- stack = stack.reduce(function(list, line) {
356
- if (isMochaInternal(line)) return list;
357
- if (is.node && isNodeInternal(line)) return list;
358
- if (/:\d+:\d+\)?$/.test(line)) line = line.replace("(" + cwd, "(");
359
- list.push(line);
360
- return list;
361
- }, []);
362
- return stack.join("\n");
363
- };
364
- };
365
- /**
366
- * Crude, but effective.
367
- * @public
368
- * @param {*} value
369
- * @returns {boolean} Whether or not `value` is a Promise
370
- */
371
- exports.isPromise = function isPromise(value) {
372
- return typeof value === "object" && value !== null && typeof value.then === "function";
373
- };
374
- /**
375
- * Clamps a numeric value to an inclusive range.
376
- *
377
- * @param {number} value - Value to be clamped.
378
- * @param {number[]} range - Two element array specifying [min, max] range.
379
- * @returns {number} clamped value
380
- */
381
- exports.clamp = function clamp(value, range) {
382
- return Math.min(Math.max(value, range[0]), range[1]);
383
- };
384
- /**
385
- * It's a noop.
386
- * @public
387
- */
388
- exports.noop = function() {};
389
- /**
390
- * Creates a map-like object.
391
- *
392
- * @description
393
- * A "map" is an object with no prototype, for our purposes. In some cases
394
- * this would be more appropriate than a `Map`, especially if your environment
395
- * doesn't support it. Recommended for use in Mocha's public APIs.
396
- *
397
- * @public
398
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Custom_and_Null_objects|MDN:Map}
399
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Custom_and_Null_objects|MDN:Object.create - Custom objects}
400
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Custom_and_Null_objects|MDN:Object.assign}
401
- * @param {...*} [obj] - Arguments to `Object.assign()`.
402
- * @returns {Object} An object with no prototype, having `...obj` properties
403
- */
404
- exports.createMap = function() {
405
- return Object.assign.apply(null, [Object.create(null)].concat(Array.prototype.slice.call(arguments)));
406
- };
407
- /**
408
- * Creates a read-only map-like object.
409
- *
410
- * @description
411
- * This differs from {@link module:utils.createMap createMap} only in that
412
- * the argument must be non-empty, because the result is frozen.
413
- *
414
- * @see {@link module:utils.createMap createMap}
415
- * @param {...*} [obj] - Arguments to `Object.assign()`.
416
- * @returns {Object} A frozen object with no prototype, having `...obj` properties
417
- * @throws {TypeError} if argument is not a non-empty object.
418
- */
419
- exports.defineConstants = function(obj) {
420
- if (canonicalType(obj) !== "object" || !Object.keys(obj).length) throw new TypeError("Invalid argument; expected a non-empty object");
421
- return Object.freeze(exports.createMap(obj));
422
- };
423
- /**
424
- * Returns current working directory
425
- *
426
- * Wrapper around `process.cwd()` for isolation
427
- * @private
428
- */
429
- exports.cwd = function cwd() {
430
- return process.cwd();
431
- };
432
- /**
433
- * Returns `true` if Mocha is running in a browser.
434
- * Checks for `process.browser`.
435
- * @returns {boolean}
436
- * @private
437
- */
438
- exports.isBrowser = function isBrowser() {
439
- return Boolean(process.browser);
440
- };
441
- exports.castArray = function castArray(value) {
442
- if (value === void 0) return [];
443
- if (value === null) return [null];
444
- if (typeof value === "object" && (typeof value[Symbol.iterator] === "function" || value.length !== void 0)) return Array.from(value);
445
- return [value];
446
- };
447
- exports.constants = exports.defineConstants({ MOCHA_ID_PROP_NAME });
448
- const uniqueIDBase = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
449
- /**
450
- * Creates a new unique identifier
451
- * Does not create cryptographically safe ids.
452
- * Trivial copy of nanoid/non-secure
453
- * @returns {string} Unique identifier
454
- */
455
- exports.uniqueID = () => {
456
- let id = "";
457
- for (let i = 0; i < 21; i++) id += uniqueIDBase[Math.random() * 64 | 0];
458
- return id;
459
- };
460
- exports.assignNewMochaID = (obj) => {
461
- const id = exports.uniqueID();
462
- Object.defineProperty(obj, MOCHA_ID_PROP_NAME, { get() {
463
- return id;
464
- } });
465
- return obj;
466
- };
467
- /**
468
- * Retrieves a Mocha ID from an object, if present.
469
- * @param {*} [obj] - Object
470
- * @returns {string|void}
471
- */
472
- exports.getMochaID = (obj) => obj && typeof obj === "object" ? obj[MOCHA_ID_PROP_NAME] : void 0;
473
- /**
474
- * Replaces any detected circular dependency with the string '[Circular]'
475
- * Mutates original object
476
- * @param inputObj {*}
477
- * @returns {*}
478
- */
479
- exports.breakCircularDeps = (inputObj) => {
480
- const seen = /* @__PURE__ */ new Set();
481
- function _breakCircularDeps(obj) {
482
- if (obj && typeof obj !== "object") return obj;
483
- if (seen.has(obj)) return "[Circular]";
484
- seen.add(obj);
485
- for (const k in obj) {
486
- const descriptor = Object.getOwnPropertyDescriptor(obj, k);
487
- if (descriptor && descriptor.writable) obj[k] = _breakCircularDeps(obj[k], k);
488
- }
489
- seen.delete(obj);
490
- return obj;
491
- }
492
- return _breakCircularDeps(inputObj);
493
- };
494
- /**
495
- * Checks if provided input can be parsed as a JavaScript Number.
496
- */
497
- exports.isNumeric = (input) => {
498
- return !isNaN(parseFloat(input));
499
- };
500
- }) });
501
-
502
- //#endregion
503
- export default require_utils();
504
-
505
- export { require_utils };