@stemy/ngx-utils 12.1.6 → 12.2.2

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.
@@ -1407,7 +1407,13 @@
1407
1407
  .concat(["level-" + this.level]);
1408
1408
  }
1409
1409
  FileSystemEntry.prototype.open = function () {
1410
+ var _this = this;
1410
1411
  this.result = this.result || this.openCb(this.data, this);
1412
+ this.result.then(function (res) {
1413
+ if (Array.isArray(res))
1414
+ return;
1415
+ _this.result = null;
1416
+ });
1411
1417
  return this.result;
1412
1418
  };
1413
1419
  return FileSystemEntry;
@@ -1690,7 +1696,7 @@
1690
1696
  }
1691
1697
  MathUtils.equal = function (a, b, epsilon) {
1692
1698
  if (epsilon === void 0) { epsilon = null; }
1693
- epsilon = ObjectUtils.isNumber(epsilon) ? epsilon : Math.E;
1699
+ epsilon = ObjectUtils.isNumber(epsilon) ? epsilon : MathUtils.EPSILON;
1694
1700
  return Math.abs(a - b) < epsilon;
1695
1701
  };
1696
1702
  MathUtils.clamp = function (value, min, max) {
@@ -1702,8 +1708,40 @@
1702
1708
  precision = Math.pow(10, precision);
1703
1709
  return Math.round(value * precision / divider) / precision;
1704
1710
  };
1711
+ MathUtils.approxIndex = function (x, values, epsilon) {
1712
+ if (epsilon === void 0) { epsilon = null; }
1713
+ if (!Array.isArray(values) || values.length == 0) {
1714
+ return -1;
1715
+ }
1716
+ var s = 0;
1717
+ var e = values.length - 1;
1718
+ while (s <= e) {
1719
+ var i = Math.floor((s + e) / 2);
1720
+ var v = values[i];
1721
+ if (MathUtils.equal(v, x, epsilon)) {
1722
+ return i;
1723
+ }
1724
+ if (v < x) {
1725
+ s = i + 1;
1726
+ }
1727
+ else {
1728
+ e = i - 1;
1729
+ }
1730
+ }
1731
+ var m = Math.max(e, 0);
1732
+ var a = values[s];
1733
+ var b = values[m];
1734
+ return Math.abs(a - x) < Math.abs(b - x) ? s : m;
1735
+ };
1736
+ MathUtils.approximate = function (x, values, epsilon) {
1737
+ if (epsilon === void 0) { epsilon = null; }
1738
+ var _a;
1739
+ var index = MathUtils.approxIndex(x, values, epsilon);
1740
+ return (_a = values[index]) !== null && _a !== void 0 ? _a : null;
1741
+ };
1705
1742
  return MathUtils;
1706
- }());
1743
+ }());
1744
+ MathUtils.EPSILON = 1e-9;
1707
1745
 
1708
1746
  /**
1709
1747
  * Use this service to determine which is the current environment