@gjsify/assert 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,31 @@
1
1
  # @gjsify/assert
2
2
 
3
- Node.js assert module for Gjs
3
+ GJS implementation of the Node.js `assert` module. Provides assertion functions for testing including deepEqual, throws, and strict mode.
4
+
5
+ Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @gjsify/assert
11
+ # or
12
+ yarn add @gjsify/assert
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { strictEqual, deepStrictEqual, throws } from '@gjsify/assert';
19
+
20
+ strictEqual(1 + 1, 2);
21
+ deepStrictEqual({ a: 1 }, { a: 1 });
22
+ throws(() => { throw new Error('fail'); });
23
+ ```
4
24
 
5
25
  ## Inspirations and credits
26
+
6
27
  - https://deno.land/std/node/assert.ts
7
28
 
29
+ ## License
30
+
31
+ MIT
package/cjs-compat.cjs ADDED
@@ -0,0 +1,6 @@
1
+ // CJS compatibility wrapper for npm packages that require('assert')
2
+ // In Node.js CJS, require('assert') returns the assert function directly.
3
+ // When esbuild bundles ESM @gjsify/assert for CJS consumers, it returns a
4
+ // namespace object instead. This wrapper extracts the default export.
5
+ const mod = require('./lib/esm/index.js');
6
+ module.exports = mod.default || mod;
@@ -0,0 +1,71 @@
1
+ import { safeInspect } from "./inspect-fallback.js";
2
+ class AssertionError extends Error {
3
+ actual;
4
+ expected;
5
+ operator;
6
+ code;
7
+ generatedMessage;
8
+ constructor(options) {
9
+ const {
10
+ actual,
11
+ expected,
12
+ operator = "fail",
13
+ stackStartFn
14
+ } = options;
15
+ const isGenerated = options.message == null;
16
+ const message = isGenerated ? generateMessage(actual, expected, operator) : String(options.message);
17
+ super(message);
18
+ this.name = "AssertionError";
19
+ this.code = "ERR_ASSERTION";
20
+ this.actual = actual;
21
+ this.expected = expected;
22
+ this.operator = operator;
23
+ this.generatedMessage = isGenerated;
24
+ if (typeof Error.captureStackTrace === "function") {
25
+ Error.captureStackTrace(this, stackStartFn || this.constructor);
26
+ }
27
+ }
28
+ toString() {
29
+ return `${this.name} [${this.code}]: ${this.message}`;
30
+ }
31
+ // Support for util.inspect and console.log
32
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](_depth, _options) {
33
+ return this.toString();
34
+ }
35
+ }
36
+ const kReadableOperator = {
37
+ "deepStrictEqual": "Expected values to be strictly deep-equal:",
38
+ "strictEqual": "Expected values to be strictly equal:",
39
+ "strictEqualObject": 'Expected "actual" to be reference-equal to "expected":',
40
+ "deepEqual": "Expected values to be loosely deep-equal:",
41
+ "notDeepStrictEqual": 'Expected "actual" not to be strictly deep-equal to:',
42
+ "notStrictEqual": 'Expected "actual" to be strictly unequal to:',
43
+ "notStrictEqualObject": 'Expected "actual" not to be reference-equal to "expected":',
44
+ "notDeepEqual": 'Expected "actual" not to be loosely deep-equal to:',
45
+ "notIdentical": "Values have same structure but are not reference-equal:",
46
+ "notEqual": 'Expected "actual" to be loosely unequal to:',
47
+ "equal": "Expected values to be loosely equal:",
48
+ "==": "Expected values to be loosely equal:",
49
+ "!=": 'Expected "actual" to be loosely unequal to:',
50
+ "===": "Expected values to be strictly equal:",
51
+ "!==": 'Expected "actual" to be strictly unequal to:',
52
+ "fail": "Failed"
53
+ };
54
+ function generateMessage(actual, expected, operator) {
55
+ const header = kReadableOperator[operator] || `Operator: ${operator}`;
56
+ if (operator === "fail") {
57
+ return "Failed";
58
+ }
59
+ const actualStr = safeInspect(actual);
60
+ const expectedStr = safeInspect(expected);
61
+ return `${header}
62
+
63
+ + actual - expected
64
+
65
+ + ${actualStr}
66
+ - ${expectedStr}
67
+ `;
68
+ }
69
+ export {
70
+ AssertionError
71
+ };
@@ -0,0 +1,525 @@
1
+ var ValueType = /* @__PURE__ */ ((ValueType2) => {
2
+ ValueType2[ValueType2["noIterator"] = 0] = "noIterator";
3
+ ValueType2[ValueType2["isArray"] = 1] = "isArray";
4
+ ValueType2[ValueType2["isSet"] = 2] = "isSet";
5
+ ValueType2[ValueType2["isMap"] = 3] = "isMap";
6
+ return ValueType2;
7
+ })(ValueType || {});
8
+ const kStrict = 1;
9
+ const kLoose = 0;
10
+ function isDate(v) {
11
+ return v instanceof Date;
12
+ }
13
+ function isRegExp(v) {
14
+ return v instanceof RegExp;
15
+ }
16
+ function isMap(v) {
17
+ return v instanceof Map;
18
+ }
19
+ function isSet(v) {
20
+ return v instanceof Set;
21
+ }
22
+ function isError(v) {
23
+ return v instanceof Error;
24
+ }
25
+ function isAnyArrayBuffer(v) {
26
+ return v instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer;
27
+ }
28
+ function isArrayBufferView(v) {
29
+ return ArrayBuffer.isView(v);
30
+ }
31
+ function isBoxedPrimitive(v) {
32
+ return v instanceof Number || v instanceof String || v instanceof Boolean || v instanceof BigInt || v instanceof Symbol;
33
+ }
34
+ function isNumberObject(v) {
35
+ return v instanceof Number;
36
+ }
37
+ function isStringObject(v) {
38
+ return v instanceof String;
39
+ }
40
+ function isBooleanObject(v) {
41
+ return v instanceof Boolean;
42
+ }
43
+ function isBigIntObject(v) {
44
+ return typeof BigInt !== "undefined" && v instanceof Object && Object.prototype.toString.call(v) === "[object BigInt]";
45
+ }
46
+ function isSymbolObject(v) {
47
+ return v instanceof Object && Object.prototype.toString.call(v) === "[object Symbol]";
48
+ }
49
+ function isFloatTypedArray(v) {
50
+ return v instanceof Float32Array || v instanceof Float64Array;
51
+ }
52
+ const hasOwn = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
53
+ const hasEnumerable = (obj, prop) => Object.prototype.propertyIsEnumerable.call(obj, prop);
54
+ const wellKnownConstructors = /* @__PURE__ */ new Set([
55
+ Array,
56
+ ArrayBuffer,
57
+ Boolean,
58
+ DataView,
59
+ Date,
60
+ Error,
61
+ Float32Array,
62
+ Float64Array,
63
+ Function,
64
+ Int8Array,
65
+ Int16Array,
66
+ Int32Array,
67
+ Map,
68
+ Number,
69
+ Object,
70
+ Promise,
71
+ RegExp,
72
+ Set,
73
+ String,
74
+ Symbol,
75
+ Uint8Array,
76
+ Uint16Array,
77
+ Uint32Array,
78
+ Uint8ClampedArray,
79
+ BigInt64Array,
80
+ BigUint64Array,
81
+ WeakMap,
82
+ WeakSet
83
+ ]);
84
+ function getOwnNonIndexProperties(obj, skipSymbols) {
85
+ const keys = Object.getOwnPropertyNames(obj);
86
+ const result = [];
87
+ for (const key of keys) {
88
+ const num = Number(key);
89
+ if (Number.isInteger(num) && num >= 0 && num < 2 ** 32 - 1 && String(num) === key) {
90
+ continue;
91
+ }
92
+ if (!hasEnumerable(obj, key)) {
93
+ continue;
94
+ }
95
+ result.push(key);
96
+ }
97
+ if (!skipSymbols) {
98
+ const symbols = Object.getOwnPropertySymbols(obj);
99
+ for (const sym of symbols) {
100
+ if (hasEnumerable(obj, sym)) {
101
+ result.push(sym);
102
+ }
103
+ }
104
+ }
105
+ return result;
106
+ }
107
+ function areSimilarRegExps(a, b) {
108
+ return a.source === b.source && a.flags === b.flags && a.lastIndex === b.lastIndex;
109
+ }
110
+ function areSimilarFloatArrays(a, b) {
111
+ if (a.byteLength !== b.byteLength) return false;
112
+ const viewA = a;
113
+ const viewB = b;
114
+ for (let i = 0; i < viewA.length; i++) {
115
+ if (viewA[i] !== viewB[i]) return false;
116
+ }
117
+ return true;
118
+ }
119
+ function areSimilarTypedArrays(a, b) {
120
+ if (a.byteLength !== b.byteLength) return false;
121
+ const viewA = new Uint8Array(a.buffer, a.byteOffset, a.byteLength);
122
+ const viewB = new Uint8Array(b.buffer, b.byteOffset, b.byteLength);
123
+ for (let i = 0; i < viewA.length; i++) {
124
+ if (viewA[i] !== viewB[i]) return false;
125
+ }
126
+ return true;
127
+ }
128
+ function areEqualArrayBuffers(buf1, buf2) {
129
+ if (buf1.byteLength !== buf2.byteLength) return false;
130
+ const a = new Uint8Array(buf1);
131
+ const b = new Uint8Array(buf2);
132
+ for (let i = 0; i < a.length; i++) {
133
+ if (a[i] !== b[i]) return false;
134
+ }
135
+ return true;
136
+ }
137
+ function isEqualBoxedPrimitive(val1, val2) {
138
+ if (isNumberObject(val1)) {
139
+ return isNumberObject(val2) && Object.is(val1.valueOf(), val2.valueOf());
140
+ }
141
+ if (isStringObject(val1)) {
142
+ return isStringObject(val2) && val1.valueOf() === val2.valueOf();
143
+ }
144
+ if (isBooleanObject(val1)) {
145
+ return isBooleanObject(val2) && val1.valueOf() === val2.valueOf();
146
+ }
147
+ if (isBigIntObject(val1)) {
148
+ return isBigIntObject(val2) && val1[Symbol.toPrimitive]("number") === val2[Symbol.toPrimitive]("number");
149
+ }
150
+ if (isSymbolObject(val1)) {
151
+ return isSymbolObject(val2) && Symbol.prototype.valueOf.call(val1) === Symbol.prototype.valueOf.call(val2);
152
+ }
153
+ return false;
154
+ }
155
+ function getTypedArrayTag(val) {
156
+ return Object.prototype.toString.call(val).slice(8, -1);
157
+ }
158
+ function innerDeepEqual(val1, val2, mode, memos) {
159
+ if (val1 === val2) {
160
+ return val1 !== 0 || Object.is(val1, val2) || mode === kLoose;
161
+ }
162
+ if (mode !== kLoose) {
163
+ if (typeof val1 === "number") {
164
+ return val1 !== val1 && val2 !== val2;
165
+ }
166
+ if (typeof val2 !== "object" || typeof val1 !== "object" || val1 === null || val2 === null) {
167
+ return false;
168
+ }
169
+ } else {
170
+ if (val1 === null || typeof val1 !== "object") {
171
+ return (val2 === null || typeof val2 !== "object") && // eslint-disable-next-line eqeqeq
172
+ (val1 == val2 || val1 !== val1 && val2 !== val2);
173
+ }
174
+ if (val2 === null || typeof val2 !== "object") {
175
+ return false;
176
+ }
177
+ }
178
+ return objectComparisonStart(val1, val2, mode, memos);
179
+ }
180
+ function objectComparisonStart(val1, val2, mode, memos) {
181
+ if (mode === kStrict) {
182
+ if (wellKnownConstructors.has(val1.constructor) || val1.constructor !== void 0 && !hasOwn(val1, "constructor")) {
183
+ if (val1.constructor !== val2.constructor) {
184
+ return false;
185
+ }
186
+ } else if (Object.getPrototypeOf(val1) !== Object.getPrototypeOf(val2)) {
187
+ return false;
188
+ }
189
+ }
190
+ const val1Tag = Object.prototype.toString.call(val1);
191
+ const val2Tag = Object.prototype.toString.call(val2);
192
+ if (val1Tag !== val2Tag) {
193
+ return false;
194
+ }
195
+ if (Array.isArray(val1)) {
196
+ if (!Array.isArray(val2) || val1.length !== val2.length) {
197
+ return false;
198
+ }
199
+ const keys2 = getOwnNonIndexProperties(val2, mode === kLoose);
200
+ if (keys2.length !== getOwnNonIndexProperties(val1, mode === kLoose).length) {
201
+ return false;
202
+ }
203
+ return keyCheck(val1, val2, mode, memos, 1 /* isArray */, keys2);
204
+ } else if (val1Tag === "[object Object]") {
205
+ return keyCheck(val1, val2, mode, memos, 0 /* noIterator */);
206
+ } else if (isDate(val1)) {
207
+ if (!isDate(val2)) return false;
208
+ const time1 = val1.getTime();
209
+ const time2 = val2.getTime();
210
+ if (time1 !== time2 && !(Number.isNaN(time1) && Number.isNaN(time2))) {
211
+ return false;
212
+ }
213
+ } else if (isRegExp(val1)) {
214
+ if (!isRegExp(val2) || !areSimilarRegExps(val1, val2)) {
215
+ return false;
216
+ }
217
+ } else if (isArrayBufferView(val1)) {
218
+ if (getTypedArrayTag(val1) !== getTypedArrayTag(val2)) {
219
+ return false;
220
+ }
221
+ if (mode === kLoose && isFloatTypedArray(val1)) {
222
+ if (!areSimilarFloatArrays(val1, val2)) {
223
+ return false;
224
+ }
225
+ } else if (!areSimilarTypedArrays(val1, val2)) {
226
+ return false;
227
+ }
228
+ const keys2 = getOwnNonIndexProperties(val2, mode === kLoose);
229
+ if (keys2.length !== getOwnNonIndexProperties(val1, mode === kLoose).length) {
230
+ return false;
231
+ }
232
+ return keyCheck(val1, val2, mode, memos, 0 /* noIterator */, keys2);
233
+ } else if (isSet(val1)) {
234
+ if (!isSet(val2) || val1.size !== val2.size) {
235
+ return false;
236
+ }
237
+ return keyCheck(val1, val2, mode, memos, 2 /* isSet */);
238
+ } else if (isMap(val1)) {
239
+ if (!isMap(val2) || val1.size !== val2.size) {
240
+ return false;
241
+ }
242
+ return keyCheck(val1, val2, mode, memos, 3 /* isMap */);
243
+ } else if (isAnyArrayBuffer(val1)) {
244
+ if (!isAnyArrayBuffer(val2) || !areEqualArrayBuffers(val1, val2)) {
245
+ return false;
246
+ }
247
+ } else if (isError(val1)) {
248
+ if (!isError(val2) || val1.message !== val2.message || val1.name !== val2.name) {
249
+ return false;
250
+ }
251
+ if (hasOwn(val1, "cause") !== hasOwn(val2, "cause")) {
252
+ return false;
253
+ }
254
+ if (hasOwn(val1, "cause") && !innerDeepEqual(val1.cause, val2.cause, mode, memos)) {
255
+ return false;
256
+ }
257
+ } else if (isBoxedPrimitive(val1)) {
258
+ if (!isEqualBoxedPrimitive(val1, val2)) {
259
+ return false;
260
+ }
261
+ } else if (Array.isArray(val2) || isArrayBufferView(val2) || isSet(val2) || isMap(val2) || isDate(val2) || isRegExp(val2) || isAnyArrayBuffer(val2) || isBoxedPrimitive(val2) || isError(val2)) {
262
+ return false;
263
+ }
264
+ return keyCheck(val1, val2, mode, memos, 0 /* noIterator */);
265
+ }
266
+ function getEnumerables(val, keys) {
267
+ return keys.filter((key) => hasEnumerable(val, key));
268
+ }
269
+ function keyCheck(val1, val2, mode, memos, iterationType, keys2) {
270
+ const isArrayLikeObject = keys2 !== void 0;
271
+ if (keys2 === void 0) {
272
+ keys2 = Object.keys(val2);
273
+ }
274
+ let keys1;
275
+ if (!isArrayLikeObject) {
276
+ if (keys2.length !== (keys1 = Object.keys(val1)).length) {
277
+ return false;
278
+ } else if (mode === kStrict) {
279
+ const symbolKeysA = Object.getOwnPropertySymbols(val1);
280
+ if (symbolKeysA.length !== 0) {
281
+ let count = 0;
282
+ for (const key of symbolKeysA) {
283
+ if (hasEnumerable(val1, key)) {
284
+ if (!hasEnumerable(val2, key)) return false;
285
+ keys2.push(key);
286
+ count++;
287
+ } else if (hasEnumerable(val2, key)) {
288
+ return false;
289
+ }
290
+ }
291
+ const symbolKeysB = Object.getOwnPropertySymbols(val2);
292
+ if (symbolKeysA.length !== symbolKeysB.length && getEnumerables(val2, symbolKeysB).length !== count) {
293
+ return false;
294
+ }
295
+ } else {
296
+ const symbolKeysB = Object.getOwnPropertySymbols(val2);
297
+ if (symbolKeysB.length !== 0 && getEnumerables(val2, symbolKeysB).length !== 0) {
298
+ return false;
299
+ }
300
+ }
301
+ }
302
+ }
303
+ if (keys2.length === 0 && (iterationType === 0 /* noIterator */ || iterationType === 1 /* isArray */ && val2.length === 0 || val2.size === 0)) {
304
+ return true;
305
+ }
306
+ if (memos === null) {
307
+ return objEquiv(val1, val2, mode, keys1, keys2, memos, iterationType);
308
+ }
309
+ return handleCycles(val1, val2, mode, keys1, keys2, memos, iterationType);
310
+ }
311
+ function handleCycles(val1, val2, mode, keys1, keys2, memos, iterationType) {
312
+ if (memos === void 0) {
313
+ memos = {
314
+ set: void 0,
315
+ a: val1,
316
+ b: val2,
317
+ c: void 0,
318
+ d: void 0,
319
+ deep: false
320
+ };
321
+ return objEquiv(val1, val2, mode, keys1, keys2, memos, iterationType);
322
+ }
323
+ if (memos.set === void 0) {
324
+ if (memos.deep === false) {
325
+ if (memos.a === val1) return memos.b === val2;
326
+ if (memos.b === val2) return false;
327
+ memos.c = val1;
328
+ memos.d = val2;
329
+ memos.deep = true;
330
+ const result = objEquiv(val1, val2, mode, keys1, keys2, memos, iterationType);
331
+ memos.deep = false;
332
+ return result;
333
+ }
334
+ memos.set = /* @__PURE__ */ new Set();
335
+ memos.set.add(memos.a);
336
+ memos.set.add(memos.b);
337
+ memos.set.add(memos.c);
338
+ memos.set.add(memos.d);
339
+ }
340
+ const { set } = memos;
341
+ const originalSize = set.size;
342
+ set.add(val1);
343
+ set.add(val2);
344
+ if (originalSize !== set.size - 2) {
345
+ return originalSize === set.size;
346
+ }
347
+ const areEq = objEquiv(val1, val2, mode, keys1, keys2, memos, iterationType);
348
+ set.delete(val1);
349
+ set.delete(val2);
350
+ return areEq;
351
+ }
352
+ function findLooseMatchingPrimitives(prim) {
353
+ switch (typeof prim) {
354
+ case "undefined":
355
+ return null;
356
+ case "object":
357
+ return void 0;
358
+ case "symbol":
359
+ return false;
360
+ case "string":
361
+ prim = +prim;
362
+ // falls through
363
+ case "number":
364
+ if (prim !== prim) return false;
365
+ }
366
+ return true;
367
+ }
368
+ function setMightHaveLoosePrim(a, b, prim) {
369
+ const altValue = findLooseMatchingPrimitives(prim);
370
+ if (altValue != null) return altValue;
371
+ return !b.has(altValue) && a.has(altValue);
372
+ }
373
+ function mapMightHaveLoosePrim(a, b, prim, item2, memo) {
374
+ const altValue = findLooseMatchingPrimitives(prim);
375
+ if (altValue != null) return altValue;
376
+ const item1 = a.get(altValue);
377
+ if (item1 === void 0 && !a.has(altValue) || !innerDeepEqual(item1, item2, kLoose, memo)) {
378
+ return false;
379
+ }
380
+ return !b.has(altValue) && innerDeepEqual(item1, item2, kLoose, memo);
381
+ }
382
+ function setEquiv(a, b, mode, memo) {
383
+ let array;
384
+ for (const val of b) {
385
+ if (!a.has(val)) {
386
+ if ((typeof val !== "object" || val === null) && (mode !== kLoose || !setMightHaveLoosePrim(a, b, val))) {
387
+ return false;
388
+ }
389
+ if (array === void 0) array = [];
390
+ array.push(val);
391
+ }
392
+ }
393
+ if (array === void 0) return true;
394
+ for (const val1 of a) {
395
+ if (typeof val1 === "object" && val1 !== null) {
396
+ if (!b.has(val1)) {
397
+ let found = false;
398
+ for (let i = 0; i < array.length; i++) {
399
+ if (innerDeepEqual(val1, array[i], mode, memo)) {
400
+ array.splice(i, 1);
401
+ found = true;
402
+ break;
403
+ }
404
+ }
405
+ if (!found) return false;
406
+ }
407
+ } else if (!b.has(val1) && (mode !== kLoose || !setMightHaveLoosePrim(b, a, val1))) {
408
+ let found = false;
409
+ for (let i = 0; i < array.length; i++) {
410
+ if (innerDeepEqual(val1, array[i], mode, memo)) {
411
+ array.splice(i, 1);
412
+ found = true;
413
+ break;
414
+ }
415
+ }
416
+ if (!found) return false;
417
+ }
418
+ }
419
+ return array.length === 0;
420
+ }
421
+ function mapEquiv(a, b, mode, memo) {
422
+ let array;
423
+ for (const [key2, item2] of b) {
424
+ if (typeof key2 === "object" && key2 !== null) {
425
+ if (array === void 0) {
426
+ if (a.size === 1) {
427
+ const [key1, item1] = a.entries().next().value;
428
+ return innerDeepEqual(key1, key2, mode, memo) && innerDeepEqual(item1, item2, mode, memo);
429
+ }
430
+ array = [];
431
+ }
432
+ array.push(key2);
433
+ } else {
434
+ const item1 = a.get(key2);
435
+ if (item1 === void 0 && !a.has(key2) || !innerDeepEqual(item1, item2, mode, memo)) {
436
+ if (mode !== kLoose) return false;
437
+ if (!mapMightHaveLoosePrim(a, b, key2, item2, memo)) return false;
438
+ if (array === void 0) array = [];
439
+ array.push(key2);
440
+ }
441
+ }
442
+ }
443
+ if (array === void 0) return true;
444
+ for (const [key1, item1] of a) {
445
+ if (typeof key1 === "object" && key1 !== null) {
446
+ if (!b.has(key1)) {
447
+ let found = false;
448
+ for (let i = 0; i < array.length; i++) {
449
+ const key2 = array[i];
450
+ if (innerDeepEqual(key1, key2, mode, memo) && innerDeepEqual(item1, b.get(key2), mode, memo)) {
451
+ array.splice(i, 1);
452
+ found = true;
453
+ break;
454
+ }
455
+ }
456
+ if (!found) return false;
457
+ }
458
+ } else if (mode === kLoose && typeof key1 !== "object" && (!a.has(key1) || !innerDeepEqual(item1, a.get(key1), mode, memo))) {
459
+ }
460
+ }
461
+ return array.length === 0;
462
+ }
463
+ function objEquiv(a, b, mode, keys1, keys2, memos, iterationType) {
464
+ if (keys2.length > 0) {
465
+ const aRec = a;
466
+ const bRec = b;
467
+ let i = 0;
468
+ if (keys1 !== void 0) {
469
+ for (; i < keys2.length; i++) {
470
+ const key = keys2[i];
471
+ if (keys1[i] !== key) break;
472
+ if (!innerDeepEqual(aRec[key], bRec[key], mode, memos)) return false;
473
+ }
474
+ }
475
+ for (; i < keys2.length; i++) {
476
+ const key = keys2[i];
477
+ const descriptor = Object.getOwnPropertyDescriptor(a, key);
478
+ if (!descriptor?.enumerable || !innerDeepEqual(
479
+ descriptor.value !== void 0 ? descriptor.value : aRec[key],
480
+ bRec[key],
481
+ mode,
482
+ memos
483
+ )) {
484
+ return false;
485
+ }
486
+ }
487
+ }
488
+ if (iterationType === 1 /* isArray */) {
489
+ const aArr = a;
490
+ const bArr = b;
491
+ for (let i = 0; i < aArr.length; i++) {
492
+ if (bArr[i] === void 0 && !hasOwn(b, i)) {
493
+ if (aArr[i] !== void 0 || hasOwn(a, i)) return false;
494
+ continue;
495
+ }
496
+ if (mode !== kLoose && aArr[i] === void 0 && !hasOwn(a, i)) {
497
+ return false;
498
+ }
499
+ if (!innerDeepEqual(aArr[i], bArr[i], mode, memos)) return false;
500
+ }
501
+ } else if (iterationType === 2 /* isSet */) {
502
+ if (!setEquiv(a, b, mode, memos)) return false;
503
+ } else if (iterationType === 3 /* isMap */) {
504
+ if (!mapEquiv(a, b, mode, memos)) return false;
505
+ }
506
+ return true;
507
+ }
508
+ let detectCycles = function(val1, val2, mode) {
509
+ try {
510
+ return innerDeepEqual(val1, val2, mode, null);
511
+ } catch {
512
+ detectCycles = (v1, v2, m) => innerDeepEqual(v1, v2, m, void 0);
513
+ return innerDeepEqual(val1, val2, mode, void 0);
514
+ }
515
+ };
516
+ function isDeepEqual(val1, val2) {
517
+ return detectCycles(val1, val2, kLoose);
518
+ }
519
+ function isDeepStrictEqual(val1, val2) {
520
+ return detectCycles(val1, val2, kStrict);
521
+ }
522
+ export {
523
+ isDeepEqual,
524
+ isDeepStrictEqual
525
+ };