git.iko.soy/rowtype-yoga/purescript-backend-optimizer
on main help sign in
42 lines 955 B history raw
1import * as $runtime from "../runtime.js";
2const diffWithKeyAndIxE = (o1, as, fk, f1, f2, f3) => {
3 const o2 = {};
4 for (const i of $runtime.range(0, as.length)) {
5 const a = as[i];
6 const k = fk(a);
7 if (Object.hasOwn(o1, k)) {
8 const v2 = f1(k, i, o1[k], a);
9 o2[k] = v2;
10 continue;
11 }
12 const v2 = f3(k, i, a);
13 o2[k] = v2;
14 }
15 for (const k of Object.keys(o1)) {
16 if (Object.hasOwn(o2, k)) { continue; }
17 f2(k, o1[k]);
18 }
19 return o2;
20};
21const diffWithIxE = (a1, a2, f1, f2, f3) => {
22 const a3 = [];
23 const l1 = a1.length;
24 const l2 = a2.length;
25 for (const i of $runtime.range(0, l1 < l2 ? l2 : l1)) {
26 if (i < l1) {
27 if (i < l2) {
28 const v3 = f1(i, a1[i], a2[i]);
29 a3.push(v3);
30 continue;
31 }
32 f2(i, a1[i]);
33 continue;
34 }
35 if (i < l2) {
36 const v3 = f3(i, a2[i]);
37 a3.push(v3);
38 }
39 }
40 return a3;
41};
42export {diffWithIxE, diffWithKeyAndIxE};