@shirudo/ddd-kit 2.2.0 → 3.0.0-rc.4
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 +206 -55
- package/dist/chunks/deep-equal-except.js +639 -0
- package/dist/chunks/deep-equal-except.js.map +1 -0
- package/dist/chunks/errors.d.ts +785 -0
- package/dist/chunks/errors.js +822 -0
- package/dist/chunks/errors.js.map +1 -0
- package/dist/chunks/ports.js +891 -0
- package/dist/chunks/ports.js.map +1 -0
- package/dist/chunks/snapshot-store.d.ts +2808 -0
- package/dist/chunks/utils.d.ts +110 -0
- package/dist/http.d.ts +64 -51
- package/dist/http.js +54 -20
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +2351 -2650
- package/dist/index.js +6140 -3915
- package/dist/index.js.map +1 -1
- package/dist/money.d.ts +376 -0
- package/dist/money.js +578 -0
- package/dist/money.js.map +1 -0
- package/dist/presentation.d.ts +86 -37
- package/dist/presentation.js +208 -39
- package/dist/presentation.js.map +1 -1
- package/dist/testing.d.ts +517 -335
- package/dist/testing.js +2396 -1184
- package/dist/testing.js.map +1 -1
- package/dist/utils.d.ts +2 -106
- package/dist/utils.js +2 -530
- package/package.json +35 -18
- package/dist/aggregate-DFi6HlEh.d.ts +0 -771
- package/dist/utils.js.map +0 -1
package/dist/utils.d.ts
CHANGED
|
@@ -1,106 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* This function compares values recursively, handling:
|
|
5
|
-
* - Primitives (with special handling for NaN)
|
|
6
|
-
* - Arrays (nested arrays supported)
|
|
7
|
-
* - Objects (plain objects and class instances)
|
|
8
|
-
* - TypedArrays (Uint8Array, Int32Array, etc.)
|
|
9
|
-
* - DataView
|
|
10
|
-
* - Maps and Sets
|
|
11
|
-
* - Dates and RegExp
|
|
12
|
-
* - Wrapper objects (Boolean, Number, String)
|
|
13
|
-
* - Circular references (detected and handled)
|
|
14
|
-
*
|
|
15
|
-
* @param a - The first value to compare
|
|
16
|
-
* @param b - The second value to compare
|
|
17
|
-
* @returns `true` if the values are deeply equal, `false` otherwise
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* deepEqual([1, 2, 3], [1, 2, 3]); // true
|
|
22
|
-
* deepEqual({ a: 1, b: [2, 3] }, { a: 1, b: [2, 3] }); // true
|
|
23
|
-
* deepEqual(NaN, NaN); // true
|
|
24
|
-
* deepEqual([1, 2], [1, 2, 3]); // false
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
28
|
-
|
|
29
|
-
type Key = string | symbol;
|
|
30
|
-
type PathSegment = string | number | symbol;
|
|
31
|
-
interface DeepOmitOptions {
|
|
32
|
-
/**
|
|
33
|
-
* Keys to ignore everywhere in the object tree.
|
|
34
|
-
* Only applies to object properties, not Map/Set/TypedArray contents.
|
|
35
|
-
*/
|
|
36
|
-
readonly ignoreKeys?: readonly Key[];
|
|
37
|
-
/**
|
|
38
|
-
* Fine-grained control: Key + path (without current key).
|
|
39
|
-
* Example path: ["user", "meta", 0, "data"]
|
|
40
|
-
*/
|
|
41
|
-
readonly ignoreKeyPredicate?: (key: Key, path: readonly PathSegment[]) => boolean;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Creates a deep copy of `value` with certain keys removed according to the
|
|
45
|
-
* provided rules.
|
|
46
|
-
*
|
|
47
|
-
* Walks the object tree and skips keys that match `ignoreKeys` /
|
|
48
|
-
* `ignoreKeyPredicate`. Built-in atomic types that `deepEqual` compares by
|
|
49
|
-
* value (Date, RegExp, Map, Set, TypedArrays, DataView) are cloned by type
|
|
50
|
-
* rather than walked, since their internal structure has no key filtering to
|
|
51
|
-
* apply. Types that `deepEqual` compares by reference (Error, ArrayBuffer,
|
|
52
|
-
* SharedArrayBuffer, Promise, WeakMap, WeakSet) are passed through by
|
|
53
|
-
* reference, so `deepEqualExcept(x, x)` stays reflexive. Cycles are
|
|
54
|
-
* preserved: a cycle `a → a` clones to `a' → a'`. Arrays retain sparse
|
|
55
|
-
* holes and all non-ignored own properties, including symbol keys.
|
|
56
|
-
*
|
|
57
|
-
* **Shared references.** Without `ignoreKeyPredicate`, an object reached
|
|
58
|
-
* via several paths dedupes to a single clone. With a predicate, each
|
|
59
|
-
* path gets its own clone, because the predicate may decide differently per
|
|
60
|
-
* path, so memoising the first path's result would be wrong. This is
|
|
61
|
-
* inherently exponential for diamond-shaped sharing (a node reachable
|
|
62
|
-
* via 2^n paths is cloned 2^n times); the walk aborts with a descriptive
|
|
63
|
-
* error after {@link PATH_SENSITIVE_VISIT_BUDGET} node visits instead of
|
|
64
|
-
* hanging the process.
|
|
65
|
-
*
|
|
66
|
-
* **Prototype-pollution safety.** `__proto__` and `constructor` keys
|
|
67
|
-
* encountered as *own* properties of the input (typical of `JSON.parse`
|
|
68
|
-
* output) are copied as inert data properties via `Object.defineProperty`
|
|
69
|
-
* so the clone graph cannot bleed into `Object.prototype`.
|
|
70
|
-
*
|
|
71
|
-
* **Class instances.** When the input is a class instance, the clone is
|
|
72
|
-
* built via `Object.create(proto)` so the prototype is preserved, but the
|
|
73
|
-
* constructor is NOT re-invoked, so class invariants enforced by the
|
|
74
|
-
* constructor are not re-checked. `deepOmit` is therefore best used for
|
|
75
|
-
* comparison/serialisation (`voEqualsExcept`, `deepEqualExcept`), not as
|
|
76
|
-
* a general-purpose clone for behaviour-carrying objects.
|
|
77
|
-
*
|
|
78
|
-
* @param value - The value to create a deep copy from
|
|
79
|
-
* @param options - Options specifying which keys to ignore
|
|
80
|
-
* @returns A deep copy of `value` with specified keys removed
|
|
81
|
-
*/
|
|
82
|
-
declare function deepOmit<T>(value: T, options: DeepOmitOptions): T;
|
|
83
|
-
|
|
84
|
-
type DeepEqualExceptOptions = DeepOmitOptions;
|
|
85
|
-
/**
|
|
86
|
-
* Performs a deep equality comparison between two values after omitting specified keys.
|
|
87
|
-
*
|
|
88
|
-
* This function first removes the specified keys from both values using `deepOmit`,
|
|
89
|
-
* then performs a deep equality check using `deepEqual`.
|
|
90
|
-
*
|
|
91
|
-
* @param a - The first value to compare
|
|
92
|
-
* @param b - The second value to compare
|
|
93
|
-
* @param options - Options specifying which keys to omit before comparison
|
|
94
|
-
* @returns `true` if the values are deeply equal after omitting specified keys, `false` otherwise
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```ts
|
|
98
|
-
* const obj1 = { id: 1, name: "Alice", updatedAt: "2024-01-01" };
|
|
99
|
-
* const obj2 = { id: 2, name: "Alice", updatedAt: "2024-01-02" };
|
|
100
|
-
*
|
|
101
|
-
* deepEqualExcept(obj1, obj2, { ignoreKeys: ["id", "updatedAt"] }); // true
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
declare function deepEqualExcept(a: unknown, b: unknown, options: DeepEqualExceptOptions): boolean;
|
|
105
|
-
|
|
106
|
-
export { type DeepEqualExceptOptions, type DeepOmitOptions, type Key, type PathSegment, deepEqual, deepEqualExcept, deepOmit };
|
|
1
|
+
import { a as DeepOmitPathSegment, i as DeepOmitOptions, n as deepEqualExcept, o as deepOmit, r as DeepOmitKey, s as deepEqual, t as DeepEqualExceptOptions } from "./chunks/utils.js";
|
|
2
|
+
export { type DeepEqualExceptOptions, type DeepOmitKey, type DeepOmitOptions, type DeepOmitPathSegment, deepEqual, deepEqualExcept, deepOmit };
|
package/dist/utils.js
CHANGED
|
@@ -1,531 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
1
|
+
import { n as deepOmit, r as deepEqual, t as deepEqualExcept } from "./chunks/deep-equal-except.js";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
var BUILT_IN_TAGS = /* @__PURE__ */ new Set([
|
|
6
|
-
"[object Date]",
|
|
7
|
-
"[object RegExp]",
|
|
8
|
-
"[object Map]",
|
|
9
|
-
"[object Set]",
|
|
10
|
-
"[object WeakMap]",
|
|
11
|
-
"[object WeakSet]",
|
|
12
|
-
"[object Promise]",
|
|
13
|
-
"[object Error]",
|
|
14
|
-
"[object Boolean]",
|
|
15
|
-
"[object Number]",
|
|
16
|
-
"[object String]",
|
|
17
|
-
"[object BigInt]",
|
|
18
|
-
"[object ArrayBuffer]",
|
|
19
|
-
"[object SharedArrayBuffer]",
|
|
20
|
-
"[object DataView]"
|
|
21
|
-
]);
|
|
22
|
-
function intrinsicGetter(proto, prop) {
|
|
23
|
-
const get = Object.getOwnPropertyDescriptor(proto, prop)?.get;
|
|
24
|
-
if (!get) throw new Error(`missing intrinsic getter for ${prop}`);
|
|
25
|
-
return get;
|
|
26
|
-
}
|
|
27
|
-
__name(intrinsicGetter, "intrinsicGetter");
|
|
28
|
-
var dateGetTime = Date.prototype.getTime;
|
|
29
|
-
var mapSizeGet = intrinsicGetter(Map.prototype, "size");
|
|
30
|
-
var setSizeGet = intrinsicGetter(Set.prototype, "size");
|
|
31
|
-
var weakMapHas = WeakMap.prototype.has;
|
|
32
|
-
var weakSetHas = WeakSet.prototype.has;
|
|
33
|
-
var dataViewByteLengthGet = intrinsicGetter(DataView.prototype, "byteLength");
|
|
34
|
-
var arrayBufferByteLengthGet = intrinsicGetter(
|
|
35
|
-
ArrayBuffer.prototype,
|
|
36
|
-
"byteLength"
|
|
37
|
-
);
|
|
38
|
-
var sharedArrayBufferByteLengthGet = typeof SharedArrayBuffer === "undefined" ? void 0 : intrinsicGetter(SharedArrayBuffer.prototype, "byteLength");
|
|
39
|
-
var regExpSourceGet = intrinsicGetter(RegExp.prototype, "source");
|
|
40
|
-
var booleanValueOf = Boolean.prototype.valueOf;
|
|
41
|
-
var numberValueOf = Number.prototype.valueOf;
|
|
42
|
-
var stringValueOf = String.prototype.valueOf;
|
|
43
|
-
var bigIntValueOf = BigInt.prototype.valueOf;
|
|
44
|
-
var functionToString = Function.prototype.toString;
|
|
45
|
-
var PROBE_KEY = {};
|
|
46
|
-
var INTRINSIC_CONSTRUCTOR_NAMES = [
|
|
47
|
-
"Object",
|
|
48
|
-
"Array",
|
|
49
|
-
"Date",
|
|
50
|
-
"RegExp",
|
|
51
|
-
"Map",
|
|
52
|
-
"Set",
|
|
53
|
-
"WeakMap",
|
|
54
|
-
"WeakSet",
|
|
55
|
-
"Promise",
|
|
56
|
-
"Error",
|
|
57
|
-
"EvalError",
|
|
58
|
-
"RangeError",
|
|
59
|
-
"ReferenceError",
|
|
60
|
-
"SyntaxError",
|
|
61
|
-
"TypeError",
|
|
62
|
-
"URIError",
|
|
63
|
-
"AggregateError",
|
|
64
|
-
"Boolean",
|
|
65
|
-
"Number",
|
|
66
|
-
"String",
|
|
67
|
-
"BigInt",
|
|
68
|
-
"ArrayBuffer",
|
|
69
|
-
"SharedArrayBuffer",
|
|
70
|
-
"DataView",
|
|
71
|
-
"Int8Array",
|
|
72
|
-
"Uint8Array",
|
|
73
|
-
"Uint8ClampedArray",
|
|
74
|
-
"Int16Array",
|
|
75
|
-
"Uint16Array",
|
|
76
|
-
"Int32Array",
|
|
77
|
-
"Uint32Array",
|
|
78
|
-
"Float32Array",
|
|
79
|
-
"Float64Array",
|
|
80
|
-
"BigInt64Array",
|
|
81
|
-
"BigUint64Array"
|
|
82
|
-
];
|
|
83
|
-
var intrinsicConstructorSources = new Map(
|
|
84
|
-
INTRINSIC_CONSTRUCTOR_NAMES.flatMap((name) => {
|
|
85
|
-
const descriptor = Object.getOwnPropertyDescriptor(globalThis, name);
|
|
86
|
-
const intrinsic = descriptor?.value;
|
|
87
|
-
return typeof intrinsic === "function" ? [[name, functionToString.call(intrinsic)]] : [];
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
var intrinsicConstructorSourceSet = new Set(
|
|
91
|
-
intrinsicConstructorSources.values()
|
|
92
|
-
);
|
|
93
|
-
var ERROR_INTRINSIC_NAMES = [
|
|
94
|
-
"Error",
|
|
95
|
-
"EvalError",
|
|
96
|
-
"RangeError",
|
|
97
|
-
"ReferenceError",
|
|
98
|
-
"SyntaxError",
|
|
99
|
-
"TypeError",
|
|
100
|
-
"URIError",
|
|
101
|
-
"AggregateError"
|
|
102
|
-
];
|
|
103
|
-
function isIntrinsicConstructorPrototype(prototype, expectedName) {
|
|
104
|
-
const constructorDescriptor = Object.getOwnPropertyDescriptor(
|
|
105
|
-
prototype,
|
|
106
|
-
"constructor"
|
|
107
|
-
);
|
|
108
|
-
const candidateConstructor = constructorDescriptor?.value;
|
|
109
|
-
if (constructorDescriptor === void 0 || !("value" in constructorDescriptor) || typeof candidateConstructor !== "function") {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
let candidateSource;
|
|
113
|
-
try {
|
|
114
|
-
candidateSource = functionToString.call(candidateConstructor);
|
|
115
|
-
} catch {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
const expectedSource = expectedName === void 0 ? void 0 : intrinsicConstructorSources.get(expectedName);
|
|
119
|
-
if (expectedSource !== void 0 && candidateSource !== expectedSource || expectedSource === void 0 && !intrinsicConstructorSourceSet.has(candidateSource)) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
const nameDescriptor = Object.getOwnPropertyDescriptor(
|
|
123
|
-
candidateConstructor,
|
|
124
|
-
"name"
|
|
125
|
-
);
|
|
126
|
-
const candidateName = nameDescriptor !== void 0 && "value" in nameDescriptor && typeof nameDescriptor.value === "string" ? nameDescriptor.value : void 0;
|
|
127
|
-
const intrinsicName = expectedName ?? candidateName;
|
|
128
|
-
const intrinsicSource = intrinsicName === void 0 ? void 0 : intrinsicConstructorSources.get(intrinsicName);
|
|
129
|
-
return candidateName === intrinsicName && intrinsicSource !== void 0 && candidateSource === intrinsicSource && Object.getOwnPropertyDescriptor(candidateConstructor, "prototype")?.value === prototype;
|
|
130
|
-
}
|
|
131
|
-
__name(isIntrinsicConstructorPrototype, "isIntrinsicConstructorPrototype");
|
|
132
|
-
var REFERENCE_COMPARED_TAGS = /* @__PURE__ */ new Set([
|
|
133
|
-
"[object Error]",
|
|
134
|
-
"[object ArrayBuffer]",
|
|
135
|
-
"[object SharedArrayBuffer]",
|
|
136
|
-
"[object Promise]",
|
|
137
|
-
"[object WeakMap]",
|
|
138
|
-
"[object WeakSet]"
|
|
139
|
-
]);
|
|
140
|
-
function hasNativePrototype(value, expectedName) {
|
|
141
|
-
const visited = /* @__PURE__ */ new WeakSet();
|
|
142
|
-
let prototype = Object.getPrototypeOf(value);
|
|
143
|
-
while (prototype !== null && !visited.has(prototype)) {
|
|
144
|
-
visited.add(prototype);
|
|
145
|
-
if (isIntrinsicConstructorPrototype(prototype, expectedName)) {
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
prototype = Object.getPrototypeOf(prototype);
|
|
149
|
-
}
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
__name(hasNativePrototype, "hasNativePrototype");
|
|
153
|
-
function hasBrand(obj, tag) {
|
|
154
|
-
try {
|
|
155
|
-
switch (tag) {
|
|
156
|
-
case "[object Date]":
|
|
157
|
-
dateGetTime.call(obj);
|
|
158
|
-
return true;
|
|
159
|
-
case "[object RegExp]":
|
|
160
|
-
regExpSourceGet.call(obj);
|
|
161
|
-
return true;
|
|
162
|
-
case "[object Map]":
|
|
163
|
-
mapSizeGet.call(obj);
|
|
164
|
-
return true;
|
|
165
|
-
case "[object Set]":
|
|
166
|
-
setSizeGet.call(obj);
|
|
167
|
-
return true;
|
|
168
|
-
case "[object WeakMap]":
|
|
169
|
-
weakMapHas.call(obj, PROBE_KEY);
|
|
170
|
-
return true;
|
|
171
|
-
case "[object WeakSet]":
|
|
172
|
-
weakSetHas.call(obj, PROBE_KEY);
|
|
173
|
-
return true;
|
|
174
|
-
case "[object DataView]":
|
|
175
|
-
dataViewByteLengthGet.call(obj);
|
|
176
|
-
return true;
|
|
177
|
-
case "[object ArrayBuffer]":
|
|
178
|
-
arrayBufferByteLengthGet.call(obj);
|
|
179
|
-
return true;
|
|
180
|
-
case "[object SharedArrayBuffer]":
|
|
181
|
-
if (!sharedArrayBufferByteLengthGet) return false;
|
|
182
|
-
sharedArrayBufferByteLengthGet.call(obj);
|
|
183
|
-
return true;
|
|
184
|
-
case "[object Boolean]":
|
|
185
|
-
booleanValueOf.call(obj);
|
|
186
|
-
return true;
|
|
187
|
-
case "[object Number]":
|
|
188
|
-
numberValueOf.call(obj);
|
|
189
|
-
return true;
|
|
190
|
-
case "[object String]":
|
|
191
|
-
stringValueOf.call(obj);
|
|
192
|
-
return true;
|
|
193
|
-
case "[object BigInt]":
|
|
194
|
-
bigIntValueOf.call(obj);
|
|
195
|
-
return true;
|
|
196
|
-
case "[object Promise]":
|
|
197
|
-
return hasNativePrototype(obj, "Promise");
|
|
198
|
-
case "[object Error]":
|
|
199
|
-
return ERROR_INTRINSIC_NAMES.some(
|
|
200
|
-
(name) => hasNativePrototype(obj, name)
|
|
201
|
-
);
|
|
202
|
-
default:
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
} catch {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
__name(hasBrand, "hasBrand");
|
|
210
|
-
function isBuiltInObject(obj, tag) {
|
|
211
|
-
if (ArrayBuffer.isView(obj)) return true;
|
|
212
|
-
if (tag.endsWith("Array]")) return false;
|
|
213
|
-
return BUILT_IN_TAGS.has(tag) && hasBrand(obj, tag);
|
|
214
|
-
}
|
|
215
|
-
__name(isBuiltInObject, "isBuiltInObject");
|
|
216
|
-
|
|
217
|
-
// src/utils/array/deep-equal.ts
|
|
218
|
-
var objProto = Object.prototype;
|
|
219
|
-
var objToString = objProto.toString;
|
|
220
|
-
var objHasOwn = objProto.hasOwnProperty;
|
|
221
|
-
function sameValueZero(a, b) {
|
|
222
|
-
return a === b || Number.isNaN(a) && Number.isNaN(b);
|
|
223
|
-
}
|
|
224
|
-
__name(sameValueZero, "sameValueZero");
|
|
225
|
-
function deepEqual(a, b) {
|
|
226
|
-
return deepEqualInner(a, b, /* @__PURE__ */ new WeakMap());
|
|
227
|
-
}
|
|
228
|
-
__name(deepEqual, "deepEqual");
|
|
229
|
-
function deepEqualInner(a, b, visited) {
|
|
230
|
-
if (a === b) return true;
|
|
231
|
-
const typeA = typeof a;
|
|
232
|
-
const typeB = typeof b;
|
|
233
|
-
if (typeA !== "object" || a === null || typeB !== "object" || b === null) {
|
|
234
|
-
if (typeA === "number" && typeB === "number") {
|
|
235
|
-
return Number.isNaN(a) && Number.isNaN(b);
|
|
236
|
-
}
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
const objA = a;
|
|
240
|
-
const objB = b;
|
|
241
|
-
let cachedBs = visited.get(objA);
|
|
242
|
-
if (cachedBs?.has(objB)) {
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
if (!cachedBs) {
|
|
246
|
-
cachedBs = /* @__PURE__ */ new WeakSet();
|
|
247
|
-
visited.set(objA, cachedBs);
|
|
248
|
-
}
|
|
249
|
-
cachedBs.add(objB);
|
|
250
|
-
if (ArrayBuffer.isView(objA) || ArrayBuffer.isView(objB)) {
|
|
251
|
-
if (!ArrayBuffer.isView(objA) || !ArrayBuffer.isView(objB)) return false;
|
|
252
|
-
const tagA2 = objToString.call(objA);
|
|
253
|
-
const tagB2 = objToString.call(objB);
|
|
254
|
-
if (tagA2 !== tagB2) return false;
|
|
255
|
-
if (tagA2 === "[object DataView]") {
|
|
256
|
-
const viewA = objA;
|
|
257
|
-
const viewB = objB;
|
|
258
|
-
if (viewA.byteLength !== viewB.byteLength) return false;
|
|
259
|
-
const len2 = viewA.byteLength;
|
|
260
|
-
for (let i = 0; i < len2; i++) {
|
|
261
|
-
if (viewA.getUint8(i) !== viewB.getUint8(i)) return false;
|
|
262
|
-
}
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
const arrA = objA;
|
|
266
|
-
const arrB = objB;
|
|
267
|
-
const len = arrA.length;
|
|
268
|
-
if (len !== arrB.length) return false;
|
|
269
|
-
for (let i = 0; i < len; i++) {
|
|
270
|
-
if (!sameValueZero(arrA[i], arrB[i])) return false;
|
|
271
|
-
}
|
|
272
|
-
return true;
|
|
273
|
-
}
|
|
274
|
-
if (Array.isArray(objA) || Array.isArray(objB)) {
|
|
275
|
-
if (!Array.isArray(objA) || !Array.isArray(objB)) return false;
|
|
276
|
-
if (objA.length !== objB.length) return false;
|
|
277
|
-
const keysA = Reflect.ownKeys(objA).filter((key) => key !== "length");
|
|
278
|
-
const keysB = Reflect.ownKeys(objB).filter((key) => key !== "length");
|
|
279
|
-
if (keysA.length !== keysB.length) return false;
|
|
280
|
-
const arrA = objA;
|
|
281
|
-
const arrB = objB;
|
|
282
|
-
for (const key of keysA) {
|
|
283
|
-
if (!objHasOwn.call(objB, key)) return false;
|
|
284
|
-
if (!deepEqualInner(arrA[key], arrB[key], visited)) {
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
const tagA = objToString.call(objA);
|
|
291
|
-
const tagB = objToString.call(objB);
|
|
292
|
-
if (tagA !== tagB) return false;
|
|
293
|
-
const builtInA = isBuiltInObject(objA, tagA);
|
|
294
|
-
const builtInB = isBuiltInObject(objB, tagB);
|
|
295
|
-
if (builtInA !== builtInB) return false;
|
|
296
|
-
if (!builtInA) {
|
|
297
|
-
return comparePlainObjects(objA, objB, visited);
|
|
298
|
-
}
|
|
299
|
-
switch (tagA) {
|
|
300
|
-
case "[object Map]": {
|
|
301
|
-
const mapA = objA;
|
|
302
|
-
const mapB = objB;
|
|
303
|
-
if (mapA.size !== mapB.size) return false;
|
|
304
|
-
for (const [key, valA] of mapA) {
|
|
305
|
-
if (!mapB.has(key)) return false;
|
|
306
|
-
const valB = mapB.get(key);
|
|
307
|
-
if (!deepEqualInner(valA, valB, visited)) return false;
|
|
308
|
-
}
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
311
|
-
case "[object Set]": {
|
|
312
|
-
const setA = objA;
|
|
313
|
-
const setB = objB;
|
|
314
|
-
if (setA.size !== setB.size) return false;
|
|
315
|
-
for (const value of setA) {
|
|
316
|
-
if (!setB.has(value)) return false;
|
|
317
|
-
}
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
|
-
case "[object Date]": {
|
|
321
|
-
return sameValueZero(objA.getTime(), objB.getTime());
|
|
322
|
-
}
|
|
323
|
-
case "[object RegExp]": {
|
|
324
|
-
const regA = objA;
|
|
325
|
-
const regB = objB;
|
|
326
|
-
return regA.source === regB.source && regA.flags === regB.flags;
|
|
327
|
-
}
|
|
328
|
-
case "[object Boolean]":
|
|
329
|
-
case "[object Number]":
|
|
330
|
-
case "[object String]":
|
|
331
|
-
case "[object BigInt]": {
|
|
332
|
-
return sameValueZero(
|
|
333
|
-
objA.valueOf(),
|
|
334
|
-
objB.valueOf()
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
default: {
|
|
338
|
-
return objA === objB;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
__name(deepEqualInner, "deepEqualInner");
|
|
343
|
-
function comparePlainObjects(objA, objB, visited) {
|
|
344
|
-
const recA = objA;
|
|
345
|
-
const recB = objB;
|
|
346
|
-
const stringKeysA = Object.getOwnPropertyNames(objA);
|
|
347
|
-
const stringKeysB = Object.getOwnPropertyNames(objB);
|
|
348
|
-
if (stringKeysA.length !== stringKeysB.length) return false;
|
|
349
|
-
const symbolKeysA = Object.getOwnPropertySymbols(objA);
|
|
350
|
-
const symbolKeysB = Object.getOwnPropertySymbols(objB);
|
|
351
|
-
if (symbolKeysA.length !== symbolKeysB.length) return false;
|
|
352
|
-
const symbolKeysBSet = new Set(symbolKeysB);
|
|
353
|
-
for (const key of stringKeysA) {
|
|
354
|
-
if (!objHasOwn.call(objB, key)) return false;
|
|
355
|
-
}
|
|
356
|
-
for (const key of symbolKeysA) {
|
|
357
|
-
if (!symbolKeysBSet.has(key)) return false;
|
|
358
|
-
}
|
|
359
|
-
for (const key of stringKeysA) {
|
|
360
|
-
if (!deepEqualInner(recA[key], recB[key], visited)) {
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
for (const key of symbolKeysA) {
|
|
365
|
-
if (!deepEqualInner(recA[key], recB[key], visited)) {
|
|
366
|
-
return false;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return true;
|
|
370
|
-
}
|
|
371
|
-
__name(comparePlainObjects, "comparePlainObjects");
|
|
372
|
-
|
|
373
|
-
// src/utils/array/deep-omit.ts
|
|
374
|
-
function deepOmit(value, options) {
|
|
375
|
-
const visited = /* @__PURE__ */ new WeakMap();
|
|
376
|
-
const ignoreKeys = options.ignoreKeys ? new Set(options.ignoreKeys) : void 0;
|
|
377
|
-
const budget = options.ignoreKeyPredicate ? { visits: 0 } : void 0;
|
|
378
|
-
return omitInternal(value, options, ignoreKeys, [], visited, budget);
|
|
379
|
-
}
|
|
380
|
-
__name(deepOmit, "deepOmit");
|
|
381
|
-
var PATH_SENSITIVE_VISIT_BUDGET = 1e6;
|
|
382
|
-
function omitInternal(value, options, ignoreKeys, path, visited, budget) {
|
|
383
|
-
if (value === null) return value;
|
|
384
|
-
if (typeof value !== "object") return value;
|
|
385
|
-
const obj = value;
|
|
386
|
-
if (visited.has(obj)) {
|
|
387
|
-
return visited.get(obj);
|
|
388
|
-
}
|
|
389
|
-
if (budget && ++budget.visits > PATH_SENSITIVE_VISIT_BUDGET) {
|
|
390
|
-
throw new Error(
|
|
391
|
-
`deepOmit: exceeded ${PATH_SENSITIVE_VISIT_BUDGET} node visits. With ignoreKeyPredicate, objects reached via shared references are cloned once per path (the predicate may decide differently per path), which expands exponentially on diamond-shaped sharing. Restructure the input to a tree, or use ignoreKeys for path-independent filtering.`
|
|
392
|
-
);
|
|
393
|
-
}
|
|
394
|
-
if (Array.isArray(obj)) {
|
|
395
|
-
const arr = obj;
|
|
396
|
-
const clone2 = new Array(arr.length);
|
|
397
|
-
const lengthDescriptor = Object.getOwnPropertyDescriptor(arr, "length");
|
|
398
|
-
visited.set(obj, clone2);
|
|
399
|
-
for (const key of Reflect.ownKeys(arr)) {
|
|
400
|
-
if (key === "length") continue;
|
|
401
|
-
const segment = arrayPathSegment(key);
|
|
402
|
-
if (typeof segment !== "number" && shouldIgnoreKey(key, path, ignoreKeys, options)) {
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
const descriptor = Object.getOwnPropertyDescriptor(arr, key);
|
|
406
|
-
if (descriptor === void 0) continue;
|
|
407
|
-
path.push(segment);
|
|
408
|
-
if ("value" in descriptor) {
|
|
409
|
-
descriptor.value = omitInternal(
|
|
410
|
-
descriptor.value,
|
|
411
|
-
options,
|
|
412
|
-
ignoreKeys,
|
|
413
|
-
path,
|
|
414
|
-
visited,
|
|
415
|
-
budget
|
|
416
|
-
);
|
|
417
|
-
}
|
|
418
|
-
Object.defineProperty(clone2, key, descriptor);
|
|
419
|
-
path.pop();
|
|
420
|
-
}
|
|
421
|
-
if (lengthDescriptor !== void 0) {
|
|
422
|
-
Object.defineProperty(clone2, "length", lengthDescriptor);
|
|
423
|
-
}
|
|
424
|
-
if (budget) visited.delete(obj);
|
|
425
|
-
return clone2;
|
|
426
|
-
}
|
|
427
|
-
const tag = Object.prototype.toString.call(obj);
|
|
428
|
-
if (isBuiltInObject(obj, tag)) {
|
|
429
|
-
const builtInClone = cloneBuiltIn(obj, tag);
|
|
430
|
-
visited.set(obj, builtInClone);
|
|
431
|
-
return builtInClone;
|
|
432
|
-
}
|
|
433
|
-
const clone = Object.create(Object.getPrototypeOf(obj));
|
|
434
|
-
visited.set(obj, clone);
|
|
435
|
-
const stringKeys = Object.keys(obj);
|
|
436
|
-
const symbolKeys = Object.getOwnPropertySymbols(obj);
|
|
437
|
-
for (const key of stringKeys) {
|
|
438
|
-
if (shouldIgnoreKey(key, path, ignoreKeys, options)) continue;
|
|
439
|
-
path.push(key);
|
|
440
|
-
assignOwn(
|
|
441
|
-
clone,
|
|
442
|
-
key,
|
|
443
|
-
omitInternal(
|
|
444
|
-
obj[key],
|
|
445
|
-
options,
|
|
446
|
-
ignoreKeys,
|
|
447
|
-
path,
|
|
448
|
-
visited,
|
|
449
|
-
budget
|
|
450
|
-
)
|
|
451
|
-
);
|
|
452
|
-
path.pop();
|
|
453
|
-
}
|
|
454
|
-
for (const key of symbolKeys) {
|
|
455
|
-
if (shouldIgnoreKey(key, path, ignoreKeys, options)) continue;
|
|
456
|
-
path.push(key);
|
|
457
|
-
assignOwn(
|
|
458
|
-
clone,
|
|
459
|
-
key,
|
|
460
|
-
omitInternal(
|
|
461
|
-
obj[key],
|
|
462
|
-
options,
|
|
463
|
-
ignoreKeys,
|
|
464
|
-
path,
|
|
465
|
-
visited,
|
|
466
|
-
budget
|
|
467
|
-
)
|
|
468
|
-
);
|
|
469
|
-
path.pop();
|
|
470
|
-
}
|
|
471
|
-
if (budget) visited.delete(obj);
|
|
472
|
-
return clone;
|
|
473
|
-
}
|
|
474
|
-
__name(omitInternal, "omitInternal");
|
|
475
|
-
function arrayPathSegment(key) {
|
|
476
|
-
if (typeof key === "symbol") return key;
|
|
477
|
-
const index = Number(key);
|
|
478
|
-
return Number.isInteger(index) && index >= 0 && index < 4294967295 && String(index) === key ? index : key;
|
|
479
|
-
}
|
|
480
|
-
__name(arrayPathSegment, "arrayPathSegment");
|
|
481
|
-
function assignOwn(target, key, value) {
|
|
482
|
-
Object.defineProperty(target, key, {
|
|
483
|
-
value,
|
|
484
|
-
writable: true,
|
|
485
|
-
enumerable: true,
|
|
486
|
-
configurable: true
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
__name(assignOwn, "assignOwn");
|
|
490
|
-
function cloneBuiltIn(obj, tag) {
|
|
491
|
-
if (REFERENCE_COMPARED_TAGS.has(tag)) return obj;
|
|
492
|
-
switch (tag) {
|
|
493
|
-
case "[object Date]":
|
|
494
|
-
return new Date(obj.getTime());
|
|
495
|
-
case "[object RegExp]": {
|
|
496
|
-
const re = obj;
|
|
497
|
-
const copy = new RegExp(re.source, re.flags);
|
|
498
|
-
copy.lastIndex = re.lastIndex;
|
|
499
|
-
return copy;
|
|
500
|
-
}
|
|
501
|
-
case "[object Map]": {
|
|
502
|
-
const m = obj;
|
|
503
|
-
return new Map(m);
|
|
504
|
-
}
|
|
505
|
-
case "[object Set]": {
|
|
506
|
-
const s = obj;
|
|
507
|
-
return new Set(s);
|
|
508
|
-
}
|
|
509
|
-
default:
|
|
510
|
-
return structuredClone(obj);
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
__name(cloneBuiltIn, "cloneBuiltIn");
|
|
514
|
-
function shouldIgnoreKey(key, path, ignoreKeys, options) {
|
|
515
|
-
if (ignoreKeys?.has(key)) return true;
|
|
516
|
-
if (options.ignoreKeyPredicate?.(key, path)) return true;
|
|
517
|
-
return false;
|
|
518
|
-
}
|
|
519
|
-
__name(shouldIgnoreKey, "shouldIgnoreKey");
|
|
520
|
-
|
|
521
|
-
// src/utils/array/deep-equal-except.ts
|
|
522
|
-
function deepEqualExcept(a, b, options) {
|
|
523
|
-
const prunedA = deepOmit(a, options);
|
|
524
|
-
const prunedB = deepOmit(b, options);
|
|
525
|
-
return deepEqual(prunedA, prunedB);
|
|
526
|
-
}
|
|
527
|
-
__name(deepEqualExcept, "deepEqualExcept");
|
|
528
|
-
|
|
529
|
-
export { deepEqual, deepEqualExcept, deepOmit };
|
|
530
|
-
//# sourceMappingURL=utils.js.map
|
|
531
|
-
//# sourceMappingURL=utils.js.map
|
|
3
|
+
export { deepEqual, deepEqualExcept, deepOmit };
|