@dhis2/expression-parser 1.3.1 → 1.4.0

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.
@@ -18,6 +18,7 @@ import {
18
18
  numberToDouble210hrknaofnhf as numberToDouble,
19
19
  isNaNymqb93xtq8w8 as isNaN_0,
20
20
  isInfinite12nl8hpz1hbp2 as isInfinite,
21
+ Exceptiondt2hlxn7j7vw as Exception,
21
22
  Long2qws0ah9gnpki as Long,
22
23
  NoSuchElementException_init_$Create$4w03vct39ryy as NoSuchElementException_init_$Create$,
23
24
  toString1pkumu07cwy4m as toString,
@@ -54,7 +55,6 @@ import {
54
55
  numberToChar93r9buh19yek as numberToChar,
55
56
  toBoolean2azvnq2ukl7b3 as toBoolean,
56
57
  toDouble1kn912gjoizjp as toDouble,
57
- Exceptiondt2hlxn7j7vw as Exception,
58
58
  getKClassFromExpression348iqjl4fnx2f as getKClassFromExpression,
59
59
  toMutableList20rdgwi7d3cwi as toMutableList,
60
60
  THROW_CCE2g6jy02ryeudk as THROW_CCE,
@@ -622,7 +622,7 @@ function d2_minValue(value) {
622
622
  return tmp;
623
623
  }
624
624
  function d2_modulus(left, right) {
625
- return numberToDouble(Companion_getInstance_3().a1d(left, right));
625
+ return numberToDouble(Companion_getInstance_3().b1d(left, right));
626
626
  }
627
627
  function d2_monthsBetween(start, end) {
628
628
  // Inline function 'kotlin.require' call
@@ -1470,6 +1470,22 @@ function isSpecialDouble($this, n) {
1470
1470
  var d = numberToDouble(n);
1471
1471
  return isNaN_0(d) || isInfinite(d);
1472
1472
  }
1473
+ function tryToNumber($this, value) {
1474
+ var tmp;
1475
+ try {
1476
+ tmp = Companion_instance_7.q1c(value);
1477
+ } catch ($p) {
1478
+ var tmp_0;
1479
+ if ($p instanceof Exception) {
1480
+ var _unused_var__etf5q3 = $p;
1481
+ tmp_0 = null;
1482
+ } else {
1483
+ throw $p;
1484
+ }
1485
+ tmp = tmp_0;
1486
+ }
1487
+ return tmp;
1488
+ }
1473
1489
  var BinaryOperator_EXP_instance;
1474
1490
  var BinaryOperator_MUL_instance;
1475
1491
  var BinaryOperator_DIV_instance;
@@ -1488,7 +1504,7 @@ function Companion() {
1488
1504
  Companion_instance = this;
1489
1505
  this.p1c_1 = new DecimalMode(new Long(16, 0), RoundingMode_ROUND_HALF_AWAY_FROM_ZERO_getInstance());
1490
1506
  }
1491
- protoOf(Companion).q1c = function (symbol) {
1507
+ protoOf(Companion).r1c = function (symbol) {
1492
1508
  var tmp;
1493
1509
  switch (symbol) {
1494
1510
  case 'and':
@@ -1505,7 +1521,7 @@ protoOf(Companion).q1c = function (symbol) {
1505
1521
  var _iterator__ex2g4s = tmp0.l();
1506
1522
  while (_iterator__ex2g4s.m()) {
1507
1523
  var element = _iterator__ex2g4s.n();
1508
- if (element.t1c_1 === symbol) {
1524
+ if (element.u1c_1 === symbol) {
1509
1525
  tmp$ret$1 = element;
1510
1526
  break $l$block;
1511
1527
  }
@@ -1518,7 +1534,7 @@ protoOf(Companion).q1c = function (symbol) {
1518
1534
  }
1519
1535
  return tmp;
1520
1536
  };
1521
- protoOf(Companion).w1c = function (left, right) {
1537
+ protoOf(Companion).x1c = function (left, right) {
1522
1538
  // Inline function 'kotlin.require' call
1523
1539
  if (!!(left == null)) {
1524
1540
  var message = 'left operator of addition must not be null';
@@ -1531,7 +1547,7 @@ protoOf(Companion).w1c = function (left, right) {
1531
1547
  }
1532
1548
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) ? numberToDouble(left) + numberToDouble(right) : asBigDecimal(this, left).fz(asBigDecimal(this, right)).b10(false);
1533
1549
  };
1534
- protoOf(Companion).x1c = function (left, right) {
1550
+ protoOf(Companion).y1c = function (left, right) {
1535
1551
  // Inline function 'kotlin.require' call
1536
1552
  if (!!(left == null)) {
1537
1553
  var message = 'left operator of subtraction must not be null';
@@ -1544,7 +1560,7 @@ protoOf(Companion).x1c = function (left, right) {
1544
1560
  }
1545
1561
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) ? numberToDouble(left) - numberToDouble(right) : asBigDecimal(this, left).hz(asBigDecimal(this, right)).b10(false);
1546
1562
  };
1547
- protoOf(Companion).y1c = function (left, right) {
1563
+ protoOf(Companion).z1c = function (left, right) {
1548
1564
  // Inline function 'kotlin.require' call
1549
1565
  if (!!(left == null)) {
1550
1566
  var message = 'left operator of multiplication must not be null';
@@ -1557,7 +1573,7 @@ protoOf(Companion).y1c = function (left, right) {
1557
1573
  }
1558
1574
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) ? numberToDouble(left) * numberToDouble(right) : asBigDecimal(this, left).jz(asBigDecimal(this, right)).b10(false);
1559
1575
  };
1560
- protoOf(Companion).z1c = function (left, right) {
1576
+ protoOf(Companion).a1d = function (left, right) {
1561
1577
  // Inline function 'kotlin.require' call
1562
1578
  if (!!(left == null)) {
1563
1579
  var message = 'left operator of division must not be null';
@@ -1570,7 +1586,7 @@ protoOf(Companion).z1c = function (left, right) {
1570
1586
  }
1571
1587
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) || numberToDouble(right) === 0.0 ? numberToDouble(left) / numberToDouble(right) : asBigDecimal(this, left).lz(asBigDecimal(this, right)).b10(false);
1572
1588
  };
1573
- protoOf(Companion).a1d = function (left, right) {
1589
+ protoOf(Companion).b1d = function (left, right) {
1574
1590
  // Inline function 'kotlin.require' call
1575
1591
  if (!!(left == null)) {
1576
1592
  var message = 'left operator of modulo must not be null';
@@ -1583,7 +1599,7 @@ protoOf(Companion).a1d = function (left, right) {
1583
1599
  }
1584
1600
  return isSpecialDouble(this, left) || isSpecialDouble(this, right) || numberToDouble(right) === 0.0 ? numberToDouble(left) % numberToDouble(right) : Companion_getInstance_0().ky(numberToDouble(left)).nz(Companion_getInstance_0().ky(numberToDouble(right))).b10(false);
1585
1601
  };
1586
- protoOf(Companion).b1d = function (base, exponent) {
1602
+ protoOf(Companion).c1d = function (base, exponent) {
1587
1603
  // Inline function 'kotlin.require' call
1588
1604
  if (!!(base == null)) {
1589
1605
  var message = 'base operator of exponential function must not be null';
@@ -1605,17 +1621,17 @@ protoOf(Companion).b1d = function (base, exponent) {
1605
1621
  }
1606
1622
  return tmp;
1607
1623
  };
1608
- protoOf(Companion).c1d = function (left, right) {
1624
+ protoOf(Companion).d1d = function (left, right) {
1609
1625
  if (left == null)
1610
1626
  return right === true ? true : null;
1611
1627
  if (right == null)
1612
1628
  return left === true ? true : null;
1613
1629
  return left || right;
1614
1630
  };
1615
- protoOf(Companion).d1d = function (left, right) {
1631
+ protoOf(Companion).e1d = function (left, right) {
1616
1632
  return left == null || right == null ? null : left && right;
1617
1633
  };
1618
- protoOf(Companion).e1d = function (left, right) {
1634
+ protoOf(Companion).f1d = function (left, right) {
1619
1635
  var tmp;
1620
1636
  var tmp_0;
1621
1637
  if (!(left == null) ? typeof left === 'string' : false) {
@@ -1626,7 +1642,7 @@ protoOf(Companion).e1d = function (left, right) {
1626
1642
  if (tmp_0) {
1627
1643
  tmp = compareTo(left, right) < 0;
1628
1644
  } else {
1629
- tmp = ensureNotNull(Companion_instance_7.f1d(left)) < ensureNotNull(Companion_instance_7.f1d(right));
1645
+ tmp = ensureNotNull(Companion_instance_7.q1c(left)) < ensureNotNull(Companion_instance_7.q1c(right));
1630
1646
  }
1631
1647
  return tmp;
1632
1648
  };
@@ -1641,7 +1657,7 @@ protoOf(Companion).g1d = function (left, right) {
1641
1657
  if (tmp_0) {
1642
1658
  tmp = compareTo(left, right) <= 0;
1643
1659
  } else {
1644
- tmp = ensureNotNull(Companion_instance_7.f1d(left)) <= ensureNotNull(Companion_instance_7.f1d(right));
1660
+ tmp = ensureNotNull(Companion_instance_7.q1c(left)) <= ensureNotNull(Companion_instance_7.q1c(right));
1645
1661
  }
1646
1662
  return tmp;
1647
1663
  };
@@ -1656,7 +1672,7 @@ protoOf(Companion).h1d = function (left, right) {
1656
1672
  if (tmp_0) {
1657
1673
  tmp = compareTo(left, right) > 0;
1658
1674
  } else {
1659
- tmp = ensureNotNull(Companion_instance_7.f1d(left)) > ensureNotNull(Companion_instance_7.f1d(right));
1675
+ tmp = ensureNotNull(Companion_instance_7.q1c(left)) > ensureNotNull(Companion_instance_7.q1c(right));
1660
1676
  }
1661
1677
  return tmp;
1662
1678
  };
@@ -1671,7 +1687,7 @@ protoOf(Companion).i1d = function (left, right) {
1671
1687
  if (tmp_0) {
1672
1688
  tmp = compareTo(left, right) >= 0;
1673
1689
  } else {
1674
- tmp = ensureNotNull(Companion_instance_7.f1d(left)) >= ensureNotNull(Companion_instance_7.f1d(right));
1690
+ tmp = ensureNotNull(Companion_instance_7.q1c(left)) >= ensureNotNull(Companion_instance_7.q1c(right));
1675
1691
  }
1676
1692
  return tmp;
1677
1693
  };
@@ -1680,27 +1696,43 @@ protoOf(Companion).j1d = function (left, right) {
1680
1696
  return left == null && right == null;
1681
1697
  }
1682
1698
  var tmp;
1683
- if (typeof left === 'boolean') {
1699
+ if (isNumber(left)) {
1684
1700
  tmp = true;
1685
1701
  } else {
1686
- tmp = typeof right === 'boolean';
1702
+ tmp = isNumber(right);
1687
1703
  }
1688
1704
  if (tmp) {
1689
- return Companion_instance_7.k1d(left) == Companion_instance_7.k1d(right);
1705
+ var tmp0_elvis_lhs = tryToNumber(this, left);
1706
+ var tmp_0;
1707
+ if (tmp0_elvis_lhs == null) {
1708
+ return false;
1709
+ } else {
1710
+ tmp_0 = tmp0_elvis_lhs;
1711
+ }
1712
+ var leftNum = tmp_0;
1713
+ var tmp1_elvis_lhs = tryToNumber(this, right);
1714
+ var tmp_1;
1715
+ if (tmp1_elvis_lhs == null) {
1716
+ return false;
1717
+ } else {
1718
+ tmp_1 = tmp1_elvis_lhs;
1719
+ }
1720
+ var rightNum = tmp_1;
1721
+ return leftNum === rightNum;
1690
1722
  }
1691
- var tmp_0;
1692
- var tmp_1;
1693
- if (isNumber(left)) {
1694
- tmp_1 = true;
1723
+ var tmp_2;
1724
+ var tmp_3;
1725
+ if (typeof left === 'boolean') {
1726
+ tmp_3 = true;
1695
1727
  } else {
1696
- tmp_1 = isNumber(right);
1728
+ tmp_3 = typeof right === 'boolean';
1697
1729
  }
1698
- if (tmp_1) {
1699
- tmp_0 = Companion_instance_7.f1d(left) == Companion_instance_7.f1d(right);
1730
+ if (tmp_3) {
1731
+ tmp_2 = Companion_instance_7.k1d(left) == Companion_instance_7.k1d(right);
1700
1732
  } else {
1701
- tmp_0 = equals(left, right);
1733
+ tmp_2 = equals(left, right);
1702
1734
  }
1703
- return tmp_0;
1735
+ return tmp_2;
1704
1736
  };
1705
1737
  protoOf(Companion).l1d = function (left, right) {
1706
1738
  return !this.j1d(left, right);
@@ -1744,12 +1776,12 @@ function BinaryOperator_initEntries() {
1744
1776
  var $ENTRIES_0;
1745
1777
  function BinaryOperator(name, ordinal, symbol, returnType, operandsType) {
1746
1778
  Enum.call(this, name, ordinal);
1747
- this.t1c_1 = symbol;
1748
- this.u1c_1 = returnType;
1749
- this.v1c_1 = operandsType;
1779
+ this.u1c_1 = symbol;
1780
+ this.v1c_1 = returnType;
1781
+ this.w1c_1 = operandsType;
1750
1782
  }
1751
1783
  protoOf(BinaryOperator).m1d = function () {
1752
- return this.u1c_1;
1784
+ return this.v1c_1;
1753
1785
  };
1754
1786
  function BinaryOperator_EXP_getInstance() {
1755
1787
  BinaryOperator_initEntries();
@@ -2930,7 +2962,7 @@ function Nodes$TextNode$_init_$lambda_upoqix(it) {
2930
2962
  }
2931
2963
  function VariableType$Companion$fromSymbol$ref(p0) {
2932
2964
  var l = function (_this__u8e3s4) {
2933
- return p0.q1c(_this__u8e3s4);
2965
+ return p0.r1c(_this__u8e3s4);
2934
2966
  };
2935
2967
  l.callableName = 'fromSymbol';
2936
2968
  return l;
@@ -3033,7 +3065,7 @@ function Nodes$Utf8StringNode$_init_$lambda_3cq3o4(raw) {
3033
3065
  }
3034
3066
  function UnaryOperator$Companion$fromSymbol$ref(p0) {
3035
3067
  var l = function (_this__u8e3s4) {
3036
- return p0.q1c(_this__u8e3s4);
3068
+ return p0.r1c(_this__u8e3s4);
3037
3069
  };
3038
3070
  l.callableName = 'fromSymbol';
3039
3071
  return l;
@@ -3045,14 +3077,14 @@ function UnaryOperator$_get_symbol_$ref_7bcm8j() {
3045
3077
  }
3046
3078
  function BinaryOperator$Companion$fromSymbol$ref(p0) {
3047
3079
  var l = function (_this__u8e3s4) {
3048
- return p0.q1c(_this__u8e3s4);
3080
+ return p0.r1c(_this__u8e3s4);
3049
3081
  };
3050
3082
  l.callableName = 'fromSymbol';
3051
3083
  return l;
3052
3084
  }
3053
3085
  function BinaryOperator$_get_symbol_$ref_w802f3() {
3054
3086
  return function (p0) {
3055
- return p0.t1c_1;
3087
+ return p0.u1c_1;
3056
3088
  };
3057
3089
  }
3058
3090
  function toBoolean$ref() {
@@ -3839,11 +3871,11 @@ function isNonFractionValue($this, value) {
3839
3871
  }
3840
3872
  function Companion_7() {
3841
3873
  }
3842
- protoOf(Companion_7).f1d = function (value) {
3874
+ protoOf(Companion_7).q1c = function (value) {
3843
3875
  if (value == null)
3844
3876
  return null;
3845
3877
  if (value instanceof VariableValue)
3846
- return this.f1d(this.l1l(value));
3878
+ return this.q1c(this.l1l(value));
3847
3879
  if (typeof value === 'boolean')
3848
3880
  return equals(value, true) ? 1.0 : 0.0;
3849
3881
  if (value instanceof LocalDate)
@@ -3898,7 +3930,7 @@ protoOf(Companion_7).l1l = function (value) {
3898
3930
  if (value instanceof VariableValue) {
3899
3931
  switch (value.o1l_1.d2_1) {
3900
3932
  case 1:
3901
- tmp = this.f1d(value.s1l());
3933
+ tmp = this.q1c(value.s1l());
3902
3934
  break;
3903
3935
  case 2:
3904
3936
  tmp = this.k1d(value.s1l());
@@ -3925,7 +3957,7 @@ var UnaryOperator_NOT_instance;
3925
3957
  var UnaryOperator_DISTINCT_instance;
3926
3958
  function Companion_8() {
3927
3959
  }
3928
- protoOf(Companion_8).q1c = function (symbol) {
3960
+ protoOf(Companion_8).r1c = function (symbol) {
3929
3961
  var tmp;
3930
3962
  if ('not' === symbol) {
3931
3963
  tmp = UnaryOperator_NOT_getInstance();
@@ -4005,7 +4037,7 @@ var VariableType_PROGRAM_instance;
4005
4037
  var VariableType_PROGRAM_RULE_instance;
4006
4038
  function Companion_9() {
4007
4039
  }
4008
- protoOf(Companion_9).q1c = function (symbol) {
4040
+ protoOf(Companion_9).r1c = function (symbol) {
4009
4041
  return 'V' === symbol ? VariableType_PROGRAM_getInstance() : VariableType_PROGRAM_RULE_getInstance();
4010
4042
  };
4011
4043
  var Companion_instance_9;
@@ -4408,7 +4440,7 @@ function Calculator$evalToMixed$ref_0(p0) {
4408
4440
  }
4409
4441
  function BinaryOperator$Companion$and$ref(p0) {
4410
4442
  var l = function (_this__u8e3s4, p0_0) {
4411
- return p0.d1d(_this__u8e3s4, p0_0);
4443
+ return p0.e1d(_this__u8e3s4, p0_0);
4412
4444
  };
4413
4445
  l.callableName = 'and';
4414
4446
  return l;
@@ -4422,7 +4454,7 @@ function Calculator$evalToBoolean$ref(p0) {
4422
4454
  }
4423
4455
  function BinaryOperator$Companion$or$ref(p0) {
4424
4456
  var l = function (_this__u8e3s4, p0_0) {
4425
- return p0.c1d(_this__u8e3s4, p0_0);
4457
+ return p0.d1d(_this__u8e3s4, p0_0);
4426
4458
  };
4427
4459
  l.callableName = 'or';
4428
4460
  return l;
@@ -4436,7 +4468,7 @@ function Calculator$evalToBoolean$ref_0(p0) {
4436
4468
  }
4437
4469
  function BinaryOperator$Companion$lessThan$ref(p0) {
4438
4470
  var l = function (_this__u8e3s4, p0_0) {
4439
- return p0.e1d(_this__u8e3s4, p0_0);
4471
+ return p0.f1d(_this__u8e3s4, p0_0);
4440
4472
  };
4441
4473
  l.callableName = 'lessThan';
4442
4474
  return l;
@@ -4496,7 +4528,7 @@ function Calculator$evalToMixed$ref_4(p0) {
4496
4528
  }
4497
4529
  function BinaryOperator$Companion$add$ref(p0) {
4498
4530
  var l = function (_this__u8e3s4, p0_0) {
4499
- return p0.w1c(_this__u8e3s4, p0_0);
4531
+ return p0.x1c(_this__u8e3s4, p0_0);
4500
4532
  };
4501
4533
  l.callableName = 'add';
4502
4534
  return l;
@@ -4510,7 +4542,7 @@ function Calculator$evalToNumber$ref(p0) {
4510
4542
  }
4511
4543
  function BinaryOperator$Companion$subtract$ref(p0) {
4512
4544
  var l = function (_this__u8e3s4, p0_0) {
4513
- return p0.x1c(_this__u8e3s4, p0_0);
4545
+ return p0.y1c(_this__u8e3s4, p0_0);
4514
4546
  };
4515
4547
  l.callableName = 'subtract';
4516
4548
  return l;
@@ -4524,7 +4556,7 @@ function Calculator$evalToNumber$ref_0(p0) {
4524
4556
  }
4525
4557
  function BinaryOperator$Companion$multiply$ref(p0) {
4526
4558
  var l = function (_this__u8e3s4, p0_0) {
4527
- return p0.y1c(_this__u8e3s4, p0_0);
4559
+ return p0.z1c(_this__u8e3s4, p0_0);
4528
4560
  };
4529
4561
  l.callableName = 'multiply';
4530
4562
  return l;
@@ -4538,7 +4570,7 @@ function Calculator$evalToNumber$ref_1(p0) {
4538
4570
  }
4539
4571
  function BinaryOperator$Companion$divide$ref(p0) {
4540
4572
  var l = function (_this__u8e3s4, p0_0) {
4541
- return p0.z1c(_this__u8e3s4, p0_0);
4573
+ return p0.a1d(_this__u8e3s4, p0_0);
4542
4574
  };
4543
4575
  l.callableName = 'divide';
4544
4576
  return l;
@@ -4552,7 +4584,7 @@ function Calculator$evalToNumber$ref_2(p0) {
4552
4584
  }
4553
4585
  function BinaryOperator$Companion$modulo$ref(p0) {
4554
4586
  var l = function (_this__u8e3s4, p0_0) {
4555
- return p0.a1d(_this__u8e3s4, p0_0);
4587
+ return p0.b1d(_this__u8e3s4, p0_0);
4556
4588
  };
4557
4589
  l.callableName = 'modulo';
4558
4590
  return l;
@@ -4566,7 +4598,7 @@ function Calculator$evalToNumber$ref_3(p0) {
4566
4598
  }
4567
4599
  function BinaryOperator$Companion$exp$ref(p0) {
4568
4600
  var l = function (_this__u8e3s4, p0_0) {
4569
- return p0.b1d(_this__u8e3s4, p0_0);
4601
+ return p0.c1d(_this__u8e3s4, p0_0);
4570
4602
  };
4571
4603
  l.callableName = 'exp';
4572
4604
  return l;
@@ -4611,7 +4643,7 @@ function Typed$Companion$toBooleanTypeCoercion$ref(p0) {
4611
4643
  }
4612
4644
  function Typed$Companion$toNumberTypeCoercion$ref(p0) {
4613
4645
  var l = function (_this__u8e3s4) {
4614
- return p0.f1d(_this__u8e3s4);
4646
+ return p0.q1c(_this__u8e3s4);
4615
4647
  };
4616
4648
  l.callableName = 'toNumberTypeCoercion';
4617
4649
  return l;
@@ -5485,7 +5517,7 @@ function isStaticallyDefined($this, node) {
5485
5517
  return type === NodeType_BINARY_OPERATOR_getInstance() && isStaticallyDefined($this, node.p1e(0)) && isStaticallyDefined($this, node.p1e(1));
5486
5518
  }
5487
5519
  function checkBinaryOperatorOperand($this, operator, operand, name) {
5488
- var expected = operator.e1e().v1c_1;
5520
+ var expected = operator.e1e().w1c_1;
5489
5521
  var leftActual = operand.m1d();
5490
5522
  if (!leftActual.isAssignableTo(expected)) {
5491
5523
  if (isStaticallyDefined(Companion_instance_13, operand)) {