@mojir/lits 2.1.12 → 2.1.13
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/cli/cli.js +460 -54
- package/dist/cli/reference/api.d.ts +4 -4
- package/dist/cli/reference/index.d.ts +7 -1
- package/dist/index.esm.js +422 -48
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +422 -48
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +422 -48
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +4 -4
- package/dist/reference/index.d.ts +7 -1
- package/dist/testFramework.esm.js +211 -16
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +211 -16
- package/dist/testFramework.js.map +1 -1
- package/package.json +2 -2
package/dist/testFramework.js
CHANGED
|
@@ -448,6 +448,8 @@ function isNumber(value, options) {
|
|
|
448
448
|
if (options === void 0) { options = {}; }
|
|
449
449
|
if (typeof value !== 'number')
|
|
450
450
|
return false;
|
|
451
|
+
if (Number.isNaN(value))
|
|
452
|
+
return false;
|
|
451
453
|
if (options.integer && !Number.isInteger(value))
|
|
452
454
|
return false;
|
|
453
455
|
if (options.finite && !Number.isFinite(value))
|
|
@@ -1068,6 +1070,35 @@ var collectionNormalExpression = {
|
|
|
1068
1070
|
},
|
|
1069
1071
|
paramCount: 2,
|
|
1070
1072
|
},
|
|
1073
|
+
'filteri': {
|
|
1074
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1075
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1076
|
+
var executeFunction = _b.executeFunction;
|
|
1077
|
+
assertColl(coll, sourceCodeInfo);
|
|
1078
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1079
|
+
if (Array.isArray(coll)) {
|
|
1080
|
+
var result = coll.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
1081
|
+
return result;
|
|
1082
|
+
}
|
|
1083
|
+
if (isString(coll)) {
|
|
1084
|
+
return coll
|
|
1085
|
+
.split('')
|
|
1086
|
+
.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
1087
|
+
.join('');
|
|
1088
|
+
}
|
|
1089
|
+
return Object.entries(coll)
|
|
1090
|
+
.filter(function (_a) {
|
|
1091
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1092
|
+
return executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
1093
|
+
})
|
|
1094
|
+
.reduce(function (result, _a) {
|
|
1095
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1096
|
+
result[key] = value;
|
|
1097
|
+
return result;
|
|
1098
|
+
}, {});
|
|
1099
|
+
},
|
|
1100
|
+
paramCount: 2,
|
|
1101
|
+
},
|
|
1071
1102
|
'map': {
|
|
1072
1103
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1073
1104
|
var executeFunction = _a.executeFunction;
|
|
@@ -1110,6 +1141,30 @@ var collectionNormalExpression = {
|
|
|
1110
1141
|
},
|
|
1111
1142
|
paramCount: { min: 2 },
|
|
1112
1143
|
},
|
|
1144
|
+
'mapi': {
|
|
1145
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1146
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1147
|
+
var executeFunction = _b.executeFunction;
|
|
1148
|
+
assertColl(coll, sourceCodeInfo);
|
|
1149
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1150
|
+
if (Array.isArray(coll)) {
|
|
1151
|
+
return coll.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
1152
|
+
}
|
|
1153
|
+
if (isString(coll)) {
|
|
1154
|
+
return coll
|
|
1155
|
+
.split('')
|
|
1156
|
+
.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
1157
|
+
.join('');
|
|
1158
|
+
}
|
|
1159
|
+
return Object.entries(coll)
|
|
1160
|
+
.reduce(function (acc, _a) {
|
|
1161
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1162
|
+
acc[key] = executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
1163
|
+
return acc;
|
|
1164
|
+
}, {});
|
|
1165
|
+
},
|
|
1166
|
+
paramCount: 2,
|
|
1167
|
+
},
|
|
1113
1168
|
'reduce': {
|
|
1114
1169
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1115
1170
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1143,6 +1198,39 @@ var collectionNormalExpression = {
|
|
|
1143
1198
|
},
|
|
1144
1199
|
paramCount: 3,
|
|
1145
1200
|
},
|
|
1201
|
+
'reducei': {
|
|
1202
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1203
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1204
|
+
var executeFunction = _b.executeFunction;
|
|
1205
|
+
assertColl(coll, sourceCodeInfo);
|
|
1206
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1207
|
+
assertAny(initial, sourceCodeInfo);
|
|
1208
|
+
if (typeof coll === 'string') {
|
|
1209
|
+
assertString(initial, sourceCodeInfo);
|
|
1210
|
+
if (coll.length === 0)
|
|
1211
|
+
return initial;
|
|
1212
|
+
return coll.split('').reduce(function (result, elem, index) {
|
|
1213
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1214
|
+
}, initial);
|
|
1215
|
+
}
|
|
1216
|
+
else if (Array.isArray(coll)) {
|
|
1217
|
+
if (coll.length === 0)
|
|
1218
|
+
return initial;
|
|
1219
|
+
return coll.reduce(function (result, elem, index) {
|
|
1220
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1221
|
+
}, initial);
|
|
1222
|
+
}
|
|
1223
|
+
else {
|
|
1224
|
+
if (Object.keys(coll).length === 0)
|
|
1225
|
+
return initial;
|
|
1226
|
+
return Object.entries(coll).reduce(function (result, _a) {
|
|
1227
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1228
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1229
|
+
}, initial);
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
paramCount: 3,
|
|
1233
|
+
},
|
|
1146
1234
|
'reduce-right': {
|
|
1147
1235
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1148
1236
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1175,6 +1263,38 @@ var collectionNormalExpression = {
|
|
|
1175
1263
|
},
|
|
1176
1264
|
paramCount: 3,
|
|
1177
1265
|
},
|
|
1266
|
+
'reducei-right': {
|
|
1267
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1268
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1269
|
+
var executeFunction = _b.executeFunction;
|
|
1270
|
+
assertColl(coll, sourceCodeInfo);
|
|
1271
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1272
|
+
assertAny(initial, sourceCodeInfo);
|
|
1273
|
+
if (typeof coll === 'string') {
|
|
1274
|
+
if (coll.length === 0)
|
|
1275
|
+
return initial;
|
|
1276
|
+
return coll.split('').reduceRight(function (result, elem, index) {
|
|
1277
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1278
|
+
}, initial);
|
|
1279
|
+
}
|
|
1280
|
+
else if (Array.isArray(coll)) {
|
|
1281
|
+
if (coll.length === 0)
|
|
1282
|
+
return initial;
|
|
1283
|
+
return coll.reduceRight(function (result, elem, index) {
|
|
1284
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1285
|
+
}, initial);
|
|
1286
|
+
}
|
|
1287
|
+
else {
|
|
1288
|
+
if (Object.keys(coll).length === 0)
|
|
1289
|
+
return initial;
|
|
1290
|
+
return Object.entries(coll).reduceRight(function (result, _a) {
|
|
1291
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1292
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1293
|
+
}, initial);
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
paramCount: 3,
|
|
1297
|
+
},
|
|
1178
1298
|
'reductions': {
|
|
1179
1299
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1180
1300
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1221,6 +1341,52 @@ var collectionNormalExpression = {
|
|
|
1221
1341
|
},
|
|
1222
1342
|
paramCount: 3,
|
|
1223
1343
|
},
|
|
1344
|
+
'reductionsi': {
|
|
1345
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1346
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1347
|
+
var executeFunction = _b.executeFunction;
|
|
1348
|
+
assertColl(coll, sourceCodeInfo);
|
|
1349
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1350
|
+
assertAny(initial, sourceCodeInfo);
|
|
1351
|
+
assertAny(initial, sourceCodeInfo);
|
|
1352
|
+
if (typeof coll === 'string') {
|
|
1353
|
+
assertString(initial, sourceCodeInfo);
|
|
1354
|
+
if (coll.length === 0)
|
|
1355
|
+
return [initial];
|
|
1356
|
+
var resultArray_4 = [initial];
|
|
1357
|
+
coll.split('').reduce(function (result, elem, index) {
|
|
1358
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1359
|
+
resultArray_4.push(newVal);
|
|
1360
|
+
return newVal;
|
|
1361
|
+
}, initial);
|
|
1362
|
+
return resultArray_4;
|
|
1363
|
+
}
|
|
1364
|
+
else if (Array.isArray(coll)) {
|
|
1365
|
+
if (coll.length === 0)
|
|
1366
|
+
return [initial];
|
|
1367
|
+
var resultArray_5 = [initial];
|
|
1368
|
+
coll.reduce(function (result, elem, index) {
|
|
1369
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1370
|
+
resultArray_5.push(newVal);
|
|
1371
|
+
return newVal;
|
|
1372
|
+
}, initial);
|
|
1373
|
+
return resultArray_5;
|
|
1374
|
+
}
|
|
1375
|
+
else {
|
|
1376
|
+
if (Object.keys(coll).length === 0)
|
|
1377
|
+
return [initial];
|
|
1378
|
+
var resultArray_6 = [initial];
|
|
1379
|
+
Object.entries(coll).reduce(function (result, _a) {
|
|
1380
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1381
|
+
var newVal = executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1382
|
+
resultArray_6.push(newVal);
|
|
1383
|
+
return newVal;
|
|
1384
|
+
}, initial);
|
|
1385
|
+
return resultArray_6;
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1388
|
+
paramCount: 3,
|
|
1389
|
+
},
|
|
1224
1390
|
'get': {
|
|
1225
1391
|
evaluate: function (params, sourceCodeInfo) {
|
|
1226
1392
|
var _a = __read(params, 2), coll = _a[0], key = _a[1];
|
|
@@ -1474,7 +1640,7 @@ var collectionNormalExpression = {
|
|
|
1474
1640
|
};
|
|
1475
1641
|
|
|
1476
1642
|
var arrayNormalExpression = {
|
|
1477
|
-
range: {
|
|
1643
|
+
'range': {
|
|
1478
1644
|
evaluate: function (params, sourceCodeInfo) {
|
|
1479
1645
|
var _a = __read(params, 3), first = _a[0], second = _a[1], third = _a[2];
|
|
1480
1646
|
var from;
|
|
@@ -1512,7 +1678,7 @@ var arrayNormalExpression = {
|
|
|
1512
1678
|
},
|
|
1513
1679
|
paramCount: { min: 1, max: 3 },
|
|
1514
1680
|
},
|
|
1515
|
-
repeat: {
|
|
1681
|
+
'repeat': {
|
|
1516
1682
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1517
1683
|
var _b = __read(_a, 2), value = _b[0], count = _b[1];
|
|
1518
1684
|
assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true });
|
|
@@ -1523,7 +1689,7 @@ var arrayNormalExpression = {
|
|
|
1523
1689
|
},
|
|
1524
1690
|
paramCount: 2,
|
|
1525
1691
|
},
|
|
1526
|
-
flatten: {
|
|
1692
|
+
'flatten': {
|
|
1527
1693
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1528
1694
|
var _b = __read(_a, 2), seq = _b[0], depth = _b[1];
|
|
1529
1695
|
assertArray(seq, sourceCodeInfo);
|
|
@@ -1534,7 +1700,7 @@ var arrayNormalExpression = {
|
|
|
1534
1700
|
},
|
|
1535
1701
|
paramCount: { min: 1, max: 2 },
|
|
1536
1702
|
},
|
|
1537
|
-
mapcat: {
|
|
1703
|
+
'mapcat': {
|
|
1538
1704
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1539
1705
|
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1540
1706
|
var executeFunction = _b.executeFunction;
|
|
@@ -1544,6 +1710,38 @@ var arrayNormalExpression = {
|
|
|
1544
1710
|
},
|
|
1545
1711
|
paramCount: 2,
|
|
1546
1712
|
},
|
|
1713
|
+
'moving-fn': {
|
|
1714
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1715
|
+
var _c = __read(_a, 3), arr = _c[0], windowSize = _c[1], fn = _c[2];
|
|
1716
|
+
var executeFunction = _b.executeFunction;
|
|
1717
|
+
assertArray(arr, sourceCodeInfo);
|
|
1718
|
+
assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length });
|
|
1719
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1720
|
+
var result = [];
|
|
1721
|
+
for (var i = 0; i <= arr.length - windowSize; i++) {
|
|
1722
|
+
var window_1 = arr.slice(i, i + windowSize);
|
|
1723
|
+
var value = executeFunction(fn, [window_1], contextStack, sourceCodeInfo);
|
|
1724
|
+
result.push(value);
|
|
1725
|
+
}
|
|
1726
|
+
return result;
|
|
1727
|
+
},
|
|
1728
|
+
paramCount: 3,
|
|
1729
|
+
},
|
|
1730
|
+
'running-fn': {
|
|
1731
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1732
|
+
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1733
|
+
var executeFunction = _b.executeFunction;
|
|
1734
|
+
assertArray(arr, sourceCodeInfo);
|
|
1735
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1736
|
+
var result = [];
|
|
1737
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
1738
|
+
var subArr = arr.slice(0, i + 1);
|
|
1739
|
+
result.push(executeFunction(fn, [subArr], contextStack, sourceCodeInfo));
|
|
1740
|
+
}
|
|
1741
|
+
return result;
|
|
1742
|
+
},
|
|
1743
|
+
paramCount: 2,
|
|
1744
|
+
},
|
|
1547
1745
|
};
|
|
1548
1746
|
|
|
1549
1747
|
var sequenceNormalExpression = {
|
|
@@ -2275,7 +2473,7 @@ function isVector(vector) {
|
|
|
2275
2473
|
if (vectors.has(vector)) {
|
|
2276
2474
|
return true;
|
|
2277
2475
|
}
|
|
2278
|
-
if (vector.every(function (elem) { return isNumber(elem
|
|
2476
|
+
if (vector.every(function (elem) { return isNumber(elem); })) {
|
|
2279
2477
|
annotatedArrays.add(vector);
|
|
2280
2478
|
vectors.add(vector);
|
|
2281
2479
|
return true;
|
|
@@ -2384,7 +2582,7 @@ function isMatrix(matrix) {
|
|
|
2384
2582
|
if (row.length !== nbrOfCols) {
|
|
2385
2583
|
return false;
|
|
2386
2584
|
}
|
|
2387
|
-
if (row.some(function (cell) { return !isNumber(cell
|
|
2585
|
+
if (row.some(function (cell) { return !isNumber(cell); })) {
|
|
2388
2586
|
return false;
|
|
2389
2587
|
}
|
|
2390
2588
|
}
|
|
@@ -3917,14 +4115,6 @@ var predicatesNormalExpression = {
|
|
|
3917
4115
|
},
|
|
3918
4116
|
paramCount: 1,
|
|
3919
4117
|
},
|
|
3920
|
-
'nan?': {
|
|
3921
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
3922
|
-
var _b = __read(_a, 1), value = _b[0];
|
|
3923
|
-
assertNumber(value, sourceCodeInfo);
|
|
3924
|
-
return Number.isNaN(value);
|
|
3925
|
-
},
|
|
3926
|
-
paramCount: 1,
|
|
3927
|
-
},
|
|
3928
4118
|
'positive-infinity?': {
|
|
3929
4119
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3930
4120
|
var _b = __read(_a, 1), value = _b[0];
|
|
@@ -12486,8 +12676,13 @@ function evaluateNode(node, contextStack) {
|
|
|
12486
12676
|
return contextStack.evaluateSymbol(node);
|
|
12487
12677
|
case NodeTypes.ReservedSymbol:
|
|
12488
12678
|
return evaluateReservedSymbol(node);
|
|
12489
|
-
case NodeTypes.NormalExpression:
|
|
12490
|
-
|
|
12679
|
+
case NodeTypes.NormalExpression: {
|
|
12680
|
+
var result = evaluateNormalExpression(node, contextStack);
|
|
12681
|
+
if (typeof result === 'number' && Number.isNaN(result)) {
|
|
12682
|
+
throw new LitsError('Number is NaN', node[2]);
|
|
12683
|
+
}
|
|
12684
|
+
return annotate(result);
|
|
12685
|
+
}
|
|
12491
12686
|
case NodeTypes.SpecialExpression:
|
|
12492
12687
|
return annotate(evaluateSpecialExpression(node, contextStack));
|
|
12493
12688
|
/* v8 ignore next 2 */
|