@neon/sdk 1.3.0 → 1.4.1

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 (83) hide show
  1. package/{LICENSE.md → LICENSE} +27 -3
  2. package/README.md +22 -1
  3. package/dist/_virtual/_rolldown/runtime.js +1 -2
  4. package/dist/client/types.gen.d.ts.map +1 -1
  5. package/dist/neon/errors.d.ts +25 -2
  6. package/dist/neon/errors.d.ts.map +1 -1
  7. package/dist/neon/errors.js +60 -5
  8. package/dist/neon/errors.js.map +1 -1
  9. package/package.json +4 -3
  10. package/dist/neon/client.test-d.d.ts +0 -1
  11. package/dist/neon/client.test-d.js +0 -98
  12. package/dist/neon/client.test-d.js.map +0 -1
  13. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.0.9/node_modules/@vitest/pretty-format/dist/index.js +0 -879
  14. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.0.9/node_modules/@vitest/pretty-format/dist/index.js.map +0 -1
  15. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/chunk-tasks.js +0 -30
  16. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/chunk-tasks.js.map +0 -1
  17. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/index.js +0 -579
  18. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/index.js.map +0 -1
  19. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/utils.js +0 -2
  20. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +0 -92
  21. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js.map +0 -1
  22. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js +0 -43
  23. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js.map +0 -1
  24. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js +0 -450
  25. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js.map +0 -1
  26. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js +0 -168
  27. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js.map +0 -1
  28. package/dist/node_modules/.pnpm/chai@5.2.0/node_modules/chai/chai.js +0 -3101
  29. package/dist/node_modules/.pnpm/chai@5.2.0/node_modules/chai/chai.js.map +0 -1
  30. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.js +0 -10
  31. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.js.map +0 -1
  32. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/index.js +0 -109
  33. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/index.js.map +0 -1
  34. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.js +0 -10
  35. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.js.map +0 -1
  36. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.js +0 -10
  37. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.js.map +0 -1
  38. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.js +0 -10
  39. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.js.map +0 -1
  40. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +0 -11
  41. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js.map +0 -1
  42. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +0 -16
  43. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js.map +0 -1
  44. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +0 -11
  45. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js.map +0 -1
  46. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +0 -15
  47. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js.map +0 -1
  48. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +0 -13
  49. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js.map +0 -1
  50. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +0 -34
  51. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js.map +0 -1
  52. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +0 -12
  53. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js.map +0 -1
  54. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +0 -122
  55. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js.map +0 -1
  56. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +0 -39
  57. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js.map +0 -1
  58. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +0 -99
  59. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js.map +0 -1
  60. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +0 -25
  61. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js.map +0 -1
  62. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +0 -14
  63. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js.map +0 -1
  64. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +0 -21
  65. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js.map +0 -1
  66. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +0 -6
  67. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js.map +0 -1
  68. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +0 -12
  69. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js.map +0 -1
  70. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +0 -18
  71. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js.map +0 -1
  72. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +0 -24
  73. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js.map +0 -1
  74. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +0 -9
  75. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js.map +0 -1
  76. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +0 -30
  77. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js.map +0 -1
  78. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +0 -82
  79. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js.map +0 -1
  80. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js +0 -7
  81. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js.map +0 -1
  82. package/dist/node_modules/.pnpm/vitest@3.0.9_@types_debug@4.1.13_@types_node@20.19.17_jiti@2.7.0_jsdom@26.1.0_lightning_fb7ae83398b95c49208c9194029bba02/node_modules/vitest/dist/index.js +0 -10
  83. package/dist/node_modules/.pnpm/vitest@3.0.9_@types_debug@4.1.13_@types_node@20.19.17_jiti@2.7.0_jsdom@26.1.0_lightning_fb7ae83398b95c49208c9194029bba02/node_modules/vitest/dist/index.js.map +0 -1
