@mojir/lits 2.1.11 → 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 +492 -72
- package/dist/cli/reference/api.d.ts +4 -4
- package/dist/cli/reference/index.d.ts +7 -1
- package/dist/cli/src/tokenizer/operators.d.ts +1 -1
- package/dist/index.esm.js +454 -66
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +454 -66
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +454 -66
- 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/src/tokenizer/operators.d.ts +1 -1
- package/dist/testFramework.esm.js +243 -34
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +243 -34
- package/dist/testFramework.js.map +1 -1
- package/package.json +2 -2
package/dist/cli/cli.js
CHANGED
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
var version = "2.1.
|
|
95
|
+
var version = "2.1.13";
|
|
96
96
|
|
|
97
97
|
function getCodeMarker(sourceCodeInfo) {
|
|
98
98
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -453,6 +453,8 @@ function isNumber(value, options) {
|
|
|
453
453
|
if (options === void 0) { options = {}; }
|
|
454
454
|
if (typeof value !== 'number')
|
|
455
455
|
return false;
|
|
456
|
+
if (Number.isNaN(value))
|
|
457
|
+
return false;
|
|
456
458
|
if (options.integer && !Number.isInteger(value))
|
|
457
459
|
return false;
|
|
458
460
|
if (options.finite && !Number.isFinite(value))
|
|
@@ -1088,6 +1090,35 @@ var collectionNormalExpression = {
|
|
|
1088
1090
|
},
|
|
1089
1091
|
paramCount: 2,
|
|
1090
1092
|
},
|
|
1093
|
+
'filteri': {
|
|
1094
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1095
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1096
|
+
var executeFunction = _b.executeFunction;
|
|
1097
|
+
assertColl(coll, sourceCodeInfo);
|
|
1098
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1099
|
+
if (Array.isArray(coll)) {
|
|
1100
|
+
var result = coll.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
1101
|
+
return result;
|
|
1102
|
+
}
|
|
1103
|
+
if (isString(coll)) {
|
|
1104
|
+
return coll
|
|
1105
|
+
.split('')
|
|
1106
|
+
.filter(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
1107
|
+
.join('');
|
|
1108
|
+
}
|
|
1109
|
+
return Object.entries(coll)
|
|
1110
|
+
.filter(function (_a) {
|
|
1111
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1112
|
+
return executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
1113
|
+
})
|
|
1114
|
+
.reduce(function (result, _a) {
|
|
1115
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1116
|
+
result[key] = value;
|
|
1117
|
+
return result;
|
|
1118
|
+
}, {});
|
|
1119
|
+
},
|
|
1120
|
+
paramCount: 2,
|
|
1121
|
+
},
|
|
1091
1122
|
'map': {
|
|
1092
1123
|
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1093
1124
|
var executeFunction = _a.executeFunction;
|
|
@@ -1130,6 +1161,30 @@ var collectionNormalExpression = {
|
|
|
1130
1161
|
},
|
|
1131
1162
|
paramCount: { min: 2 },
|
|
1132
1163
|
},
|
|
1164
|
+
'mapi': {
|
|
1165
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1166
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1167
|
+
var executeFunction = _b.executeFunction;
|
|
1168
|
+
assertColl(coll, sourceCodeInfo);
|
|
1169
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1170
|
+
if (Array.isArray(coll)) {
|
|
1171
|
+
return coll.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); });
|
|
1172
|
+
}
|
|
1173
|
+
if (isString(coll)) {
|
|
1174
|
+
return coll
|
|
1175
|
+
.split('')
|
|
1176
|
+
.map(function (elem, index) { return executeFunction(fn, [elem, index], contextStack, sourceCodeInfo); })
|
|
1177
|
+
.join('');
|
|
1178
|
+
}
|
|
1179
|
+
return Object.entries(coll)
|
|
1180
|
+
.reduce(function (acc, _a) {
|
|
1181
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1182
|
+
acc[key] = executeFunction(fn, [value, key], contextStack, sourceCodeInfo);
|
|
1183
|
+
return acc;
|
|
1184
|
+
}, {});
|
|
1185
|
+
},
|
|
1186
|
+
paramCount: 2,
|
|
1187
|
+
},
|
|
1133
1188
|
'reduce': {
|
|
1134
1189
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1135
1190
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1163,6 +1218,39 @@ var collectionNormalExpression = {
|
|
|
1163
1218
|
},
|
|
1164
1219
|
paramCount: 3,
|
|
1165
1220
|
},
|
|
1221
|
+
'reducei': {
|
|
1222
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1223
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1224
|
+
var executeFunction = _b.executeFunction;
|
|
1225
|
+
assertColl(coll, sourceCodeInfo);
|
|
1226
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1227
|
+
assertAny(initial, sourceCodeInfo);
|
|
1228
|
+
if (typeof coll === 'string') {
|
|
1229
|
+
assertString(initial, sourceCodeInfo);
|
|
1230
|
+
if (coll.length === 0)
|
|
1231
|
+
return initial;
|
|
1232
|
+
return coll.split('').reduce(function (result, elem, index) {
|
|
1233
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1234
|
+
}, initial);
|
|
1235
|
+
}
|
|
1236
|
+
else if (Array.isArray(coll)) {
|
|
1237
|
+
if (coll.length === 0)
|
|
1238
|
+
return initial;
|
|
1239
|
+
return coll.reduce(function (result, elem, index) {
|
|
1240
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1241
|
+
}, initial);
|
|
1242
|
+
}
|
|
1243
|
+
else {
|
|
1244
|
+
if (Object.keys(coll).length === 0)
|
|
1245
|
+
return initial;
|
|
1246
|
+
return Object.entries(coll).reduce(function (result, _a) {
|
|
1247
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1248
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1249
|
+
}, initial);
|
|
1250
|
+
}
|
|
1251
|
+
},
|
|
1252
|
+
paramCount: 3,
|
|
1253
|
+
},
|
|
1166
1254
|
'reduce-right': {
|
|
1167
1255
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1168
1256
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1195,6 +1283,38 @@ var collectionNormalExpression = {
|
|
|
1195
1283
|
},
|
|
1196
1284
|
paramCount: 3,
|
|
1197
1285
|
},
|
|
1286
|
+
'reducei-right': {
|
|
1287
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1288
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1289
|
+
var executeFunction = _b.executeFunction;
|
|
1290
|
+
assertColl(coll, sourceCodeInfo);
|
|
1291
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1292
|
+
assertAny(initial, sourceCodeInfo);
|
|
1293
|
+
if (typeof coll === 'string') {
|
|
1294
|
+
if (coll.length === 0)
|
|
1295
|
+
return initial;
|
|
1296
|
+
return coll.split('').reduceRight(function (result, elem, index) {
|
|
1297
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1298
|
+
}, initial);
|
|
1299
|
+
}
|
|
1300
|
+
else if (Array.isArray(coll)) {
|
|
1301
|
+
if (coll.length === 0)
|
|
1302
|
+
return initial;
|
|
1303
|
+
return coll.reduceRight(function (result, elem, index) {
|
|
1304
|
+
return executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1305
|
+
}, initial);
|
|
1306
|
+
}
|
|
1307
|
+
else {
|
|
1308
|
+
if (Object.keys(coll).length === 0)
|
|
1309
|
+
return initial;
|
|
1310
|
+
return Object.entries(coll).reduceRight(function (result, _a) {
|
|
1311
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1312
|
+
return executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1313
|
+
}, initial);
|
|
1314
|
+
}
|
|
1315
|
+
},
|
|
1316
|
+
paramCount: 3,
|
|
1317
|
+
},
|
|
1198
1318
|
'reductions': {
|
|
1199
1319
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1200
1320
|
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
@@ -1241,6 +1361,52 @@ var collectionNormalExpression = {
|
|
|
1241
1361
|
},
|
|
1242
1362
|
paramCount: 3,
|
|
1243
1363
|
},
|
|
1364
|
+
'reductionsi': {
|
|
1365
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1366
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1367
|
+
var executeFunction = _b.executeFunction;
|
|
1368
|
+
assertColl(coll, sourceCodeInfo);
|
|
1369
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1370
|
+
assertAny(initial, sourceCodeInfo);
|
|
1371
|
+
assertAny(initial, sourceCodeInfo);
|
|
1372
|
+
if (typeof coll === 'string') {
|
|
1373
|
+
assertString(initial, sourceCodeInfo);
|
|
1374
|
+
if (coll.length === 0)
|
|
1375
|
+
return [initial];
|
|
1376
|
+
var resultArray_4 = [initial];
|
|
1377
|
+
coll.split('').reduce(function (result, elem, index) {
|
|
1378
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1379
|
+
resultArray_4.push(newVal);
|
|
1380
|
+
return newVal;
|
|
1381
|
+
}, initial);
|
|
1382
|
+
return resultArray_4;
|
|
1383
|
+
}
|
|
1384
|
+
else if (Array.isArray(coll)) {
|
|
1385
|
+
if (coll.length === 0)
|
|
1386
|
+
return [initial];
|
|
1387
|
+
var resultArray_5 = [initial];
|
|
1388
|
+
coll.reduce(function (result, elem, index) {
|
|
1389
|
+
var newVal = executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo);
|
|
1390
|
+
resultArray_5.push(newVal);
|
|
1391
|
+
return newVal;
|
|
1392
|
+
}, initial);
|
|
1393
|
+
return resultArray_5;
|
|
1394
|
+
}
|
|
1395
|
+
else {
|
|
1396
|
+
if (Object.keys(coll).length === 0)
|
|
1397
|
+
return [initial];
|
|
1398
|
+
var resultArray_6 = [initial];
|
|
1399
|
+
Object.entries(coll).reduce(function (result, _a) {
|
|
1400
|
+
var _b = __read(_a, 2), key = _b[0], elem = _b[1];
|
|
1401
|
+
var newVal = executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo);
|
|
1402
|
+
resultArray_6.push(newVal);
|
|
1403
|
+
return newVal;
|
|
1404
|
+
}, initial);
|
|
1405
|
+
return resultArray_6;
|
|
1406
|
+
}
|
|
1407
|
+
},
|
|
1408
|
+
paramCount: 3,
|
|
1409
|
+
},
|
|
1244
1410
|
'get': {
|
|
1245
1411
|
evaluate: function (params, sourceCodeInfo) {
|
|
1246
1412
|
var _a = __read(params, 2), coll = _a[0], key = _a[1];
|
|
@@ -1494,7 +1660,7 @@ var collectionNormalExpression = {
|
|
|
1494
1660
|
};
|
|
1495
1661
|
|
|
1496
1662
|
var arrayNormalExpression = {
|
|
1497
|
-
range: {
|
|
1663
|
+
'range': {
|
|
1498
1664
|
evaluate: function (params, sourceCodeInfo) {
|
|
1499
1665
|
var _a = __read(params, 3), first = _a[0], second = _a[1], third = _a[2];
|
|
1500
1666
|
var from;
|
|
@@ -1532,7 +1698,7 @@ var arrayNormalExpression = {
|
|
|
1532
1698
|
},
|
|
1533
1699
|
paramCount: { min: 1, max: 3 },
|
|
1534
1700
|
},
|
|
1535
|
-
repeat: {
|
|
1701
|
+
'repeat': {
|
|
1536
1702
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1537
1703
|
var _b = __read(_a, 2), value = _b[0], count = _b[1];
|
|
1538
1704
|
assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true });
|
|
@@ -1543,7 +1709,7 @@ var arrayNormalExpression = {
|
|
|
1543
1709
|
},
|
|
1544
1710
|
paramCount: 2,
|
|
1545
1711
|
},
|
|
1546
|
-
flatten: {
|
|
1712
|
+
'flatten': {
|
|
1547
1713
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1548
1714
|
var _b = __read(_a, 2), seq = _b[0], depth = _b[1];
|
|
1549
1715
|
assertArray(seq, sourceCodeInfo);
|
|
@@ -1554,7 +1720,7 @@ var arrayNormalExpression = {
|
|
|
1554
1720
|
},
|
|
1555
1721
|
paramCount: { min: 1, max: 2 },
|
|
1556
1722
|
},
|
|
1557
|
-
mapcat: {
|
|
1723
|
+
'mapcat': {
|
|
1558
1724
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1559
1725
|
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1560
1726
|
var executeFunction = _b.executeFunction;
|
|
@@ -1564,6 +1730,38 @@ var arrayNormalExpression = {
|
|
|
1564
1730
|
},
|
|
1565
1731
|
paramCount: 2,
|
|
1566
1732
|
},
|
|
1733
|
+
'moving-fn': {
|
|
1734
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1735
|
+
var _c = __read(_a, 3), arr = _c[0], windowSize = _c[1], fn = _c[2];
|
|
1736
|
+
var executeFunction = _b.executeFunction;
|
|
1737
|
+
assertArray(arr, sourceCodeInfo);
|
|
1738
|
+
assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length });
|
|
1739
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1740
|
+
var result = [];
|
|
1741
|
+
for (var i = 0; i <= arr.length - windowSize; i++) {
|
|
1742
|
+
var window_1 = arr.slice(i, i + windowSize);
|
|
1743
|
+
var value = executeFunction(fn, [window_1], contextStack, sourceCodeInfo);
|
|
1744
|
+
result.push(value);
|
|
1745
|
+
}
|
|
1746
|
+
return result;
|
|
1747
|
+
},
|
|
1748
|
+
paramCount: 3,
|
|
1749
|
+
},
|
|
1750
|
+
'running-fn': {
|
|
1751
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1752
|
+
var _c = __read(_a, 2), arr = _c[0], fn = _c[1];
|
|
1753
|
+
var executeFunction = _b.executeFunction;
|
|
1754
|
+
assertArray(arr, sourceCodeInfo);
|
|
1755
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1756
|
+
var result = [];
|
|
1757
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
1758
|
+
var subArr = arr.slice(0, i + 1);
|
|
1759
|
+
result.push(executeFunction(fn, [subArr], contextStack, sourceCodeInfo));
|
|
1760
|
+
}
|
|
1761
|
+
return result;
|
|
1762
|
+
},
|
|
1763
|
+
paramCount: 2,
|
|
1764
|
+
},
|
|
1567
1765
|
};
|
|
1568
1766
|
|
|
1569
1767
|
var sequenceNormalExpression = {
|
|
@@ -2295,7 +2493,7 @@ function isVector(vector) {
|
|
|
2295
2493
|
if (vectors.has(vector)) {
|
|
2296
2494
|
return true;
|
|
2297
2495
|
}
|
|
2298
|
-
if (vector.every(function (elem) { return isNumber(elem
|
|
2496
|
+
if (vector.every(function (elem) { return isNumber(elem); })) {
|
|
2299
2497
|
annotatedArrays.add(vector);
|
|
2300
2498
|
vectors.add(vector);
|
|
2301
2499
|
return true;
|
|
@@ -2404,7 +2602,7 @@ function isMatrix(matrix) {
|
|
|
2404
2602
|
if (row.length !== nbrOfCols) {
|
|
2405
2603
|
return false;
|
|
2406
2604
|
}
|
|
2407
|
-
if (row.some(function (cell) { return !isNumber(cell
|
|
2605
|
+
if (row.some(function (cell) { return !isNumber(cell); })) {
|
|
2408
2606
|
return false;
|
|
2409
2607
|
}
|
|
2410
2608
|
}
|
|
@@ -3937,14 +4135,6 @@ var predicatesNormalExpression = {
|
|
|
3937
4135
|
},
|
|
3938
4136
|
paramCount: 1,
|
|
3939
4137
|
},
|
|
3940
|
-
'nan?': {
|
|
3941
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
3942
|
-
var _b = __read(_a, 1), value = _b[0];
|
|
3943
|
-
assertNumber(value, sourceCodeInfo);
|
|
3944
|
-
return Number.isNaN(value);
|
|
3945
|
-
},
|
|
3946
|
-
paramCount: 1,
|
|
3947
|
-
},
|
|
3948
4138
|
'positive-infinity?': {
|
|
3949
4139
|
evaluate: function (_a, sourceCodeInfo) {
|
|
3950
4140
|
var _b = __read(_a, 1), value = _b[0];
|
|
@@ -12506,8 +12696,13 @@ function evaluateNode(node, contextStack) {
|
|
|
12506
12696
|
return contextStack.evaluateSymbol(node);
|
|
12507
12697
|
case NodeTypes.ReservedSymbol:
|
|
12508
12698
|
return evaluateReservedSymbol(node);
|
|
12509
|
-
case NodeTypes.NormalExpression:
|
|
12510
|
-
|
|
12699
|
+
case NodeTypes.NormalExpression: {
|
|
12700
|
+
var result = evaluateNormalExpression(node, contextStack);
|
|
12701
|
+
if (typeof result === 'number' && Number.isNaN(result)) {
|
|
12702
|
+
throw new LitsError('Number is NaN', node[2]);
|
|
12703
|
+
}
|
|
12704
|
+
return annotate(result);
|
|
12705
|
+
}
|
|
12511
12706
|
case NodeTypes.SpecialExpression:
|
|
12512
12707
|
return annotate(evaluateSpecialExpression(node, contextStack));
|
|
12513
12708
|
/* v8 ignore next 2 */
|
|
@@ -12899,6 +13094,8 @@ var binaryOperators = [
|
|
|
12899
13094
|
'|>', // pipe
|
|
12900
13095
|
];
|
|
12901
13096
|
var otherOperators = [
|
|
13097
|
+
'?', // conditional operator
|
|
13098
|
+
':', // conditional operator
|
|
12902
13099
|
'->', // lambda
|
|
12903
13100
|
'...', // rest
|
|
12904
13101
|
'.', // property accessor
|
|
@@ -12908,17 +13105,12 @@ var otherOperators = [
|
|
|
12908
13105
|
];
|
|
12909
13106
|
var symbolicOperators = __spreadArray(__spreadArray([], __read(binaryOperators), false), __read(otherOperators), false);
|
|
12910
13107
|
var nonFunctionOperators = [
|
|
12911
|
-
'??',
|
|
12912
|
-
'&&',
|
|
12913
|
-
'||',
|
|
12914
13108
|
'comment',
|
|
12915
13109
|
'cond',
|
|
12916
13110
|
'def',
|
|
12917
13111
|
'defined?',
|
|
12918
|
-
// 'defn',
|
|
12919
13112
|
'do',
|
|
12920
13113
|
'doseq',
|
|
12921
|
-
// 'fn',
|
|
12922
13114
|
'if',
|
|
12923
13115
|
'let',
|
|
12924
13116
|
'loop',
|
|
@@ -13496,8 +13688,9 @@ function untokenize(tokenStream) {
|
|
|
13496
13688
|
}, '');
|
|
13497
13689
|
}
|
|
13498
13690
|
|
|
13499
|
-
var exponentiationPrecedence =
|
|
13500
|
-
var binaryFunctionalOperatorPrecedence =
|
|
13691
|
+
var exponentiationPrecedence = 12;
|
|
13692
|
+
var binaryFunctionalOperatorPrecedence = 3;
|
|
13693
|
+
var conditionalOperatorPrecedence = 1;
|
|
13501
13694
|
var placeholderRegexp = /^\$([1-9]\d?)?$/;
|
|
13502
13695
|
function withSourceCodeInfo(node, sourceCodeInfo) {
|
|
13503
13696
|
if (sourceCodeInfo) {
|
|
@@ -13512,38 +13705,39 @@ function getPrecedence(operatorSign, sourceCodeInfo) {
|
|
|
13512
13705
|
case '*': // multiplication
|
|
13513
13706
|
case '/': // division
|
|
13514
13707
|
case '%': // remainder
|
|
13515
|
-
return
|
|
13708
|
+
return 11;
|
|
13516
13709
|
case '+': // addition
|
|
13517
13710
|
case '-': // subtraction
|
|
13518
|
-
return
|
|
13711
|
+
return 10;
|
|
13519
13712
|
case '<<': // left shift
|
|
13520
13713
|
case '>>': // signed right shift
|
|
13521
13714
|
case '>>>': // unsigned right shift
|
|
13522
|
-
return
|
|
13715
|
+
return 9;
|
|
13523
13716
|
case '++': // string concatenation
|
|
13524
|
-
return
|
|
13717
|
+
return 8;
|
|
13525
13718
|
case '<': // less than
|
|
13526
13719
|
case '<=': // less than or equal
|
|
13527
13720
|
case '≤': // less than or equal
|
|
13528
13721
|
case '>': // greater than
|
|
13529
13722
|
case '>=': // greater than or equal
|
|
13530
13723
|
case '≥': // greater than or equal
|
|
13531
|
-
return
|
|
13724
|
+
return 7;
|
|
13532
13725
|
case '=': // equal
|
|
13533
13726
|
case '!=': // not equal
|
|
13534
13727
|
case '≠': // not equal
|
|
13535
|
-
return
|
|
13728
|
+
return 6;
|
|
13536
13729
|
case '&': // bitwise AND
|
|
13537
13730
|
case 'xor': // bitwise XOR
|
|
13538
13731
|
case '|': // bitwise OR
|
|
13539
|
-
return
|
|
13732
|
+
return 5;
|
|
13540
13733
|
case '&&': // logical AND
|
|
13541
13734
|
case '||': // logical OR
|
|
13542
13735
|
case '??': // nullish coalescing
|
|
13543
|
-
return
|
|
13736
|
+
return 4;
|
|
13737
|
+
// leave room for binaryFunctionalOperatorPrecedence = 3
|
|
13544
13738
|
case '|>': // pipe
|
|
13545
|
-
return
|
|
13546
|
-
// leave room for
|
|
13739
|
+
return 2;
|
|
13740
|
+
// leave room for conditionalOperatorPrecedence = 1
|
|
13547
13741
|
/* v8 ignore next 2 */
|
|
13548
13742
|
default:
|
|
13549
13743
|
throw new LitsError("Unknown binary operator: ".concat(operatorSign), sourceCodeInfo);
|
|
@@ -13591,13 +13785,15 @@ function fromBinaryOperatorToNode(operator, symbolNode, left, right, sourceCodeI
|
|
|
13591
13785
|
case '||':
|
|
13592
13786
|
case '??':
|
|
13593
13787
|
return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes[operatorName], [left, right]]], sourceCodeInfo);
|
|
13594
|
-
/* v8 ignore next
|
|
13788
|
+
/* v8 ignore next 11 */
|
|
13595
13789
|
case '.':
|
|
13596
13790
|
case ';':
|
|
13597
13791
|
case ':=':
|
|
13598
13792
|
case ',':
|
|
13599
13793
|
case '->':
|
|
13600
13794
|
case '...':
|
|
13795
|
+
case '?':
|
|
13796
|
+
case ':':
|
|
13601
13797
|
throw new LitsError("Unknown binary operator: ".concat(operatorName), sourceCodeInfo);
|
|
13602
13798
|
default:
|
|
13603
13799
|
throw new LitsError("Unknown binary operator: ".concat(operatorName), sourceCodeInfo);
|
|
@@ -13713,6 +13909,19 @@ var Parser = /** @class */ (function () {
|
|
|
13713
13909
|
}
|
|
13714
13910
|
left = createNamedNormalExpressionNode(operatorSymbol, [left, right], operator[2]);
|
|
13715
13911
|
}
|
|
13912
|
+
else if ((operator === null || operator === void 0 ? void 0 : operator[1]) === '?') {
|
|
13913
|
+
if (conditionalOperatorPrecedence <= precedence) {
|
|
13914
|
+
break;
|
|
13915
|
+
}
|
|
13916
|
+
this.advance();
|
|
13917
|
+
var trueNode = this.parseExpression();
|
|
13918
|
+
if (!isOperatorToken(this.peek(), ':')) {
|
|
13919
|
+
throw new LitsError('Expected :', this.peekSourceCodeInfo());
|
|
13920
|
+
}
|
|
13921
|
+
this.advance();
|
|
13922
|
+
var falseNode = this.parseExpression();
|
|
13923
|
+
left = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.if, [left, trueNode, falseNode]]], left[2]);
|
|
13924
|
+
}
|
|
13716
13925
|
else {
|
|
13717
13926
|
break;
|
|
13718
13927
|
}
|
|
@@ -15056,10 +15265,15 @@ function getVectorReductionNames(name) {
|
|
|
15056
15265
|
var api = {
|
|
15057
15266
|
collection: [
|
|
15058
15267
|
'filter',
|
|
15268
|
+
'filteri',
|
|
15059
15269
|
'map',
|
|
15270
|
+
'mapi',
|
|
15060
15271
|
'reduce',
|
|
15272
|
+
'reducei',
|
|
15061
15273
|
'reduce-right',
|
|
15274
|
+
'reducei-right',
|
|
15062
15275
|
'reductions',
|
|
15276
|
+
'reductionsi',
|
|
15063
15277
|
'count',
|
|
15064
15278
|
'get',
|
|
15065
15279
|
'get-in',
|
|
@@ -15080,6 +15294,8 @@ var api = {
|
|
|
15080
15294
|
'repeat',
|
|
15081
15295
|
'flatten',
|
|
15082
15296
|
'mapcat',
|
|
15297
|
+
'moving-fn',
|
|
15298
|
+
'running-fn',
|
|
15083
15299
|
],
|
|
15084
15300
|
sequence: [
|
|
15085
15301
|
'nth',
|
|
@@ -15219,7 +15435,6 @@ var api = {
|
|
|
15219
15435
|
'even?',
|
|
15220
15436
|
'odd?',
|
|
15221
15437
|
'finite?',
|
|
15222
|
-
'nan?',
|
|
15223
15438
|
'negative-infinity?',
|
|
15224
15439
|
'positive-infinity?',
|
|
15225
15440
|
'false?',
|
|
@@ -15535,7 +15750,7 @@ function getOperatorArgs(a, b) {
|
|
|
15535
15750
|
}
|
|
15536
15751
|
|
|
15537
15752
|
var arrayReference = {
|
|
15538
|
-
range: {
|
|
15753
|
+
'range': {
|
|
15539
15754
|
title: 'range',
|
|
15540
15755
|
category: 'Array',
|
|
15541
15756
|
linkName: 'range',
|
|
@@ -15560,7 +15775,7 @@ var arrayReference = {
|
|
|
15560
15775
|
"\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)",
|
|
15561
15776
|
],
|
|
15562
15777
|
},
|
|
15563
|
-
repeat: {
|
|
15778
|
+
'repeat': {
|
|
15564
15779
|
title: 'repeat',
|
|
15565
15780
|
category: 'Array',
|
|
15566
15781
|
linkName: 'repeat',
|
|
@@ -15579,7 +15794,7 @@ var arrayReference = {
|
|
|
15579
15794
|
'"Albert" repeat 5',
|
|
15580
15795
|
],
|
|
15581
15796
|
},
|
|
15582
|
-
flatten: {
|
|
15797
|
+
'flatten': {
|
|
15583
15798
|
title: 'flatten',
|
|
15584
15799
|
category: 'Array',
|
|
15585
15800
|
linkName: 'flatten',
|
|
@@ -15603,7 +15818,7 @@ var arrayReference = {
|
|
|
15603
15818
|
],
|
|
15604
15819
|
noOperatorDocumentation: true,
|
|
15605
15820
|
},
|
|
15606
|
-
mapcat: {
|
|
15821
|
+
'mapcat': {
|
|
15607
15822
|
title: 'mapcat',
|
|
15608
15823
|
category: 'Array',
|
|
15609
15824
|
linkName: 'mapcat',
|
|
@@ -15628,6 +15843,60 @@ var arrayReference = {
|
|
|
15628
15843
|
"\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ remove even?\n)",
|
|
15629
15844
|
],
|
|
15630
15845
|
},
|
|
15846
|
+
'moving-fn': {
|
|
15847
|
+
title: 'moving-fn',
|
|
15848
|
+
category: 'Array',
|
|
15849
|
+
linkName: 'moving-fn',
|
|
15850
|
+
returns: {
|
|
15851
|
+
type: 'array',
|
|
15852
|
+
},
|
|
15853
|
+
args: {
|
|
15854
|
+
arr: {
|
|
15855
|
+
type: 'array',
|
|
15856
|
+
},
|
|
15857
|
+
windowSize: {
|
|
15858
|
+
type: 'number',
|
|
15859
|
+
description: 'The size of the moving window.',
|
|
15860
|
+
},
|
|
15861
|
+
fn: {
|
|
15862
|
+
type: 'function',
|
|
15863
|
+
},
|
|
15864
|
+
},
|
|
15865
|
+
variants: [{
|
|
15866
|
+
argumentNames: ['arr', 'windowSize', 'fn'],
|
|
15867
|
+
}],
|
|
15868
|
+
description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',
|
|
15869
|
+
examples: [
|
|
15870
|
+
'moving-fn([1, 2, 3], 2, vec:sum)',
|
|
15871
|
+
'moving-fn([1, 2, 3], 1, vec:sum)',
|
|
15872
|
+
'moving-fn([1, 2, 3], 3, vec:sum)',
|
|
15873
|
+
],
|
|
15874
|
+
},
|
|
15875
|
+
'running-fn': {
|
|
15876
|
+
title: 'running-fn',
|
|
15877
|
+
category: 'Array',
|
|
15878
|
+
linkName: 'running-fn',
|
|
15879
|
+
returns: {
|
|
15880
|
+
type: 'array',
|
|
15881
|
+
},
|
|
15882
|
+
args: {
|
|
15883
|
+
a: {
|
|
15884
|
+
type: 'array',
|
|
15885
|
+
},
|
|
15886
|
+
b: {
|
|
15887
|
+
type: 'function',
|
|
15888
|
+
},
|
|
15889
|
+
},
|
|
15890
|
+
variants: [{
|
|
15891
|
+
argumentNames: ['a', 'b'],
|
|
15892
|
+
}],
|
|
15893
|
+
description: 'Returns the result of applying $b to each element of $a.',
|
|
15894
|
+
examples: [
|
|
15895
|
+
'running-fn([1, 2, 3], vec:sum)',
|
|
15896
|
+
'running-fn([1, 2, 3], vec:max)',
|
|
15897
|
+
'running-fn([1, 2, 3], vec:min)',
|
|
15898
|
+
],
|
|
15899
|
+
},
|
|
15631
15900
|
};
|
|
15632
15901
|
|
|
15633
15902
|
var assertReference = {
|
|
@@ -16288,6 +16557,32 @@ var collectionReference = {
|
|
|
16288
16557
|
"\nfilter(\n { a := 1, b := 2 },\n odd?\n)",
|
|
16289
16558
|
],
|
|
16290
16559
|
},
|
|
16560
|
+
'filteri': {
|
|
16561
|
+
title: 'filteri',
|
|
16562
|
+
category: 'Collection',
|
|
16563
|
+
linkName: 'filteri',
|
|
16564
|
+
returns: {
|
|
16565
|
+
type: 'collection',
|
|
16566
|
+
},
|
|
16567
|
+
args: {
|
|
16568
|
+
a: {
|
|
16569
|
+
type: 'collection',
|
|
16570
|
+
},
|
|
16571
|
+
b: {
|
|
16572
|
+
type: 'function',
|
|
16573
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16574
|
+
},
|
|
16575
|
+
},
|
|
16576
|
+
variants: [
|
|
16577
|
+
{ argumentNames: ['a', 'b'] },
|
|
16578
|
+
],
|
|
16579
|
+
description: 'Creates a new collection with all elements that pass the test implemented by $b. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.',
|
|
16580
|
+
examples: [
|
|
16581
|
+
'filteri([1, 2, 3], (x, i) -> i % 2 = 0)',
|
|
16582
|
+
'filteri([1, 2, 3], (x, i) -> x % 2 = 0)',
|
|
16583
|
+
'filteri([1, 2, 3], (x, i) -> x + i > 3)',
|
|
16584
|
+
],
|
|
16585
|
+
},
|
|
16291
16586
|
'map': {
|
|
16292
16587
|
title: 'map',
|
|
16293
16588
|
category: 'Collection',
|
|
@@ -16316,6 +16611,34 @@ var collectionReference = {
|
|
|
16316
16611
|
'map({ a := 1, b := 2 }, { a := 10, b := 20 }, +)',
|
|
16317
16612
|
],
|
|
16318
16613
|
},
|
|
16614
|
+
'mapi': {
|
|
16615
|
+
title: 'mapi',
|
|
16616
|
+
category: 'Collection',
|
|
16617
|
+
linkName: 'mapi',
|
|
16618
|
+
returns: {
|
|
16619
|
+
type: 'collection',
|
|
16620
|
+
},
|
|
16621
|
+
args: {
|
|
16622
|
+
a: {
|
|
16623
|
+
type: 'collection',
|
|
16624
|
+
},
|
|
16625
|
+
b: {
|
|
16626
|
+
type: 'function',
|
|
16627
|
+
description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',
|
|
16628
|
+
},
|
|
16629
|
+
},
|
|
16630
|
+
variants: [
|
|
16631
|
+
{ argumentNames: ['a', 'b'] },
|
|
16632
|
+
],
|
|
16633
|
+
description: 'Creates a new collection populated with the results of calling $b on every element in $a. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.',
|
|
16634
|
+
examples: [
|
|
16635
|
+
'mapi([1, 2, 3], (x, i) -> x + i)',
|
|
16636
|
+
'mapi([1, 2, 3], (x, i) -> x * i)',
|
|
16637
|
+
'mapi([1, 2, 3], (x, i) -> x - i)',
|
|
16638
|
+
'mapi([1, 2, 3], (x, i) -> x / i)',
|
|
16639
|
+
'mapi([1, 2, 3], (x, i) -> x % inc(i))',
|
|
16640
|
+
],
|
|
16641
|
+
},
|
|
16319
16642
|
'reduce': {
|
|
16320
16643
|
title: 'reduce',
|
|
16321
16644
|
category: 'Collection',
|
|
@@ -16372,12 +16695,73 @@ var collectionReference = {
|
|
|
16372
16695
|
'reduce-right({ a := 1, b := 2 }, +, 0)',
|
|
16373
16696
|
],
|
|
16374
16697
|
},
|
|
16698
|
+
'reducei-right': {
|
|
16699
|
+
title: 'reducei-right',
|
|
16700
|
+
category: 'Collection',
|
|
16701
|
+
linkName: 'reducei-right',
|
|
16702
|
+
returns: {
|
|
16703
|
+
type: 'any',
|
|
16704
|
+
},
|
|
16705
|
+
args: {
|
|
16706
|
+
coll: {
|
|
16707
|
+
type: 'collection',
|
|
16708
|
+
},
|
|
16709
|
+
fun: {
|
|
16710
|
+
type: 'function',
|
|
16711
|
+
description: 'The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.',
|
|
16712
|
+
},
|
|
16713
|
+
initial: {
|
|
16714
|
+
type: 'any',
|
|
16715
|
+
description: 'The initial value to use as the accumulator.',
|
|
16716
|
+
},
|
|
16717
|
+
},
|
|
16718
|
+
variants: [
|
|
16719
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16720
|
+
],
|
|
16721
|
+
description: 'Runs $fun function on each element of the $coll (starting from the last item), passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.',
|
|
16722
|
+
examples: [
|
|
16723
|
+
'reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16724
|
+
'reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16725
|
+
'reducei-right({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16726
|
+
],
|
|
16727
|
+
},
|
|
16728
|
+
'reducei': {
|
|
16729
|
+
title: 'reducei',
|
|
16730
|
+
category: 'Collection',
|
|
16731
|
+
linkName: 'reducei',
|
|
16732
|
+
returns: {
|
|
16733
|
+
type: 'any',
|
|
16734
|
+
},
|
|
16735
|
+
args: {
|
|
16736
|
+
coll: {
|
|
16737
|
+
type: 'collection',
|
|
16738
|
+
},
|
|
16739
|
+
fun: {
|
|
16740
|
+
type: 'function',
|
|
16741
|
+
description: 'The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.',
|
|
16742
|
+
},
|
|
16743
|
+
initial: {
|
|
16744
|
+
type: 'any',
|
|
16745
|
+
description: 'The initial value to use as the accumulator.',
|
|
16746
|
+
},
|
|
16747
|
+
},
|
|
16748
|
+
variants: [
|
|
16749
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16750
|
+
],
|
|
16751
|
+
description: 'Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.',
|
|
16752
|
+
examples: [
|
|
16753
|
+
'reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16754
|
+
'reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16755
|
+
'reducei({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16756
|
+
],
|
|
16757
|
+
},
|
|
16375
16758
|
'reductions': {
|
|
16376
16759
|
title: 'reductions',
|
|
16377
16760
|
category: 'Collection',
|
|
16378
16761
|
linkName: 'reductions',
|
|
16379
16762
|
returns: {
|
|
16380
16763
|
type: 'any',
|
|
16764
|
+
array: true,
|
|
16381
16765
|
},
|
|
16382
16766
|
args: {
|
|
16383
16767
|
fun: {
|
|
@@ -16402,6 +16786,37 @@ var collectionReference = {
|
|
|
16402
16786
|
"\nreductions(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + if even?(value) then value else 0 end,\n 0\n)",
|
|
16403
16787
|
],
|
|
16404
16788
|
},
|
|
16789
|
+
'reductionsi': {
|
|
16790
|
+
title: 'reductionsi',
|
|
16791
|
+
category: 'Collection',
|
|
16792
|
+
linkName: 'reductionsi',
|
|
16793
|
+
returns: {
|
|
16794
|
+
type: 'any',
|
|
16795
|
+
array: true,
|
|
16796
|
+
},
|
|
16797
|
+
args: {
|
|
16798
|
+
coll: {
|
|
16799
|
+
type: 'collection',
|
|
16800
|
+
},
|
|
16801
|
+
fun: {
|
|
16802
|
+
type: 'function',
|
|
16803
|
+
description: 'The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.',
|
|
16804
|
+
},
|
|
16805
|
+
initial: {
|
|
16806
|
+
type: 'any',
|
|
16807
|
+
description: 'The initial value to use as the accumulator.',
|
|
16808
|
+
},
|
|
16809
|
+
},
|
|
16810
|
+
variants: [
|
|
16811
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16812
|
+
],
|
|
16813
|
+
description: 'Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.',
|
|
16814
|
+
examples: [
|
|
16815
|
+
'reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',
|
|
16816
|
+
'reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")',
|
|
16817
|
+
'reductionsi({ a := 1, b := 2 }, -> $1 ++ $3, "")',
|
|
16818
|
+
],
|
|
16819
|
+
},
|
|
16405
16820
|
'count': {
|
|
16406
16821
|
title: 'count',
|
|
16407
16822
|
category: 'Collection',
|
|
@@ -24866,30 +25281,6 @@ var predicateReference = {
|
|
|
24866
25281
|
'finite?(1.0)',
|
|
24867
25282
|
'finite?(1 / 0)',
|
|
24868
25283
|
'finite?(-1 / 0)',
|
|
24869
|
-
'finite?(sqrt(-1))',
|
|
24870
|
-
],
|
|
24871
|
-
},
|
|
24872
|
-
'nan?': {
|
|
24873
|
-
title: 'nan?',
|
|
24874
|
-
category: 'Predicate',
|
|
24875
|
-
linkName: 'nan-question',
|
|
24876
|
-
returns: {
|
|
24877
|
-
type: 'boolean',
|
|
24878
|
-
},
|
|
24879
|
-
args: {
|
|
24880
|
-
x: {
|
|
24881
|
-
type: 'number',
|
|
24882
|
-
},
|
|
24883
|
-
},
|
|
24884
|
-
variants: [
|
|
24885
|
-
{ argumentNames: ['x'] },
|
|
24886
|
-
],
|
|
24887
|
-
description: 'Returns `true` if $x is NaN (! a number), otherwise `false`.',
|
|
24888
|
-
examples: [
|
|
24889
|
-
'nan?(1.0)',
|
|
24890
|
-
'nan?(1 / 0)',
|
|
24891
|
-
'nan?(-1 / 0)',
|
|
24892
|
-
'nan?(sqrt(-1))',
|
|
24893
25284
|
],
|
|
24894
25285
|
},
|
|
24895
25286
|
'negative-infinity?': {
|
|
@@ -24912,7 +25303,6 @@ var predicateReference = {
|
|
|
24912
25303
|
'negative-infinity?(1.0)',
|
|
24913
25304
|
'negative-infinity?(1 / 0)',
|
|
24914
25305
|
'negative-infinity?(-1 / 0)',
|
|
24915
|
-
'negative-infinity?(sqrt(-1))',
|
|
24916
25306
|
],
|
|
24917
25307
|
},
|
|
24918
25308
|
'positive-infinity?': {
|
|
@@ -24935,7 +25325,6 @@ var predicateReference = {
|
|
|
24935
25325
|
'positive-infinity?(1.0)',
|
|
24936
25326
|
'positive-infinity?(1 / 0)',
|
|
24937
25327
|
'positive-infinity?(-1 / 0)',
|
|
24938
|
-
'positive-infinity?(sqrt(-1))',
|
|
24939
25328
|
],
|
|
24940
25329
|
},
|
|
24941
25330
|
'false?': {
|
|
@@ -30767,7 +31156,6 @@ var numberTheoryReference = __assign(__assign(__assign(__assign(__assign(__assig
|
|
|
30767
31156
|
'12 nth:lcm 8',
|
|
30768
31157
|
'nth:lcm(100, 25)',
|
|
30769
31158
|
'nth:lcm(37, 1)',
|
|
30770
|
-
'nth:lcm(0, 0)',
|
|
30771
31159
|
'nth:lcm(0, 5)',
|
|
30772
31160
|
'nth:lcm(5, 0)',
|
|
30773
31161
|
],
|
|
@@ -32999,6 +33387,12 @@ class ExpressionParser {
|
|
|
32999
33387
|
* @returns A string containing the symbolic representation
|
|
33000
33388
|
*/
|
|
33001
33389
|
function prettyPi(num, config = {}) {
|
|
33390
|
+
if (isNaN(num)) {
|
|
33391
|
+
return "NaN";
|
|
33392
|
+
}
|
|
33393
|
+
if (!isFinite(num)) {
|
|
33394
|
+
return num > 0 ? "∞" : "-∞";
|
|
33395
|
+
}
|
|
33002
33396
|
setConfig(config);
|
|
33003
33397
|
const parser = new ExpressionParser();
|
|
33004
33398
|
const exprTree = parser.parseNumber(num);
|
|
@@ -33022,10 +33416,6 @@ function stringifyValue(value, html) {
|
|
|
33022
33416
|
return value.toString();
|
|
33023
33417
|
if (typeof value === 'object' && value instanceof RegExp)
|
|
33024
33418
|
return "".concat(value);
|
|
33025
|
-
if (value === Number.POSITIVE_INFINITY)
|
|
33026
|
-
return "".concat(Number.POSITIVE_INFINITY);
|
|
33027
|
-
if (value === Number.NEGATIVE_INFINITY)
|
|
33028
|
-
return "".concat(Number.NEGATIVE_INFINITY);
|
|
33029
33419
|
if (typeof value === 'number') {
|
|
33030
33420
|
return prettyPi(value);
|
|
33031
33421
|
}
|
|
@@ -33049,7 +33439,37 @@ function stringifyValue(value, html) {
|
|
|
33049
33439
|
}).join(', '), "]");
|
|
33050
33440
|
}
|
|
33051
33441
|
}
|
|
33052
|
-
return JSON.stringify(value, null, 2);
|
|
33442
|
+
return JSON.stringify(replaceInfinities(value), null, 2);
|
|
33443
|
+
}
|
|
33444
|
+
function replaceInfinities(value) {
|
|
33445
|
+
var e_1, _a;
|
|
33446
|
+
if (value === Number.POSITIVE_INFINITY) {
|
|
33447
|
+
return '∞';
|
|
33448
|
+
}
|
|
33449
|
+
if (value === Number.NEGATIVE_INFINITY) {
|
|
33450
|
+
return '-∞';
|
|
33451
|
+
}
|
|
33452
|
+
if (Array.isArray(value)) {
|
|
33453
|
+
return value.map(replaceInfinities);
|
|
33454
|
+
}
|
|
33455
|
+
if (typeof value === 'object' && value !== null) {
|
|
33456
|
+
var result = {};
|
|
33457
|
+
try {
|
|
33458
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
33459
|
+
var _d = __read(_c.value, 2), key = _d[0], val = _d[1];
|
|
33460
|
+
result[key] = replaceInfinities(val);
|
|
33461
|
+
}
|
|
33462
|
+
}
|
|
33463
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33464
|
+
finally {
|
|
33465
|
+
try {
|
|
33466
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
33467
|
+
}
|
|
33468
|
+
finally { if (e_1) throw e_1.error; }
|
|
33469
|
+
}
|
|
33470
|
+
return result;
|
|
33471
|
+
}
|
|
33472
|
+
return value;
|
|
33053
33473
|
}
|
|
33054
33474
|
function prettyIfNumber(value) {
|
|
33055
33475
|
if (typeof value === 'number') {
|