@rkmodules/rules 0.0.67 → 0.0.68
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/dist/index.cjs.js +225 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +224 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/lib/DataTree/index.d.ts +1 -0
- package/dist/lib/Primitives/List/cartesianGroups.d.ts +2 -0
- package/dist/lib/Primitives/Math/cos.d.ts +2 -0
- package/dist/lib/Primitives/Math/modulo.d.ts +2 -0
- package/dist/lib/Primitives/Math/pow.d.ts +2 -0
- package/dist/lib/Primitives/Math/sin.d.ts +2 -0
- package/dist/lib/Primitives/Math/sqrt.d.ts +2 -0
- package/dist/lib/Primitives/Math/tan.d.ts +2 -0
- package/dist/lib/Primitives/Tree/simplifyTree.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -138,7 +138,7 @@ var DISCARD = Symbol("DISCARD");
|
|
|
138
138
|
* @param tree
|
|
139
139
|
* @returns
|
|
140
140
|
*/
|
|
141
|
-
function simplifyTree(tree) {
|
|
141
|
+
function simplifyTree$1(tree) {
|
|
142
142
|
var keys = Object.keys(tree);
|
|
143
143
|
if (keys.length <= 1)
|
|
144
144
|
return tree; // ✅ Don't simplify if only one path
|
|
@@ -254,6 +254,9 @@ function broadCast(value) {
|
|
|
254
254
|
function getBranch(tree, path) {
|
|
255
255
|
return tree[path];
|
|
256
256
|
}
|
|
257
|
+
function getPaths(tree) {
|
|
258
|
+
return Object.keys(tree);
|
|
259
|
+
}
|
|
257
260
|
/**
|
|
258
261
|
* maps a tree, the tree branches are flatmapped, so if an array is returned for each item in the list, a flat list is returned
|
|
259
262
|
* @param tree
|
|
@@ -653,6 +656,8 @@ var add$1 = {
|
|
|
653
656
|
return __generator(this, function (_a) {
|
|
654
657
|
return [2 /*return*/, {
|
|
655
658
|
sum: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
|
|
659
|
+
if (itemA === undefined || itemB === undefined)
|
|
660
|
+
return DISCARD;
|
|
656
661
|
return itemA + itemB;
|
|
657
662
|
}, true),
|
|
658
663
|
}];
|
|
@@ -819,6 +824,29 @@ function getUnboundSymbols(expr, scope, extraBound) {
|
|
|
819
824
|
return Array.from(free).sort();
|
|
820
825
|
}
|
|
821
826
|
|
|
827
|
+
var cosDeg = {
|
|
828
|
+
name: "cosDeg",
|
|
829
|
+
label: "Cosine",
|
|
830
|
+
description: "Cosine of angle in degrees",
|
|
831
|
+
inputs: {
|
|
832
|
+
a: { type: "number", default: 0 },
|
|
833
|
+
},
|
|
834
|
+
outputs: {
|
|
835
|
+
cos: "number",
|
|
836
|
+
},
|
|
837
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
838
|
+
return __generator(this, function (_a) {
|
|
839
|
+
return [2 /*return*/, {
|
|
840
|
+
cos: mapTree(inputs.a, function (angle) {
|
|
841
|
+
if (angle === undefined)
|
|
842
|
+
return DISCARD;
|
|
843
|
+
return Math.cos((angle * Math.PI) / 180);
|
|
844
|
+
}),
|
|
845
|
+
}];
|
|
846
|
+
});
|
|
847
|
+
}); },
|
|
848
|
+
};
|
|
849
|
+
|
|
822
850
|
var divide = {
|
|
823
851
|
name: "divide",
|
|
824
852
|
label: "Divide",
|
|
@@ -834,6 +862,8 @@ var divide = {
|
|
|
834
862
|
return __generator(this, function (_a) {
|
|
835
863
|
return [2 /*return*/, {
|
|
836
864
|
quotient: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
|
|
865
|
+
if (itemA === undefined || itemB === undefined)
|
|
866
|
+
return DISCARD;
|
|
837
867
|
if (itemB === 0)
|
|
838
868
|
return DISCARD;
|
|
839
869
|
return itemA / itemB;
|
|
@@ -903,6 +933,30 @@ var lessThan = {
|
|
|
903
933
|
}); },
|
|
904
934
|
};
|
|
905
935
|
|
|
936
|
+
var modulo = {
|
|
937
|
+
name: "modulo",
|
|
938
|
+
label: "Modulo",
|
|
939
|
+
description: "Division remainder of two numbers",
|
|
940
|
+
inputs: {
|
|
941
|
+
a: { type: "number", default: 1 },
|
|
942
|
+
b: { type: "number", default: 1 },
|
|
943
|
+
},
|
|
944
|
+
outputs: {
|
|
945
|
+
mod: "number",
|
|
946
|
+
},
|
|
947
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
948
|
+
return __generator(this, function (_a) {
|
|
949
|
+
return [2 /*return*/, {
|
|
950
|
+
mod: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
|
|
951
|
+
if (itemA === undefined || itemB === undefined)
|
|
952
|
+
return DISCARD;
|
|
953
|
+
return itemA % itemB;
|
|
954
|
+
}, true),
|
|
955
|
+
}];
|
|
956
|
+
});
|
|
957
|
+
}); },
|
|
958
|
+
};
|
|
959
|
+
|
|
906
960
|
var multiply = {
|
|
907
961
|
name: "multiply",
|
|
908
962
|
label: "Multiply",
|
|
@@ -918,6 +972,8 @@ var multiply = {
|
|
|
918
972
|
return __generator(this, function (_a) {
|
|
919
973
|
return [2 /*return*/, {
|
|
920
974
|
product: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
|
|
975
|
+
if (itemA === undefined || itemB === undefined)
|
|
976
|
+
return DISCARD;
|
|
921
977
|
return itemA * itemB;
|
|
922
978
|
}, true),
|
|
923
979
|
}];
|
|
@@ -925,6 +981,78 @@ var multiply = {
|
|
|
925
981
|
}); },
|
|
926
982
|
};
|
|
927
983
|
|
|
984
|
+
var pow = {
|
|
985
|
+
name: "pow",
|
|
986
|
+
label: "Power",
|
|
987
|
+
description: "Power a number",
|
|
988
|
+
inputs: {
|
|
989
|
+
x: { type: "number", default: 0 },
|
|
990
|
+
n: { type: "number", default: 2 },
|
|
991
|
+
},
|
|
992
|
+
outputs: {
|
|
993
|
+
pow: "number",
|
|
994
|
+
},
|
|
995
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
996
|
+
return __generator(this, function (_a) {
|
|
997
|
+
return [2 /*return*/, {
|
|
998
|
+
pow: binaryOnTree(inputs.x, inputs.n, function (x, n) {
|
|
999
|
+
if (x === undefined || n === undefined)
|
|
1000
|
+
return DISCARD;
|
|
1001
|
+
return Math.pow(x, n);
|
|
1002
|
+
}),
|
|
1003
|
+
}];
|
|
1004
|
+
});
|
|
1005
|
+
}); },
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
var sinDeg = {
|
|
1009
|
+
name: "sinDeg",
|
|
1010
|
+
label: "Sine",
|
|
1011
|
+
description: "Sine of angle in degrees",
|
|
1012
|
+
inputs: {
|
|
1013
|
+
a: { type: "number", default: 0 },
|
|
1014
|
+
},
|
|
1015
|
+
outputs: {
|
|
1016
|
+
sin: "number",
|
|
1017
|
+
},
|
|
1018
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1019
|
+
return __generator(this, function (_a) {
|
|
1020
|
+
return [2 /*return*/, {
|
|
1021
|
+
sin: mapTree(inputs.a, function (angle) {
|
|
1022
|
+
if (angle === undefined)
|
|
1023
|
+
return DISCARD;
|
|
1024
|
+
return Math.sin((angle * Math.PI) / 180);
|
|
1025
|
+
}),
|
|
1026
|
+
}];
|
|
1027
|
+
});
|
|
1028
|
+
}); },
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
var sqrt = {
|
|
1032
|
+
name: "sqrt",
|
|
1033
|
+
label: "Square root",
|
|
1034
|
+
description: "Square root of a number",
|
|
1035
|
+
inputs: {
|
|
1036
|
+
x: { type: "number", default: 0 },
|
|
1037
|
+
},
|
|
1038
|
+
outputs: {
|
|
1039
|
+
sqrt: "number",
|
|
1040
|
+
},
|
|
1041
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1042
|
+
return __generator(this, function (_a) {
|
|
1043
|
+
return [2 /*return*/, {
|
|
1044
|
+
sqrt: mapTree(inputs.x, function (x) {
|
|
1045
|
+
if (x === undefined)
|
|
1046
|
+
return DISCARD;
|
|
1047
|
+
if (x < 0)
|
|
1048
|
+
return DISCARD;
|
|
1049
|
+
return Math.sqrt(x);
|
|
1050
|
+
}),
|
|
1051
|
+
}];
|
|
1052
|
+
});
|
|
1053
|
+
}); },
|
|
1054
|
+
};
|
|
1055
|
+
|
|
928
1056
|
var subtract$1 = {
|
|
929
1057
|
name: "subtract",
|
|
930
1058
|
label: "Subtract",
|
|
@@ -940,6 +1068,8 @@ var subtract$1 = {
|
|
|
940
1068
|
return __generator(this, function (_a) {
|
|
941
1069
|
return [2 /*return*/, {
|
|
942
1070
|
difference: binaryOnTree(inputs.a, inputs.b, function (itemA, itemB) {
|
|
1071
|
+
if (itemA === undefined || itemB === undefined)
|
|
1072
|
+
return DISCARD;
|
|
943
1073
|
return itemA - itemB;
|
|
944
1074
|
}, true),
|
|
945
1075
|
}];
|
|
@@ -947,6 +1077,29 @@ var subtract$1 = {
|
|
|
947
1077
|
}); },
|
|
948
1078
|
};
|
|
949
1079
|
|
|
1080
|
+
var tanDeg = {
|
|
1081
|
+
name: "tanDeg",
|
|
1082
|
+
label: "Tangent",
|
|
1083
|
+
description: "Tangent of angle in degrees",
|
|
1084
|
+
inputs: {
|
|
1085
|
+
a: { type: "number", default: 0 },
|
|
1086
|
+
},
|
|
1087
|
+
outputs: {
|
|
1088
|
+
tan: "number",
|
|
1089
|
+
},
|
|
1090
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1091
|
+
return __generator(this, function (_a) {
|
|
1092
|
+
return [2 /*return*/, {
|
|
1093
|
+
tan: mapTree(inputs.a, function (angle) {
|
|
1094
|
+
if (angle === undefined)
|
|
1095
|
+
return DISCARD;
|
|
1096
|
+
return Math.tan((angle * Math.PI) / 180);
|
|
1097
|
+
}),
|
|
1098
|
+
}];
|
|
1099
|
+
});
|
|
1100
|
+
}); },
|
|
1101
|
+
};
|
|
1102
|
+
|
|
950
1103
|
var _a$5;
|
|
951
1104
|
var primitives$5 = (_a$5 = {},
|
|
952
1105
|
_a$5[calc.name] = calc,
|
|
@@ -956,6 +1109,12 @@ var primitives$5 = (_a$5 = {},
|
|
|
956
1109
|
_a$5[subtract$1.name] = subtract$1,
|
|
957
1110
|
_a$5[multiply.name] = multiply,
|
|
958
1111
|
_a$5[divide.name] = divide,
|
|
1112
|
+
_a$5[modulo.name] = modulo,
|
|
1113
|
+
_a$5[sinDeg.name] = sinDeg,
|
|
1114
|
+
_a$5[cosDeg.name] = cosDeg,
|
|
1115
|
+
_a$5[tanDeg.name] = tanDeg,
|
|
1116
|
+
_a$5[sqrt.name] = sqrt,
|
|
1117
|
+
_a$5[pow.name] = pow,
|
|
959
1118
|
_a$5);
|
|
960
1119
|
|
|
961
1120
|
var filterList = {
|
|
@@ -1123,6 +1282,45 @@ var shiftList = {
|
|
|
1123
1282
|
}); },
|
|
1124
1283
|
};
|
|
1125
1284
|
|
|
1285
|
+
var cartesianGroups = {
|
|
1286
|
+
name: "cartesianGroups",
|
|
1287
|
+
label: "Cartesian Groups",
|
|
1288
|
+
description: "Duplicate groups such that all pairings are created.",
|
|
1289
|
+
inputs: {
|
|
1290
|
+
treeA: "any",
|
|
1291
|
+
treeB: "any",
|
|
1292
|
+
},
|
|
1293
|
+
params: {},
|
|
1294
|
+
outputs: {
|
|
1295
|
+
treeA: "any",
|
|
1296
|
+
treeB: "any",
|
|
1297
|
+
},
|
|
1298
|
+
impl: function (inputs, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1299
|
+
var pathsA, pathsB, treeA, treeB;
|
|
1300
|
+
return __generator(this, function (_a) {
|
|
1301
|
+
if (!inputs.treeA || !inputs.treeB) {
|
|
1302
|
+
return [2 /*return*/, {}];
|
|
1303
|
+
}
|
|
1304
|
+
pathsA = getPaths(inputs.treeA);
|
|
1305
|
+
pathsB = getPaths(inputs.treeB);
|
|
1306
|
+
treeA = {};
|
|
1307
|
+
treeB = {};
|
|
1308
|
+
pathsB.forEach(function (pathB, ib) {
|
|
1309
|
+
pathsA.forEach(function (pathA, ia) {
|
|
1310
|
+
var pa = "".concat(ib, ";").concat(pathA);
|
|
1311
|
+
treeA[pa] = inputs.treeA[pathA];
|
|
1312
|
+
var pb = "".concat(pathB, ";").concat(ia);
|
|
1313
|
+
treeB[pb] = inputs.treeB[pathB];
|
|
1314
|
+
});
|
|
1315
|
+
});
|
|
1316
|
+
return [2 /*return*/, {
|
|
1317
|
+
treeA: treeA,
|
|
1318
|
+
treeB: treeB,
|
|
1319
|
+
}];
|
|
1320
|
+
});
|
|
1321
|
+
}); },
|
|
1322
|
+
};
|
|
1323
|
+
|
|
1126
1324
|
var _a$4;
|
|
1127
1325
|
var primitives$4 = (_a$4 = {},
|
|
1128
1326
|
_a$4[splitGroup.name] = splitGroup,
|
|
@@ -1131,6 +1329,7 @@ var primitives$4 = (_a$4 = {},
|
|
|
1131
1329
|
_a$4[listLength.name] = listLength,
|
|
1132
1330
|
_a$4[filterList.name] = filterList,
|
|
1133
1331
|
_a$4[shiftList.name] = shiftList,
|
|
1332
|
+
_a$4[cartesianGroups.name] = cartesianGroups,
|
|
1134
1333
|
_a$4);
|
|
1135
1334
|
|
|
1136
1335
|
var series = {
|
|
@@ -1202,9 +1401,32 @@ var mergeTree = {
|
|
|
1202
1401
|
}); },
|
|
1203
1402
|
};
|
|
1204
1403
|
|
|
1404
|
+
var simplifyTree = {
|
|
1405
|
+
name: "simplifyTree",
|
|
1406
|
+
label: "Simplify Tree",
|
|
1407
|
+
description: "Simplify a tree by removing redundant groups.",
|
|
1408
|
+
inputs: {
|
|
1409
|
+
tree: "any",
|
|
1410
|
+
},
|
|
1411
|
+
outputs: {
|
|
1412
|
+
tree: "any",
|
|
1413
|
+
},
|
|
1414
|
+
impl: function (inputs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1415
|
+
return __generator(this, function (_a) {
|
|
1416
|
+
if (!inputs.tree) {
|
|
1417
|
+
return [2 /*return*/, {}];
|
|
1418
|
+
}
|
|
1419
|
+
return [2 /*return*/, {
|
|
1420
|
+
tree: simplifyTree$1(inputs.tree),
|
|
1421
|
+
}];
|
|
1422
|
+
});
|
|
1423
|
+
}); },
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1205
1426
|
var _a$2;
|
|
1206
1427
|
var primitives$2 = (_a$2 = {},
|
|
1207
1428
|
_a$2[mergeTree.name] = mergeTree,
|
|
1429
|
+
_a$2[simplifyTree.name] = simplifyTree,
|
|
1208
1430
|
_a$2);
|
|
1209
1431
|
|
|
1210
1432
|
var groupAnd = {
|
|
@@ -6165,6 +6387,7 @@ exports.binaryOnTreeBranch = binaryOnTreeBranch;
|
|
|
6165
6387
|
exports.broadCast = broadCast;
|
|
6166
6388
|
exports.expandTree = expandTree;
|
|
6167
6389
|
exports.getBranch = getBranch;
|
|
6390
|
+
exports.getPaths = getPaths;
|
|
6168
6391
|
exports.getReferences = getReferences;
|
|
6169
6392
|
exports.getValue = getValue$1;
|
|
6170
6393
|
exports.graftTree = graftTree;
|
|
@@ -6181,7 +6404,7 @@ exports.normalizeVarDef = normalizeVarDef;
|
|
|
6181
6404
|
exports.parseReference = parseReference;
|
|
6182
6405
|
exports.primitives = primitives;
|
|
6183
6406
|
exports.sameShape = sameShape;
|
|
6184
|
-
exports.simplifyTree = simplifyTree;
|
|
6407
|
+
exports.simplifyTree = simplifyTree$1;
|
|
6185
6408
|
exports.toArray = toArray;
|
|
6186
6409
|
exports.topSort = topSort;
|
|
6187
6410
|
exports.treeSize = treeSize;
|