@fincity/kirun-js 1.1.7 → 1.3.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/__tests__/engine/runtime/expression/ExpressionEvaluationTest.ts +82 -1
- package/__tests__/engine/util/deepEqualTest.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/runtime/expression/ExpressionEvaluator.ts +82 -8
- package/src/engine/runtime/expression/Operation.ts +5 -0
- package/src/engine/runtime/expression/operators/binary/LogicalEqualOperator.ts +2 -7
- package/src/engine/runtime/expression/operators/binary/LogicalNotEqualOperator.ts +2 -7
- package/src/engine/runtime/expression/operators/binary/LogicalNullishCoalescingOperator.ts +8 -0
- package/src/engine/runtime/expression/operators/binary/index.ts +1 -0
- package/src/engine/util/Tuples.ts +49 -4
- package/src/engine/util/deepEqual.ts +49 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LinkedList } from './LinkedList';
|
|
2
|
+
|
|
3
|
+
export function deepEqual(x: any, y: any) {
|
|
4
|
+
let xa = new LinkedList();
|
|
5
|
+
xa.push(x);
|
|
6
|
+
let yb = new LinkedList();
|
|
7
|
+
yb.push(y);
|
|
8
|
+
|
|
9
|
+
while (!xa.isEmpty() && !yb.isEmpty()) {
|
|
10
|
+
const a: any = xa.pop();
|
|
11
|
+
const b: any = yb.pop();
|
|
12
|
+
|
|
13
|
+
if (a === b) continue;
|
|
14
|
+
|
|
15
|
+
const typeOfA = typeof a;
|
|
16
|
+
const typeOfB = typeof b;
|
|
17
|
+
|
|
18
|
+
if (typeOfA === 'undefined' || typeOfB === 'undefined') {
|
|
19
|
+
if (!a && !b) continue;
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (typeOfA !== typeOfB) return false;
|
|
24
|
+
|
|
25
|
+
if (Array.isArray(a)) {
|
|
26
|
+
if (!Array.isArray(b) || a.length != b.length) return false;
|
|
27
|
+
for (let i = 0; i < a.length; i++) {
|
|
28
|
+
xa.push(a[i]);
|
|
29
|
+
yb.push(b[i]);
|
|
30
|
+
}
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeOfA === 'object') {
|
|
35
|
+
const entriesOfA = Object.entries(a);
|
|
36
|
+
const entriesOfB = Object.entries(b);
|
|
37
|
+
if (entriesOfA.length !== entriesOfB.length) return false;
|
|
38
|
+
for (const [k, v] of entriesOfA) {
|
|
39
|
+
xa.push(v);
|
|
40
|
+
yb.push(b[k]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return true;
|
|
49
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './engine/util/string/StringFormatter';
|
|
|
10
10
|
export * from './engine/util/string/StringUtil';
|
|
11
11
|
export * from './engine/util/Tuples';
|
|
12
12
|
export * from './engine/util/ArrayUtil';
|
|
13
|
+
export * from './engine/util/deepEqual';
|
|
13
14
|
export * from './engine/runtime/StatementExecution';
|
|
14
15
|
export * from './engine/runtime/StatementMessage';
|
|
15
16
|
export * from './engine/runtime/ContextElement';
|