@stemy/ngx-utils 12.1.5 → 12.2.1

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.
@@ -1690,7 +1690,7 @@
1690
1690
  }
1691
1691
  MathUtils.equal = function (a, b, epsilon) {
1692
1692
  if (epsilon === void 0) { epsilon = null; }
1693
- epsilon = ObjectUtils.isNumber(epsilon) ? epsilon : Math.E;
1693
+ epsilon = ObjectUtils.isNumber(epsilon) ? epsilon : MathUtils.EPSILON;
1694
1694
  return Math.abs(a - b) < epsilon;
1695
1695
  };
1696
1696
  MathUtils.clamp = function (value, min, max) {
@@ -1702,8 +1702,40 @@
1702
1702
  precision = Math.pow(10, precision);
1703
1703
  return Math.round(value * precision / divider) / precision;
1704
1704
  };
1705
+ MathUtils.approxIndex = function (x, values, epsilon) {
1706
+ if (epsilon === void 0) { epsilon = null; }
1707
+ if (!Array.isArray(values) || values.length == 0) {
1708
+ return -1;
1709
+ }
1710
+ var s = 0;
1711
+ var e = values.length - 1;
1712
+ while (s <= e) {
1713
+ var i = Math.floor((s + e) / 2);
1714
+ var v = values[i];
1715
+ if (MathUtils.equal(v, x, epsilon)) {
1716
+ return i;
1717
+ }
1718
+ if (v < x) {
1719
+ s = i + 1;
1720
+ }
1721
+ else {
1722
+ e = i - 1;
1723
+ }
1724
+ }
1725
+ var m = Math.max(e, 0);
1726
+ var a = values[s];
1727
+ var b = values[m];
1728
+ return Math.abs(a - x) < Math.abs(b - x) ? s : m;
1729
+ };
1730
+ MathUtils.approximate = function (x, values, epsilon) {
1731
+ if (epsilon === void 0) { epsilon = null; }
1732
+ var _a;
1733
+ var index = MathUtils.approxIndex(x, values, epsilon);
1734
+ return (_a = values[index]) !== null && _a !== void 0 ? _a : null;
1735
+ };
1705
1736
  return MathUtils;
1706
- }());
1737
+ }());
1738
+ MathUtils.EPSILON = 1e-9;
1707
1739
 
1708
1740
  /**
1709
1741
  * Use this service to determine which is the current environment
@@ -2539,6 +2571,13 @@
2539
2571
  }
2540
2572
  return result;
2541
2573
  };
2574
+ ArrayUtils.unique = function (arr) {
2575
+ if (!ObjectUtils.isArray(arr))
2576
+ return [];
2577
+ return arr.filter(function (value, index, self) {
2578
+ return self.indexOf(value) === index;
2579
+ });
2580
+ };
2542
2581
  return ArrayUtils;
2543
2582
  }());
2544
2583