@mojir/lits 2.1.5 → 2.1.6
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 +458 -407
- package/dist/cli/reference/api.d.ts +4 -4
- package/dist/cli/reference/index.d.ts +3 -3
- package/dist/cli/src/parser/types.d.ts +1 -0
- package/dist/cli/src/tokenizer/operators.d.ts +2 -2
- package/dist/cli/src/tokenizer/reservedNames.d.ts +2 -0
- package/dist/index.esm.js +457 -406
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +457 -406
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +457 -406
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +4 -4
- package/dist/reference/index.d.ts +3 -3
- package/dist/src/parser/types.d.ts +1 -0
- package/dist/src/tokenizer/operators.d.ts +2 -2
- package/dist/src/tokenizer/reservedNames.d.ts +2 -0
- package/dist/testFramework.esm.js +298 -245
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +298 -245
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
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.6";
|
|
96
96
|
|
|
97
97
|
function getCodeMarker(sourceCodeInfo) {
|
|
98
98
|
if (!sourceCodeInfo.position || !sourceCodeInfo.code)
|
|
@@ -942,6 +942,32 @@ function assertCharArray(value, sourceCodeInfo) {
|
|
|
942
942
|
throw getAssertionError('array of strings', value, sourceCodeInfo);
|
|
943
943
|
}
|
|
944
944
|
|
|
945
|
+
function mapObjects(_a) {
|
|
946
|
+
var colls = _a.colls, contextStack = _a.contextStack, executeFunction = _a.executeFunction, fn = _a.fn, sourceCodeInfo = _a.sourceCodeInfo;
|
|
947
|
+
assertObj(colls[0], sourceCodeInfo);
|
|
948
|
+
var keys = Object.keys(colls[0]);
|
|
949
|
+
var params = {};
|
|
950
|
+
colls.forEach(function (obj) {
|
|
951
|
+
assertObj(obj, sourceCodeInfo);
|
|
952
|
+
var objKeys = Object.keys(obj);
|
|
953
|
+
if (objKeys.length !== keys.length) {
|
|
954
|
+
throw new LitsError("All objects must have the same keys. Expected: ".concat(keys.join(', '), ". Found: ").concat(objKeys.join(', ')), sourceCodeInfo);
|
|
955
|
+
}
|
|
956
|
+
if (!objKeys.every(function (key) { return keys.includes(key); })) {
|
|
957
|
+
throw new LitsError("All objects must have the same keys. Expected: ".concat(keys.join(', '), ". Found: ").concat(objKeys.join(', ')), sourceCodeInfo);
|
|
958
|
+
}
|
|
959
|
+
Object.entries(obj).forEach(function (_a) {
|
|
960
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
961
|
+
if (!params[key])
|
|
962
|
+
params[key] = [];
|
|
963
|
+
params[key].push(value);
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
return keys.reduce(function (result, key) {
|
|
967
|
+
result[key] = executeFunction(fn, params[key], contextStack, sourceCodeInfo);
|
|
968
|
+
return result;
|
|
969
|
+
}, {});
|
|
970
|
+
}
|
|
945
971
|
function cloneAndGetMeta(originalColl, keys, sourceCodeInfo) {
|
|
946
972
|
var coll = cloneColl(originalColl);
|
|
947
973
|
var butLastKeys = keys.slice(0, keys.length - 1);
|
|
@@ -1034,6 +1060,188 @@ function assoc(coll, key, value, sourceCodeInfo) {
|
|
|
1034
1060
|
return copy;
|
|
1035
1061
|
}
|
|
1036
1062
|
var collectionNormalExpression = {
|
|
1063
|
+
'filter': {
|
|
1064
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1065
|
+
var _c = __read(_a, 2), coll = _c[0], fn = _c[1];
|
|
1066
|
+
var executeFunction = _b.executeFunction;
|
|
1067
|
+
assertColl(coll, sourceCodeInfo);
|
|
1068
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1069
|
+
if (Array.isArray(coll)) {
|
|
1070
|
+
var result = coll.filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
|
|
1071
|
+
return result;
|
|
1072
|
+
}
|
|
1073
|
+
if (isString(coll)) {
|
|
1074
|
+
return coll
|
|
1075
|
+
.split('')
|
|
1076
|
+
.filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); })
|
|
1077
|
+
.join('');
|
|
1078
|
+
}
|
|
1079
|
+
return Object.entries(coll)
|
|
1080
|
+
.filter(function (_a) {
|
|
1081
|
+
var _b = __read(_a, 2), value = _b[1];
|
|
1082
|
+
return executeFunction(fn, [value], contextStack, sourceCodeInfo);
|
|
1083
|
+
})
|
|
1084
|
+
.reduce(function (result, _a) {
|
|
1085
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1086
|
+
result[key] = value;
|
|
1087
|
+
return result;
|
|
1088
|
+
}, {});
|
|
1089
|
+
},
|
|
1090
|
+
paramCount: 2,
|
|
1091
|
+
},
|
|
1092
|
+
'map': {
|
|
1093
|
+
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1094
|
+
var executeFunction = _a.executeFunction;
|
|
1095
|
+
var fn = asFunctionLike(params.at(-1), sourceCodeInfo);
|
|
1096
|
+
if (isObj(params[0])) {
|
|
1097
|
+
return mapObjects({
|
|
1098
|
+
colls: params.slice(0, -1),
|
|
1099
|
+
fn: fn,
|
|
1100
|
+
sourceCodeInfo: sourceCodeInfo,
|
|
1101
|
+
contextStack: contextStack,
|
|
1102
|
+
executeFunction: executeFunction,
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
var seqs = params.slice(0, -1);
|
|
1106
|
+
assertSeq(seqs[0], sourceCodeInfo);
|
|
1107
|
+
var isStr = typeof seqs[0] === 'string';
|
|
1108
|
+
var len = seqs[0].length;
|
|
1109
|
+
seqs.slice(1).forEach(function (seq) {
|
|
1110
|
+
if (isStr) {
|
|
1111
|
+
assertString(seq, sourceCodeInfo);
|
|
1112
|
+
}
|
|
1113
|
+
else {
|
|
1114
|
+
assertArray(seq, sourceCodeInfo);
|
|
1115
|
+
}
|
|
1116
|
+
len = Math.min(len, seq.length);
|
|
1117
|
+
});
|
|
1118
|
+
var paramArray = [];
|
|
1119
|
+
var _loop_1 = function (i) {
|
|
1120
|
+
paramArray.push(seqs.map(function (seq) { return seq[i]; }));
|
|
1121
|
+
};
|
|
1122
|
+
for (var i = 0; i < len; i++) {
|
|
1123
|
+
_loop_1(i);
|
|
1124
|
+
}
|
|
1125
|
+
var mapped = paramArray.map(function (p) { return executeFunction(fn, p, contextStack, sourceCodeInfo); });
|
|
1126
|
+
if (!isStr) {
|
|
1127
|
+
return mapped;
|
|
1128
|
+
}
|
|
1129
|
+
mapped.forEach(function (char) { return assertString(char, sourceCodeInfo); });
|
|
1130
|
+
return mapped.join('');
|
|
1131
|
+
},
|
|
1132
|
+
paramCount: { min: 2 },
|
|
1133
|
+
},
|
|
1134
|
+
'reduce': {
|
|
1135
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1136
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1137
|
+
var executeFunction = _b.executeFunction;
|
|
1138
|
+
assertColl(coll, sourceCodeInfo);
|
|
1139
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1140
|
+
assertAny(initial, sourceCodeInfo);
|
|
1141
|
+
if (typeof coll === 'string') {
|
|
1142
|
+
assertString(initial, sourceCodeInfo);
|
|
1143
|
+
if (coll.length === 0)
|
|
1144
|
+
return initial;
|
|
1145
|
+
return coll.split('').reduce(function (result, elem) {
|
|
1146
|
+
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1147
|
+
}, initial);
|
|
1148
|
+
}
|
|
1149
|
+
else if (Array.isArray(coll)) {
|
|
1150
|
+
if (coll.length === 0)
|
|
1151
|
+
return initial;
|
|
1152
|
+
return coll.reduce(function (result, elem) {
|
|
1153
|
+
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1154
|
+
}, initial);
|
|
1155
|
+
}
|
|
1156
|
+
else {
|
|
1157
|
+
if (Object.keys(coll).length === 0)
|
|
1158
|
+
return initial;
|
|
1159
|
+
return Object.entries(coll).reduce(function (result, _a) {
|
|
1160
|
+
var _b = __read(_a, 2), elem = _b[1];
|
|
1161
|
+
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1162
|
+
}, initial);
|
|
1163
|
+
}
|
|
1164
|
+
},
|
|
1165
|
+
paramCount: 3,
|
|
1166
|
+
},
|
|
1167
|
+
'reduce-right': {
|
|
1168
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1169
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1170
|
+
var executeFunction = _b.executeFunction;
|
|
1171
|
+
assertColl(coll, sourceCodeInfo);
|
|
1172
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1173
|
+
assertAny(initial, sourceCodeInfo);
|
|
1174
|
+
if (typeof coll === 'string') {
|
|
1175
|
+
if (coll.length === 0)
|
|
1176
|
+
return initial;
|
|
1177
|
+
return coll.split('').reduceRight(function (result, elem) {
|
|
1178
|
+
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1179
|
+
}, initial);
|
|
1180
|
+
}
|
|
1181
|
+
else if (Array.isArray(coll)) {
|
|
1182
|
+
if (coll.length === 0)
|
|
1183
|
+
return initial;
|
|
1184
|
+
return coll.reduceRight(function (result, elem) {
|
|
1185
|
+
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1186
|
+
}, initial);
|
|
1187
|
+
}
|
|
1188
|
+
else {
|
|
1189
|
+
if (Object.keys(coll).length === 0)
|
|
1190
|
+
return initial;
|
|
1191
|
+
return Object.entries(coll).reduceRight(function (result, _a) {
|
|
1192
|
+
var _b = __read(_a, 2), elem = _b[1];
|
|
1193
|
+
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1194
|
+
}, initial);
|
|
1195
|
+
}
|
|
1196
|
+
},
|
|
1197
|
+
paramCount: 3,
|
|
1198
|
+
},
|
|
1199
|
+
'reductions': {
|
|
1200
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1201
|
+
var _c = __read(_a, 3), coll = _c[0], fn = _c[1], initial = _c[2];
|
|
1202
|
+
var executeFunction = _b.executeFunction;
|
|
1203
|
+
assertColl(coll, sourceCodeInfo);
|
|
1204
|
+
assertFunctionLike(fn, sourceCodeInfo);
|
|
1205
|
+
assertAny(initial, sourceCodeInfo);
|
|
1206
|
+
assertAny(initial, sourceCodeInfo);
|
|
1207
|
+
if (typeof coll === 'string') {
|
|
1208
|
+
assertString(initial, sourceCodeInfo);
|
|
1209
|
+
if (coll.length === 0)
|
|
1210
|
+
return [initial];
|
|
1211
|
+
var resultArray_1 = [initial];
|
|
1212
|
+
coll.split('').reduce(function (result, elem) {
|
|
1213
|
+
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1214
|
+
resultArray_1.push(newVal);
|
|
1215
|
+
return newVal;
|
|
1216
|
+
}, initial);
|
|
1217
|
+
return resultArray_1;
|
|
1218
|
+
}
|
|
1219
|
+
else if (Array.isArray(coll)) {
|
|
1220
|
+
if (coll.length === 0)
|
|
1221
|
+
return [initial];
|
|
1222
|
+
var resultArray_2 = [initial];
|
|
1223
|
+
coll.reduce(function (result, elem) {
|
|
1224
|
+
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1225
|
+
resultArray_2.push(newVal);
|
|
1226
|
+
return newVal;
|
|
1227
|
+
}, initial);
|
|
1228
|
+
return resultArray_2;
|
|
1229
|
+
}
|
|
1230
|
+
else {
|
|
1231
|
+
if (Object.keys(coll).length === 0)
|
|
1232
|
+
return [initial];
|
|
1233
|
+
var resultArray_3 = [initial];
|
|
1234
|
+
Object.entries(coll).reduce(function (result, _a) {
|
|
1235
|
+
var _b = __read(_a, 2), elem = _b[1];
|
|
1236
|
+
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1237
|
+
resultArray_3.push(newVal);
|
|
1238
|
+
return newVal;
|
|
1239
|
+
}, initial);
|
|
1240
|
+
return resultArray_3;
|
|
1241
|
+
}
|
|
1242
|
+
},
|
|
1243
|
+
paramCount: 3,
|
|
1244
|
+
},
|
|
1037
1245
|
'get': {
|
|
1038
1246
|
evaluate: function (params, sourceCodeInfo) {
|
|
1039
1247
|
var _a = __read(params, 2), coll = _a[0], key = _a[1];
|
|
@@ -1376,23 +1584,6 @@ var sequenceNormalExpression = {
|
|
|
1376
1584
|
},
|
|
1377
1585
|
paramCount: { min: 2, max: 3 },
|
|
1378
1586
|
},
|
|
1379
|
-
'filter': {
|
|
1380
|
-
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
1381
|
-
var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
|
|
1382
|
-
var executeFunction = _b.executeFunction;
|
|
1383
|
-
assertSeq(seq, sourceCodeInfo);
|
|
1384
|
-
assertFunctionLike(fn, sourceCodeInfo);
|
|
1385
|
-
if (Array.isArray(seq)) {
|
|
1386
|
-
var result = seq.filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
|
|
1387
|
-
return result;
|
|
1388
|
-
}
|
|
1389
|
-
return seq
|
|
1390
|
-
.split('')
|
|
1391
|
-
.filter(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); })
|
|
1392
|
-
.join('');
|
|
1393
|
-
},
|
|
1394
|
-
paramCount: 2,
|
|
1395
|
-
},
|
|
1396
1587
|
'first': {
|
|
1397
1588
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1398
1589
|
var _b = __read(_a, 1), array = _b[0];
|
|
@@ -1415,39 +1606,6 @@ var sequenceNormalExpression = {
|
|
|
1415
1606
|
},
|
|
1416
1607
|
paramCount: 1,
|
|
1417
1608
|
},
|
|
1418
|
-
'map': {
|
|
1419
|
-
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1420
|
-
var executeFunction = _a.executeFunction;
|
|
1421
|
-
var fn = asFunctionLike(params.at(-1), sourceCodeInfo);
|
|
1422
|
-
var seqs = params.slice(0, -1);
|
|
1423
|
-
assertSeq(seqs[0], sourceCodeInfo);
|
|
1424
|
-
var isString = typeof seqs[0] === 'string';
|
|
1425
|
-
var len = seqs[0].length;
|
|
1426
|
-
seqs.slice(1).forEach(function (seq) {
|
|
1427
|
-
if (isString) {
|
|
1428
|
-
assertString(seq, sourceCodeInfo);
|
|
1429
|
-
}
|
|
1430
|
-
else {
|
|
1431
|
-
assertArray(seq, sourceCodeInfo);
|
|
1432
|
-
}
|
|
1433
|
-
len = Math.min(len, seq.length);
|
|
1434
|
-
});
|
|
1435
|
-
var paramArray = [];
|
|
1436
|
-
var _loop_1 = function (i) {
|
|
1437
|
-
paramArray.push(seqs.map(function (seq) { return seq[i]; }));
|
|
1438
|
-
};
|
|
1439
|
-
for (var i = 0; i < len; i++) {
|
|
1440
|
-
_loop_1(i);
|
|
1441
|
-
}
|
|
1442
|
-
var mapped = paramArray.map(function (p) { return executeFunction(fn, p, contextStack, sourceCodeInfo); });
|
|
1443
|
-
if (!isString) {
|
|
1444
|
-
return mapped;
|
|
1445
|
-
}
|
|
1446
|
-
mapped.forEach(function (char) { return assertString(char, sourceCodeInfo); });
|
|
1447
|
-
return mapped.join('');
|
|
1448
|
-
},
|
|
1449
|
-
paramCount: { min: 2 },
|
|
1450
|
-
},
|
|
1451
1609
|
'pop': {
|
|
1452
1610
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1453
1611
|
var _b = __read(_a, 1), seq = _b[0];
|
|
@@ -1530,160 +1688,6 @@ var sequenceNormalExpression = {
|
|
|
1530
1688
|
},
|
|
1531
1689
|
paramCount: { min: 2 },
|
|
1532
1690
|
},
|
|
1533
|
-
'reductions': {
|
|
1534
|
-
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1535
|
-
var executeFunction = _a.executeFunction;
|
|
1536
|
-
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
1537
|
-
assertSeq(seq, sourceCodeInfo);
|
|
1538
|
-
assertFunctionLike(fn, sourceCodeInfo);
|
|
1539
|
-
if (params.length === 2) {
|
|
1540
|
-
if (seq.length === 0)
|
|
1541
|
-
return [executeFunction(fn, [], contextStack, sourceCodeInfo)];
|
|
1542
|
-
else if (seq.length === 1)
|
|
1543
|
-
return [toAny(seq[0])];
|
|
1544
|
-
if (typeof seq === 'string') {
|
|
1545
|
-
var chars = seq.split('');
|
|
1546
|
-
var resultArray_1 = [asAny(chars[0], sourceCodeInfo)];
|
|
1547
|
-
chars.slice(1).reduce(function (result, elem) {
|
|
1548
|
-
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1549
|
-
resultArray_1.push(newVal);
|
|
1550
|
-
return newVal;
|
|
1551
|
-
}, asAny(chars[0], sourceCodeInfo));
|
|
1552
|
-
return resultArray_1;
|
|
1553
|
-
}
|
|
1554
|
-
else {
|
|
1555
|
-
var resultArray_2 = [toAny(seq[0])];
|
|
1556
|
-
seq.slice(1).reduce(function (result, elem) {
|
|
1557
|
-
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1558
|
-
resultArray_2.push(newVal);
|
|
1559
|
-
return newVal;
|
|
1560
|
-
}, toAny(seq[0]));
|
|
1561
|
-
return resultArray_2;
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
else {
|
|
1565
|
-
var val = params[2];
|
|
1566
|
-
assertAny(val, sourceCodeInfo);
|
|
1567
|
-
if (typeof seq === 'string') {
|
|
1568
|
-
assertString(val, sourceCodeInfo);
|
|
1569
|
-
if (seq.length === 0)
|
|
1570
|
-
return [val];
|
|
1571
|
-
var resultArray_3 = [val];
|
|
1572
|
-
seq.split('').reduce(function (result, elem) {
|
|
1573
|
-
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1574
|
-
resultArray_3.push(newVal);
|
|
1575
|
-
return newVal;
|
|
1576
|
-
}, val);
|
|
1577
|
-
return resultArray_3;
|
|
1578
|
-
}
|
|
1579
|
-
else {
|
|
1580
|
-
if (seq.length === 0)
|
|
1581
|
-
return [val];
|
|
1582
|
-
var resultArray_4 = [val];
|
|
1583
|
-
seq.reduce(function (result, elem) {
|
|
1584
|
-
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1585
|
-
resultArray_4.push(newVal);
|
|
1586
|
-
return newVal;
|
|
1587
|
-
}, val);
|
|
1588
|
-
return resultArray_4;
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
},
|
|
1592
|
-
paramCount: { min: 2, max: 3 },
|
|
1593
|
-
},
|
|
1594
|
-
'reduce': {
|
|
1595
|
-
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1596
|
-
var executeFunction = _a.executeFunction;
|
|
1597
|
-
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
1598
|
-
assertSeq(seq, sourceCodeInfo);
|
|
1599
|
-
assertFunctionLike(fn, sourceCodeInfo);
|
|
1600
|
-
if (params.length === 2) {
|
|
1601
|
-
if (seq.length === 0)
|
|
1602
|
-
return executeFunction(fn, [], contextStack, sourceCodeInfo);
|
|
1603
|
-
else if (seq.length === 1)
|
|
1604
|
-
return toAny(seq[0]);
|
|
1605
|
-
if (typeof seq === 'string') {
|
|
1606
|
-
var chars = seq.split('');
|
|
1607
|
-
return chars.slice(1).reduce(function (result, elem) {
|
|
1608
|
-
var val = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1609
|
-
return val;
|
|
1610
|
-
}, asAny(chars[0], sourceCodeInfo));
|
|
1611
|
-
}
|
|
1612
|
-
else {
|
|
1613
|
-
return seq.slice(1).reduce(function (result, elem) {
|
|
1614
|
-
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1615
|
-
}, toAny(seq[0]));
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
else {
|
|
1619
|
-
var val = params[2];
|
|
1620
|
-
assertAny(val, sourceCodeInfo);
|
|
1621
|
-
if (typeof seq === 'string') {
|
|
1622
|
-
assertString(val, sourceCodeInfo);
|
|
1623
|
-
if (seq.length === 0)
|
|
1624
|
-
return val;
|
|
1625
|
-
return seq.split('').reduce(function (result, elem) {
|
|
1626
|
-
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1627
|
-
}, val);
|
|
1628
|
-
}
|
|
1629
|
-
else {
|
|
1630
|
-
if (seq.length === 0)
|
|
1631
|
-
return val;
|
|
1632
|
-
return seq.reduce(function (result, elem) {
|
|
1633
|
-
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1634
|
-
}, val);
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
},
|
|
1638
|
-
paramCount: { min: 2, max: 3 },
|
|
1639
|
-
},
|
|
1640
|
-
'reduce-right': {
|
|
1641
|
-
evaluate: function (params, sourceCodeInfo, contextStack, _a) {
|
|
1642
|
-
var executeFunction = _a.executeFunction;
|
|
1643
|
-
var _b = __read(params, 2), seq = _b[0], fn = _b[1];
|
|
1644
|
-
assertSeq(seq, sourceCodeInfo);
|
|
1645
|
-
assertFunctionLike(fn, sourceCodeInfo);
|
|
1646
|
-
if (params.length === 2) {
|
|
1647
|
-
if (seq.length === 0)
|
|
1648
|
-
return executeFunction(fn, [], contextStack, sourceCodeInfo);
|
|
1649
|
-
else if (seq.length === 1)
|
|
1650
|
-
return toAny(seq[0]);
|
|
1651
|
-
if (typeof seq === 'string') {
|
|
1652
|
-
var chars = seq.split('');
|
|
1653
|
-
return chars.slice(0, chars.length - 1).reduceRight(function (result, elem) {
|
|
1654
|
-
var newVal = executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1655
|
-
assertString(newVal, sourceCodeInfo);
|
|
1656
|
-
return newVal;
|
|
1657
|
-
}, chars[chars.length - 1]);
|
|
1658
|
-
}
|
|
1659
|
-
else {
|
|
1660
|
-
return seq.slice(0, seq.length - 1).reduceRight(function (result, elem) {
|
|
1661
|
-
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1662
|
-
}, asAny(seq[seq.length - 1], sourceCodeInfo));
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
else {
|
|
1666
|
-
var val = params[2];
|
|
1667
|
-
assertAny(val, sourceCodeInfo);
|
|
1668
|
-
assertSeq(seq, sourceCodeInfo);
|
|
1669
|
-
if (typeof seq === 'string') {
|
|
1670
|
-
if (seq.length === 0)
|
|
1671
|
-
return val;
|
|
1672
|
-
return seq.split('').reduceRight(function (result, elem) {
|
|
1673
|
-
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1674
|
-
}, val);
|
|
1675
|
-
}
|
|
1676
|
-
else {
|
|
1677
|
-
if (seq.length === 0)
|
|
1678
|
-
return val;
|
|
1679
|
-
return seq.reduceRight(function (result, elem) {
|
|
1680
|
-
return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo);
|
|
1681
|
-
}, val);
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
},
|
|
1685
|
-
paramCount: { min: 2, max: 3 },
|
|
1686
|
-
},
|
|
1687
1691
|
'rest': {
|
|
1688
1692
|
evaluate: function (_a, sourceCodeInfo) {
|
|
1689
1693
|
var _b = __read(_a, 1), seq = _b[0];
|
|
@@ -2002,7 +2006,7 @@ var sequenceNormalExpression = {
|
|
|
2002
2006
|
assertSeq(input, sourceCodeInfo);
|
|
2003
2007
|
if (Array.isArray(input)) {
|
|
2004
2008
|
var result = [];
|
|
2005
|
-
var
|
|
2009
|
+
var _loop_1 = function (item) {
|
|
2006
2010
|
assertAny(item, sourceCodeInfo);
|
|
2007
2011
|
if (!result.some(function (existingItem) { return deepEqual(existingItem, item, sourceCodeInfo); })) {
|
|
2008
2012
|
result.push(item);
|
|
@@ -2011,7 +2015,7 @@ var sequenceNormalExpression = {
|
|
|
2011
2015
|
try {
|
|
2012
2016
|
for (var input_1 = __values(input), input_1_1 = input_1.next(); !input_1_1.done; input_1_1 = input_1.next()) {
|
|
2013
2017
|
var item = input_1_1.value;
|
|
2014
|
-
|
|
2018
|
+
_loop_1(item);
|
|
2015
2019
|
}
|
|
2016
2020
|
}
|
|
2017
2021
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -4315,6 +4319,15 @@ function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
|
|
|
4315
4319
|
}
|
|
4316
4320
|
|
|
4317
4321
|
var functionalNormalExpression = {
|
|
4322
|
+
'|>': {
|
|
4323
|
+
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
4324
|
+
var _c = __read(_a, 2), value = _c[0], func = _c[1];
|
|
4325
|
+
var executeFunction = _b.executeFunction;
|
|
4326
|
+
assertFunctionLike(func, sourceCodeInfo);
|
|
4327
|
+
return executeFunction(func, [value], contextStack, sourceCodeInfo);
|
|
4328
|
+
},
|
|
4329
|
+
paramCount: 2,
|
|
4330
|
+
},
|
|
4318
4331
|
'apply': {
|
|
4319
4332
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
4320
4333
|
var _c = __read(_a), func = _c[0], params = _c.slice(1);
|
|
@@ -4335,20 +4348,6 @@ var functionalNormalExpression = {
|
|
|
4335
4348
|
},
|
|
4336
4349
|
paramCount: 1,
|
|
4337
4350
|
},
|
|
4338
|
-
'partial': {
|
|
4339
|
-
evaluate: function (_a, sourceCodeInfo) {
|
|
4340
|
-
var _b;
|
|
4341
|
-
var _c = __read(_a), fn = _c[0], params = _c.slice(1);
|
|
4342
|
-
return _b = {},
|
|
4343
|
-
_b[FUNCTION_SYMBOL] = true,
|
|
4344
|
-
_b.sourceCodeInfo = sourceCodeInfo,
|
|
4345
|
-
_b.functionType = 'Partial',
|
|
4346
|
-
_b.function = asFunctionLike(fn, sourceCodeInfo),
|
|
4347
|
-
_b.params = params,
|
|
4348
|
-
_b;
|
|
4349
|
-
},
|
|
4350
|
-
paramCount: { min: 1 },
|
|
4351
|
-
},
|
|
4352
4351
|
'comp': {
|
|
4353
4352
|
evaluate: function (params, sourceCodeInfo) {
|
|
4354
4353
|
var _a;
|
|
@@ -11275,6 +11274,7 @@ var nonNumberReservedSymbolRecord = {
|
|
|
11275
11274
|
function: null,
|
|
11276
11275
|
export: null,
|
|
11277
11276
|
as: null,
|
|
11277
|
+
_: null,
|
|
11278
11278
|
};
|
|
11279
11279
|
var phi = (1 + Math.sqrt(5)) / 2;
|
|
11280
11280
|
var numberReservedSymbolRecord = {
|
|
@@ -12124,8 +12124,27 @@ var functionExecutors = {
|
|
|
12124
12124
|
}
|
|
12125
12125
|
},
|
|
12126
12126
|
Partial: function (fn, params, sourceCodeInfo, contextStack, _a) {
|
|
12127
|
+
var e_2, _b;
|
|
12127
12128
|
var executeFunction = _a.executeFunction;
|
|
12128
|
-
|
|
12129
|
+
var actualParams = __spreadArray([], __read(fn.params), false);
|
|
12130
|
+
if (params.length !== fn.placeholders.length) {
|
|
12131
|
+
throw new LitsError("(partial) expects ".concat(fn.placeholders.length, " arguments, got ").concat(params.length, "."), sourceCodeInfo);
|
|
12132
|
+
}
|
|
12133
|
+
var paramsCopy = __spreadArray([], __read(params), false);
|
|
12134
|
+
try {
|
|
12135
|
+
for (var _c = __values(fn.placeholders), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
12136
|
+
var placeholderIndex = _d.value;
|
|
12137
|
+
actualParams.splice(placeholderIndex, 0, paramsCopy.shift());
|
|
12138
|
+
}
|
|
12139
|
+
}
|
|
12140
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
12141
|
+
finally {
|
|
12142
|
+
try {
|
|
12143
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
12144
|
+
}
|
|
12145
|
+
finally { if (e_2) throw e_2.error; }
|
|
12146
|
+
}
|
|
12147
|
+
return executeFunction(fn.function, actualParams, contextStack, sourceCodeInfo);
|
|
12129
12148
|
},
|
|
12130
12149
|
Comp: function (fn, params, sourceCodeInfo, contextStack, _a) {
|
|
12131
12150
|
var executeFunction = _a.executeFunction;
|
|
@@ -12151,66 +12170,66 @@ var functionExecutors = {
|
|
|
12151
12170
|
return !executeFunction(fn.function, params, contextStack, sourceCodeInfo);
|
|
12152
12171
|
},
|
|
12153
12172
|
EveryPred: function (fn, params, sourceCodeInfo, contextStack, _a) {
|
|
12154
|
-
var
|
|
12173
|
+
var e_3, _b, e_4, _c;
|
|
12155
12174
|
var executeFunction = _a.executeFunction;
|
|
12156
12175
|
try {
|
|
12157
12176
|
for (var _d = __values(fn.params), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
12158
12177
|
var f = _e.value;
|
|
12159
12178
|
try {
|
|
12160
|
-
for (var params_1 = (
|
|
12179
|
+
for (var params_1 = (e_4 = void 0, __values(params)), params_1_1 = params_1.next(); !params_1_1.done; params_1_1 = params_1.next()) {
|
|
12161
12180
|
var param = params_1_1.value;
|
|
12162
12181
|
var result = executeFunction(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo);
|
|
12163
12182
|
if (!result)
|
|
12164
12183
|
return false;
|
|
12165
12184
|
}
|
|
12166
12185
|
}
|
|
12167
|
-
catch (
|
|
12186
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
12168
12187
|
finally {
|
|
12169
12188
|
try {
|
|
12170
12189
|
if (params_1_1 && !params_1_1.done && (_c = params_1.return)) _c.call(params_1);
|
|
12171
12190
|
}
|
|
12172
|
-
finally { if (
|
|
12191
|
+
finally { if (e_4) throw e_4.error; }
|
|
12173
12192
|
}
|
|
12174
12193
|
}
|
|
12175
12194
|
}
|
|
12176
|
-
catch (
|
|
12195
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
12177
12196
|
finally {
|
|
12178
12197
|
try {
|
|
12179
12198
|
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
12180
12199
|
}
|
|
12181
|
-
finally { if (
|
|
12200
|
+
finally { if (e_3) throw e_3.error; }
|
|
12182
12201
|
}
|
|
12183
12202
|
return true;
|
|
12184
12203
|
},
|
|
12185
12204
|
SomePred: function (fn, params, sourceCodeInfo, contextStack, _a) {
|
|
12186
|
-
var
|
|
12205
|
+
var e_5, _b, e_6, _c;
|
|
12187
12206
|
var executeFunction = _a.executeFunction;
|
|
12188
12207
|
try {
|
|
12189
12208
|
for (var _d = __values(fn.params), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
12190
12209
|
var f = _e.value;
|
|
12191
12210
|
try {
|
|
12192
|
-
for (var params_2 = (
|
|
12211
|
+
for (var params_2 = (e_6 = void 0, __values(params)), params_2_1 = params_2.next(); !params_2_1.done; params_2_1 = params_2.next()) {
|
|
12193
12212
|
var param = params_2_1.value;
|
|
12194
12213
|
var result = executeFunction(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo);
|
|
12195
12214
|
if (result)
|
|
12196
12215
|
return true;
|
|
12197
12216
|
}
|
|
12198
12217
|
}
|
|
12199
|
-
catch (
|
|
12218
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
12200
12219
|
finally {
|
|
12201
12220
|
try {
|
|
12202
12221
|
if (params_2_1 && !params_2_1.done && (_c = params_2.return)) _c.call(params_2);
|
|
12203
12222
|
}
|
|
12204
|
-
finally { if (
|
|
12223
|
+
finally { if (e_6) throw e_6.error; }
|
|
12205
12224
|
}
|
|
12206
12225
|
}
|
|
12207
12226
|
}
|
|
12208
|
-
catch (
|
|
12227
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
12209
12228
|
finally {
|
|
12210
12229
|
try {
|
|
12211
12230
|
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
12212
12231
|
}
|
|
12213
|
-
finally { if (
|
|
12232
|
+
finally { if (e_5) throw e_5.error; }
|
|
12214
12233
|
}
|
|
12215
12234
|
return false;
|
|
12216
12235
|
},
|
|
@@ -12283,6 +12302,9 @@ function evaluateString(node) {
|
|
|
12283
12302
|
}
|
|
12284
12303
|
function evaluateReservedSymbol(node) {
|
|
12285
12304
|
var reservedName = node[1];
|
|
12305
|
+
if (!['true', 'false', 'null'].includes(reservedName)) {
|
|
12306
|
+
throw new LitsError("Reserved symbol ".concat(reservedName, " cannot be evaluated"), node[2]);
|
|
12307
|
+
}
|
|
12286
12308
|
var value = reservedSymbolRecord[reservedName];
|
|
12287
12309
|
return asNonUndefined(value, node[2]);
|
|
12288
12310
|
}
|
|
@@ -12290,7 +12312,8 @@ function evaluateNormalExpression(node, contextStack) {
|
|
|
12290
12312
|
var sourceCodeInfo = node[2];
|
|
12291
12313
|
var paramNodes = node[1][1];
|
|
12292
12314
|
var params = [];
|
|
12293
|
-
|
|
12315
|
+
var placeholders = [];
|
|
12316
|
+
paramNodes.forEach(function (paramNode, index) {
|
|
12294
12317
|
if (isSpreadNode(paramNode)) {
|
|
12295
12318
|
var spreadValue = evaluateNode(paramNode[1], contextStack);
|
|
12296
12319
|
if (Array.isArray(spreadValue)) {
|
|
@@ -12300,12 +12323,27 @@ function evaluateNormalExpression(node, contextStack) {
|
|
|
12300
12323
|
throw new LitsError("Spread operator requires an array, got ".concat(valueToString(paramNode)), paramNode[2]);
|
|
12301
12324
|
}
|
|
12302
12325
|
}
|
|
12326
|
+
else if (paramNode[0] === NodeTypes.ReservedSymbol && paramNode[1] === '_') {
|
|
12327
|
+
placeholders.push(index);
|
|
12328
|
+
}
|
|
12303
12329
|
else {
|
|
12304
12330
|
params.push(evaluateNode(paramNode, contextStack));
|
|
12305
12331
|
}
|
|
12306
12332
|
});
|
|
12307
12333
|
if (isNormalExpressionNodeWithName(node)) {
|
|
12308
12334
|
var nameSymbol = node[1][0];
|
|
12335
|
+
if (placeholders.length > 0) {
|
|
12336
|
+
var fn = evaluateNode(nameSymbol, contextStack);
|
|
12337
|
+
var partialFunction = {
|
|
12338
|
+
'^^fn^^': true,
|
|
12339
|
+
'function': asFunctionLike(fn, sourceCodeInfo),
|
|
12340
|
+
'functionType': 'Partial',
|
|
12341
|
+
params: params,
|
|
12342
|
+
placeholders: placeholders,
|
|
12343
|
+
sourceCodeInfo: sourceCodeInfo,
|
|
12344
|
+
};
|
|
12345
|
+
return partialFunction;
|
|
12346
|
+
}
|
|
12309
12347
|
if (isNormalBuiltinSymbolNode(nameSymbol)) {
|
|
12310
12348
|
var type = nameSymbol[1];
|
|
12311
12349
|
var normalExpression = builtin.allNormalExpressions[type];
|
|
@@ -12322,6 +12360,17 @@ function evaluateNormalExpression(node, contextStack) {
|
|
|
12322
12360
|
else {
|
|
12323
12361
|
var fnNode = node[1][0];
|
|
12324
12362
|
var fn = asFunctionLike(evaluateNode(fnNode, contextStack), sourceCodeInfo);
|
|
12363
|
+
if (placeholders.length > 0) {
|
|
12364
|
+
var partialFunction = {
|
|
12365
|
+
'^^fn^^': true,
|
|
12366
|
+
'function': asFunctionLike(fn, sourceCodeInfo),
|
|
12367
|
+
'functionType': 'Partial',
|
|
12368
|
+
params: params,
|
|
12369
|
+
placeholders: placeholders,
|
|
12370
|
+
sourceCodeInfo: sourceCodeInfo,
|
|
12371
|
+
};
|
|
12372
|
+
return partialFunction;
|
|
12373
|
+
}
|
|
12325
12374
|
return executeFunction(fn, params, contextStack, sourceCodeInfo);
|
|
12326
12375
|
}
|
|
12327
12376
|
}
|
|
@@ -12627,6 +12676,7 @@ var binaryOperators = [
|
|
|
12627
12676
|
'&&', // logical AND
|
|
12628
12677
|
'||', // logical OR
|
|
12629
12678
|
'??', // nullish coalescing
|
|
12679
|
+
'|>', // pipe
|
|
12630
12680
|
];
|
|
12631
12681
|
var otherOperators = [
|
|
12632
12682
|
'->', // lambda
|
|
@@ -13220,8 +13270,8 @@ function untokenize(tokenStream) {
|
|
|
13220
13270
|
}, '');
|
|
13221
13271
|
}
|
|
13222
13272
|
|
|
13223
|
-
var exponentiationPrecedence =
|
|
13224
|
-
var binaryFunctionalOperatorPrecedence =
|
|
13273
|
+
var exponentiationPrecedence = 11;
|
|
13274
|
+
var binaryFunctionalOperatorPrecedence = 2;
|
|
13225
13275
|
var placeholderRegexp = /^\$([1-9]\d?)?$/;
|
|
13226
13276
|
function withSourceCodeInfo(node, sourceCodeInfo) {
|
|
13227
13277
|
if (sourceCodeInfo) {
|
|
@@ -13236,38 +13286,40 @@ function getPrecedence(operatorSign, sourceCodeInfo) {
|
|
|
13236
13286
|
case '*': // multiplication
|
|
13237
13287
|
case '/': // division
|
|
13238
13288
|
case '%': // remainder
|
|
13239
|
-
return
|
|
13289
|
+
return 10;
|
|
13240
13290
|
case '+': // addition
|
|
13241
13291
|
case '-': // subtraction
|
|
13242
|
-
return
|
|
13292
|
+
return 9;
|
|
13243
13293
|
case '<<': // left shift
|
|
13244
13294
|
case '>>': // signed right shift
|
|
13245
13295
|
case '>>>': // unsigned right shift
|
|
13246
|
-
return
|
|
13296
|
+
return 8;
|
|
13247
13297
|
case '++': // string concatenation
|
|
13248
|
-
return
|
|
13298
|
+
return 7;
|
|
13249
13299
|
case '<': // less than
|
|
13250
13300
|
case '<=': // less than or equal
|
|
13251
13301
|
case '≤': // less than or equal
|
|
13252
13302
|
case '>': // greater than
|
|
13253
13303
|
case '>=': // greater than or equal
|
|
13254
13304
|
case '≥': // greater than or equal
|
|
13255
|
-
return
|
|
13305
|
+
return 6;
|
|
13256
13306
|
case '=': // equal
|
|
13257
13307
|
case '!=': // not equal
|
|
13258
13308
|
case '≠': // not equal
|
|
13259
13309
|
case '~': // approximate
|
|
13260
13310
|
case '≈': // approximate
|
|
13261
|
-
return
|
|
13311
|
+
return 5;
|
|
13262
13312
|
case '&': // bitwise AND
|
|
13263
13313
|
case 'xor': // bitwise XOR
|
|
13264
13314
|
case '|': // bitwise OR
|
|
13265
|
-
return
|
|
13315
|
+
return 4;
|
|
13266
13316
|
case '&&': // logical AND
|
|
13267
13317
|
case '||': // logical OR
|
|
13268
13318
|
case '??': // nullish coalescing
|
|
13269
|
-
return
|
|
13270
|
-
|
|
13319
|
+
return 3;
|
|
13320
|
+
case '|>': // pipe
|
|
13321
|
+
return 1;
|
|
13322
|
+
// leave room for binaryFunctionalOperatorPrecedence = 2
|
|
13271
13323
|
/* v8 ignore next 2 */
|
|
13272
13324
|
default:
|
|
13273
13325
|
throw new LitsError("Unknown binary operator: ".concat(operatorSign), sourceCodeInfo);
|
|
@@ -13311,6 +13363,7 @@ function fromBinaryOperatorToNode(operator, symbolNode, left, right, sourceCodeI
|
|
|
13311
13363
|
case '|':
|
|
13312
13364
|
case '~':
|
|
13313
13365
|
case '≈':
|
|
13366
|
+
case '|>':
|
|
13314
13367
|
return createNamedNormalExpressionNode(symbolNode, [left, right], sourceCodeInfo);
|
|
13315
13368
|
case '&&':
|
|
13316
13369
|
case '||':
|
|
@@ -14768,6 +14821,11 @@ function getVectorReductionNames(name) {
|
|
|
14768
14821
|
}
|
|
14769
14822
|
var api = {
|
|
14770
14823
|
collection: [
|
|
14824
|
+
'filter',
|
|
14825
|
+
'map',
|
|
14826
|
+
'reduce',
|
|
14827
|
+
'reduce-right',
|
|
14828
|
+
'reductions',
|
|
14771
14829
|
'count',
|
|
14772
14830
|
'get',
|
|
14773
14831
|
'get-in',
|
|
@@ -14797,11 +14855,6 @@ var api = {
|
|
|
14797
14855
|
'shift',
|
|
14798
14856
|
'slice',
|
|
14799
14857
|
'splice',
|
|
14800
|
-
'reductions',
|
|
14801
|
-
'reduce',
|
|
14802
|
-
'reduce-right',
|
|
14803
|
-
'map',
|
|
14804
|
-
'filter',
|
|
14805
14858
|
'position',
|
|
14806
14859
|
'index-of',
|
|
14807
14860
|
'last-index-of',
|
|
@@ -14874,9 +14927,9 @@ var api = {
|
|
|
14874
14927
|
'atanh',
|
|
14875
14928
|
],
|
|
14876
14929
|
functional: [
|
|
14930
|
+
'|>',
|
|
14877
14931
|
'apply',
|
|
14878
14932
|
'identity',
|
|
14879
|
-
'partial',
|
|
14880
14933
|
'comp',
|
|
14881
14934
|
'constantly',
|
|
14882
14935
|
'juxt',
|
|
@@ -15971,6 +16024,142 @@ var bitwiseReference = {
|
|
|
15971
16024
|
};
|
|
15972
16025
|
|
|
15973
16026
|
var collectionReference = {
|
|
16027
|
+
'filter': {
|
|
16028
|
+
title: 'filter',
|
|
16029
|
+
category: 'Collection',
|
|
16030
|
+
linkName: 'filter',
|
|
16031
|
+
returns: {
|
|
16032
|
+
type: 'collection',
|
|
16033
|
+
},
|
|
16034
|
+
args: __assign(__assign({}, getOperatorArgs('collection', 'function')), { coll: {
|
|
16035
|
+
type: 'collection',
|
|
16036
|
+
}, fun: {
|
|
16037
|
+
type: 'function',
|
|
16038
|
+
} }),
|
|
16039
|
+
variants: [
|
|
16040
|
+
{ argumentNames: ['coll', 'fun'] },
|
|
16041
|
+
],
|
|
16042
|
+
description: 'Creates a new collection with all elements that pass the test implemented by $fun.',
|
|
16043
|
+
examples: [
|
|
16044
|
+
"\nfilter(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)",
|
|
16045
|
+
"\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)",
|
|
16046
|
+
"\nfilter(\n { a := 1, b := 2 },\n odd?\n)",
|
|
16047
|
+
],
|
|
16048
|
+
},
|
|
16049
|
+
'map': {
|
|
16050
|
+
title: 'map',
|
|
16051
|
+
category: 'Collection',
|
|
16052
|
+
linkName: 'map',
|
|
16053
|
+
returns: {
|
|
16054
|
+
type: 'collection',
|
|
16055
|
+
},
|
|
16056
|
+
args: __assign(__assign({}, getOperatorArgs('collection', 'function')), { colls: {
|
|
16057
|
+
type: 'collection',
|
|
16058
|
+
rest: true,
|
|
16059
|
+
description: 'At least one.',
|
|
16060
|
+
}, fun: {
|
|
16061
|
+
type: 'function',
|
|
16062
|
+
} }),
|
|
16063
|
+
variants: [
|
|
16064
|
+
{ argumentNames: ['colls', 'fun'] },
|
|
16065
|
+
],
|
|
16066
|
+
description: 'Creates a new collection populated with the results of calling $fun on every element in $colls.',
|
|
16067
|
+
examples: [
|
|
16068
|
+
'[1, 2, 3] map -',
|
|
16069
|
+
'[1, 2, 3] map -> -($)',
|
|
16070
|
+
'map(["Albert", "Mojir", 42], str)',
|
|
16071
|
+
'map([1, 2, 3], inc)',
|
|
16072
|
+
'map([1, 2, 3], [1, 10, 100], *)',
|
|
16073
|
+
'map({ a := 1, b := 2 }, inc)',
|
|
16074
|
+
'map({ a := 1, b := 2 }, { a := 10, b := 20 }, +)',
|
|
16075
|
+
],
|
|
16076
|
+
},
|
|
16077
|
+
'reduce': {
|
|
16078
|
+
title: 'reduce',
|
|
16079
|
+
category: 'Collection',
|
|
16080
|
+
linkName: 'reduce',
|
|
16081
|
+
returns: {
|
|
16082
|
+
type: 'any',
|
|
16083
|
+
},
|
|
16084
|
+
args: {
|
|
16085
|
+
fun: {
|
|
16086
|
+
type: 'function',
|
|
16087
|
+
},
|
|
16088
|
+
coll: {
|
|
16089
|
+
type: 'collection',
|
|
16090
|
+
},
|
|
16091
|
+
initial: {
|
|
16092
|
+
type: 'any',
|
|
16093
|
+
},
|
|
16094
|
+
},
|
|
16095
|
+
variants: [
|
|
16096
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16097
|
+
],
|
|
16098
|
+
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.',
|
|
16099
|
+
examples: [
|
|
16100
|
+
'reduce([1, 2, 3], +, 0)',
|
|
16101
|
+
'reduce([], +, 0)',
|
|
16102
|
+
'reduce({ a := 1, b := 2 }, +, 0)',
|
|
16103
|
+
"\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + if even?(value) then value else 0 end,\n 0)",
|
|
16104
|
+
],
|
|
16105
|
+
},
|
|
16106
|
+
'reduce-right': {
|
|
16107
|
+
title: 'reduce-right',
|
|
16108
|
+
category: 'Collection',
|
|
16109
|
+
linkName: 'reduce-right',
|
|
16110
|
+
returns: {
|
|
16111
|
+
type: 'any',
|
|
16112
|
+
},
|
|
16113
|
+
args: {
|
|
16114
|
+
fun: {
|
|
16115
|
+
type: 'function',
|
|
16116
|
+
},
|
|
16117
|
+
coll: {
|
|
16118
|
+
type: 'collection',
|
|
16119
|
+
},
|
|
16120
|
+
initial: {
|
|
16121
|
+
type: 'any',
|
|
16122
|
+
},
|
|
16123
|
+
},
|
|
16124
|
+
variants: [
|
|
16125
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16126
|
+
],
|
|
16127
|
+
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.',
|
|
16128
|
+
examples: [
|
|
16129
|
+
'reduce-right(["A", "B", "C"], str, "")',
|
|
16130
|
+
'reduce-right({ a := 1, b := 2 }, +, 0)',
|
|
16131
|
+
],
|
|
16132
|
+
},
|
|
16133
|
+
'reductions': {
|
|
16134
|
+
title: 'reductions',
|
|
16135
|
+
category: 'Collection',
|
|
16136
|
+
linkName: 'reductions',
|
|
16137
|
+
returns: {
|
|
16138
|
+
type: 'any',
|
|
16139
|
+
},
|
|
16140
|
+
args: {
|
|
16141
|
+
fun: {
|
|
16142
|
+
type: 'function',
|
|
16143
|
+
},
|
|
16144
|
+
coll: {
|
|
16145
|
+
type: 'collection',
|
|
16146
|
+
},
|
|
16147
|
+
initial: {
|
|
16148
|
+
type: 'any',
|
|
16149
|
+
},
|
|
16150
|
+
},
|
|
16151
|
+
variants: [
|
|
16152
|
+
{ argumentNames: ['coll', 'fun', 'initial'] },
|
|
16153
|
+
],
|
|
16154
|
+
description: 'Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun.',
|
|
16155
|
+
examples: [
|
|
16156
|
+
'reductions([1, 2, 3], +, 0)',
|
|
16157
|
+
'reductions([1, 2, 3], +, 10)',
|
|
16158
|
+
'reductions([], +, 0)',
|
|
16159
|
+
'reductions({ a := 1, b := 2 }, +, 0)',
|
|
16160
|
+
"\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)",
|
|
16161
|
+
],
|
|
16162
|
+
},
|
|
15974
16163
|
'count': {
|
|
15975
16164
|
title: 'count',
|
|
15976
16165
|
category: 'Collection',
|
|
@@ -16354,6 +16543,23 @@ var collectionReference = {
|
|
|
16354
16543
|
};
|
|
16355
16544
|
|
|
16356
16545
|
var functionalReference = {
|
|
16546
|
+
'|>': {
|
|
16547
|
+
title: '|>',
|
|
16548
|
+
category: 'Functional',
|
|
16549
|
+
linkName: '-or-gt',
|
|
16550
|
+
returns: {
|
|
16551
|
+
type: 'any',
|
|
16552
|
+
},
|
|
16553
|
+
args: __assign({}, getOperatorArgs('any', 'function')),
|
|
16554
|
+
variants: [
|
|
16555
|
+
{ argumentNames: ['a', 'b'] },
|
|
16556
|
+
],
|
|
16557
|
+
description: 'Takes a value $a and a function $b, and returns the result of applying $b to $a.',
|
|
16558
|
+
examples: [
|
|
16559
|
+
"\n1 |> inc |> inc",
|
|
16560
|
+
"range(10)\n |> map(_, -> $ ^ 2) // [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]\n |> filter(_, odd?) // [1, 9, 25, 49, 81]\n |> reduce(_, +, 0) // 165\n |> sqrt // 12.84523257866513\n |> round(_, 2)",
|
|
16561
|
+
],
|
|
16562
|
+
},
|
|
16357
16563
|
'apply': {
|
|
16358
16564
|
title: 'apply',
|
|
16359
16565
|
category: 'Functional',
|
|
@@ -16394,33 +16600,6 @@ var functionalReference = {
|
|
|
16394
16600
|
description: 'Returns $x.',
|
|
16395
16601
|
examples: ['identity(1)', 'identity("Albert")', 'identity({ a := 1 })', 'identity(null)'],
|
|
16396
16602
|
},
|
|
16397
|
-
'partial': {
|
|
16398
|
-
title: 'partial',
|
|
16399
|
-
category: 'Functional',
|
|
16400
|
-
linkName: 'partial',
|
|
16401
|
-
returns: {
|
|
16402
|
-
type: 'function',
|
|
16403
|
-
},
|
|
16404
|
-
args: {
|
|
16405
|
-
fun: {
|
|
16406
|
-
type: 'function',
|
|
16407
|
-
},
|
|
16408
|
-
args: {
|
|
16409
|
-
type: 'any',
|
|
16410
|
-
rest: true,
|
|
16411
|
-
},
|
|
16412
|
-
},
|
|
16413
|
-
variants: [
|
|
16414
|
-
{ argumentNames: ['fun', 'args'] },
|
|
16415
|
-
],
|
|
16416
|
-
description: "Takes a function $fun and a optional number arguments $args to $fun.\nIt returns a function that takes the additional additional arguments.\nWhen called, the returned function calls `(`$fun `...`$args` ...additional_arguments)`.",
|
|
16417
|
-
examples: [
|
|
16418
|
-
'partial(+, 100)',
|
|
16419
|
-
"\nlet plusMany := partial(+, 100, 1000);\nplusMany(1, 10)",
|
|
16420
|
-
"\nlet addHundred := partial(+, 100);\naddHundred(10)",
|
|
16421
|
-
],
|
|
16422
|
-
noOperatorDocumentation: true,
|
|
16423
|
-
},
|
|
16424
16603
|
'comp': {
|
|
16425
16604
|
title: 'comp',
|
|
16426
16605
|
category: 'Functional',
|
|
@@ -24732,134 +24911,6 @@ var sequenceReference = {
|
|
|
24732
24911
|
'splice("Albert", 2, 2, "fo")',
|
|
24733
24912
|
],
|
|
24734
24913
|
},
|
|
24735
|
-
'reductions': {
|
|
24736
|
-
title: 'reductions',
|
|
24737
|
-
category: 'Sequence',
|
|
24738
|
-
linkName: 'reductions',
|
|
24739
|
-
returns: {
|
|
24740
|
-
type: 'any',
|
|
24741
|
-
rest: true,
|
|
24742
|
-
},
|
|
24743
|
-
args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { fun: {
|
|
24744
|
-
type: 'function',
|
|
24745
|
-
}, seq: {
|
|
24746
|
-
type: 'sequence',
|
|
24747
|
-
rest: true,
|
|
24748
|
-
}, start: {
|
|
24749
|
-
type: 'any',
|
|
24750
|
-
} }),
|
|
24751
|
-
variants: [
|
|
24752
|
-
{ argumentNames: ['seq', 'fun'] },
|
|
24753
|
-
{ argumentNames: ['seq', 'fun', 'start'] },
|
|
24754
|
-
],
|
|
24755
|
-
description: 'Returns an array of the intermediate values of the reduction (see `reduce`) of $seq by $fun.',
|
|
24756
|
-
examples: [
|
|
24757
|
-
'[1, 2, 3] reductions +',
|
|
24758
|
-
'reductions([1, 2, 3], +)',
|
|
24759
|
-
'reductions([1, 2, 3], +, 10)',
|
|
24760
|
-
'reductions([], +, 0)',
|
|
24761
|
-
"\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)",
|
|
24762
|
-
],
|
|
24763
|
-
},
|
|
24764
|
-
'reduce': {
|
|
24765
|
-
title: 'reduce',
|
|
24766
|
-
category: 'Sequence',
|
|
24767
|
-
linkName: 'reduce',
|
|
24768
|
-
returns: {
|
|
24769
|
-
type: 'any',
|
|
24770
|
-
},
|
|
24771
|
-
args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { fun: {
|
|
24772
|
-
type: 'function',
|
|
24773
|
-
}, seq: {
|
|
24774
|
-
type: 'sequence',
|
|
24775
|
-
}, start: {
|
|
24776
|
-
type: 'any',
|
|
24777
|
-
} }),
|
|
24778
|
-
variants: [
|
|
24779
|
-
{ argumentNames: ['seq', 'fun'] },
|
|
24780
|
-
{ argumentNames: ['seq', 'fun', 'start'] },
|
|
24781
|
-
],
|
|
24782
|
-
description: 'Runs $fun function on each element of the $seq, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $seq is a single value.',
|
|
24783
|
-
examples: [
|
|
24784
|
-
'[1, 2, 3] reduce +',
|
|
24785
|
-
'reduce([1, 2, 3], +)',
|
|
24786
|
-
'reduce([1, 2, 3], +, 0)',
|
|
24787
|
-
'reduce([], +, 0)',
|
|
24788
|
-
"\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + if even?(value) then value else 0 end,\n 0)",
|
|
24789
|
-
],
|
|
24790
|
-
},
|
|
24791
|
-
'reduce-right': {
|
|
24792
|
-
title: 'reduce-right',
|
|
24793
|
-
category: 'Sequence',
|
|
24794
|
-
linkName: 'reduce-right',
|
|
24795
|
-
returns: {
|
|
24796
|
-
type: 'sequence',
|
|
24797
|
-
},
|
|
24798
|
-
args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { fun: {
|
|
24799
|
-
type: 'function',
|
|
24800
|
-
}, seq: {
|
|
24801
|
-
type: 'sequence',
|
|
24802
|
-
}, start: {
|
|
24803
|
-
type: 'any',
|
|
24804
|
-
} }),
|
|
24805
|
-
variants: [
|
|
24806
|
-
{ argumentNames: ['seq', 'fun'] },
|
|
24807
|
-
{ argumentNames: ['seq', 'fun', 'start'] },
|
|
24808
|
-
],
|
|
24809
|
-
description: 'Runs $fun function on each element of the $seq (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 $seq is a single value.',
|
|
24810
|
-
examples: [
|
|
24811
|
-
'range(1, 10) reduce-right *',
|
|
24812
|
-
'reduce-right(["A", "B", "C"], str, "")',
|
|
24813
|
-
],
|
|
24814
|
-
},
|
|
24815
|
-
'map': {
|
|
24816
|
-
title: 'map',
|
|
24817
|
-
category: 'Sequence',
|
|
24818
|
-
linkName: 'map',
|
|
24819
|
-
returns: {
|
|
24820
|
-
type: 'any',
|
|
24821
|
-
rest: true,
|
|
24822
|
-
},
|
|
24823
|
-
args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { seqs: {
|
|
24824
|
-
type: 'sequence',
|
|
24825
|
-
rest: true,
|
|
24826
|
-
description: 'At least one.',
|
|
24827
|
-
}, fun: {
|
|
24828
|
-
type: 'function',
|
|
24829
|
-
} }),
|
|
24830
|
-
variants: [
|
|
24831
|
-
{ argumentNames: ['seqs', 'fun'] },
|
|
24832
|
-
],
|
|
24833
|
-
description: 'Creates a new array populated with the results of calling $fun on every element in $seqs.',
|
|
24834
|
-
examples: [
|
|
24835
|
-
'[1, 2, 3] map -',
|
|
24836
|
-
'[1, 2, 3] map -> -($)',
|
|
24837
|
-
'map(["Albert", "Mojir", 42], str)',
|
|
24838
|
-
'map([1, 2, 3], inc)',
|
|
24839
|
-
'map([1, 2, 3], [1, 10, 100], *)',
|
|
24840
|
-
],
|
|
24841
|
-
},
|
|
24842
|
-
'filter': {
|
|
24843
|
-
title: 'filter',
|
|
24844
|
-
category: 'Sequence',
|
|
24845
|
-
linkName: 'filter',
|
|
24846
|
-
returns: {
|
|
24847
|
-
type: 'sequence',
|
|
24848
|
-
},
|
|
24849
|
-
args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { seq: {
|
|
24850
|
-
type: 'sequence',
|
|
24851
|
-
}, fun: {
|
|
24852
|
-
type: 'function',
|
|
24853
|
-
} }),
|
|
24854
|
-
variants: [
|
|
24855
|
-
{ argumentNames: ['seq', 'fun'] },
|
|
24856
|
-
],
|
|
24857
|
-
description: 'Creates a new array with all elements that pass the test implemented by $fun.',
|
|
24858
|
-
examples: [
|
|
24859
|
-
"\nfilter(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)",
|
|
24860
|
-
"\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)",
|
|
24861
|
-
],
|
|
24862
|
-
},
|
|
24863
24914
|
'position': {
|
|
24864
24915
|
title: 'position',
|
|
24865
24916
|
category: 'Sequence',
|