@woosh/meep-engine 2.109.21 → 2.109.22
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/build/meep.cjs +57 -28
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +57 -28
- package/package.json +1 -1
- package/src/core/collection/array/isArraysEqualWithComparator.d.ts.map +1 -1
- package/src/core/collection/array/isArraysEqualWithComparator.js +3 -2
- package/src/core/model/object/objectDeepEquals.d.ts +1 -1
- package/src/core/model/object/objectDeepEquals.d.ts.map +1 -1
- package/src/core/model/object/objectDeepEquals.js +54 -26
package/build/meep.module.js
CHANGED
|
@@ -76726,9 +76726,10 @@ function planesEqual(a, b) {
|
|
|
76726
76726
|
* @param {T[]} a
|
|
76727
76727
|
* @param {T[]} b
|
|
76728
76728
|
* @param {function(T,T):boolean} elements_equal
|
|
76729
|
+
* @param {*} [element_equal_context]
|
|
76729
76730
|
* @returns {boolean}
|
|
76730
76731
|
*/
|
|
76731
|
-
function isArraysEqualWithComparator(a, b, elements_equal) {
|
|
76732
|
+
function isArraysEqualWithComparator(a, b, elements_equal, element_equal_context) {
|
|
76732
76733
|
if (a === b) {
|
|
76733
76734
|
// same object
|
|
76734
76735
|
return true;
|
|
@@ -76749,7 +76750,7 @@ function isArraysEqualWithComparator(a, b, elements_equal) {
|
|
|
76749
76750
|
const aE = a[i];
|
|
76750
76751
|
const bE = b[i];
|
|
76751
76752
|
|
|
76752
|
-
if (!elements_equal(aE, bE)) {
|
|
76753
|
+
if (!elements_equal.call(element_equal_context, aE, bE)) {
|
|
76753
76754
|
return false;
|
|
76754
76755
|
}
|
|
76755
76756
|
}
|
|
@@ -102535,9 +102536,16 @@ function easeInOutQuad(t) {
|
|
|
102535
102536
|
* @template A,B
|
|
102536
102537
|
* @param {A} a
|
|
102537
102538
|
* @param {B} b
|
|
102539
|
+
* @param {function(a:A, b:B):boolean} [value_equality_function] allows you to insert custom element comparison function
|
|
102540
|
+
* @param {*} [value_equality_function_context]
|
|
102538
102541
|
* @returns {boolean}
|
|
102539
102542
|
*/
|
|
102540
|
-
function objectDeepEquals(
|
|
102543
|
+
function objectDeepEquals(
|
|
102544
|
+
a, b,
|
|
102545
|
+
value_equality_function = objectDeepEquals,
|
|
102546
|
+
value_equality_function_context = null
|
|
102547
|
+
) {
|
|
102548
|
+
|
|
102541
102549
|
if (a === b) {
|
|
102542
102550
|
// identity shortcut
|
|
102543
102551
|
return true;
|
|
@@ -102553,43 +102561,64 @@ function objectDeepEquals(a, b) {
|
|
|
102553
102561
|
if (tA !== "object") {
|
|
102554
102562
|
// primitive types, identity equality already checked
|
|
102555
102563
|
return false;
|
|
102556
|
-
}
|
|
102564
|
+
}
|
|
102557
102565
|
|
|
102558
|
-
|
|
102559
|
-
|
|
102566
|
+
if (a === null || b === null) {
|
|
102567
|
+
// we know that A and B are not the same, so if one of them is a null - there is no possible equality
|
|
102568
|
+
return false;
|
|
102569
|
+
}
|
|
102570
|
+
|
|
102571
|
+
if (Array.isArray(a)) {
|
|
102572
|
+
// special fast path for arrays
|
|
102573
|
+
if (!Array.isArray(b)) {
|
|
102574
|
+
// one is an array, the other is not
|
|
102560
102575
|
return false;
|
|
102561
102576
|
}
|
|
102577
|
+
return isArraysEqualWithComparator(a, b, value_equality_function, value_equality_function_context);
|
|
102578
|
+
}
|
|
102562
102579
|
|
|
102563
|
-
|
|
102564
|
-
|
|
102565
|
-
|
|
102566
|
-
|
|
102567
|
-
|
|
102568
|
-
|
|
102569
|
-
|
|
102570
|
-
}
|
|
102580
|
+
// try equals function
|
|
102581
|
+
if (
|
|
102582
|
+
typeof a.equals === "function"
|
|
102583
|
+
&& typeof b.equals === "function"
|
|
102584
|
+
) {
|
|
102585
|
+
return a.equals(b);
|
|
102586
|
+
}
|
|
102571
102587
|
|
|
102572
|
-
|
|
102573
|
-
|
|
102588
|
+
const keys_a = Object.keys(a);
|
|
102589
|
+
const keys_b = Object.keys(b);
|
|
102574
102590
|
|
|
102575
|
-
|
|
102576
|
-
|
|
102577
|
-
|
|
102578
|
-
}
|
|
102591
|
+
// sort keys to eliminate ordering concerns
|
|
102592
|
+
keys_a.sort();
|
|
102593
|
+
keys_b.sort();
|
|
102579
102594
|
|
|
102580
|
-
|
|
102595
|
+
if (!isArrayEqualStrict(keys_a, keys_b)) {
|
|
102596
|
+
// different fields
|
|
102597
|
+
return false;
|
|
102598
|
+
}
|
|
102581
102599
|
|
|
102582
|
-
|
|
102583
|
-
const key = keys_a[i];
|
|
102600
|
+
const key_count = keys_a.length;
|
|
102584
102601
|
|
|
102585
|
-
|
|
102586
|
-
|
|
102587
|
-
}
|
|
102588
|
-
}
|
|
102602
|
+
for (let i = 0; i < key_count; i++) {
|
|
102603
|
+
const key = keys_a[i];
|
|
102589
102604
|
|
|
102590
|
-
|
|
102605
|
+
const a_value = a[key];
|
|
102606
|
+
const b_value = b[key];
|
|
102591
102607
|
|
|
102608
|
+
const values_are_equal = value_equality_function.call(
|
|
102609
|
+
value_equality_function_context,
|
|
102610
|
+
a_value,
|
|
102611
|
+
b_value
|
|
102612
|
+
);
|
|
102613
|
+
|
|
102614
|
+
if (!values_are_equal) {
|
|
102615
|
+
return false;
|
|
102616
|
+
}
|
|
102592
102617
|
}
|
|
102618
|
+
|
|
102619
|
+
// looks like we have equality
|
|
102620
|
+
return true;
|
|
102621
|
+
|
|
102593
102622
|
}
|
|
102594
102623
|
|
|
102595
102624
|
/**
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isArraysEqualWithComparator.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/isArraysEqualWithComparator.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"isArraysEqualWithComparator.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/isArraysEqualWithComparator.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qGAJyB,OAAO,gCAEnB,OAAO,CA6BnB"}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* @param {T[]} a
|
|
4
4
|
* @param {T[]} b
|
|
5
5
|
* @param {function(T,T):boolean} elements_equal
|
|
6
|
+
* @param {*} [element_equal_context]
|
|
6
7
|
* @returns {boolean}
|
|
7
8
|
*/
|
|
8
|
-
export function isArraysEqualWithComparator(a, b, elements_equal) {
|
|
9
|
+
export function isArraysEqualWithComparator(a, b, elements_equal, element_equal_context) {
|
|
9
10
|
if (a === b) {
|
|
10
11
|
// same object
|
|
11
12
|
return true;
|
|
@@ -26,7 +27,7 @@ export function isArraysEqualWithComparator(a, b, elements_equal) {
|
|
|
26
27
|
const aE = a[i];
|
|
27
28
|
const bE = b[i];
|
|
28
29
|
|
|
29
|
-
if (!elements_equal(aE, bE)) {
|
|
30
|
+
if (!elements_equal.call(element_equal_context, aE, bE)) {
|
|
30
31
|
return false;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function objectDeepEquals(a:
|
|
1
|
+
export function objectDeepEquals<A extends object, B extends object>(a: A, b: B, value_equals: (a: A, b: B) => boolean, value_equals_context?: any): boolean
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectDeepEquals.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/object/objectDeepEquals.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"objectDeepEquals.d.ts","sourceRoot":"","sources":["../../../../../src/core/model/object/objectDeepEquals.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,8IAFa,OAAO,CAiFnB"}
|
|
@@ -5,9 +5,16 @@ import { isArraysEqualWithComparator } from "../../collection/array/isArraysEqua
|
|
|
5
5
|
* @template A,B
|
|
6
6
|
* @param {A} a
|
|
7
7
|
* @param {B} b
|
|
8
|
+
* @param {function(a:A, b:B):boolean} [value_equality_function] allows you to insert custom element comparison function
|
|
9
|
+
* @param {*} [value_equality_function_context]
|
|
8
10
|
* @returns {boolean}
|
|
9
11
|
*/
|
|
10
|
-
export function objectDeepEquals(
|
|
12
|
+
export function objectDeepEquals(
|
|
13
|
+
a, b,
|
|
14
|
+
value_equality_function = objectDeepEquals,
|
|
15
|
+
value_equality_function_context = null
|
|
16
|
+
) {
|
|
17
|
+
|
|
11
18
|
if (a === b) {
|
|
12
19
|
// identity shortcut
|
|
13
20
|
return true;
|
|
@@ -23,41 +30,62 @@ export function objectDeepEquals(a, b) {
|
|
|
23
30
|
if (tA !== "object") {
|
|
24
31
|
// primitive types, identity equality already checked
|
|
25
32
|
return false;
|
|
26
|
-
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (a === null || b === null) {
|
|
36
|
+
// we know that A and B are not the same, so if one of them is a null - there is no possible equality
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
if (Array.isArray(a)) {
|
|
41
|
+
// special fast path for arrays
|
|
42
|
+
if (!Array.isArray(b)) {
|
|
43
|
+
// one is an array, the other is not
|
|
30
44
|
return false;
|
|
31
45
|
}
|
|
46
|
+
return isArraysEqualWithComparator(a, b, value_equality_function, value_equality_function_context);
|
|
47
|
+
}
|
|
32
48
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
49
|
+
// try equals function
|
|
50
|
+
if (
|
|
51
|
+
typeof a.equals === "function"
|
|
52
|
+
&& typeof b.equals === "function"
|
|
53
|
+
) {
|
|
54
|
+
return a.equals(b);
|
|
55
|
+
}
|
|
41
56
|
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
const keys_a = Object.keys(a);
|
|
58
|
+
const keys_b = Object.keys(b);
|
|
44
59
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
60
|
+
// sort keys to eliminate ordering concerns
|
|
61
|
+
keys_a.sort();
|
|
62
|
+
keys_b.sort();
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
if (!isArrayEqualStrict(keys_a, keys_b)) {
|
|
65
|
+
// different fields
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
51
68
|
|
|
52
|
-
|
|
53
|
-
const key = keys_a[i];
|
|
69
|
+
const key_count = keys_a.length;
|
|
54
70
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}
|
|
71
|
+
for (let i = 0; i < key_count; i++) {
|
|
72
|
+
const key = keys_a[i];
|
|
59
73
|
|
|
60
|
-
|
|
74
|
+
const a_value = a[key];
|
|
75
|
+
const b_value = b[key];
|
|
76
|
+
|
|
77
|
+
const values_are_equal = value_equality_function.call(
|
|
78
|
+
value_equality_function_context,
|
|
79
|
+
a_value,
|
|
80
|
+
b_value
|
|
81
|
+
);
|
|
61
82
|
|
|
83
|
+
if (!values_are_equal) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
62
86
|
}
|
|
87
|
+
|
|
88
|
+
// looks like we have equality
|
|
89
|
+
return true;
|
|
90
|
+
|
|
63
91
|
}
|