@@ -1,3101 +0,0 @@
1
- //#region ../../node_modules/.pnpm/chai@5.2.0/node_modules/chai/chai.js
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __name = (target, value) => __defProp(target, "name", {
5
- value,
6
- configurable: true
7
- });
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __export = (target, all) => {
12
- for (var name in all) __defProp(target, name, {
13
- get: all[name],
14
- enumerable: true
15
- });
16
- };
17
- var require_util = __commonJS({ "(disabled):util"() {} });
18
- var utils_exports = {};
19
- __export(utils_exports, {
20
- addChainableMethod: () => addChainableMethod,
21
- addLengthGuard: () => addLengthGuard,
22
- addMethod: () => addMethod,
23
- addProperty: () => addProperty,
24
- checkError: () => check_error_exports,
25
- compareByInspect: () => compareByInspect,
26
- eql: () => deep_eql_default,
27
- expectTypes: () => expectTypes,
28
- flag: () => flag,
29
- getActual: () => getActual,
30
- getMessage: () => getMessage2,
31
- getName: () => getName,
32
- getOperator: () => getOperator,
33
- getOwnEnumerableProperties: () => getOwnEnumerableProperties,
34
- getOwnEnumerablePropertySymbols: () => getOwnEnumerablePropertySymbols,
35
- getPathInfo: () => getPathInfo,
36
- hasProperty: () => hasProperty,
37
- inspect: () => inspect2,
38
- isNaN: () => isNaN2,
39
- isNumeric: () => isNumeric,
40
- isProxyEnabled: () => isProxyEnabled,
41
- isRegExp: () => isRegExp2,
42
- objDisplay: () => objDisplay,
43
- overwriteChainableMethod: () => overwriteChainableMethod,
44
- overwriteMethod: () => overwriteMethod,
45
- overwriteProperty: () => overwriteProperty,
46
- proxify: () => proxify,
47
- test: () => test,
48
- transferFlags: () => transferFlags,
49
- type: () => type
50
- });
51
- var check_error_exports = {};
52
- __export(check_error_exports, {
53
- compatibleConstructor: () => compatibleConstructor,
54
- compatibleInstance: () => compatibleInstance,
55
- compatibleMessage: () => compatibleMessage,
56
- getConstructorName: () => getConstructorName,
57
- getMessage: () => getMessage
58
- });
59
- function isErrorInstance(obj) {
60
- return obj instanceof Error || Object.prototype.toString.call(obj) === "[object Error]";
61
- }
62
- __name(isErrorInstance, "isErrorInstance");
63
- function isRegExp(obj) {
64
- return Object.prototype.toString.call(obj) === "[object RegExp]";
65
- }
66
- __name(isRegExp, "isRegExp");
67
- function compatibleInstance(thrown, errorLike) {
68
- return isErrorInstance(errorLike) && thrown === errorLike;
69
- }
70
- __name(compatibleInstance, "compatibleInstance");
71
- function compatibleConstructor(thrown, errorLike) {
72
- if (isErrorInstance(errorLike)) return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
73
- else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) return thrown.constructor === errorLike || thrown instanceof errorLike;
74
- return false;
75
- }
76
- __name(compatibleConstructor, "compatibleConstructor");
77
- function compatibleMessage(thrown, errMatcher) {
78
- const comparisonString = typeof thrown === "string" ? thrown : thrown.message;
79
- if (isRegExp(errMatcher)) return errMatcher.test(comparisonString);
80
- else if (typeof errMatcher === "string") return comparisonString.indexOf(errMatcher) !== -1;
81
- return false;
82
- }
83
- __name(compatibleMessage, "compatibleMessage");
84
- function getConstructorName(errorLike) {
85
- let constructorName = errorLike;
86
- if (isErrorInstance(errorLike)) constructorName = errorLike.constructor.name;
87
- else if (typeof errorLike === "function") {
88
- constructorName = errorLike.name;
89
- if (constructorName === "") constructorName = new errorLike().name || constructorName;
90
- }
91
- return constructorName;
92
- }
93
- __name(getConstructorName, "getConstructorName");
94
- function getMessage(errorLike) {
95
- let msg = "";
96
- if (errorLike && errorLike.message) msg = errorLike.message;
97
- else if (typeof errorLike === "string") msg = errorLike;
98
- return msg;
99
- }
100
- __name(getMessage, "getMessage");
101
- function flag(obj, key, value) {
102
- var flags = obj.__flags || (obj.__flags = /* @__PURE__ */ Object.create(null));
103
- if (arguments.length === 3) flags[key] = value;
104
- else return flags[key];
105
- }
106
- __name(flag, "flag");
107
- function test(obj, args) {
108
- var negate = flag(obj, "negate"), expr = args[0];
109
- return negate ? !expr : expr;
110
- }
111
- __name(test, "test");
112
- function type(obj) {
113
- if (typeof obj === "undefined") return "undefined";
114
- if (obj === null) return "null";
115
- const stringTag = obj[Symbol.toStringTag];
116
- if (typeof stringTag === "string") return stringTag;
117
- return Object.prototype.toString.call(obj).slice(8, -1);
118
- }
119
- __name(type, "type");
120
- var canElideFrames = "captureStackTrace" in Error;
121
- var AssertionError = class _AssertionError extends Error {
122
- static {
123
- __name(this, "AssertionError");
124
- }
125
- message;
126
- get name() {
127
- return "AssertionError";
128
- }
129
- get ok() {
130
- return false;
131
- }
132
- constructor(message = "Unspecified AssertionError", props, ssf) {
133
- super(message);
134
- this.message = message;
135
- if (canElideFrames) Error.captureStackTrace(this, ssf || _AssertionError);
136
- for (const key in props) if (!(key in this)) this[key] = props[key];
137
- }
138
- toJSON(stack) {
139
- return {
140
- ...this,
141
- name: this.name,
142
- message: this.message,
143
- ok: false,
144
- stack: stack !== false ? this.stack : void 0
145
- };
146
- }
147
- };
148
- function expectTypes(obj, types) {
149
- var flagMsg = flag(obj, "message");
150
- var ssfi = flag(obj, "ssfi");
151
- flagMsg = flagMsg ? flagMsg + ": " : "";
152
- obj = flag(obj, "object");
153
- types = types.map(function(t) {
154
- return t.toLowerCase();
155
- });
156
- types.sort();
157
- var str = types.map(function(t, index) {
158
- var art = ~[
159
- "a",
160
- "e",
161
- "i",
162
- "o",
163
- "u"
164
- ].indexOf(t.charAt(0)) ? "an" : "a";
165
- return (types.length > 1 && index === types.length - 1 ? "or " : "") + art + " " + t;
166
- }).join(", ");
167
- var objType = type(obj).toLowerCase();
168
- if (!types.some(function(expected) {
169
- return objType === expected;
170
- })) throw new AssertionError(flagMsg + "object tested must be " + str + ", but " + objType + " given", void 0, ssfi);
171
- }
172
- __name(expectTypes, "expectTypes");
173
- function getActual(obj, args) {
174
- return args.length > 4 ? args[4] : obj._obj;
175
- }
176
- __name(getActual, "getActual");
177
- var ansiColors = {
178
- bold: ["1", "22"],
179
- dim: ["2", "22"],
180
- italic: ["3", "23"],
181
- underline: ["4", "24"],
182
- inverse: ["7", "27"],
183
- hidden: ["8", "28"],
184
- strike: ["9", "29"],
185
- black: ["30", "39"],
186
- red: ["31", "39"],
187
- green: ["32", "39"],
188
- yellow: ["33", "39"],
189
- blue: ["34", "39"],
190
- magenta: ["35", "39"],
191
- cyan: ["36", "39"],
192
- white: ["37", "39"],
193
- brightblack: ["30;1", "39"],
194
- brightred: ["31;1", "39"],
195
- brightgreen: ["32;1", "39"],
196
- brightyellow: ["33;1", "39"],
197
- brightblue: ["34;1", "39"],
198
- brightmagenta: ["35;1", "39"],
199
- brightcyan: ["36;1", "39"],
200
- brightwhite: ["37;1", "39"],
201
- grey: ["90", "39"]
202
- };
203
- var styles = {
204
- special: "cyan",
205
- number: "yellow",
206
- bigint: "yellow",
207
- boolean: "yellow",
208
- undefined: "grey",
209
- null: "bold",
210
- string: "green",
211
- symbol: "green",
212
- date: "magenta",
213
- regexp: "red"
214
- };
215
- var truncator = "…";
216
- function colorise(value, styleType) {
217
- const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
218
- if (!color) return String(value);
219
- return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
220
- }
221
- __name(colorise, "colorise");
222
- function normaliseOptions({ showHidden = false, depth = 2, colors = false, customInspect = true, showProxy = false, maxArrayLength = Infinity, breakLength = Infinity, seen = [], truncate: truncate2 = Infinity, stylize = String } = {}, inspect3) {
223
- const options = {
224
- showHidden: Boolean(showHidden),
225
- depth: Number(depth),
226
- colors: Boolean(colors),
227
- customInspect: Boolean(customInspect),
228
- showProxy: Boolean(showProxy),
229
- maxArrayLength: Number(maxArrayLength),
230
- breakLength: Number(breakLength),
231
- truncate: Number(truncate2),
232
- seen,
233
- inspect: inspect3,
234
- stylize
235
- };
236
- if (options.colors) options.stylize = colorise;
237
- return options;
238
- }
239
- __name(normaliseOptions, "normaliseOptions");
240
- function isHighSurrogate(char) {
241
- return char >= "\ud800" && char <= "\udbff";
242
- }
243
- __name(isHighSurrogate, "isHighSurrogate");
244
- function truncate(string, length, tail = truncator) {
245
- string = String(string);
246
- const tailLength = tail.length;
247
- const stringLength = string.length;
248
- if (tailLength > length && stringLength > tailLength) return tail;
249
- if (stringLength > length && stringLength > tailLength) {
250
- let end = length - tailLength;
251
- if (end > 0 && isHighSurrogate(string[end - 1])) end = end - 1;
252
- return `${string.slice(0, end)}${tail}`;
253
- }
254
- return string;
255
- }
256
- __name(truncate, "truncate");
257
- function inspectList(list, options, inspectItem, separator = ", ") {
258
- inspectItem = inspectItem || options.inspect;
259
- const size = list.length;
260
- if (size === 0) return "";
261
- const originalLength = options.truncate;
262
- let output = "";
263
- let peek = "";
264
- let truncated = "";
265
- for (let i = 0; i < size; i += 1) {
266
- const last = i + 1 === list.length;
267
- const secondToLast = i + 2 === list.length;
268
- truncated = `${truncator}(${list.length - i})`;
269
- const value = list[i];
270
- options.truncate = originalLength - output.length - (last ? 0 : separator.length);
271
- const string = peek || inspectItem(value, options) + (last ? "" : separator);
272
- const nextLength = output.length + string.length;
273
- const truncatedLength = nextLength + truncated.length;
274
- if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) break;
275
- if (!last && !secondToLast && truncatedLength > originalLength) break;
276
- peek = last ? "" : inspectItem(list[i + 1], options) + (secondToLast ? "" : separator);
277
- if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) break;
278
- output += string;
279
- if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
280
- truncated = `${truncator}(${list.length - i - 1})`;
281
- break;
282
- }
283
- truncated = "";
284
- }
285
- return `${output}${truncated}`;
286
- }
287
- __name(inspectList, "inspectList");
288
- function quoteComplexKey(key) {
289
- if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) return key;
290
- return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
291
- }
292
- __name(quoteComplexKey, "quoteComplexKey");
293
- function inspectProperty([key, value], options) {
294
- options.truncate -= 2;
295
- if (typeof key === "string") key = quoteComplexKey(key);
296
- else if (typeof key !== "number") key = `[${options.inspect(key, options)}]`;
297
- options.truncate -= key.length;
298
- value = options.inspect(value, options);
299
- return `${key}: ${value}`;
300
- }
301
- __name(inspectProperty, "inspectProperty");
302
- function inspectArray(array, options) {
303
- const nonIndexProperties = Object.keys(array).slice(array.length);
304
- if (!array.length && !nonIndexProperties.length) return "[]";
305
- options.truncate -= 4;
306
- const listContents = inspectList(array, options);
307
- options.truncate -= listContents.length;
308
- let propertyContents = "";
309
- if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
310
- return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
311
- }
312
- __name(inspectArray, "inspectArray");
313
- var getArrayName = /* @__PURE__ */ __name((array) => {
314
- if (typeof Buffer === "function" && array instanceof Buffer) return "Buffer";
315
- if (array[Symbol.toStringTag]) return array[Symbol.toStringTag];
316
- return array.constructor.name;
317
- }, "getArrayName");
318
- function inspectTypedArray(array, options) {
319
- const name = getArrayName(array);
320
- options.truncate -= name.length + 4;
321
- const nonIndexProperties = Object.keys(array).slice(array.length);
322
- if (!array.length && !nonIndexProperties.length) return `${name}[]`;
323
- let output = "";
324
- for (let i = 0; i < array.length; i++) {
325
- const string = `${options.stylize(truncate(array[i], options.truncate), "number")}${i === array.length - 1 ? "" : ", "}`;
326
- options.truncate -= string.length;
327
- if (array[i] !== array.length && options.truncate <= 3) {
328
- output += `${truncator}(${array.length - array[i] + 1})`;
329
- break;
330
- }
331
- output += string;
332
- }
333
- let propertyContents = "";
334
- if (nonIndexProperties.length) propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
335
- return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
336
- }
337
- __name(inspectTypedArray, "inspectTypedArray");
338
- function inspectDate(dateObject, options) {
339
- const stringRepresentation = dateObject.toJSON();
340
- if (stringRepresentation === null) return "Invalid Date";
341
- const split = stringRepresentation.split("T");
342
- const date = split[0];
343
- return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
344
- }
345
- __name(inspectDate, "inspectDate");
346
- function inspectFunction(func, options) {
347
- const functionType = func[Symbol.toStringTag] || "Function";
348
- const name = func.name;
349
- if (!name) return options.stylize(`[${functionType}]`, "special");
350
- return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
351
- }
352
- __name(inspectFunction, "inspectFunction");
353
- function inspectMapEntry([key, value], options) {
354
- options.truncate -= 4;
355
- key = options.inspect(key, options);
356
- options.truncate -= key.length;
357
- value = options.inspect(value, options);
358
- return `${key} => ${value}`;
359
- }
360
- __name(inspectMapEntry, "inspectMapEntry");
361
- function mapToEntries(map) {
362
- const entries = [];
363
- map.forEach((value, key) => {
364
- entries.push([key, value]);
365
- });
366
- return entries;
367
- }
368
- __name(mapToEntries, "mapToEntries");
369
- function inspectMap(map, options) {
370
- if (map.size - 1 <= 0) return "Map{}";
371
- options.truncate -= 7;
372
- return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
373
- }
374
- __name(inspectMap, "inspectMap");
375
- var isNaN = Number.isNaN || ((i) => i !== i);
376
- function inspectNumber(number, options) {
377
- if (isNaN(number)) return options.stylize("NaN", "number");
378
- if (number === Infinity) return options.stylize("Infinity", "number");
379
- if (number === -Infinity) return options.stylize("-Infinity", "number");
380
- if (number === 0) return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
381
- return options.stylize(truncate(String(number), options.truncate), "number");
382
- }
383
- __name(inspectNumber, "inspectNumber");
384
- function inspectBigInt(number, options) {
385
- let nums = truncate(number.toString(), options.truncate - 1);
386
- if (nums !== truncator) nums += "n";
387
- return options.stylize(nums, "bigint");
388
- }
389
- __name(inspectBigInt, "inspectBigInt");
390
- function inspectRegExp(value, options) {
391
- const flags = value.toString().split("/")[2];
392
- const sourceLength = options.truncate - (2 + flags.length);
393
- const source = value.source;
394
- return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
395
- }
396
- __name(inspectRegExp, "inspectRegExp");
397
- function arrayFromSet(set2) {
398
- const values = [];
399
- set2.forEach((value) => {
400
- values.push(value);
401
- });
402
- return values;
403
- }
404
- __name(arrayFromSet, "arrayFromSet");
405
- function inspectSet(set2, options) {
406
- if (set2.size === 0) return "Set{}";
407
- options.truncate -= 7;
408
- return `Set{ ${inspectList(arrayFromSet(set2), options)} }`;
409
- }
410
- __name(inspectSet, "inspectSet");
411
- var stringEscapeChars = /* @__PURE__ */ new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
412
- var escapeCharacters = {
413
- "\b": "\\b",
414
- " ": "\\t",
415
- "\n": "\\n",
416
- "\f": "\\f",
417
- "\r": "\\r",
418
- "'": "\\'",
419
- "\\": "\\\\"
420
- };
421
- var hex = 16;
422
- var unicodeLength = 4;
423
- function escape(char) {
424
- return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-unicodeLength)}`;
425
- }
426
- __name(escape, "escape");
427
- function inspectString(string, options) {
428
- if (stringEscapeChars.test(string)) string = string.replace(stringEscapeChars, escape);
429
- return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
430
- }
431
- __name(inspectString, "inspectString");
432
- function inspectSymbol(value) {
433
- if ("description" in Symbol.prototype) return value.description ? `Symbol(${value.description})` : "Symbol()";
434
- return value.toString();
435
- }
436
- __name(inspectSymbol, "inspectSymbol");
437
- var getPromiseValue = /* @__PURE__ */ __name(() => "Promise{…}", "getPromiseValue");
438
- try {
439
- const { getPromiseDetails, kPending, kRejected } = process.binding("util");
440
- if (Array.isArray(getPromiseDetails(Promise.resolve()))) getPromiseValue = /* @__PURE__ */ __name((value, options) => {
441
- const [state, innerValue] = getPromiseDetails(value);
442
- if (state === kPending) return "Promise{<pending>}";
443
- return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
444
- }, "getPromiseValue");
445
- } catch (notNode) {}
446
- var promise_default = getPromiseValue;
447
- function inspectObject(object, options) {
448
- const properties = Object.getOwnPropertyNames(object);
449
- const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
450
- if (properties.length === 0 && symbols.length === 0) return "{}";
451
- options.truncate -= 4;
452
- options.seen = options.seen || [];
453
- if (options.seen.includes(object)) return "[Circular]";
454
- options.seen.push(object);
455
- const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
456
- const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
457
- options.seen.pop();
458
- let sep = "";
459
- if (propertyContents && symbolContents) sep = ", ";
460
- return `{ ${propertyContents}${sep}${symbolContents} }`;
461
- }
462
- __name(inspectObject, "inspectObject");
463
- var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
464
- function inspectClass(value, options) {
465
- let name = "";
466
- if (toStringTag && toStringTag in value) name = value[toStringTag];
467
- name = name || value.constructor.name;
468
- if (!name || name === "_class") name = "<Anonymous Class>";
469
- options.truncate -= name.length;
470
- return `${name}${inspectObject(value, options)}`;
471
- }
472
- __name(inspectClass, "inspectClass");
473
- function inspectArguments(args, options) {
474
- if (args.length === 0) return "Arguments[]";
475
- options.truncate -= 13;
476
- return `Arguments[ ${inspectList(args, options)} ]`;
477
- }
478
- __name(inspectArguments, "inspectArguments");
479
- var errorKeys = [
480
- "stack",
481
- "line",
482
- "column",
483
- "name",
484
- "message",
485
- "fileName",
486
- "lineNumber",
487
- "columnNumber",
488
- "number",
489
- "description",
490
- "cause"
491
- ];
492
- function inspectObject2(error, options) {
493
- const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
494
- const name = error.name;
495
- options.truncate -= name.length;
496
- let message = "";
497
- if (typeof error.message === "string") message = truncate(error.message, options.truncate);
498
- else properties.unshift("message");
499
- message = message ? `: ${message}` : "";
500
- options.truncate -= message.length + 5;
501
- options.seen = options.seen || [];
502
- if (options.seen.includes(error)) return "[Circular]";
503
- options.seen.push(error);
504
- const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
505
- return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
506
- }
507
- __name(inspectObject2, "inspectObject");
508
- function inspectAttribute([key, value], options) {
509
- options.truncate -= 3;
510
- if (!value) return `${options.stylize(String(key), "yellow")}`;
511
- return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
512
- }
513
- __name(inspectAttribute, "inspectAttribute");
514
- function inspectHTMLCollection(collection, options) {
515
- return inspectList(collection, options, inspectHTML, "\n");
516
- }
517
- __name(inspectHTMLCollection, "inspectHTMLCollection");
518
- function inspectHTML(element, options) {
519
- const properties = element.getAttributeNames();
520
- const name = element.tagName.toLowerCase();
521
- const head = options.stylize(`<${name}`, "special");
522
- const headClose = options.stylize(`>`, "special");
523
- const tail = options.stylize(`</${name}>`, "special");
524
- options.truncate -= name.length * 2 + 5;
525
- let propertyContents = "";
526
- if (properties.length > 0) {
527
- propertyContents += " ";
528
- propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
529
- }
530
- options.truncate -= propertyContents.length;
531
- const truncate2 = options.truncate;
532
- let children = inspectHTMLCollection(element.children, options);
533
- if (children && children.length > truncate2) children = `${truncator}(${element.children.length})`;
534
- return `${head}${propertyContents}${headClose}${children}${tail}`;
535
- }
536
- __name(inspectHTML, "inspectHTML");
537
- var chaiInspect = typeof Symbol === "function" && typeof Symbol.for === "function" ? Symbol.for("chai/inspect") : "@@chai/inspect";
538
- var nodeInspect = false;
539
- try {
540
- const nodeUtil = require_util();
541
- nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false;
542
- } catch (noNodeInspect) {
543
- nodeInspect = false;
544
- }
545
- var constructorMap = /* @__PURE__ */ new WeakMap();
546
- var stringTagMap = {};
547
- var baseTypesMap = {
548
- undefined: (value, options) => options.stylize("undefined", "undefined"),
549
- null: (value, options) => options.stylize("null", "null"),
550
- boolean: (value, options) => options.stylize(String(value), "boolean"),
551
- Boolean: (value, options) => options.stylize(String(value), "boolean"),
552
- number: inspectNumber,
553
- Number: inspectNumber,
554
- bigint: inspectBigInt,
555
- BigInt: inspectBigInt,
556
- string: inspectString,
557
- String: inspectString,
558
- function: inspectFunction,
559
- Function: inspectFunction,
560
- symbol: inspectSymbol,
561
- Symbol: inspectSymbol,
562
- Array: inspectArray,
563
- Date: inspectDate,
564
- Map: inspectMap,
565
- Set: inspectSet,
566
- RegExp: inspectRegExp,
567
- Promise: promise_default,
568
- WeakSet: (value, options) => options.stylize("WeakSet{…}", "special"),
569
- WeakMap: (value, options) => options.stylize("WeakMap{…}", "special"),
570
- Arguments: inspectArguments,
571
- Int8Array: inspectTypedArray,
572
- Uint8Array: inspectTypedArray,
573
- Uint8ClampedArray: inspectTypedArray,
574
- Int16Array: inspectTypedArray,
575
- Uint16Array: inspectTypedArray,
576
- Int32Array: inspectTypedArray,
577
- Uint32Array: inspectTypedArray,
578
- Float32Array: inspectTypedArray,
579
- Float64Array: inspectTypedArray,
580
- Generator: () => "",
581
- DataView: () => "",
582
- ArrayBuffer: () => "",
583
- Error: inspectObject2,
584
- HTMLCollection: inspectHTMLCollection,
585
- NodeList: inspectHTMLCollection
586
- };
587
- var inspectCustom = /* @__PURE__ */ __name((value, options, type3) => {
588
- if (chaiInspect in value && typeof value[chaiInspect] === "function") return value[chaiInspect](options);
589
- if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === "function") return value[nodeInspect](options.depth, options);
590
- if ("inspect" in value && typeof value.inspect === "function") return value.inspect(options.depth, options);
591
- if ("constructor" in value && constructorMap.has(value.constructor)) return constructorMap.get(value.constructor)(value, options);
592
- if (stringTagMap[type3]) return stringTagMap[type3](value, options);
593
- return "";
594
- }, "inspectCustom");
595
- var toString = Object.prototype.toString;
596
- function inspect(value, opts = {}) {
597
- const options = normaliseOptions(opts, inspect);
598
- const { customInspect } = options;
599
- let type3 = value === null ? "null" : typeof value;
600
- if (type3 === "object") type3 = toString.call(value).slice(8, -1);
601
- if (type3 in baseTypesMap) return baseTypesMap[type3](value, options);
602
- if (customInspect && value) {
603
- const output = inspectCustom(value, options, type3);
604
- if (output) {
605
- if (typeof output === "string") return output;
606
- return inspect(output, options);
607
- }
608
- }
609
- const proto = value ? Object.getPrototypeOf(value) : false;
610
- if (proto === Object.prototype || proto === null) return inspectObject(value, options);
611
- if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) return inspectHTML(value, options);
612
- if ("constructor" in value) {
613
- if (value.constructor !== Object) return inspectClass(value, options);
614
- return inspectObject(value, options);
615
- }
616
- if (value === Object(value)) return inspectObject(value, options);
617
- return options.stylize(String(value), type3);
618
- }
619
- __name(inspect, "inspect");
620
- var config = {
621
- /**
622
- * ### config.includeStack
623
- *
624
- * User configurable property, influences whether stack trace
625
- * is included in Assertion error message. Default of false
626
- * suppresses stack trace in the error message.
627
- *
628
- * chai.config.includeStack = true; // enable stack on error
629
- *
630
- * @param {boolean}
631
- * @public
632
- */
633
- includeStack: false,
634
- /**
635
- * ### config.showDiff
636
- *
637
- * User configurable property, influences whether or not
638
- * the `showDiff` flag should be included in the thrown
639
- * AssertionErrors. `false` will always be `false`; `true`
640
- * will be true when the assertion has requested a diff
641
- * be shown.
642
- *
643
- * @param {boolean}
644
- * @public
645
- */
646
- showDiff: true,
647
- /**
648
- * ### config.truncateThreshold
649
- *
650
- * User configurable property, sets length threshold for actual and
651
- * expected values in assertion errors. If this threshold is exceeded, for
652
- * example for large data structures, the value is replaced with something
653
- * like `[ Array(3) ]` or `{ Object (prop1, prop2) }`.
654
- *
655
- * Set it to zero if you want to disable truncating altogether.
656
- *
657
- * This is especially userful when doing assertions on arrays: having this
658
- * set to a reasonable large value makes the failure messages readily
659
- * inspectable.
660
- *
661
- * chai.config.truncateThreshold = 0; // disable truncating
662
- *
663
- * @param {number}
664
- * @public
665
- */
666
- truncateThreshold: 40,
667
- /**
668
- * ### config.useProxy
669
- *
670
- * User configurable property, defines if chai will use a Proxy to throw
671
- * an error when a non-existent property is read, which protects users
672
- * from typos when using property-based assertions.
673
- *
674
- * Set it to false if you want to disable this feature.
675
- *
676
- * chai.config.useProxy = false; // disable use of Proxy
677
- *
678
- * This feature is automatically disabled regardless of this config value
679
- * in environments that don't support proxies.
680
- *
681
- * @param {boolean}
682
- * @public
683
- */
684
- useProxy: true,
685
- /**
686
- * ### config.proxyExcludedKeys
687
- *
688
- * User configurable property, defines which properties should be ignored
689
- * instead of throwing an error if they do not exist on the assertion.
690
- * This is only applied if the environment Chai is running in supports proxies and
691
- * if the `useProxy` configuration setting is enabled.
692
- * By default, `then` and `inspect` will not throw an error if they do not exist on the
693
- * assertion object because the `.inspect` property is read by `util.inspect` (for example, when
694
- * using `console.log` on the assertion object) and `.then` is necessary for promise type-checking.
695
- *
696
- * // By default these keys will not throw an error if they do not exist on the assertion object
697
- * chai.config.proxyExcludedKeys = ['then', 'inspect'];
698
- *
699
- * @param {Array}
700
- * @public
701
- */
702
- proxyExcludedKeys: [
703
- "then",
704
- "catch",
705
- "inspect",
706
- "toJSON"
707
- ],
708
- /**
709
- * ### config.deepEqual
710
- *
711
- * User configurable property, defines which a custom function to use for deepEqual
712
- * comparisons.
713
- * By default, the function used is the one from the `deep-eql` package without custom comparator.
714
- *
715
- * // use a custom comparator
716
- * chai.config.deepEqual = (expected, actual) => {
717
- * return chai.util.eql(expected, actual, {
718
- * comparator: (expected, actual) => {
719
- * // for non number comparison, use the default behavior
720
- * if(typeof expected !== 'number') return null;
721
- * // allow a difference of 10 between compared numbers
722
- * return typeof actual === 'number' && Math.abs(actual - expected) < 10
723
- * }
724
- * })
725
- * };
726
- *
727
- * @param {Function}
728
- * @public
729
- */
730
- deepEqual: null
731
- };
732
- function inspect2(obj, showHidden, depth, colors) {
733
- return inspect(obj, {
734
- colors,
735
- depth: typeof depth === "undefined" ? 2 : depth,
736
- showHidden,
737
- truncate: config.truncateThreshold ? config.truncateThreshold : Infinity
738
- });
739
- }
740
- __name(inspect2, "inspect");
741
- function objDisplay(obj) {
742
- var str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
743
- if (config.truncateThreshold && str.length >= config.truncateThreshold) if (type3 === "[object Function]") return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
744
- else if (type3 === "[object Array]") return "[ Array(" + obj.length + ") ]";
745
- else if (type3 === "[object Object]") {
746
- var keys = Object.keys(obj);
747
- return "{ Object (" + (keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ")) + ") }";
748
- } else return str;
749
- else return str;
750
- }
751
- __name(objDisplay, "objDisplay");
752
- function getMessage2(obj, args) {
753
- var negate = flag(obj, "negate"), val = flag(obj, "object"), expected = args[3], actual = getActual(obj, args), msg = negate ? args[2] : args[1], flagMsg = flag(obj, "message");
754
- if (typeof msg === "function") msg = msg();
755
- msg = msg || "";
756
- msg = msg.replace(/#\{this\}/g, function() {
757
- return objDisplay(val);
758
- }).replace(/#\{act\}/g, function() {
759
- return objDisplay(actual);
760
- }).replace(/#\{exp\}/g, function() {
761
- return objDisplay(expected);
762
- });
763
- return flagMsg ? flagMsg + ": " + msg : msg;
764
- }
765
- __name(getMessage2, "getMessage");
766
- function transferFlags(assertion, object, includeAll) {
767
- var flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
768
- if (!object.__flags) object.__flags = /* @__PURE__ */ Object.create(null);
769
- includeAll = arguments.length === 3 ? includeAll : true;
770
- for (var flag3 in flags) if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") object.__flags[flag3] = flags[flag3];
771
- }
772
- __name(transferFlags, "transferFlags");
773
- function type2(obj) {
774
- if (typeof obj === "undefined") return "undefined";
775
- if (obj === null) return "null";
776
- const stringTag = obj[Symbol.toStringTag];
777
- if (typeof stringTag === "string") return stringTag;
778
- return Object.prototype.toString.call(obj).slice(8, -1);
779
- }
780
- __name(type2, "type");
781
- function FakeMap() {
782
- this._key = "chai/deep-eql__" + Math.random() + Date.now();
783
- }
784
- __name(FakeMap, "FakeMap");
785
- FakeMap.prototype = {
786
- get: /* @__PURE__ */ __name(function get(key) {
787
- return key[this._key];
788
- }, "get"),
789
- set: /* @__PURE__ */ __name(function set(key, value) {
790
- if (Object.isExtensible(key)) Object.defineProperty(key, this._key, {
791
- value,
792
- configurable: true
793
- });
794
- }, "set")
795
- };
796
- var MemoizeMap = typeof WeakMap === "function" ? WeakMap : FakeMap;
797
- function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
798
- if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return null;
799
- var leftHandMap = memoizeMap.get(leftHandOperand);
800
- if (leftHandMap) {
801
- var result = leftHandMap.get(rightHandOperand);
802
- if (typeof result === "boolean") return result;
803
- }
804
- return null;
805
- }
806
- __name(memoizeCompare, "memoizeCompare");
807
- function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
808
- if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return;
809
- var leftHandMap = memoizeMap.get(leftHandOperand);
810
- if (leftHandMap) leftHandMap.set(rightHandOperand, result);
811
- else {
812
- leftHandMap = new MemoizeMap();
813
- leftHandMap.set(rightHandOperand, result);
814
- memoizeMap.set(leftHandOperand, leftHandMap);
815
- }
816
- }
817
- __name(memoizeSet, "memoizeSet");
818
- var deep_eql_default = deepEqual;
819
- function deepEqual(leftHandOperand, rightHandOperand, options) {
820
- if (options && options.comparator) return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
821
- var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
822
- if (simpleResult !== null) return simpleResult;
823
- return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
824
- }
825
- __name(deepEqual, "deepEqual");
826
- function simpleEqual(leftHandOperand, rightHandOperand) {
827
- if (leftHandOperand === rightHandOperand) return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
828
- if (leftHandOperand !== leftHandOperand && rightHandOperand !== rightHandOperand) return true;
829
- if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) return false;
830
- return null;
831
- }
832
- __name(simpleEqual, "simpleEqual");
833
- function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
834
- options = options || {};
835
- options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap();
836
- var comparator = options && options.comparator;
837
- var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
838
- if (memoizeResultLeft !== null) return memoizeResultLeft;
839
- var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
840
- if (memoizeResultRight !== null) return memoizeResultRight;
841
- if (comparator) {
842
- var comparatorResult = comparator(leftHandOperand, rightHandOperand);
843
- if (comparatorResult === false || comparatorResult === true) {
844
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
845
- return comparatorResult;
846
- }
847
- var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
848
- if (simpleResult !== null) return simpleResult;
849
- }
850
- var leftHandType = type2(leftHandOperand);
851
- if (leftHandType !== type2(rightHandOperand)) {
852
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
853
- return false;
854
- }
855
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
856
- var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
857
- memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
858
- return result;
859
- }
860
- __name(extensiveDeepEqual, "extensiveDeepEqual");
861
- function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
862
- switch (leftHandType) {
863
- case "String":
864
- case "Number":
865
- case "Boolean":
866
- case "Date": return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
867
- case "Promise":
868
- case "Symbol":
869
- case "function":
870
- case "WeakMap":
871
- case "WeakSet": return leftHandOperand === rightHandOperand;
872
- case "Error": return keysEqual(leftHandOperand, rightHandOperand, [
873
- "name",
874
- "message",
875
- "code"
876
- ], options);
877
- case "Arguments":
878
- case "Int8Array":
879
- case "Uint8Array":
880
- case "Uint8ClampedArray":
881
- case "Int16Array":
882
- case "Uint16Array":
883
- case "Int32Array":
884
- case "Uint32Array":
885
- case "Float32Array":
886
- case "Float64Array":
887
- case "Array": return iterableEqual(leftHandOperand, rightHandOperand, options);
888
- case "RegExp": return regexpEqual(leftHandOperand, rightHandOperand);
889
- case "Generator": return generatorEqual(leftHandOperand, rightHandOperand, options);
890
- case "DataView": return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
891
- case "ArrayBuffer": return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
892
- case "Set": return entriesEqual(leftHandOperand, rightHandOperand, options);
893
- case "Map": return entriesEqual(leftHandOperand, rightHandOperand, options);
894
- case "Temporal.PlainDate":
895
- case "Temporal.PlainTime":
896
- case "Temporal.PlainDateTime":
897
- case "Temporal.Instant":
898
- case "Temporal.ZonedDateTime":
899
- case "Temporal.PlainYearMonth":
900
- case "Temporal.PlainMonthDay": return leftHandOperand.equals(rightHandOperand);
901
- case "Temporal.Duration": return leftHandOperand.total("nanoseconds") === rightHandOperand.total("nanoseconds");
902
- case "Temporal.TimeZone":
903
- case "Temporal.Calendar": return leftHandOperand.toString() === rightHandOperand.toString();
904
- default: return objectEqual(leftHandOperand, rightHandOperand, options);
905
- }
906
- }
907
- __name(extensiveDeepEqualByType, "extensiveDeepEqualByType");
908
- function regexpEqual(leftHandOperand, rightHandOperand) {
909
- return leftHandOperand.toString() === rightHandOperand.toString();
910
- }
911
- __name(regexpEqual, "regexpEqual");
912
- function entriesEqual(leftHandOperand, rightHandOperand, options) {
913
- try {
914
- if (leftHandOperand.size !== rightHandOperand.size) return false;
915
- if (leftHandOperand.size === 0) return true;
916
- } catch (sizeError) {
917
- return false;
918
- }
919
- var leftHandItems = [];
920
- var rightHandItems = [];
921
- leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
922
- leftHandItems.push([key, value]);
923
- }, "gatherEntries"));
924
- rightHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
925
- rightHandItems.push([key, value]);
926
- }, "gatherEntries"));
927
- return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
928
- }
929
- __name(entriesEqual, "entriesEqual");
930
- function iterableEqual(leftHandOperand, rightHandOperand, options) {
931
- var length = leftHandOperand.length;
932
- if (length !== rightHandOperand.length) return false;
933
- if (length === 0) return true;
934
- var index = -1;
935
- while (++index < length) if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) return false;
936
- return true;
937
- }
938
- __name(iterableEqual, "iterableEqual");
939
- function generatorEqual(leftHandOperand, rightHandOperand, options) {
940
- return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
941
- }
942
- __name(generatorEqual, "generatorEqual");
943
- function hasIteratorFunction(target) {
944
- return typeof Symbol !== "undefined" && typeof target === "object" && typeof Symbol.iterator !== "undefined" && typeof target[Symbol.iterator] === "function";
945
- }
946
- __name(hasIteratorFunction, "hasIteratorFunction");
947
- function getIteratorEntries(target) {
948
- if (hasIteratorFunction(target)) try {
949
- return getGeneratorEntries(target[Symbol.iterator]());
950
- } catch (iteratorError) {
951
- return [];
952
- }
953
- return [];
954
- }
955
- __name(getIteratorEntries, "getIteratorEntries");
956
- function getGeneratorEntries(generator) {
957
- var generatorResult = generator.next();
958
- var accumulator = [generatorResult.value];
959
- while (generatorResult.done === false) {
960
- generatorResult = generator.next();
961
- accumulator.push(generatorResult.value);
962
- }
963
- return accumulator;
964
- }
965
- __name(getGeneratorEntries, "getGeneratorEntries");
966
- function getEnumerableKeys(target) {
967
- var keys = [];
968
- for (var key in target) keys.push(key);
969
- return keys;
970
- }
971
- __name(getEnumerableKeys, "getEnumerableKeys");
972
- function getEnumerableSymbols(target) {
973
- var keys = [];
974
- var allKeys = Object.getOwnPropertySymbols(target);
975
- for (var i = 0; i < allKeys.length; i += 1) {
976
- var key = allKeys[i];
977
- if (Object.getOwnPropertyDescriptor(target, key).enumerable) keys.push(key);
978
- }
979
- return keys;
980
- }
981
- __name(getEnumerableSymbols, "getEnumerableSymbols");
982
- function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
983
- var length = keys.length;
984
- if (length === 0) return true;
985
- for (var i = 0; i < length; i += 1) if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) return false;
986
- return true;
987
- }
988
- __name(keysEqual, "keysEqual");
989
- function objectEqual(leftHandOperand, rightHandOperand, options) {
990
- var leftHandKeys = getEnumerableKeys(leftHandOperand);
991
- var rightHandKeys = getEnumerableKeys(rightHandOperand);
992
- var leftHandSymbols = getEnumerableSymbols(leftHandOperand);
993
- var rightHandSymbols = getEnumerableSymbols(rightHandOperand);
994
- leftHandKeys = leftHandKeys.concat(leftHandSymbols);
995
- rightHandKeys = rightHandKeys.concat(rightHandSymbols);
996
- if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
997
- if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false) return false;
998
- return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
999
- }
1000
- var leftHandEntries = getIteratorEntries(leftHandOperand);
1001
- var rightHandEntries = getIteratorEntries(rightHandOperand);
1002
- if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
1003
- leftHandEntries.sort();
1004
- rightHandEntries.sort();
1005
- return iterableEqual(leftHandEntries, rightHandEntries, options);
1006
- }
1007
- if (leftHandKeys.length === 0 && leftHandEntries.length === 0 && rightHandKeys.length === 0 && rightHandEntries.length === 0) return true;
1008
- return false;
1009
- }
1010
- __name(objectEqual, "objectEqual");
1011
- function isPrimitive(value) {
1012
- return value === null || typeof value !== "object";
1013
- }
1014
- __name(isPrimitive, "isPrimitive");
1015
- function mapSymbols(arr) {
1016
- return arr.map(/* @__PURE__ */ __name(function mapSymbol(entry) {
1017
- if (typeof entry === "symbol") return entry.toString();
1018
- return entry;
1019
- }, "mapSymbol"));
1020
- }
1021
- __name(mapSymbols, "mapSymbols");
1022
- function hasProperty(obj, name) {
1023
- if (typeof obj === "undefined" || obj === null) return false;
1024
- return name in Object(obj);
1025
- }
1026
- __name(hasProperty, "hasProperty");
1027
- function parsePath(path) {
1028
- return path.replace(/([^\\])\[/g, "$1.[").match(/(\\\.|[^.]+?)+/g).map((value) => {
1029
- if (value === "constructor" || value === "__proto__" || value === "prototype") return {};
1030
- const mArr = /^\[(\d+)\]$/.exec(value);
1031
- let parsed = null;
1032
- if (mArr) parsed = { i: parseFloat(mArr[1]) };
1033
- else parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
1034
- return parsed;
1035
- });
1036
- }
1037
- __name(parsePath, "parsePath");
1038
- function internalGetPathValue(obj, parsed, pathDepth) {
1039
- let temporaryValue = obj;
1040
- let res = null;
1041
- pathDepth = typeof pathDepth === "undefined" ? parsed.length : pathDepth;
1042
- for (let i = 0; i < pathDepth; i++) {
1043
- const part = parsed[i];
1044
- if (temporaryValue) {
1045
- if (typeof part.p === "undefined") temporaryValue = temporaryValue[part.i];
1046
- else temporaryValue = temporaryValue[part.p];
1047
- if (i === pathDepth - 1) res = temporaryValue;
1048
- }
1049
- }
1050
- return res;
1051
- }
1052
- __name(internalGetPathValue, "internalGetPathValue");
1053
- function getPathInfo(obj, path) {
1054
- const parsed = parsePath(path);
1055
- const last = parsed[parsed.length - 1];
1056
- const info = {
1057
- parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
1058
- name: last.p || last.i,
1059
- value: internalGetPathValue(obj, parsed)
1060
- };
1061
- info.exists = hasProperty(info.parent, info.name);
1062
- return info;
1063
- }
1064
- __name(getPathInfo, "getPathInfo");
1065
- function Assertion(obj, msg, ssfi, lockSsfi) {
1066
- flag(this, "ssfi", ssfi || Assertion);
1067
- flag(this, "lockSsfi", lockSsfi);
1068
- flag(this, "object", obj);
1069
- flag(this, "message", msg);
1070
- flag(this, "eql", config.deepEqual || deep_eql_default);
1071
- return proxify(this);
1072
- }
1073
- __name(Assertion, "Assertion");
1074
- Object.defineProperty(Assertion, "includeStack", {
1075
- get: function() {
1076
- console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
1077
- return config.includeStack;
1078
- },
1079
- set: function(value) {
1080
- console.warn("Assertion.includeStack is deprecated, use chai.config.includeStack instead.");
1081
- config.includeStack = value;
1082
- }
1083
- });
1084
- Object.defineProperty(Assertion, "showDiff", {
1085
- get: function() {
1086
- console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
1087
- return config.showDiff;
1088
- },
1089
- set: function(value) {
1090
- console.warn("Assertion.showDiff is deprecated, use chai.config.showDiff instead.");
1091
- config.showDiff = value;
1092
- }
1093
- });
1094
- Assertion.addProperty = function(name, fn) {
1095
- addProperty(this.prototype, name, fn);
1096
- };
1097
- Assertion.addMethod = function(name, fn) {
1098
- addMethod(this.prototype, name, fn);
1099
- };
1100
- Assertion.addChainableMethod = function(name, fn, chainingBehavior) {
1101
- addChainableMethod(this.prototype, name, fn, chainingBehavior);
1102
- };
1103
- Assertion.overwriteProperty = function(name, fn) {
1104
- overwriteProperty(this.prototype, name, fn);
1105
- };
1106
- Assertion.overwriteMethod = function(name, fn) {
1107
- overwriteMethod(this.prototype, name, fn);
1108
- };
1109
- Assertion.overwriteChainableMethod = function(name, fn, chainingBehavior) {
1110
- overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
1111
- };
1112
- Assertion.prototype.assert = function(expr, msg, negateMsg, expected, _actual, showDiff) {
1113
- var ok = test(this, arguments);
1114
- if (false !== showDiff) showDiff = true;
1115
- if (void 0 === expected && void 0 === _actual) showDiff = false;
1116
- if (true !== config.showDiff) showDiff = false;
1117
- if (!ok) {
1118
- msg = getMessage2(this, arguments);
1119
- var assertionErrorObjectProperties = {
1120
- actual: getActual(this, arguments),
1121
- expected,
1122
- showDiff
1123
- };
1124
- var operator = getOperator(this, arguments);
1125
- if (operator) assertionErrorObjectProperties.operator = operator;
1126
- throw new AssertionError(msg, assertionErrorObjectProperties, config.includeStack ? this.assert : flag(this, "ssfi"));
1127
- }
1128
- };
1129
- Object.defineProperty(Assertion.prototype, "_obj", {
1130
- get: function() {
1131
- return flag(this, "object");
1132
- },
1133
- set: function(val) {
1134
- flag(this, "object", val);
1135
- }
1136
- });
1137
- function isProxyEnabled() {
1138
- return config.useProxy && typeof Proxy !== "undefined" && typeof Reflect !== "undefined";
1139
- }
1140
- __name(isProxyEnabled, "isProxyEnabled");
1141
- function addProperty(ctx, name, getter) {
1142
- getter = getter === void 0 ? function() {} : getter;
1143
- Object.defineProperty(ctx, name, {
1144
- get: /* @__PURE__ */ __name(function propertyGetter() {
1145
- if (!isProxyEnabled() && !flag(this, "lockSsfi")) flag(this, "ssfi", propertyGetter);
1146
- var result = getter.call(this);
1147
- if (result !== void 0) return result;
1148
- var newAssertion = new Assertion();
1149
- transferFlags(this, newAssertion);
1150
- return newAssertion;
1151
- }, "propertyGetter"),
1152
- configurable: true
1153
- });
1154
- }
1155
- __name(addProperty, "addProperty");
1156
- var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {}, "length");
1157
- function addLengthGuard(fn, assertionName, isChainable) {
1158
- if (!fnLengthDesc.configurable) return fn;
1159
- Object.defineProperty(fn, "length", { get: function() {
1160
- if (isChainable) throw Error("Invalid Chai property: " + assertionName + ".length. Due to a compatibility issue, \"length\" cannot directly follow \"" + assertionName + "\". Use \"" + assertionName + ".lengthOf\" instead.");
1161
- throw Error("Invalid Chai property: " + assertionName + ".length. See docs for proper usage of \"" + assertionName + "\".");
1162
- } });
1163
- return fn;
1164
- }
1165
- __name(addLengthGuard, "addLengthGuard");
1166
- function getProperties(object) {
1167
- var result = Object.getOwnPropertyNames(object);
1168
- function addProperty2(property) {
1169
- if (result.indexOf(property) === -1) result.push(property);
1170
- }
1171
- __name(addProperty2, "addProperty");
1172
- var proto = Object.getPrototypeOf(object);
1173
- while (proto !== null) {
1174
- Object.getOwnPropertyNames(proto).forEach(addProperty2);
1175
- proto = Object.getPrototypeOf(proto);
1176
- }
1177
- return result;
1178
- }
1179
- __name(getProperties, "getProperties");
1180
- var builtins = [
1181
- "__flags",
1182
- "__methods",
1183
- "_obj",
1184
- "assert"
1185
- ];
1186
- function proxify(obj, nonChainableMethodName) {
1187
- if (!isProxyEnabled()) return obj;
1188
- return new Proxy(obj, { get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
1189
- if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
1190
- if (nonChainableMethodName) throw Error("Invalid Chai property: " + nonChainableMethodName + "." + property + ". See docs for proper usage of \"" + nonChainableMethodName + "\".");
1191
- var suggestion = null;
1192
- var suggestionDistance = 4;
1193
- getProperties(target).forEach(function(prop) {
1194
- if (!Object.prototype.hasOwnProperty(prop) && builtins.indexOf(prop) === -1) {
1195
- var dist = stringDistanceCapped(property, prop, suggestionDistance);
1196
- if (dist < suggestionDistance) {
1197
- suggestion = prop;
1198
- suggestionDistance = dist;
1199
- }
1200
- }
1201
- });
1202
- if (suggestion !== null) throw Error("Invalid Chai property: " + property + ". Did you mean \"" + suggestion + "\"?");
1203
- else throw Error("Invalid Chai property: " + property);
1204
- }
1205
- if (builtins.indexOf(property) === -1 && !flag(target, "lockSsfi")) flag(target, "ssfi", proxyGetter);
1206
- return Reflect.get(target, property);
1207
- }, "proxyGetter") });
1208
- }
1209
- __name(proxify, "proxify");
1210
- function stringDistanceCapped(strA, strB, cap) {
1211
- if (Math.abs(strA.length - strB.length) >= cap) return cap;
1212
- var memo = [];
1213
- for (let i = 0; i <= strA.length; i++) {
1214
- memo[i] = Array(strB.length + 1).fill(0);
1215
- memo[i][0] = i;
1216
- }
1217
- for (let j = 0; j < strB.length; j++) memo[0][j] = j;
1218
- for (let i = 1; i <= strA.length; i++) {
1219
- var ch = strA.charCodeAt(i - 1);
1220
- for (let j = 1; j <= strB.length; j++) {
1221
- if (Math.abs(i - j) >= cap) {
1222
- memo[i][j] = cap;
1223
- continue;
1224
- }
1225
- memo[i][j] = Math.min(memo[i - 1][j] + 1, memo[i][j - 1] + 1, memo[i - 1][j - 1] + (ch === strB.charCodeAt(j - 1) ? 0 : 1));
1226
- }
1227
- }
1228
- return memo[strA.length][strB.length];
1229
- }
1230
- __name(stringDistanceCapped, "stringDistanceCapped");
1231
- function addMethod(ctx, name, method) {
1232
- var methodWrapper = /* @__PURE__ */ __name(function() {
1233
- if (!flag(this, "lockSsfi")) flag(this, "ssfi", methodWrapper);
1234
- var result = method.apply(this, arguments);
1235
- if (result !== void 0) return result;
1236
- var newAssertion = new Assertion();
1237
- transferFlags(this, newAssertion);
1238
- return newAssertion;
1239
- }, "methodWrapper");
1240
- addLengthGuard(methodWrapper, name, false);
1241
- ctx[name] = proxify(methodWrapper, name);
1242
- }
1243
- __name(addMethod, "addMethod");
1244
- function overwriteProperty(ctx, name, getter) {
1245
- var _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {}, "_super");
1246
- if (_get && "function" === typeof _get.get) _super = _get.get;
1247
- Object.defineProperty(ctx, name, {
1248
- get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
1249
- if (!isProxyEnabled() && !flag(this, "lockSsfi")) flag(this, "ssfi", overwritingPropertyGetter);
1250
- var origLockSsfi = flag(this, "lockSsfi");
1251
- flag(this, "lockSsfi", true);
1252
- var result = getter(_super).call(this);
1253
- flag(this, "lockSsfi", origLockSsfi);
1254
- if (result !== void 0) return result;
1255
- var newAssertion = new Assertion();
1256
- transferFlags(this, newAssertion);
1257
- return newAssertion;
1258
- }, "overwritingPropertyGetter"),
1259
- configurable: true
1260
- });
1261
- }
1262
- __name(overwriteProperty, "overwriteProperty");
1263
- function overwriteMethod(ctx, name, method) {
1264
- var _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
1265
- throw new Error(name + " is not a function");
1266
- }, "_super");
1267
- if (_method && "function" === typeof _method) _super = _method;
1268
- var overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
1269
- if (!flag(this, "lockSsfi")) flag(this, "ssfi", overwritingMethodWrapper);
1270
- var origLockSsfi = flag(this, "lockSsfi");
1271
- flag(this, "lockSsfi", true);
1272
- var result = method(_super).apply(this, arguments);
1273
- flag(this, "lockSsfi", origLockSsfi);
1274
- if (result !== void 0) return result;
1275
- var newAssertion = new Assertion();
1276
- transferFlags(this, newAssertion);
1277
- return newAssertion;
1278
- }, "overwritingMethodWrapper");
1279
- addLengthGuard(overwritingMethodWrapper, name, false);
1280
- ctx[name] = proxify(overwritingMethodWrapper, name);
1281
- }
1282
- __name(overwriteMethod, "overwriteMethod");
1283
- var canSetPrototype = typeof Object.setPrototypeOf === "function";
1284
- var testFn = /* @__PURE__ */ __name(function() {}, "testFn");
1285
- var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
1286
- var propDesc = Object.getOwnPropertyDescriptor(testFn, name);
1287
- if (typeof propDesc !== "object") return true;
1288
- return !propDesc.configurable;
1289
- });
1290
- var call = Function.prototype.call;
1291
- var apply = Function.prototype.apply;
1292
- function addChainableMethod(ctx, name, method, chainingBehavior) {
1293
- if (typeof chainingBehavior !== "function") chainingBehavior = /* @__PURE__ */ __name(function() {}, "chainingBehavior");
1294
- var chainableBehavior = {
1295
- method,
1296
- chainingBehavior
1297
- };
1298
- if (!ctx.__methods) ctx.__methods = {};
1299
- ctx.__methods[name] = chainableBehavior;
1300
- Object.defineProperty(ctx, name, {
1301
- get: /* @__PURE__ */ __name(function chainableMethodGetter() {
1302
- chainableBehavior.chainingBehavior.call(this);
1303
- var chainableMethodWrapper = /* @__PURE__ */ __name(function() {
1304
- if (!flag(this, "lockSsfi")) flag(this, "ssfi", chainableMethodWrapper);
1305
- var result = chainableBehavior.method.apply(this, arguments);
1306
- if (result !== void 0) return result;
1307
- var newAssertion = new Assertion();
1308
- transferFlags(this, newAssertion);
1309
- return newAssertion;
1310
- }, "chainableMethodWrapper");
1311
- addLengthGuard(chainableMethodWrapper, name, true);
1312
- if (canSetPrototype) {
1313
- var prototype = Object.create(this);
1314
- prototype.call = call;
1315
- prototype.apply = apply;
1316
- Object.setPrototypeOf(chainableMethodWrapper, prototype);
1317
- } else Object.getOwnPropertyNames(ctx).forEach(function(asserterName) {
1318
- if (excludeNames.indexOf(asserterName) !== -1) return;
1319
- var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
1320
- Object.defineProperty(chainableMethodWrapper, asserterName, pd);
1321
- });
1322
- transferFlags(this, chainableMethodWrapper);
1323
- return proxify(chainableMethodWrapper);
1324
- }, "chainableMethodGetter"),
1325
- configurable: true
1326
- });
1327
- }
1328
- __name(addChainableMethod, "addChainableMethod");
1329
- function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
1330
- var chainableBehavior = ctx.__methods[name];
1331
- var _chainingBehavior = chainableBehavior.chainingBehavior;
1332
- chainableBehavior.chainingBehavior = /* @__PURE__ */ __name(function overwritingChainableMethodGetter() {
1333
- var result = chainingBehavior(_chainingBehavior).call(this);
1334
- if (result !== void 0) return result;
1335
- var newAssertion = new Assertion();
1336
- transferFlags(this, newAssertion);
1337
- return newAssertion;
1338
- }, "overwritingChainableMethodGetter");
1339
- var _method = chainableBehavior.method;
1340
- chainableBehavior.method = /* @__PURE__ */ __name(function overwritingChainableMethodWrapper() {
1341
- var result = method(_method).apply(this, arguments);
1342
- if (result !== void 0) return result;
1343
- var newAssertion = new Assertion();
1344
- transferFlags(this, newAssertion);
1345
- return newAssertion;
1346
- }, "overwritingChainableMethodWrapper");
1347
- }
1348
- __name(overwriteChainableMethod, "overwriteChainableMethod");
1349
- function compareByInspect(a, b) {
1350
- return inspect2(a) < inspect2(b) ? -1 : 1;
1351
- }
1352
- __name(compareByInspect, "compareByInspect");
1353
- function getOwnEnumerablePropertySymbols(obj) {
1354
- if (typeof Object.getOwnPropertySymbols !== "function") return [];
1355
- return Object.getOwnPropertySymbols(obj).filter(function(sym) {
1356
- return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
1357
- });
1358
- }
1359
- __name(getOwnEnumerablePropertySymbols, "getOwnEnumerablePropertySymbols");
1360
- function getOwnEnumerableProperties(obj) {
1361
- return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
1362
- }
1363
- __name(getOwnEnumerableProperties, "getOwnEnumerableProperties");
1364
- var isNaN2 = Number.isNaN;
1365
- function isObjectType(obj) {
1366
- var objectType = type(obj);
1367
- return [
1368
- "Array",
1369
- "Object",
1370
- "Function"
1371
- ].indexOf(objectType) !== -1;
1372
- }
1373
- __name(isObjectType, "isObjectType");
1374
- function getOperator(obj, args) {
1375
- var operator = flag(obj, "operator");
1376
- var negate = flag(obj, "negate");
1377
- var expected = args[3];
1378
- var msg = negate ? args[2] : args[1];
1379
- if (operator) return operator;
1380
- if (typeof msg === "function") msg = msg();
1381
- msg = msg || "";
1382
- if (!msg) return;
1383
- if (/\shave\s/.test(msg)) return;
1384
- var isObject = isObjectType(expected);
1385
- if (/\snot\s/.test(msg)) return isObject ? "notDeepStrictEqual" : "notStrictEqual";
1386
- return isObject ? "deepStrictEqual" : "strictEqual";
1387
- }
1388
- __name(getOperator, "getOperator");
1389
- function getName(fn) {
1390
- return fn.name;
1391
- }
1392
- __name(getName, "getName");
1393
- function isRegExp2(obj) {
1394
- return Object.prototype.toString.call(obj) === "[object RegExp]";
1395
- }
1396
- __name(isRegExp2, "isRegExp");
1397
- function isNumeric(obj) {
1398
- return ["Number", "BigInt"].includes(type(obj));
1399
- }
1400
- __name(isNumeric, "isNumeric");
1401
- var { flag: flag2 } = utils_exports;
1402
- [
1403
- "to",
1404
- "be",
1405
- "been",
1406
- "is",
1407
- "and",
1408
- "has",
1409
- "have",
1410
- "with",
1411
- "that",
1412
- "which",
1413
- "at",
1414
- "of",
1415
- "same",
1416
- "but",
1417
- "does",
1418
- "still",
1419
- "also"
1420
- ].forEach(function(chain) {
1421
- Assertion.addProperty(chain);
1422
- });
1423
- Assertion.addProperty("not", function() {
1424
- flag2(this, "negate", true);
1425
- });
1426
- Assertion.addProperty("deep", function() {
1427
- flag2(this, "deep", true);
1428
- });
1429
- Assertion.addProperty("nested", function() {
1430
- flag2(this, "nested", true);
1431
- });
1432
- Assertion.addProperty("own", function() {
1433
- flag2(this, "own", true);
1434
- });
1435
- Assertion.addProperty("ordered", function() {
1436
- flag2(this, "ordered", true);
1437
- });
1438
- Assertion.addProperty("any", function() {
1439
- flag2(this, "any", true);
1440
- flag2(this, "all", false);
1441
- });
1442
- Assertion.addProperty("all", function() {
1443
- flag2(this, "all", true);
1444
- flag2(this, "any", false);
1445
- });
1446
- var functionTypes = {
1447
- function: [
1448
- "function",
1449
- "asyncfunction",
1450
- "generatorfunction",
1451
- "asyncgeneratorfunction"
1452
- ],
1453
- asyncfunction: ["asyncfunction", "asyncgeneratorfunction"],
1454
- generatorfunction: ["generatorfunction", "asyncgeneratorfunction"],
1455
- asyncgeneratorfunction: ["asyncgeneratorfunction"]
1456
- };
1457
- function an(type3, msg) {
1458
- if (msg) flag2(this, "message", msg);
1459
- type3 = type3.toLowerCase();
1460
- var obj = flag2(this, "object"), article = ~[
1461
- "a",
1462
- "e",
1463
- "i",
1464
- "o",
1465
- "u"
1466
- ].indexOf(type3.charAt(0)) ? "an " : "a ";
1467
- const detectedType = type(obj).toLowerCase();
1468
- if (functionTypes["function"].includes(type3)) this.assert(functionTypes[type3].includes(detectedType), "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
1469
- else this.assert(type3 === detectedType, "expected #{this} to be " + article + type3, "expected #{this} not to be " + article + type3);
1470
- }
1471
- __name(an, "an");
1472
- Assertion.addChainableMethod("an", an);
1473
- Assertion.addChainableMethod("a", an);
1474
- function SameValueZero(a, b) {
1475
- return isNaN2(a) && isNaN2(b) || a === b;
1476
- }
1477
- __name(SameValueZero, "SameValueZero");
1478
- function includeChainingBehavior() {
1479
- flag2(this, "contains", true);
1480
- }
1481
- __name(includeChainingBehavior, "includeChainingBehavior");
1482
- function include(val, msg) {
1483
- if (msg) flag2(this, "message", msg);
1484
- var obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), negate = flag2(this, "negate"), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), descriptor = isDeep ? "deep " : "", isEql = isDeep ? flag2(this, "eql") : SameValueZero;
1485
- flagMsg = flagMsg ? flagMsg + ": " : "";
1486
- var included = false;
1487
- switch (objType) {
1488
- case "string":
1489
- included = obj.indexOf(val) !== -1;
1490
- break;
1491
- case "weakset":
1492
- if (isDeep) throw new AssertionError(flagMsg + "unable to use .deep.include with WeakSet", void 0, ssfi);
1493
- included = obj.has(val);
1494
- break;
1495
- case "map":
1496
- obj.forEach(function(item) {
1497
- included = included || isEql(item, val);
1498
- });
1499
- break;
1500
- case "set":
1501
- if (isDeep) obj.forEach(function(item) {
1502
- included = included || isEql(item, val);
1503
- });
1504
- else included = obj.has(val);
1505
- break;
1506
- case "array":
1507
- if (isDeep) included = obj.some(function(item) {
1508
- return isEql(item, val);
1509
- });
1510
- else included = obj.indexOf(val) !== -1;
1511
- break;
1512
- default:
1513
- if (val !== Object(val)) throw new AssertionError(flagMsg + "the given combination of arguments (" + objType + " and " + type(val).toLowerCase() + ") is invalid for this assertion. You can use an array, a map, an object, a set, a string, or a weakset instead of a " + type(val).toLowerCase(), void 0, ssfi);
1514
- var props = Object.keys(val), firstErr = null, numErrs = 0;
1515
- props.forEach(function(prop) {
1516
- var propAssertion = new Assertion(obj);
1517
- transferFlags(this, propAssertion, true);
1518
- flag2(propAssertion, "lockSsfi", true);
1519
- if (!negate || props.length === 1) {
1520
- propAssertion.property(prop, val[prop]);
1521
- return;
1522
- }
1523
- try {
1524
- propAssertion.property(prop, val[prop]);
1525
- } catch (err) {
1526
- if (!check_error_exports.compatibleConstructor(err, AssertionError)) throw err;
1527
- if (firstErr === null) firstErr = err;
1528
- numErrs++;
1529
- }
1530
- }, this);
1531
- if (negate && props.length > 1 && numErrs === props.length) throw firstErr;
1532
- return;
1533
- }
1534
- this.assert(included, "expected #{this} to " + descriptor + "include " + inspect2(val), "expected #{this} to not " + descriptor + "include " + inspect2(val));
1535
- }
1536
- __name(include, "include");
1537
- Assertion.addChainableMethod("include", include, includeChainingBehavior);
1538
- Assertion.addChainableMethod("contain", include, includeChainingBehavior);
1539
- Assertion.addChainableMethod("contains", include, includeChainingBehavior);
1540
- Assertion.addChainableMethod("includes", include, includeChainingBehavior);
1541
- Assertion.addProperty("ok", function() {
1542
- this.assert(flag2(this, "object"), "expected #{this} to be truthy", "expected #{this} to be falsy");
1543
- });
1544
- Assertion.addProperty("true", function() {
1545
- this.assert(true === flag2(this, "object"), "expected #{this} to be true", "expected #{this} to be false", flag2(this, "negate") ? false : true);
1546
- });
1547
- Assertion.addProperty("numeric", function() {
1548
- const object = flag2(this, "object");
1549
- this.assert(["Number", "BigInt"].includes(type(object)), "expected #{this} to be numeric", "expected #{this} to not be numeric", flag2(this, "negate") ? false : true);
1550
- });
1551
- Assertion.addProperty("callable", function() {
1552
- const val = flag2(this, "object");
1553
- const ssfi = flag2(this, "ssfi");
1554
- const message = flag2(this, "message");
1555
- const msg = message ? `${message}: ` : "";
1556
- const negate = flag2(this, "negate");
1557
- const assertionMessage = negate ? `${msg}expected ${inspect2(val)} not to be a callable function` : `${msg}expected ${inspect2(val)} to be a callable function`;
1558
- const isCallable = [
1559
- "Function",
1560
- "AsyncFunction",
1561
- "GeneratorFunction",
1562
- "AsyncGeneratorFunction"
1563
- ].includes(type(val));
1564
- if (isCallable && negate || !isCallable && !negate) throw new AssertionError(assertionMessage, void 0, ssfi);
1565
- });
1566
- Assertion.addProperty("false", function() {
1567
- this.assert(false === flag2(this, "object"), "expected #{this} to be false", "expected #{this} to be true", flag2(this, "negate") ? true : false);
1568
- });
1569
- Assertion.addProperty("null", function() {
1570
- this.assert(null === flag2(this, "object"), "expected #{this} to be null", "expected #{this} not to be null");
1571
- });
1572
- Assertion.addProperty("undefined", function() {
1573
- this.assert(void 0 === flag2(this, "object"), "expected #{this} to be undefined", "expected #{this} not to be undefined");
1574
- });
1575
- Assertion.addProperty("NaN", function() {
1576
- this.assert(isNaN2(flag2(this, "object")), "expected #{this} to be NaN", "expected #{this} not to be NaN");
1577
- });
1578
- function assertExist() {
1579
- var val = flag2(this, "object");
1580
- this.assert(val !== null && val !== void 0, "expected #{this} to exist", "expected #{this} to not exist");
1581
- }
1582
- __name(assertExist, "assertExist");
1583
- Assertion.addProperty("exist", assertExist);
1584
- Assertion.addProperty("exists", assertExist);
1585
- Assertion.addProperty("empty", function() {
1586
- var val = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), itemsCount;
1587
- flagMsg = flagMsg ? flagMsg + ": " : "";
1588
- switch (type(val).toLowerCase()) {
1589
- case "array":
1590
- case "string":
1591
- itemsCount = val.length;
1592
- break;
1593
- case "map":
1594
- case "set":
1595
- itemsCount = val.size;
1596
- break;
1597
- case "weakmap":
1598
- case "weakset": throw new AssertionError(flagMsg + ".empty was passed a weak collection", void 0, ssfi);
1599
- case "function": throw new AssertionError((flagMsg + ".empty was passed a function " + getName(val)).trim(), void 0, ssfi);
1600
- default:
1601
- if (val !== Object(val)) throw new AssertionError(flagMsg + ".empty was passed non-string primitive " + inspect2(val), void 0, ssfi);
1602
- itemsCount = Object.keys(val).length;
1603
- }
1604
- this.assert(0 === itemsCount, "expected #{this} to be empty", "expected #{this} not to be empty");
1605
- });
1606
- function checkArguments() {
1607
- var type3 = type(flag2(this, "object"));
1608
- this.assert("Arguments" === type3, "expected #{this} to be arguments but got " + type3, "expected #{this} to not be arguments");
1609
- }
1610
- __name(checkArguments, "checkArguments");
1611
- Assertion.addProperty("arguments", checkArguments);
1612
- Assertion.addProperty("Arguments", checkArguments);
1613
- function assertEqual(val, msg) {
1614
- if (msg) flag2(this, "message", msg);
1615
- var obj = flag2(this, "object");
1616
- if (flag2(this, "deep")) {
1617
- var prevLockSsfi = flag2(this, "lockSsfi");
1618
- flag2(this, "lockSsfi", true);
1619
- this.eql(val);
1620
- flag2(this, "lockSsfi", prevLockSsfi);
1621
- } else this.assert(val === obj, "expected #{this} to equal #{exp}", "expected #{this} to not equal #{exp}", val, this._obj, true);
1622
- }
1623
- __name(assertEqual, "assertEqual");
1624
- Assertion.addMethod("equal", assertEqual);
1625
- Assertion.addMethod("equals", assertEqual);
1626
- Assertion.addMethod("eq", assertEqual);
1627
- function assertEql(obj, msg) {
1628
- if (msg) flag2(this, "message", msg);
1629
- var eql = flag2(this, "eql");
1630
- this.assert(eql(obj, flag2(this, "object")), "expected #{this} to deeply equal #{exp}", "expected #{this} to not deeply equal #{exp}", obj, this._obj, true);
1631
- }
1632
- __name(assertEql, "assertEql");
1633
- Assertion.addMethod("eql", assertEql);
1634
- Assertion.addMethod("eqls", assertEql);
1635
- function assertAbove(n, msg) {
1636
- if (msg) flag2(this, "message", msg);
1637
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase();
1638
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1639
- if (!doLength && objType === "date" && nType !== "date") throw new AssertionError(msgPrefix + "the argument to above must be a date", void 0, ssfi);
1640
- else if (!isNumeric(n) && (doLength || isNumeric(obj))) throw new AssertionError(msgPrefix + "the argument to above must be a number", void 0, ssfi);
1641
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1642
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
1643
- throw new AssertionError(msgPrefix + "expected " + printObj + " to be a number or a date", void 0, ssfi);
1644
- }
1645
- if (doLength) {
1646
- var descriptor = "length", itemsCount;
1647
- if (objType === "map" || objType === "set") {
1648
- descriptor = "size";
1649
- itemsCount = obj.size;
1650
- } else itemsCount = obj.length;
1651
- this.assert(itemsCount > n, "expected #{this} to have a " + descriptor + " above #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " above #{exp}", n, itemsCount);
1652
- } else this.assert(obj > n, "expected #{this} to be above #{exp}", "expected #{this} to be at most #{exp}", n);
1653
- }
1654
- __name(assertAbove, "assertAbove");
1655
- Assertion.addMethod("above", assertAbove);
1656
- Assertion.addMethod("gt", assertAbove);
1657
- Assertion.addMethod("greaterThan", assertAbove);
1658
- function assertLeast(n, msg) {
1659
- if (msg) flag2(this, "message", msg);
1660
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
1661
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1662
- if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to least must be a date";
1663
- else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to least must be a number";
1664
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1665
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
1666
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
1667
- } else shouldThrow = false;
1668
- if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
1669
- if (doLength) {
1670
- var descriptor = "length", itemsCount;
1671
- if (objType === "map" || objType === "set") {
1672
- descriptor = "size";
1673
- itemsCount = obj.size;
1674
- } else itemsCount = obj.length;
1675
- this.assert(itemsCount >= n, "expected #{this} to have a " + descriptor + " at least #{exp} but got #{act}", "expected #{this} to have a " + descriptor + " below #{exp}", n, itemsCount);
1676
- } else this.assert(obj >= n, "expected #{this} to be at least #{exp}", "expected #{this} to be below #{exp}", n);
1677
- }
1678
- __name(assertLeast, "assertLeast");
1679
- Assertion.addMethod("least", assertLeast);
1680
- Assertion.addMethod("gte", assertLeast);
1681
- Assertion.addMethod("greaterThanOrEqual", assertLeast);
1682
- function assertBelow(n, msg) {
1683
- if (msg) flag2(this, "message", msg);
1684
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
1685
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1686
- if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to below must be a date";
1687
- else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to below must be a number";
1688
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1689
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
1690
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
1691
- } else shouldThrow = false;
1692
- if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
1693
- if (doLength) {
1694
- var descriptor = "length", itemsCount;
1695
- if (objType === "map" || objType === "set") {
1696
- descriptor = "size";
1697
- itemsCount = obj.size;
1698
- } else itemsCount = obj.length;
1699
- this.assert(itemsCount < n, "expected #{this} to have a " + descriptor + " below #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " below #{exp}", n, itemsCount);
1700
- } else this.assert(obj < n, "expected #{this} to be below #{exp}", "expected #{this} to be at least #{exp}", n);
1701
- }
1702
- __name(assertBelow, "assertBelow");
1703
- Assertion.addMethod("below", assertBelow);
1704
- Assertion.addMethod("lt", assertBelow);
1705
- Assertion.addMethod("lessThan", assertBelow);
1706
- function assertMost(n, msg) {
1707
- if (msg) flag2(this, "message", msg);
1708
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
1709
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1710
- if (!doLength && objType === "date" && nType !== "date") errorMessage = msgPrefix + "the argument to most must be a date";
1711
- else if (!isNumeric(n) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the argument to most must be a number";
1712
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1713
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
1714
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
1715
- } else shouldThrow = false;
1716
- if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
1717
- if (doLength) {
1718
- var descriptor = "length", itemsCount;
1719
- if (objType === "map" || objType === "set") {
1720
- descriptor = "size";
1721
- itemsCount = obj.size;
1722
- } else itemsCount = obj.length;
1723
- this.assert(itemsCount <= n, "expected #{this} to have a " + descriptor + " at most #{exp} but got #{act}", "expected #{this} to have a " + descriptor + " above #{exp}", n, itemsCount);
1724
- } else this.assert(obj <= n, "expected #{this} to be at most #{exp}", "expected #{this} to be above #{exp}", n);
1725
- }
1726
- __name(assertMost, "assertMost");
1727
- Assertion.addMethod("most", assertMost);
1728
- Assertion.addMethod("lte", assertMost);
1729
- Assertion.addMethod("lessThanOrEqual", assertMost);
1730
- Assertion.addMethod("within", function(start, finish, msg) {
1731
- if (msg) flag2(this, "message", msg);
1732
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), startType = type(start).toLowerCase(), finishType = type(finish).toLowerCase(), errorMessage, shouldThrow = true, range = startType === "date" && finishType === "date" ? start.toISOString() + ".." + finish.toISOString() : start + ".." + finish;
1733
- if (doLength && objType !== "map" && objType !== "set") new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1734
- if (!doLength && objType === "date" && (startType !== "date" || finishType !== "date")) errorMessage = msgPrefix + "the arguments to within must be dates";
1735
- else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) errorMessage = msgPrefix + "the arguments to within must be numbers";
1736
- else if (!doLength && objType !== "date" && !isNumeric(obj)) {
1737
- var printObj = objType === "string" ? "'" + obj + "'" : obj;
1738
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
1739
- } else shouldThrow = false;
1740
- if (shouldThrow) throw new AssertionError(errorMessage, void 0, ssfi);
1741
- if (doLength) {
1742
- var descriptor = "length", itemsCount;
1743
- if (objType === "map" || objType === "set") {
1744
- descriptor = "size";
1745
- itemsCount = obj.size;
1746
- } else itemsCount = obj.length;
1747
- this.assert(itemsCount >= start && itemsCount <= finish, "expected #{this} to have a " + descriptor + " within " + range, "expected #{this} to not have a " + descriptor + " within " + range);
1748
- } else this.assert(obj >= start && obj <= finish, "expected #{this} to be within " + range, "expected #{this} to not be within " + range);
1749
- });
1750
- function assertInstanceOf(constructor, msg) {
1751
- if (msg) flag2(this, "message", msg);
1752
- var target = flag2(this, "object");
1753
- var ssfi = flag2(this, "ssfi");
1754
- var flagMsg = flag2(this, "message");
1755
- try {
1756
- var isInstanceOf = target instanceof constructor;
1757
- } catch (err) {
1758
- if (err instanceof TypeError) {
1759
- flagMsg = flagMsg ? flagMsg + ": " : "";
1760
- throw new AssertionError(flagMsg + "The instanceof assertion needs a constructor but " + type(constructor) + " was given.", void 0, ssfi);
1761
- }
1762
- throw err;
1763
- }
1764
- var name = getName(constructor);
1765
- if (name == null) name = "an unnamed constructor";
1766
- this.assert(isInstanceOf, "expected #{this} to be an instance of " + name, "expected #{this} to not be an instance of " + name);
1767
- }
1768
- __name(assertInstanceOf, "assertInstanceOf");
1769
- Assertion.addMethod("instanceof", assertInstanceOf);
1770
- Assertion.addMethod("instanceOf", assertInstanceOf);
1771
- function assertProperty(name, val, msg) {
1772
- if (msg) flag2(this, "message", msg);
1773
- var isNested = flag2(this, "nested"), isOwn = flag2(this, "own"), flagMsg = flag2(this, "message"), obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), nameType = typeof name;
1774
- flagMsg = flagMsg ? flagMsg + ": " : "";
1775
- if (isNested) {
1776
- if (nameType !== "string") throw new AssertionError(flagMsg + "the argument to property must be a string when using nested syntax", void 0, ssfi);
1777
- } else if (nameType !== "string" && nameType !== "number" && nameType !== "symbol") throw new AssertionError(flagMsg + "the argument to property must be a string, number, or symbol", void 0, ssfi);
1778
- if (isNested && isOwn) throw new AssertionError(flagMsg + "The \"nested\" and \"own\" flags cannot be combined.", void 0, ssfi);
1779
- if (obj === null || obj === void 0) throw new AssertionError(flagMsg + "Target cannot be null or undefined.", void 0, ssfi);
1780
- var isDeep = flag2(this, "deep"), negate = flag2(this, "negate"), pathInfo = isNested ? getPathInfo(obj, name) : null, value = isNested ? pathInfo.value : obj[name], isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
1781
- var descriptor = "";
1782
- if (isDeep) descriptor += "deep ";
1783
- if (isOwn) descriptor += "own ";
1784
- if (isNested) descriptor += "nested ";
1785
- descriptor += "property ";
1786
- var hasProperty2;
1787
- if (isOwn) hasProperty2 = Object.prototype.hasOwnProperty.call(obj, name);
1788
- else if (isNested) hasProperty2 = pathInfo.exists;
1789
- else hasProperty2 = hasProperty(obj, name);
1790
- if (!negate || arguments.length === 1) this.assert(hasProperty2, "expected #{this} to have " + descriptor + inspect2(name), "expected #{this} to not have " + descriptor + inspect2(name));
1791
- if (arguments.length > 1) this.assert(hasProperty2 && isEql(val, value), "expected #{this} to have " + descriptor + inspect2(name) + " of #{exp}, but got #{act}", "expected #{this} to not have " + descriptor + inspect2(name) + " of #{act}", val, value);
1792
- flag2(this, "object", value);
1793
- }
1794
- __name(assertProperty, "assertProperty");
1795
- Assertion.addMethod("property", assertProperty);
1796
- function assertOwnProperty(_name, _value, _msg) {
1797
- flag2(this, "own", true);
1798
- assertProperty.apply(this, arguments);
1799
- }
1800
- __name(assertOwnProperty, "assertOwnProperty");
1801
- Assertion.addMethod("ownProperty", assertOwnProperty);
1802
- Assertion.addMethod("haveOwnProperty", assertOwnProperty);
1803
- function assertOwnPropertyDescriptor(name, descriptor, msg) {
1804
- if (typeof descriptor === "string") {
1805
- msg = descriptor;
1806
- descriptor = null;
1807
- }
1808
- if (msg) flag2(this, "message", msg);
1809
- var obj = flag2(this, "object");
1810
- var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
1811
- var eql = flag2(this, "eql");
1812
- if (actualDescriptor && descriptor) this.assert(eql(descriptor, actualDescriptor), "expected the own property descriptor for " + inspect2(name) + " on #{this} to match " + inspect2(descriptor) + ", got " + inspect2(actualDescriptor), "expected the own property descriptor for " + inspect2(name) + " on #{this} to not match " + inspect2(descriptor), descriptor, actualDescriptor, true);
1813
- else this.assert(actualDescriptor, "expected #{this} to have an own property descriptor for " + inspect2(name), "expected #{this} to not have an own property descriptor for " + inspect2(name));
1814
- flag2(this, "object", actualDescriptor);
1815
- }
1816
- __name(assertOwnPropertyDescriptor, "assertOwnPropertyDescriptor");
1817
- Assertion.addMethod("ownPropertyDescriptor", assertOwnPropertyDescriptor);
1818
- Assertion.addMethod("haveOwnPropertyDescriptor", assertOwnPropertyDescriptor);
1819
- function assertLengthChain() {
1820
- flag2(this, "doLength", true);
1821
- }
1822
- __name(assertLengthChain, "assertLengthChain");
1823
- function assertLength(n, msg) {
1824
- if (msg) flag2(this, "message", msg);
1825
- var obj = flag2(this, "object"), objType = type(obj).toLowerCase(), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), descriptor = "length", itemsCount;
1826
- switch (objType) {
1827
- case "map":
1828
- case "set":
1829
- descriptor = "size";
1830
- itemsCount = obj.size;
1831
- break;
1832
- default:
1833
- new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
1834
- itemsCount = obj.length;
1835
- }
1836
- this.assert(itemsCount == n, "expected #{this} to have a " + descriptor + " of #{exp} but got #{act}", "expected #{this} to not have a " + descriptor + " of #{act}", n, itemsCount);
1837
- }
1838
- __name(assertLength, "assertLength");
1839
- Assertion.addChainableMethod("length", assertLength, assertLengthChain);
1840
- Assertion.addChainableMethod("lengthOf", assertLength, assertLengthChain);
1841
- function assertMatch(re, msg) {
1842
- if (msg) flag2(this, "message", msg);
1843
- var obj = flag2(this, "object");
1844
- this.assert(re.exec(obj), "expected #{this} to match " + re, "expected #{this} not to match " + re);
1845
- }
1846
- __name(assertMatch, "assertMatch");
1847
- Assertion.addMethod("match", assertMatch);
1848
- Assertion.addMethod("matches", assertMatch);
1849
- Assertion.addMethod("string", function(str, msg) {
1850
- if (msg) flag2(this, "message", msg);
1851
- var obj = flag2(this, "object");
1852
- new Assertion(obj, flag2(this, "message"), flag2(this, "ssfi"), true).is.a("string");
1853
- this.assert(~obj.indexOf(str), "expected #{this} to contain " + inspect2(str), "expected #{this} to not contain " + inspect2(str));
1854
- });
1855
- function assertKeys(keys) {
1856
- var obj = flag2(this, "object"), objType = type(obj), keysType = type(keys), ssfi = flag2(this, "ssfi"), isDeep = flag2(this, "deep"), str, deepStr = "", actual, ok = true, flagMsg = flag2(this, "message");
1857
- flagMsg = flagMsg ? flagMsg + ": " : "";
1858
- var mixedArgsMsg = flagMsg + "when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments";
1859
- if (objType === "Map" || objType === "Set") {
1860
- deepStr = isDeep ? "deeply " : "";
1861
- actual = [];
1862
- obj.forEach(function(val, key) {
1863
- actual.push(key);
1864
- });
1865
- if (keysType !== "Array") keys = Array.prototype.slice.call(arguments);
1866
- } else {
1867
- actual = getOwnEnumerableProperties(obj);
1868
- switch (keysType) {
1869
- case "Array":
1870
- if (arguments.length > 1) throw new AssertionError(mixedArgsMsg, void 0, ssfi);
1871
- break;
1872
- case "Object":
1873
- if (arguments.length > 1) throw new AssertionError(mixedArgsMsg, void 0, ssfi);
1874
- keys = Object.keys(keys);
1875
- break;
1876
- default: keys = Array.prototype.slice.call(arguments);
1877
- }
1878
- keys = keys.map(function(val) {
1879
- return typeof val === "symbol" ? val : String(val);
1880
- });
1881
- }
1882
- if (!keys.length) throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
1883
- var len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
1884
- if (!any && !all) all = true;
1885
- if (any) ok = expected.some(function(expectedKey) {
1886
- return actual.some(function(actualKey) {
1887
- return isEql(expectedKey, actualKey);
1888
- });
1889
- });
1890
- if (all) {
1891
- ok = expected.every(function(expectedKey) {
1892
- return actual.some(function(actualKey) {
1893
- return isEql(expectedKey, actualKey);
1894
- });
1895
- });
1896
- if (!flag2(this, "contains")) ok = ok && keys.length == actual.length;
1897
- }
1898
- if (len > 1) {
1899
- keys = keys.map(function(key) {
1900
- return inspect2(key);
1901
- });
1902
- var last = keys.pop();
1903
- if (all) str = keys.join(", ") + ", and " + last;
1904
- if (any) str = keys.join(", ") + ", or " + last;
1905
- } else str = inspect2(keys[0]);
1906
- str = (len > 1 ? "keys " : "key ") + str;
1907
- str = (flag2(this, "contains") ? "contain " : "have ") + str;
1908
- this.assert(ok, "expected #{this} to " + deepStr + str, "expected #{this} to not " + deepStr + str, expected.slice(0).sort(compareByInspect), actual.sort(compareByInspect), true);
1909
- }
1910
- __name(assertKeys, "assertKeys");
1911
- Assertion.addMethod("keys", assertKeys);
1912
- Assertion.addMethod("key", assertKeys);
1913
- function assertThrows(errorLike, errMsgMatcher, msg) {
1914
- if (msg) flag2(this, "message", msg);
1915
- var obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
1916
- new Assertion(obj, flagMsg, ssfi, true).is.a("function");
1917
- if (isRegExp2(errorLike) || typeof errorLike === "string") {
1918
- errMsgMatcher = errorLike;
1919
- errorLike = null;
1920
- }
1921
- let caughtErr;
1922
- let errorWasThrown = false;
1923
- try {
1924
- obj();
1925
- } catch (err) {
1926
- errorWasThrown = true;
1927
- caughtErr = err;
1928
- }
1929
- var everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
1930
- var everyArgIsDefined = Boolean(errorLike && errMsgMatcher);
1931
- var errorLikeFail = false;
1932
- var errMsgMatcherFail = false;
1933
- if (everyArgIsUndefined || !everyArgIsUndefined && !negate) {
1934
- var errorLikeString = "an error";
1935
- if (errorLike instanceof Error) errorLikeString = "#{exp}";
1936
- else if (errorLike) errorLikeString = check_error_exports.getConstructorName(errorLike);
1937
- let actual = caughtErr;
1938
- if (caughtErr instanceof Error) actual = caughtErr.toString();
1939
- else if (typeof caughtErr === "string") actual = caughtErr;
1940
- else if (caughtErr && (typeof caughtErr === "object" || typeof caughtErr === "function")) try {
1941
- actual = check_error_exports.getConstructorName(caughtErr);
1942
- } catch (_err) {}
1943
- this.assert(errorWasThrown, "expected #{this} to throw " + errorLikeString, "expected #{this} to not throw an error but #{act} was thrown", errorLike && errorLike.toString(), actual);
1944
- }
1945
- if (errorLike && caughtErr) {
1946
- if (errorLike instanceof Error) {
1947
- if (check_error_exports.compatibleInstance(caughtErr, errorLike) === negate) if (everyArgIsDefined && negate) errorLikeFail = true;
1948
- else this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr && !negate ? " but #{act} was thrown" : ""), errorLike.toString(), caughtErr.toString());
1949
- }
1950
- if (check_error_exports.compatibleConstructor(caughtErr, errorLike) === negate) if (everyArgIsDefined && negate) errorLikeFail = true;
1951
- else this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""), errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike), caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr));
1952
- }
1953
- if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
1954
- var placeholder = "including";
1955
- if (isRegExp2(errMsgMatcher)) placeholder = "matching";
1956
- if (check_error_exports.compatibleMessage(caughtErr, errMsgMatcher) === negate) if (everyArgIsDefined && negate) errMsgMatcherFail = true;
1957
- else this.assert(negate, "expected #{this} to throw error " + placeholder + " #{exp} but got #{act}", "expected #{this} to throw error not " + placeholder + " #{exp}", errMsgMatcher, check_error_exports.getMessage(caughtErr));
1958
- }
1959
- if (errorLikeFail && errMsgMatcherFail) this.assert(negate, "expected #{this} to throw #{exp} but #{act} was thrown", "expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""), errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike), caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr));
1960
- flag2(this, "object", caughtErr);
1961
- }
1962
- __name(assertThrows, "assertThrows");
1963
- Assertion.addMethod("throw", assertThrows);
1964
- Assertion.addMethod("throws", assertThrows);
1965
- Assertion.addMethod("Throw", assertThrows);
1966
- function respondTo(method, msg) {
1967
- if (msg) flag2(this, "message", msg);
1968
- var obj = flag2(this, "object"), itself = flag2(this, "itself"), context = "function" === typeof obj && !itself ? obj.prototype[method] : obj[method];
1969
- this.assert("function" === typeof context, "expected #{this} to respond to " + inspect2(method), "expected #{this} to not respond to " + inspect2(method));
1970
- }
1971
- __name(respondTo, "respondTo");
1972
- Assertion.addMethod("respondTo", respondTo);
1973
- Assertion.addMethod("respondsTo", respondTo);
1974
- Assertion.addProperty("itself", function() {
1975
- flag2(this, "itself", true);
1976
- });
1977
- function satisfy(matcher, msg) {
1978
- if (msg) flag2(this, "message", msg);
1979
- var result = matcher(flag2(this, "object"));
1980
- this.assert(result, "expected #{this} to satisfy " + objDisplay(matcher), "expected #{this} to not satisfy" + objDisplay(matcher), flag2(this, "negate") ? false : true, result);
1981
- }
1982
- __name(satisfy, "satisfy");
1983
- Assertion.addMethod("satisfy", satisfy);
1984
- Assertion.addMethod("satisfies", satisfy);
1985
- function closeTo(expected, delta, msg) {
1986
- if (msg) flag2(this, "message", msg);
1987
- var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
1988
- new Assertion(obj, flagMsg, ssfi, true).is.numeric;
1989
- let message = "A `delta` value is required for `closeTo`";
1990
- if (delta == void 0) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
1991
- new Assertion(delta, flagMsg, ssfi, true).is.numeric;
1992
- message = "A `expected` value is required for `closeTo`";
1993
- if (expected == void 0) throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
1994
- new Assertion(expected, flagMsg, ssfi, true).is.numeric;
1995
- const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
1996
- const strip = /* @__PURE__ */ __name((number) => parseFloat(parseFloat(number).toPrecision(12)), "strip");
1997
- this.assert(strip(abs(obj - expected)) <= delta, "expected #{this} to be close to " + expected + " +/- " + delta, "expected #{this} not to be close to " + expected + " +/- " + delta);
1998
- }
1999
- __name(closeTo, "closeTo");
2000
- Assertion.addMethod("closeTo", closeTo);
2001
- Assertion.addMethod("approximately", closeTo);
2002
- function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
2003
- let superset = Array.from(_superset);
2004
- let subset = Array.from(_subset);
2005
- if (!contains) {
2006
- if (subset.length !== superset.length) return false;
2007
- superset = superset.slice();
2008
- }
2009
- return subset.every(function(elem, idx) {
2010
- if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx];
2011
- if (!cmp) {
2012
- var matchIdx = superset.indexOf(elem);
2013
- if (matchIdx === -1) return false;
2014
- if (!contains) superset.splice(matchIdx, 1);
2015
- return true;
2016
- }
2017
- return superset.some(function(elem2, matchIdx2) {
2018
- if (!cmp(elem, elem2)) return false;
2019
- if (!contains) superset.splice(matchIdx2, 1);
2020
- return true;
2021
- });
2022
- });
2023
- }
2024
- __name(isSubsetOf, "isSubsetOf");
2025
- Assertion.addMethod("members", function(subset, msg) {
2026
- if (msg) flag2(this, "message", msg);
2027
- var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2028
- new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
2029
- new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
2030
- var contains = flag2(this, "contains");
2031
- var ordered = flag2(this, "ordered");
2032
- var subject, failMsg, failNegateMsg;
2033
- if (contains) {
2034
- subject = ordered ? "an ordered superset" : "a superset";
2035
- failMsg = "expected #{this} to be " + subject + " of #{exp}";
2036
- failNegateMsg = "expected #{this} to not be " + subject + " of #{exp}";
2037
- } else {
2038
- subject = ordered ? "ordered members" : "members";
2039
- failMsg = "expected #{this} to have the same " + subject + " as #{exp}";
2040
- failNegateMsg = "expected #{this} to not have the same " + subject + " as #{exp}";
2041
- }
2042
- var cmp = flag2(this, "deep") ? flag2(this, "eql") : void 0;
2043
- this.assert(isSubsetOf(subset, obj, cmp, contains, ordered), failMsg, failNegateMsg, subset, obj, true);
2044
- });
2045
- Assertion.addProperty("iterable", function(msg) {
2046
- if (msg) flag2(this, "message", msg);
2047
- var obj = flag2(this, "object");
2048
- this.assert(obj != void 0 && obj[Symbol.iterator], "expected #{this} to be an iterable", "expected #{this} to not be an iterable", obj);
2049
- });
2050
- function oneOf(list, msg) {
2051
- if (msg) flag2(this, "message", msg);
2052
- var expected = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), contains = flag2(this, "contains"), isDeep = flag2(this, "deep"), eql = flag2(this, "eql");
2053
- new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
2054
- if (contains) this.assert(list.some(function(possibility) {
2055
- return expected.indexOf(possibility) > -1;
2056
- }), "expected #{this} to contain one of #{exp}", "expected #{this} to not contain one of #{exp}", list, expected);
2057
- else if (isDeep) this.assert(list.some(function(possibility) {
2058
- return eql(expected, possibility);
2059
- }), "expected #{this} to deeply equal one of #{exp}", "expected #{this} to deeply equal one of #{exp}", list, expected);
2060
- else this.assert(list.indexOf(expected) > -1, "expected #{this} to be one of #{exp}", "expected #{this} to not be one of #{exp}", list, expected);
2061
- }
2062
- __name(oneOf, "oneOf");
2063
- Assertion.addMethod("oneOf", oneOf);
2064
- function assertChanges(subject, prop, msg) {
2065
- if (msg) flag2(this, "message", msg);
2066
- var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2067
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
2068
- var initial;
2069
- if (!prop) {
2070
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
2071
- initial = subject();
2072
- } else {
2073
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
2074
- initial = subject[prop];
2075
- }
2076
- fn();
2077
- var final = prop === void 0 || prop === null ? subject() : subject[prop];
2078
- var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
2079
- flag2(this, "deltaMsgObj", msgObj);
2080
- flag2(this, "initialDeltaValue", initial);
2081
- flag2(this, "finalDeltaValue", final);
2082
- flag2(this, "deltaBehavior", "change");
2083
- flag2(this, "realDelta", final !== initial);
2084
- this.assert(initial !== final, "expected " + msgObj + " to change", "expected " + msgObj + " to not change");
2085
- }
2086
- __name(assertChanges, "assertChanges");
2087
- Assertion.addMethod("change", assertChanges);
2088
- Assertion.addMethod("changes", assertChanges);
2089
- function assertIncreases(subject, prop, msg) {
2090
- if (msg) flag2(this, "message", msg);
2091
- var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2092
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
2093
- var initial;
2094
- if (!prop) {
2095
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
2096
- initial = subject();
2097
- } else {
2098
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
2099
- initial = subject[prop];
2100
- }
2101
- new Assertion(initial, flagMsg, ssfi, true).is.a("number");
2102
- fn();
2103
- var final = prop === void 0 || prop === null ? subject() : subject[prop];
2104
- var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
2105
- flag2(this, "deltaMsgObj", msgObj);
2106
- flag2(this, "initialDeltaValue", initial);
2107
- flag2(this, "finalDeltaValue", final);
2108
- flag2(this, "deltaBehavior", "increase");
2109
- flag2(this, "realDelta", final - initial);
2110
- this.assert(final - initial > 0, "expected " + msgObj + " to increase", "expected " + msgObj + " to not increase");
2111
- }
2112
- __name(assertIncreases, "assertIncreases");
2113
- Assertion.addMethod("increase", assertIncreases);
2114
- Assertion.addMethod("increases", assertIncreases);
2115
- function assertDecreases(subject, prop, msg) {
2116
- if (msg) flag2(this, "message", msg);
2117
- var fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2118
- new Assertion(fn, flagMsg, ssfi, true).is.a("function");
2119
- var initial;
2120
- if (!prop) {
2121
- new Assertion(subject, flagMsg, ssfi, true).is.a("function");
2122
- initial = subject();
2123
- } else {
2124
- new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop);
2125
- initial = subject[prop];
2126
- }
2127
- new Assertion(initial, flagMsg, ssfi, true).is.a("number");
2128
- fn();
2129
- var final = prop === void 0 || prop === null ? subject() : subject[prop];
2130
- var msgObj = prop === void 0 || prop === null ? initial : "." + prop;
2131
- flag2(this, "deltaMsgObj", msgObj);
2132
- flag2(this, "initialDeltaValue", initial);
2133
- flag2(this, "finalDeltaValue", final);
2134
- flag2(this, "deltaBehavior", "decrease");
2135
- flag2(this, "realDelta", initial - final);
2136
- this.assert(final - initial < 0, "expected " + msgObj + " to decrease", "expected " + msgObj + " to not decrease");
2137
- }
2138
- __name(assertDecreases, "assertDecreases");
2139
- Assertion.addMethod("decrease", assertDecreases);
2140
- Assertion.addMethod("decreases", assertDecreases);
2141
- function assertDelta(delta, msg) {
2142
- if (msg) flag2(this, "message", msg);
2143
- var msgObj = flag2(this, "deltaMsgObj");
2144
- var initial = flag2(this, "initialDeltaValue");
2145
- var final = flag2(this, "finalDeltaValue");
2146
- var behavior = flag2(this, "deltaBehavior");
2147
- var realDelta = flag2(this, "realDelta");
2148
- var expression;
2149
- if (behavior === "change") expression = Math.abs(final - initial) === Math.abs(delta);
2150
- else expression = realDelta === Math.abs(delta);
2151
- this.assert(expression, "expected " + msgObj + " to " + behavior + " by " + delta, "expected " + msgObj + " to not " + behavior + " by " + delta);
2152
- }
2153
- __name(assertDelta, "assertDelta");
2154
- Assertion.addMethod("by", assertDelta);
2155
- Assertion.addProperty("extensible", function() {
2156
- var obj = flag2(this, "object");
2157
- var isExtensible = obj === Object(obj) && Object.isExtensible(obj);
2158
- this.assert(isExtensible, "expected #{this} to be extensible", "expected #{this} to not be extensible");
2159
- });
2160
- Assertion.addProperty("sealed", function() {
2161
- var obj = flag2(this, "object");
2162
- var isSealed = obj === Object(obj) ? Object.isSealed(obj) : true;
2163
- this.assert(isSealed, "expected #{this} to be sealed", "expected #{this} to not be sealed");
2164
- });
2165
- Assertion.addProperty("frozen", function() {
2166
- var obj = flag2(this, "object");
2167
- var isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true;
2168
- this.assert(isFrozen, "expected #{this} to be frozen", "expected #{this} to not be frozen");
2169
- });
2170
- Assertion.addProperty("finite", function(_msg) {
2171
- var obj = flag2(this, "object");
2172
- this.assert(typeof obj === "number" && isFinite(obj), "expected #{this} to be a finite number", "expected #{this} to not be a finite number");
2173
- });
2174
- function compareSubset(expected, actual) {
2175
- if (expected === actual) return true;
2176
- if (typeof actual !== typeof expected) return false;
2177
- if (typeof expected !== "object" || expected === null) return expected === actual;
2178
- if (!actual) return false;
2179
- if (Array.isArray(expected)) {
2180
- if (!Array.isArray(actual)) return false;
2181
- return expected.every(function(exp) {
2182
- return actual.some(function(act) {
2183
- return compareSubset(exp, act);
2184
- });
2185
- });
2186
- }
2187
- if (expected instanceof Date) if (actual instanceof Date) return expected.getTime() === actual.getTime();
2188
- else return false;
2189
- return Object.keys(expected).every(function(key) {
2190
- var expectedValue = expected[key];
2191
- var actualValue = actual[key];
2192
- if (typeof expectedValue === "object" && expectedValue !== null && actualValue !== null) return compareSubset(expectedValue, actualValue);
2193
- if (typeof expectedValue === "function") return expectedValue(actualValue);
2194
- return actualValue === expectedValue;
2195
- });
2196
- }
2197
- __name(compareSubset, "compareSubset");
2198
- Assertion.addMethod("containSubset", function(expected) {
2199
- const actual = flag(this, "object");
2200
- const showDiff = config.showDiff;
2201
- this.assert(compareSubset(expected, actual), "expected #{act} to contain subset #{exp}", "expected #{act} to not contain subset #{exp}", expected, actual, showDiff);
2202
- });
2203
- function expect(val, message) {
2204
- return new Assertion(val, message);
2205
- }
2206
- __name(expect, "expect");
2207
- expect.fail = function(actual, expected, message, operator) {
2208
- if (arguments.length < 2) {
2209
- message = actual;
2210
- actual = void 0;
2211
- }
2212
- message = message || "expect.fail()";
2213
- throw new AssertionError(message, {
2214
- actual,
2215
- expected,
2216
- operator
2217
- }, expect.fail);
2218
- };
2219
- var should_exports = {};
2220
- __export(should_exports, {
2221
- Should: () => Should,
2222
- should: () => should
2223
- });
2224
- function loadShould() {
2225
- function shouldGetter() {
2226
- if (this instanceof String || this instanceof Number || this instanceof Boolean || typeof Symbol === "function" && this instanceof Symbol || typeof BigInt === "function" && this instanceof BigInt) return new Assertion(this.valueOf(), null, shouldGetter);
2227
- return new Assertion(this, null, shouldGetter);
2228
- }
2229
- __name(shouldGetter, "shouldGetter");
2230
- function shouldSetter(value) {
2231
- Object.defineProperty(this, "should", {
2232
- value,
2233
- enumerable: true,
2234
- configurable: true,
2235
- writable: true
2236
- });
2237
- }
2238
- __name(shouldSetter, "shouldSetter");
2239
- Object.defineProperty(Object.prototype, "should", {
2240
- set: shouldSetter,
2241
- get: shouldGetter,
2242
- configurable: true
2243
- });
2244
- var should2 = {};
2245
- should2.fail = function(actual, expected, message, operator) {
2246
- if (arguments.length < 2) {
2247
- message = actual;
2248
- actual = void 0;
2249
- }
2250
- message = message || "should.fail()";
2251
- throw new AssertionError(message, {
2252
- actual,
2253
- expected,
2254
- operator
2255
- }, should2.fail);
2256
- };
2257
- should2.equal = function(actual, expected, message) {
2258
- new Assertion(actual, message).to.equal(expected);
2259
- };
2260
- should2.Throw = function(fn, errt, errs, msg) {
2261
- new Assertion(fn, msg).to.Throw(errt, errs);
2262
- };
2263
- should2.exist = function(val, msg) {
2264
- new Assertion(val, msg).to.exist;
2265
- };
2266
- should2.not = {};
2267
- should2.not.equal = function(actual, expected, msg) {
2268
- new Assertion(actual, msg).to.not.equal(expected);
2269
- };
2270
- should2.not.Throw = function(fn, errt, errs, msg) {
2271
- new Assertion(fn, msg).to.not.Throw(errt, errs);
2272
- };
2273
- should2.not.exist = function(val, msg) {
2274
- new Assertion(val, msg).to.not.exist;
2275
- };
2276
- should2["throw"] = should2["Throw"];
2277
- should2.not["throw"] = should2.not["Throw"];
2278
- return should2;
2279
- }
2280
- __name(loadShould, "loadShould");
2281
- var should = loadShould;
2282
- var Should = loadShould;
2283
- function assert(express, errmsg) {
2284
- new Assertion(null, null, assert, true).assert(express, errmsg, "[ negation message unavailable ]");
2285
- }
2286
- __name(assert, "assert");
2287
- assert.fail = function(actual, expected, message, operator) {
2288
- if (arguments.length < 2) {
2289
- message = actual;
2290
- actual = void 0;
2291
- }
2292
- message = message || "assert.fail()";
2293
- throw new AssertionError(message, {
2294
- actual,
2295
- expected,
2296
- operator
2297
- }, assert.fail);
2298
- };
2299
- assert.isOk = function(val, msg) {
2300
- new Assertion(val, msg, assert.isOk, true).is.ok;
2301
- };
2302
- assert.isNotOk = function(val, msg) {
2303
- new Assertion(val, msg, assert.isNotOk, true).is.not.ok;
2304
- };
2305
- assert.equal = function(act, exp, msg) {
2306
- var test2 = new Assertion(act, msg, assert.equal, true);
2307
- test2.assert(exp == flag(test2, "object"), "expected #{this} to equal #{exp}", "expected #{this} to not equal #{act}", exp, act, true);
2308
- };
2309
- assert.notEqual = function(act, exp, msg) {
2310
- var test2 = new Assertion(act, msg, assert.notEqual, true);
2311
- test2.assert(exp != flag(test2, "object"), "expected #{this} to not equal #{exp}", "expected #{this} to equal #{act}", exp, act, true);
2312
- };
2313
- assert.strictEqual = function(act, exp, msg) {
2314
- new Assertion(act, msg, assert.strictEqual, true).to.equal(exp);
2315
- };
2316
- assert.notStrictEqual = function(act, exp, msg) {
2317
- new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp);
2318
- };
2319
- assert.deepEqual = assert.deepStrictEqual = function(act, exp, msg) {
2320
- new Assertion(act, msg, assert.deepEqual, true).to.eql(exp);
2321
- };
2322
- assert.notDeepEqual = function(act, exp, msg) {
2323
- new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp);
2324
- };
2325
- assert.isAbove = function(val, abv, msg) {
2326
- new Assertion(val, msg, assert.isAbove, true).to.be.above(abv);
2327
- };
2328
- assert.isAtLeast = function(val, atlst, msg) {
2329
- new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst);
2330
- };
2331
- assert.isBelow = function(val, blw, msg) {
2332
- new Assertion(val, msg, assert.isBelow, true).to.be.below(blw);
2333
- };
2334
- assert.isAtMost = function(val, atmst, msg) {
2335
- new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst);
2336
- };
2337
- assert.isTrue = function(val, msg) {
2338
- new Assertion(val, msg, assert.isTrue, true).is["true"];
2339
- };
2340
- assert.isNotTrue = function(val, msg) {
2341
- new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true);
2342
- };
2343
- assert.isFalse = function(val, msg) {
2344
- new Assertion(val, msg, assert.isFalse, true).is["false"];
2345
- };
2346
- assert.isNotFalse = function(val, msg) {
2347
- new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false);
2348
- };
2349
- assert.isNull = function(val, msg) {
2350
- new Assertion(val, msg, assert.isNull, true).to.equal(null);
2351
- };
2352
- assert.isNotNull = function(val, msg) {
2353
- new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null);
2354
- };
2355
- assert.isNaN = function(val, msg) {
2356
- new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
2357
- };
2358
- assert.isNotNaN = function(value, message) {
2359
- new Assertion(value, message, assert.isNotNaN, true).not.to.be.NaN;
2360
- };
2361
- assert.exists = function(val, msg) {
2362
- new Assertion(val, msg, assert.exists, true).to.exist;
2363
- };
2364
- assert.notExists = function(val, msg) {
2365
- new Assertion(val, msg, assert.notExists, true).to.not.exist;
2366
- };
2367
- assert.isUndefined = function(val, msg) {
2368
- new Assertion(val, msg, assert.isUndefined, true).to.equal(void 0);
2369
- };
2370
- assert.isDefined = function(val, msg) {
2371
- new Assertion(val, msg, assert.isDefined, true).to.not.equal(void 0);
2372
- };
2373
- assert.isCallable = function(value, message) {
2374
- new Assertion(value, message, assert.isCallable, true).is.callable;
2375
- };
2376
- assert.isNotCallable = function(value, message) {
2377
- new Assertion(value, message, assert.isNotCallable, true).is.not.callable;
2378
- };
2379
- assert.isObject = function(val, msg) {
2380
- new Assertion(val, msg, assert.isObject, true).to.be.a("object");
2381
- };
2382
- assert.isNotObject = function(val, msg) {
2383
- new Assertion(val, msg, assert.isNotObject, true).to.not.be.a("object");
2384
- };
2385
- assert.isArray = function(val, msg) {
2386
- new Assertion(val, msg, assert.isArray, true).to.be.an("array");
2387
- };
2388
- assert.isNotArray = function(val, msg) {
2389
- new Assertion(val, msg, assert.isNotArray, true).to.not.be.an("array");
2390
- };
2391
- assert.isString = function(val, msg) {
2392
- new Assertion(val, msg, assert.isString, true).to.be.a("string");
2393
- };
2394
- assert.isNotString = function(val, msg) {
2395
- new Assertion(val, msg, assert.isNotString, true).to.not.be.a("string");
2396
- };
2397
- assert.isNumber = function(val, msg) {
2398
- new Assertion(val, msg, assert.isNumber, true).to.be.a("number");
2399
- };
2400
- assert.isNotNumber = function(val, msg) {
2401
- new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a("number");
2402
- };
2403
- assert.isNumeric = function(val, msg) {
2404
- new Assertion(val, msg, assert.isNumeric, true).is.numeric;
2405
- };
2406
- assert.isNotNumeric = function(val, msg) {
2407
- new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
2408
- };
2409
- assert.isFinite = function(val, msg) {
2410
- new Assertion(val, msg, assert.isFinite, true).to.be.finite;
2411
- };
2412
- assert.isBoolean = function(val, msg) {
2413
- new Assertion(val, msg, assert.isBoolean, true).to.be.a("boolean");
2414
- };
2415
- assert.isNotBoolean = function(val, msg) {
2416
- new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a("boolean");
2417
- };
2418
- assert.typeOf = function(val, type3, msg) {
2419
- new Assertion(val, msg, assert.typeOf, true).to.be.a(type3);
2420
- };
2421
- assert.notTypeOf = function(value, type3, message) {
2422
- new Assertion(value, message, assert.notTypeOf, true).to.not.be.a(type3);
2423
- };
2424
- assert.instanceOf = function(val, type3, msg) {
2425
- new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
2426
- };
2427
- assert.notInstanceOf = function(val, type3, msg) {
2428
- new Assertion(val, msg, assert.notInstanceOf, true).to.not.be.instanceOf(type3);
2429
- };
2430
- assert.include = function(exp, inc, msg) {
2431
- new Assertion(exp, msg, assert.include, true).include(inc);
2432
- };
2433
- assert.notInclude = function(exp, inc, msg) {
2434
- new Assertion(exp, msg, assert.notInclude, true).not.include(inc);
2435
- };
2436
- assert.deepInclude = function(exp, inc, msg) {
2437
- new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc);
2438
- };
2439
- assert.notDeepInclude = function(exp, inc, msg) {
2440
- new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc);
2441
- };
2442
- assert.nestedInclude = function(exp, inc, msg) {
2443
- new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc);
2444
- };
2445
- assert.notNestedInclude = function(exp, inc, msg) {
2446
- new Assertion(exp, msg, assert.notNestedInclude, true).not.nested.include(inc);
2447
- };
2448
- assert.deepNestedInclude = function(exp, inc, msg) {
2449
- new Assertion(exp, msg, assert.deepNestedInclude, true).deep.nested.include(inc);
2450
- };
2451
- assert.notDeepNestedInclude = function(exp, inc, msg) {
2452
- new Assertion(exp, msg, assert.notDeepNestedInclude, true).not.deep.nested.include(inc);
2453
- };
2454
- assert.ownInclude = function(exp, inc, msg) {
2455
- new Assertion(exp, msg, assert.ownInclude, true).own.include(inc);
2456
- };
2457
- assert.notOwnInclude = function(exp, inc, msg) {
2458
- new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc);
2459
- };
2460
- assert.deepOwnInclude = function(exp, inc, msg) {
2461
- new Assertion(exp, msg, assert.deepOwnInclude, true).deep.own.include(inc);
2462
- };
2463
- assert.notDeepOwnInclude = function(exp, inc, msg) {
2464
- new Assertion(exp, msg, assert.notDeepOwnInclude, true).not.deep.own.include(inc);
2465
- };
2466
- assert.match = function(exp, re, msg) {
2467
- new Assertion(exp, msg, assert.match, true).to.match(re);
2468
- };
2469
- assert.notMatch = function(exp, re, msg) {
2470
- new Assertion(exp, msg, assert.notMatch, true).to.not.match(re);
2471
- };
2472
- assert.property = function(obj, prop, msg) {
2473
- new Assertion(obj, msg, assert.property, true).to.have.property(prop);
2474
- };
2475
- assert.notProperty = function(obj, prop, msg) {
2476
- new Assertion(obj, msg, assert.notProperty, true).to.not.have.property(prop);
2477
- };
2478
- assert.propertyVal = function(obj, prop, val, msg) {
2479
- new Assertion(obj, msg, assert.propertyVal, true).to.have.property(prop, val);
2480
- };
2481
- assert.notPropertyVal = function(obj, prop, val, msg) {
2482
- new Assertion(obj, msg, assert.notPropertyVal, true).to.not.have.property(prop, val);
2483
- };
2484
- assert.deepPropertyVal = function(obj, prop, val, msg) {
2485
- new Assertion(obj, msg, assert.deepPropertyVal, true).to.have.deep.property(prop, val);
2486
- };
2487
- assert.notDeepPropertyVal = function(obj, prop, val, msg) {
2488
- new Assertion(obj, msg, assert.notDeepPropertyVal, true).to.not.have.deep.property(prop, val);
2489
- };
2490
- assert.ownProperty = function(obj, prop, msg) {
2491
- new Assertion(obj, msg, assert.ownProperty, true).to.have.own.property(prop);
2492
- };
2493
- assert.notOwnProperty = function(obj, prop, msg) {
2494
- new Assertion(obj, msg, assert.notOwnProperty, true).to.not.have.own.property(prop);
2495
- };
2496
- assert.ownPropertyVal = function(obj, prop, value, msg) {
2497
- new Assertion(obj, msg, assert.ownPropertyVal, true).to.have.own.property(prop, value);
2498
- };
2499
- assert.notOwnPropertyVal = function(obj, prop, value, msg) {
2500
- new Assertion(obj, msg, assert.notOwnPropertyVal, true).to.not.have.own.property(prop, value);
2501
- };
2502
- assert.deepOwnPropertyVal = function(obj, prop, value, msg) {
2503
- new Assertion(obj, msg, assert.deepOwnPropertyVal, true).to.have.deep.own.property(prop, value);
2504
- };
2505
- assert.notDeepOwnPropertyVal = function(obj, prop, value, msg) {
2506
- new Assertion(obj, msg, assert.notDeepOwnPropertyVal, true).to.not.have.deep.own.property(prop, value);
2507
- };
2508
- assert.nestedProperty = function(obj, prop, msg) {
2509
- new Assertion(obj, msg, assert.nestedProperty, true).to.have.nested.property(prop);
2510
- };
2511
- assert.notNestedProperty = function(obj, prop, msg) {
2512
- new Assertion(obj, msg, assert.notNestedProperty, true).to.not.have.nested.property(prop);
2513
- };
2514
- assert.nestedPropertyVal = function(obj, prop, val, msg) {
2515
- new Assertion(obj, msg, assert.nestedPropertyVal, true).to.have.nested.property(prop, val);
2516
- };
2517
- assert.notNestedPropertyVal = function(obj, prop, val, msg) {
2518
- new Assertion(obj, msg, assert.notNestedPropertyVal, true).to.not.have.nested.property(prop, val);
2519
- };
2520
- assert.deepNestedPropertyVal = function(obj, prop, val, msg) {
2521
- new Assertion(obj, msg, assert.deepNestedPropertyVal, true).to.have.deep.nested.property(prop, val);
2522
- };
2523
- assert.notDeepNestedPropertyVal = function(obj, prop, val, msg) {
2524
- new Assertion(obj, msg, assert.notDeepNestedPropertyVal, true).to.not.have.deep.nested.property(prop, val);
2525
- };
2526
- assert.lengthOf = function(exp, len, msg) {
2527
- new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len);
2528
- };
2529
- assert.hasAnyKeys = function(obj, keys, msg) {
2530
- new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys);
2531
- };
2532
- assert.hasAllKeys = function(obj, keys, msg) {
2533
- new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys);
2534
- };
2535
- assert.containsAllKeys = function(obj, keys, msg) {
2536
- new Assertion(obj, msg, assert.containsAllKeys, true).to.contain.all.keys(keys);
2537
- };
2538
- assert.doesNotHaveAnyKeys = function(obj, keys, msg) {
2539
- new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true).to.not.have.any.keys(keys);
2540
- };
2541
- assert.doesNotHaveAllKeys = function(obj, keys, msg) {
2542
- new Assertion(obj, msg, assert.doesNotHaveAllKeys, true).to.not.have.all.keys(keys);
2543
- };
2544
- assert.hasAnyDeepKeys = function(obj, keys, msg) {
2545
- new Assertion(obj, msg, assert.hasAnyDeepKeys, true).to.have.any.deep.keys(keys);
2546
- };
2547
- assert.hasAllDeepKeys = function(obj, keys, msg) {
2548
- new Assertion(obj, msg, assert.hasAllDeepKeys, true).to.have.all.deep.keys(keys);
2549
- };
2550
- assert.containsAllDeepKeys = function(obj, keys, msg) {
2551
- new Assertion(obj, msg, assert.containsAllDeepKeys, true).to.contain.all.deep.keys(keys);
2552
- };
2553
- assert.doesNotHaveAnyDeepKeys = function(obj, keys, msg) {
2554
- new Assertion(obj, msg, assert.doesNotHaveAnyDeepKeys, true).to.not.have.any.deep.keys(keys);
2555
- };
2556
- assert.doesNotHaveAllDeepKeys = function(obj, keys, msg) {
2557
- new Assertion(obj, msg, assert.doesNotHaveAllDeepKeys, true).to.not.have.all.deep.keys(keys);
2558
- };
2559
- assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
2560
- if ("string" === typeof errorLike || errorLike instanceof RegExp) {
2561
- errMsgMatcher = errorLike;
2562
- errorLike = null;
2563
- }
2564
- return flag(new Assertion(fn, msg, assert.throws, true).to.throw(errorLike, errMsgMatcher), "object");
2565
- };
2566
- assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
2567
- if ("string" === typeof errorLike || errorLike instanceof RegExp) {
2568
- errMsgMatcher = errorLike;
2569
- errorLike = null;
2570
- }
2571
- new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
2572
- };
2573
- assert.operator = function(val, operator, val2, msg) {
2574
- var ok;
2575
- switch (operator) {
2576
- case "==":
2577
- ok = val == val2;
2578
- break;
2579
- case "===":
2580
- ok = val === val2;
2581
- break;
2582
- case ">":
2583
- ok = val > val2;
2584
- break;
2585
- case ">=":
2586
- ok = val >= val2;
2587
- break;
2588
- case "<":
2589
- ok = val < val2;
2590
- break;
2591
- case "<=":
2592
- ok = val <= val2;
2593
- break;
2594
- case "!=":
2595
- ok = val != val2;
2596
- break;
2597
- case "!==":
2598
- ok = val !== val2;
2599
- break;
2600
- default:
2601
- msg = msg ? msg + ": " : msg;
2602
- throw new AssertionError(msg + "Invalid operator \"" + operator + "\"", void 0, assert.operator);
2603
- }
2604
- var test2 = new Assertion(ok, msg, assert.operator, true);
2605
- test2.assert(true === flag(test2, "object"), "expected " + inspect2(val) + " to be " + operator + " " + inspect2(val2), "expected " + inspect2(val) + " to not be " + operator + " " + inspect2(val2));
2606
- };
2607
- assert.closeTo = function(act, exp, delta, msg) {
2608
- new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta);
2609
- };
2610
- assert.approximately = function(act, exp, delta, msg) {
2611
- new Assertion(act, msg, assert.approximately, true).to.be.approximately(exp, delta);
2612
- };
2613
- assert.sameMembers = function(set1, set2, msg) {
2614
- new Assertion(set1, msg, assert.sameMembers, true).to.have.same.members(set2);
2615
- };
2616
- assert.notSameMembers = function(set1, set2, msg) {
2617
- new Assertion(set1, msg, assert.notSameMembers, true).to.not.have.same.members(set2);
2618
- };
2619
- assert.sameDeepMembers = function(set1, set2, msg) {
2620
- new Assertion(set1, msg, assert.sameDeepMembers, true).to.have.same.deep.members(set2);
2621
- };
2622
- assert.notSameDeepMembers = function(set1, set2, msg) {
2623
- new Assertion(set1, msg, assert.notSameDeepMembers, true).to.not.have.same.deep.members(set2);
2624
- };
2625
- assert.sameOrderedMembers = function(set1, set2, msg) {
2626
- new Assertion(set1, msg, assert.sameOrderedMembers, true).to.have.same.ordered.members(set2);
2627
- };
2628
- assert.notSameOrderedMembers = function(set1, set2, msg) {
2629
- new Assertion(set1, msg, assert.notSameOrderedMembers, true).to.not.have.same.ordered.members(set2);
2630
- };
2631
- assert.sameDeepOrderedMembers = function(set1, set2, msg) {
2632
- new Assertion(set1, msg, assert.sameDeepOrderedMembers, true).to.have.same.deep.ordered.members(set2);
2633
- };
2634
- assert.notSameDeepOrderedMembers = function(set1, set2, msg) {
2635
- new Assertion(set1, msg, assert.notSameDeepOrderedMembers, true).to.not.have.same.deep.ordered.members(set2);
2636
- };
2637
- assert.includeMembers = function(superset, subset, msg) {
2638
- new Assertion(superset, msg, assert.includeMembers, true).to.include.members(subset);
2639
- };
2640
- assert.notIncludeMembers = function(superset, subset, msg) {
2641
- new Assertion(superset, msg, assert.notIncludeMembers, true).to.not.include.members(subset);
2642
- };
2643
- assert.includeDeepMembers = function(superset, subset, msg) {
2644
- new Assertion(superset, msg, assert.includeDeepMembers, true).to.include.deep.members(subset);
2645
- };
2646
- assert.notIncludeDeepMembers = function(superset, subset, msg) {
2647
- new Assertion(superset, msg, assert.notIncludeDeepMembers, true).to.not.include.deep.members(subset);
2648
- };
2649
- assert.includeOrderedMembers = function(superset, subset, msg) {
2650
- new Assertion(superset, msg, assert.includeOrderedMembers, true).to.include.ordered.members(subset);
2651
- };
2652
- assert.notIncludeOrderedMembers = function(superset, subset, msg) {
2653
- new Assertion(superset, msg, assert.notIncludeOrderedMembers, true).to.not.include.ordered.members(subset);
2654
- };
2655
- assert.includeDeepOrderedMembers = function(superset, subset, msg) {
2656
- new Assertion(superset, msg, assert.includeDeepOrderedMembers, true).to.include.deep.ordered.members(subset);
2657
- };
2658
- assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
2659
- new Assertion(superset, msg, assert.notIncludeDeepOrderedMembers, true).to.not.include.deep.ordered.members(subset);
2660
- };
2661
- assert.oneOf = function(inList, list, msg) {
2662
- new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
2663
- };
2664
- assert.isIterable = function(obj, msg) {
2665
- if (obj == void 0 || !obj[Symbol.iterator]) {
2666
- msg = msg ? `${msg} expected ${inspect2(obj)} to be an iterable` : `expected ${inspect2(obj)} to be an iterable`;
2667
- throw new AssertionError(msg, void 0, assert.isIterable);
2668
- }
2669
- };
2670
- assert.changes = function(fn, obj, prop, msg) {
2671
- if (arguments.length === 3 && typeof obj === "function") {
2672
- msg = prop;
2673
- prop = null;
2674
- }
2675
- new Assertion(fn, msg, assert.changes, true).to.change(obj, prop);
2676
- };
2677
- assert.changesBy = function(fn, obj, prop, delta, msg) {
2678
- if (arguments.length === 4 && typeof obj === "function") {
2679
- var tmpMsg = delta;
2680
- delta = prop;
2681
- msg = tmpMsg;
2682
- } else if (arguments.length === 3) {
2683
- delta = prop;
2684
- prop = null;
2685
- }
2686
- new Assertion(fn, msg, assert.changesBy, true).to.change(obj, prop).by(delta);
2687
- };
2688
- assert.doesNotChange = function(fn, obj, prop, msg) {
2689
- if (arguments.length === 3 && typeof obj === "function") {
2690
- msg = prop;
2691
- prop = null;
2692
- }
2693
- return new Assertion(fn, msg, assert.doesNotChange, true).to.not.change(obj, prop);
2694
- };
2695
- assert.changesButNotBy = function(fn, obj, prop, delta, msg) {
2696
- if (arguments.length === 4 && typeof obj === "function") {
2697
- var tmpMsg = delta;
2698
- delta = prop;
2699
- msg = tmpMsg;
2700
- } else if (arguments.length === 3) {
2701
- delta = prop;
2702
- prop = null;
2703
- }
2704
- new Assertion(fn, msg, assert.changesButNotBy, true).to.change(obj, prop).but.not.by(delta);
2705
- };
2706
- assert.increases = function(fn, obj, prop, msg) {
2707
- if (arguments.length === 3 && typeof obj === "function") {
2708
- msg = prop;
2709
- prop = null;
2710
- }
2711
- return new Assertion(fn, msg, assert.increases, true).to.increase(obj, prop);
2712
- };
2713
- assert.increasesBy = function(fn, obj, prop, delta, msg) {
2714
- if (arguments.length === 4 && typeof obj === "function") {
2715
- var tmpMsg = delta;
2716
- delta = prop;
2717
- msg = tmpMsg;
2718
- } else if (arguments.length === 3) {
2719
- delta = prop;
2720
- prop = null;
2721
- }
2722
- new Assertion(fn, msg, assert.increasesBy, true).to.increase(obj, prop).by(delta);
2723
- };
2724
- assert.doesNotIncrease = function(fn, obj, prop, msg) {
2725
- if (arguments.length === 3 && typeof obj === "function") {
2726
- msg = prop;
2727
- prop = null;
2728
- }
2729
- return new Assertion(fn, msg, assert.doesNotIncrease, true).to.not.increase(obj, prop);
2730
- };
2731
- assert.increasesButNotBy = function(fn, obj, prop, delta, msg) {
2732
- if (arguments.length === 4 && typeof obj === "function") {
2733
- var tmpMsg = delta;
2734
- delta = prop;
2735
- msg = tmpMsg;
2736
- } else if (arguments.length === 3) {
2737
- delta = prop;
2738
- prop = null;
2739
- }
2740
- new Assertion(fn, msg, assert.increasesButNotBy, true).to.increase(obj, prop).but.not.by(delta);
2741
- };
2742
- assert.decreases = function(fn, obj, prop, msg) {
2743
- if (arguments.length === 3 && typeof obj === "function") {
2744
- msg = prop;
2745
- prop = null;
2746
- }
2747
- return new Assertion(fn, msg, assert.decreases, true).to.decrease(obj, prop);
2748
- };
2749
- assert.decreasesBy = function(fn, obj, prop, delta, msg) {
2750
- if (arguments.length === 4 && typeof obj === "function") {
2751
- var tmpMsg = delta;
2752
- delta = prop;
2753
- msg = tmpMsg;
2754
- } else if (arguments.length === 3) {
2755
- delta = prop;
2756
- prop = null;
2757
- }
2758
- new Assertion(fn, msg, assert.decreasesBy, true).to.decrease(obj, prop).by(delta);
2759
- };
2760
- assert.doesNotDecrease = function(fn, obj, prop, msg) {
2761
- if (arguments.length === 3 && typeof obj === "function") {
2762
- msg = prop;
2763
- prop = null;
2764
- }
2765
- return new Assertion(fn, msg, assert.doesNotDecrease, true).to.not.decrease(obj, prop);
2766
- };
2767
- assert.doesNotDecreaseBy = function(fn, obj, prop, delta, msg) {
2768
- if (arguments.length === 4 && typeof obj === "function") {
2769
- var tmpMsg = delta;
2770
- delta = prop;
2771
- msg = tmpMsg;
2772
- } else if (arguments.length === 3) {
2773
- delta = prop;
2774
- prop = null;
2775
- }
2776
- return new Assertion(fn, msg, assert.doesNotDecreaseBy, true).to.not.decrease(obj, prop).by(delta);
2777
- };
2778
- assert.decreasesButNotBy = function(fn, obj, prop, delta, msg) {
2779
- if (arguments.length === 4 && typeof obj === "function") {
2780
- var tmpMsg = delta;
2781
- delta = prop;
2782
- msg = tmpMsg;
2783
- } else if (arguments.length === 3) {
2784
- delta = prop;
2785
- prop = null;
2786
- }
2787
- new Assertion(fn, msg, assert.decreasesButNotBy, true).to.decrease(obj, prop).but.not.by(delta);
2788
- };
2789
- assert.ifError = function(val) {
2790
- if (val) throw val;
2791
- };
2792
- assert.isExtensible = function(obj, msg) {
2793
- new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible;
2794
- };
2795
- assert.isNotExtensible = function(obj, msg) {
2796
- new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible;
2797
- };
2798
- assert.isSealed = function(obj, msg) {
2799
- new Assertion(obj, msg, assert.isSealed, true).to.be.sealed;
2800
- };
2801
- assert.isNotSealed = function(obj, msg) {
2802
- new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed;
2803
- };
2804
- assert.isFrozen = function(obj, msg) {
2805
- new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen;
2806
- };
2807
- assert.isNotFrozen = function(obj, msg) {
2808
- new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen;
2809
- };
2810
- assert.isEmpty = function(val, msg) {
2811
- new Assertion(val, msg, assert.isEmpty, true).to.be.empty;
2812
- };
2813
- assert.isNotEmpty = function(val, msg) {
2814
- new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty;
2815
- };
2816
- assert.containsSubset = function(val, exp, msg) {
2817
- new Assertion(val, msg).to.containSubset(exp);
2818
- };
2819
- assert.doesNotContainSubset = function(val, exp, msg) {
2820
- new Assertion(val, msg).to.not.containSubset(exp);
2821
- };
2822
- for (const [name, as] of [
2823
- ["isOk", "ok"],
2824
- ["isNotOk", "notOk"],
2825
- ["throws", "throw"],
2826
- ["throws", "Throw"],
2827
- ["isExtensible", "extensible"],
2828
- ["isNotExtensible", "notExtensible"],
2829
- ["isSealed", "sealed"],
2830
- ["isNotSealed", "notSealed"],
2831
- ["isFrozen", "frozen"],
2832
- ["isNotFrozen", "notFrozen"],
2833
- ["isEmpty", "empty"],
2834
- ["isNotEmpty", "notEmpty"],
2835
- ["isCallable", "isFunction"],
2836
- ["isNotCallable", "isNotFunction"],
2837
- ["containsSubset", "containSubset"]
2838
- ]) assert[as] = assert[name];
2839
- var used = [];
2840
- function use(fn) {
2841
- const exports = {
2842
- use,
2843
- AssertionError,
2844
- util: utils_exports,
2845
- config,
2846
- expect,
2847
- assert,
2848
- Assertion,
2849
- ...should_exports
2850
- };
2851
- if (!~used.indexOf(fn)) {
2852
- fn(exports, utils_exports);
2853
- used.push(fn);
2854
- }
2855
- return exports;
2856
- }
2857
- __name(use, "use");
2858
- /*!
2859
- * Chai - flag utility
2860
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2861
- * MIT Licensed
2862
- */
2863
- /*!
2864
- * Chai - test utility
2865
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2866
- * MIT Licensed
2867
- */
2868
- /*!
2869
- * Chai - expectTypes utility
2870
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2871
- * MIT Licensed
2872
- */
2873
- /*!
2874
- * Chai - getActual utility
2875
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2876
- * MIT Licensed
2877
- */
2878
- /*!
2879
- * Chai - message composition utility
2880
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2881
- * MIT Licensed
2882
- */
2883
- /*!
2884
- * Chai - transferFlags utility
2885
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2886
- * MIT Licensed
2887
- */
2888
- /*!
2889
- * chai
2890
- * http://chaijs.com
2891
- * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
2892
- * MIT Licensed
2893
- */
2894
- /*!
2895
- * Chai - isProxyEnabled helper
2896
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2897
- * MIT Licensed
2898
- */
2899
- /*!
2900
- * Chai - addProperty utility
2901
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2902
- * MIT Licensed
2903
- */
2904
- /*!
2905
- * Chai - addLengthGuard utility
2906
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2907
- * MIT Licensed
2908
- */
2909
- /*!
2910
- * Chai - getProperties utility
2911
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2912
- * MIT Licensed
2913
- */
2914
- /*!
2915
- * Chai - proxify utility
2916
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2917
- * MIT Licensed
2918
- */
2919
- /*!
2920
- * Chai - addMethod utility
2921
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2922
- * MIT Licensed
2923
- */
2924
- /*!
2925
- * Chai - overwriteProperty utility
2926
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2927
- * MIT Licensed
2928
- */
2929
- /*!
2930
- * Chai - overwriteMethod utility
2931
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2932
- * MIT Licensed
2933
- */
2934
- /*!
2935
- * Chai - addChainingMethod utility
2936
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2937
- * MIT Licensed
2938
- */
2939
- /*!
2940
- * Chai - overwriteChainableMethod utility
2941
- * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
2942
- * MIT Licensed
2943
- */
2944
- /*!
2945
- * Chai - compareByInspect utility
2946
- * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
2947
- * MIT Licensed
2948
- */
2949
- /*!
2950
- * Chai - getOwnEnumerablePropertySymbols utility
2951
- * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
2952
- * MIT Licensed
2953
- */
2954
- /*!
2955
- * Chai - getOwnEnumerableProperties utility
2956
- * Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
2957
- * MIT Licensed
2958
- */
2959
- /*!
2960
- * Chai - isNaN utility
2961
- * Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2962
- * MIT Licensed
2963
- */
2964
- /*!
2965
- * chai
2966
- * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
2967
- * MIT Licensed
2968
- */
2969
- /*!
2970
- * chai
2971
- * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
2972
- * MIT Licensed
2973
- */
2974
- /*! Bundled license information:
2975
-
2976
- deep-eql/index.js:
2977
- (*!
2978
- * deep-eql
2979
- * Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
2980
- * MIT Licensed
2981
- *)
2982
- (*!
2983
- * Check to see if the MemoizeMap has recorded a result of the two operands
2984
- *
2985
- * @param {Mixed} leftHandOperand
2986
- * @param {Mixed} rightHandOperand
2987
- * @param {MemoizeMap} memoizeMap
2988
- * @returns {Boolean|null} result
2989
- *)
2990
- (*!
2991
- * Set the result of the equality into the MemoizeMap
2992
- *
2993
- * @param {Mixed} leftHandOperand
2994
- * @param {Mixed} rightHandOperand
2995
- * @param {MemoizeMap} memoizeMap
2996
- * @param {Boolean} result
2997
- *)
2998
- (*!
2999
- * Primary Export
3000
- *)
3001
- (*!
3002
- * The main logic of the `deepEqual` function.
3003
- *
3004
- * @param {Mixed} leftHandOperand
3005
- * @param {Mixed} rightHandOperand
3006
- * @param {Object} [options] (optional) Additional options
3007
- * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
3008
- * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
3009
- complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
3010
- references to blow the stack.
3011
- * @return {Boolean} equal match
3012
- *)
3013
- (*!
3014
- * Compare two Regular Expressions for equality.
3015
- *
3016
- * @param {RegExp} leftHandOperand
3017
- * @param {RegExp} rightHandOperand
3018
- * @return {Boolean} result
3019
- *)
3020
- (*!
3021
- * Compare two Sets/Maps for equality. Faster than other equality functions.
3022
- *
3023
- * @param {Set} leftHandOperand
3024
- * @param {Set} rightHandOperand
3025
- * @param {Object} [options] (Optional)
3026
- * @return {Boolean} result
3027
- *)
3028
- (*!
3029
- * Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
3030
- *
3031
- * @param {Iterable} leftHandOperand
3032
- * @param {Iterable} rightHandOperand
3033
- * @param {Object} [options] (Optional)
3034
- * @return {Boolean} result
3035
- *)
3036
- (*!
3037
- * Simple equality for generator objects such as those returned by generator functions.
3038
- *
3039
- * @param {Iterable} leftHandOperand
3040
- * @param {Iterable} rightHandOperand
3041
- * @param {Object} [options] (Optional)
3042
- * @return {Boolean} result
3043
- *)
3044
- (*!
3045
- * Determine if the given object has an @@iterator function.
3046
- *
3047
- * @param {Object} target
3048
- * @return {Boolean} `true` if the object has an @@iterator function.
3049
- *)
3050
- (*!
3051
- * Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
3052
- * This will consume the iterator - which could have side effects depending on the @@iterator implementation.
3053
- *
3054
- * @param {Object} target
3055
- * @returns {Array} an array of entries from the @@iterator function
3056
- *)
3057
- (*!
3058
- * Gets all entries from a Generator. This will consume the generator - which could have side effects.
3059
- *
3060
- * @param {Generator} target
3061
- * @returns {Array} an array of entries from the Generator.
3062
- *)
3063
- (*!
3064
- * Gets all own and inherited enumerable keys from a target.
3065
- *
3066
- * @param {Object} target
3067
- * @returns {Array} an array of own and inherited enumerable keys from the target.
3068
- *)
3069
- (*!
3070
- * Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
3071
- * each key. If any value of the given key is not equal, the function will return false (early).
3072
- *
3073
- * @param {Mixed} leftHandOperand
3074
- * @param {Mixed} rightHandOperand
3075
- * @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
3076
- * @param {Object} [options] (Optional)
3077
- * @return {Boolean} result
3078
- *)
3079
- (*!
3080
- * Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
3081
- * for each enumerable key in the object.
3082
- *
3083
- * @param {Mixed} leftHandOperand
3084
- * @param {Mixed} rightHandOperand
3085
- * @param {Object} [options] (Optional)
3086
- * @return {Boolean} result
3087
- *)
3088
- (*!
3089
- * Returns true if the argument is a primitive.
3090
- *
3091
- * This intentionally returns true for all objects that can be compared by reference,
3092
- * including functions and symbols.
3093
- *
3094
- * @param {Mixed} value
3095
- * @return {Boolean} result
3096
- *)
3097
- */
3098
- //#endregion
3099
- export { Assertion, AssertionError, Should, assert, config, expect, should, use, utils_exports as util };
3100
-
3101
- //# sourceMappingURL=chai.js.map