@mojir/lits 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1264,26 +1264,37 @@ var sequenceNormalExpression = {
1264
1264
  paramCount: 1,
1265
1265
  },
1266
1266
  'map': {
1267
- evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1268
- var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
1269
- var executeFunction = _b.executeFunction;
1270
- assertSeq(seq, sourceCodeInfo);
1271
- assertLitsFunction(fn, sourceCodeInfo);
1272
- if (Array.isArray(seq)) {
1273
- return seq.map(function (elem) { return executeFunction(fn, [elem], contextStack, sourceCodeInfo); });
1267
+ evaluate: function (params, sourceCodeInfo, contextStack, _a) {
1268
+ var executeFunction = _a.executeFunction;
1269
+ var fn = asLitsFunction(params.at(-1));
1270
+ var seqs = params.slice(0, -1);
1271
+ assertSeq(seqs[0], sourceCodeInfo);
1272
+ var isString = typeof seqs[0] === 'string';
1273
+ var len = seqs[0].length;
1274
+ seqs.slice(1).forEach(function (seq) {
1275
+ if (isString) {
1276
+ assertString(seq, sourceCodeInfo);
1277
+ }
1278
+ else {
1279
+ assertArray(seq, sourceCodeInfo);
1280
+ }
1281
+ len = Math.min(len, seq.length);
1282
+ });
1283
+ var paramArray = [];
1284
+ var _loop_1 = function (i) {
1285
+ paramArray.push(seqs.map(function (seq) { return seq[i]; }));
1286
+ };
1287
+ for (var i = 0; i < len; i++) {
1288
+ _loop_1(i);
1274
1289
  }
1275
- else {
1276
- return seq
1277
- .split('')
1278
- .map(function (elem) {
1279
- var newVal = executeFunction(fn, [elem], contextStack, sourceCodeInfo);
1280
- assertString(newVal, sourceCodeInfo, { char: true });
1281
- return newVal;
1282
- })
1283
- .join('');
1290
+ var mapped = paramArray.map(function (p) { return executeFunction(fn, p, contextStack, sourceCodeInfo); });
1291
+ if (!isString) {
1292
+ return mapped;
1284
1293
  }
1294
+ mapped.forEach(function (char) { return assertString(char, sourceCodeInfo); });
1295
+ return mapped.join('');
1285
1296
  },
1286
- paramCount: 2,
1297
+ paramCount: { min: 2 },
1287
1298
  },
1288
1299
  'pop': {
1289
1300
  evaluate: function (_a, sourceCodeInfo) {
@@ -1833,7 +1844,7 @@ var sequenceNormalExpression = {
1833
1844
  assertSeq(input, sourceCodeInfo);
1834
1845
  if (Array.isArray(input)) {
1835
1846
  var result = [];
1836
- var _loop_1 = function (item) {
1847
+ var _loop_2 = function (item) {
1837
1848
  assertAny(item, sourceCodeInfo);
1838
1849
  if (!result.some(function (existingItem) { return deepEqual(existingItem, item, sourceCodeInfo); })) {
1839
1850
  result.push(item);
@@ -1842,7 +1853,7 @@ var sequenceNormalExpression = {
1842
1853
  try {
1843
1854
  for (var input_1 = __values(input), input_1_1 = input_1.next(); !input_1_1.done; input_1_1 = input_1.next()) {
1844
1855
  var item = input_1_1.value;
1845
- _loop_1(item);
1856
+ _loop_2(item);
1846
1857
  }
1847
1858
  }
1848
1859
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -11303,19 +11314,23 @@ var sequenceReference = {
11303
11314
  type: 'any',
11304
11315
  rest: true,
11305
11316
  },
11306
- args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { seq: {
11317
+ args: __assign(__assign({}, getOperatorArgs('sequence', 'function')), { seqs: {
11307
11318
  type: 'sequence',
11319
+ rest: true,
11320
+ description: 'At least one.',
11308
11321
  }, fun: {
11309
11322
  type: 'function',
11310
11323
  } }),
11311
11324
  variants: [
11312
- { argumentNames: ['seq', 'fun'] },
11325
+ { argumentNames: ['seqs', 'fun'] },
11313
11326
  ],
11314
- description: 'Creates a new array populated with the results of calling $fun on every elements in $seq.',
11327
+ description: 'Creates a new array populated with the results of calling $fun on every element in $seqs.',
11315
11328
  examples: [
11329
+ '[1, 2, 3] map -',
11316
11330
  '[1, 2, 3] map -> -($)',
11317
11331
  'map(["Albert", "Mojir", 42], str)',
11318
11332
  'map([1, 2, 3], inc)',
11333
+ 'map([1, 2, 3], [1, 10, 100], *)',
11319
11334
  ],
11320
11335
  },
11321
11336
  'filter': {