nhanh-pure-function 4.2.0 → 4.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.
package/dist/index.es.js CHANGED
@@ -451,7 +451,7 @@ function le(r) {
451
451
  const t = r.toString().split("."), e = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
452
452
  return t.length > 1 ? e + "." + t[1] : e;
453
453
  }
454
- function Gs(r, s) {
454
+ function zs(r, s) {
455
455
  const t = {
456
456
  join: !0,
457
457
  suffix: "",
@@ -464,7 +464,7 @@ function Gs(r, s) {
464
464
  const a = Math.abs(o), l = o >= 0, c = Math.max(0, Math.floor(Math.log10(a) / 4)), h = Math.pow(1e4, c), u = a / h, f = (l ? 1 : -1) * parseFloat(u.toFixed(Math.max(0, n)));
465
465
  return e ? `${f}${Pe[c]}${i}` : [f, Pe[c] + i];
466
466
  }
467
- function Us(r) {
467
+ function Gs(r) {
468
468
  const s = ["B", "KB", "MB", "GB", "TB", "PB"];
469
469
  let t = 0;
470
470
  for (; r > 1024; )
@@ -495,10 +495,10 @@ function ce(r, s = "file") {
495
495
  const t = r.split("/");
496
496
  return t[t.length - 1].split("?")[0];
497
497
  }
498
- function Xs(r, s) {
498
+ function Us(r, s) {
499
499
  return r = r.replace(/([^a-zA-Z][a-z])/g, (t) => t.toUpperCase()), s ? r.replace(/[^a-zA-Z]+/g, "") : r;
500
500
  }
501
- function zs(r, s, t = ",") {
501
+ function Xs(r, s, t = ",") {
502
502
  const e = new RegExp(
503
503
  `(^|${t})${s}(${t}|$)`,
504
504
  "g"
@@ -1167,6 +1167,7 @@ class an {
1167
1167
  }
1168
1168
  /** 开始 */
1169
1169
  start(s) {
1170
+ this.stop();
1170
1171
  const t = new WebSocket(s);
1171
1172
  this.socket = t, this.url = s, t.onopen = (e) => {
1172
1173
  var i;
@@ -1476,7 +1477,7 @@ v.comparedTo = v.cmp = function(r) {
1476
1477
  };
1477
1478
  v.cosine = v.cos = function() {
1478
1479
  var r, s, t = this, e = t.constructor;
1479
- return t.d ? t.d[0] ? (r = e.precision, s = e.rounding, e.precision = r + Math.max(t.e, t.sd()) + S, e.rounding = 1, t = hi(e, ze(e, t)), e.precision = r, e.rounding = s, C(nt == 2 || nt == 3 ? t.neg() : t, r, s, !0)) : new e(1) : new e(NaN);
1480
+ return t.d ? t.d[0] ? (r = e.precision, s = e.rounding, e.precision = r + Math.max(t.e, t.sd()) + S, e.rounding = 1, t = hi(e, Xe(e, t)), e.precision = r, e.rounding = s, C(nt == 2 || nt == 3 ? t.neg() : t, r, s, !0)) : new e(1) : new e(NaN);
1480
1481
  };
1481
1482
  v.cubeRoot = v.cbrt = function() {
1482
1483
  var r, s, t, e, i, n, o, a, l, c, h = this, u = h.constructor;
@@ -1712,7 +1713,7 @@ v.round = function() {
1712
1713
  };
1713
1714
  v.sine = v.sin = function() {
1714
1715
  var r, s, t = this, e = t.constructor;
1715
- return t.isFinite() ? t.isZero() ? new e(t) : (r = e.precision, s = e.rounding, e.precision = r + Math.max(t.e, t.sd()) + S, e.rounding = 1, t = di(e, ze(e, t)), e.precision = r, e.rounding = s, C(nt > 2 ? t.neg() : t, r, s, !0)) : new e(NaN);
1716
+ return t.isFinite() ? t.isZero() ? new e(t) : (r = e.precision, s = e.rounding, e.precision = r + Math.max(t.e, t.sd()) + S, e.rounding = 1, t = di(e, Xe(e, t)), e.precision = r, e.rounding = s, C(nt > 2 ? t.neg() : t, r, s, !0)) : new e(NaN);
1716
1717
  };
1717
1718
  v.squareRoot = v.sqrt = function() {
1718
1719
  var r, s, t, e, i, n, o = this, a = o.d, l = o.e, c = o.s, h = o.constructor;
@@ -1754,15 +1755,15 @@ v.toBinary = function(r, s) {
1754
1755
  };
1755
1756
  v.toDecimalPlaces = v.toDP = function(r, s) {
1756
1757
  var t = this, e = t.constructor;
1757
- return t = new e(t), r === void 0 ? t : (U(r, 0, ut), s === void 0 ? s = e.rounding : U(s, 0, 8), C(t, r + t.e + 1, s));
1758
+ return t = new e(t), r === void 0 ? t : (G(r, 0, ut), s === void 0 ? s = e.rounding : G(s, 0, 8), C(t, r + t.e + 1, s));
1758
1759
  };
1759
1760
  v.toExponential = function(r, s) {
1760
1761
  var t, e = this, i = e.constructor;
1761
- return r === void 0 ? t = et(e, !0) : (U(r, 0, ut), s === void 0 ? s = i.rounding : U(s, 0, 8), e = C(new i(e), r + 1, s), t = et(e, !0, r + 1)), e.isNeg() && !e.isZero() ? "-" + t : t;
1762
+ return r === void 0 ? t = et(e, !0) : (G(r, 0, ut), s === void 0 ? s = i.rounding : G(s, 0, 8), e = C(new i(e), r + 1, s), t = et(e, !0, r + 1)), e.isNeg() && !e.isZero() ? "-" + t : t;
1762
1763
  };
1763
1764
  v.toFixed = function(r, s) {
1764
1765
  var t, e, i = this, n = i.constructor;
1765
- return r === void 0 ? t = et(i) : (U(r, 0, ut), s === void 0 ? s = n.rounding : U(s, 0, 8), e = C(new n(i), r + i.e + 1, s), t = et(e, !1, r + e.e + 1)), i.isNeg() && !i.isZero() ? "-" + t : t;
1766
+ return r === void 0 ? t = et(i) : (G(r, 0, ut), s === void 0 ? s = n.rounding : G(s, 0, 8), e = C(new n(i), r + i.e + 1, s), t = et(e, !1, r + e.e + 1)), i.isNeg() && !i.isZero() ? "-" + t : t;
1766
1767
  };
1767
1768
  v.toFraction = function(r) {
1768
1769
  var s, t, e, i, n, o, a, l, c, h, u, f, m = this, p = m.d, g = m.constructor;
@@ -1786,7 +1787,7 @@ v.toNearest = function(r, s) {
1786
1787
  if (!t.d) return t;
1787
1788
  r = new e(1), s = e.rounding;
1788
1789
  } else {
1789
- if (r = new e(r), s === void 0 ? s = e.rounding : U(s, 0, 8), !t.d) return r.s ? t : r;
1790
+ if (r = new e(r), s === void 0 ? s = e.rounding : G(s, 0, 8), !t.d) return r.s ? t : r;
1790
1791
  if (!r.d)
1791
1792
  return r.s && (r.s = t.s), r;
1792
1793
  }
@@ -1804,7 +1805,7 @@ v.toPower = v.pow = function(r) {
1804
1805
  if (a = new l(a), a.eq(1)) return a;
1805
1806
  if (e = l.precision, n = l.rounding, r.eq(1)) return C(a, e, n);
1806
1807
  if (s = F(r.e / S), s >= r.d.length - 1 && (t = c < 0 ? -c : c) <= li)
1807
- return i = Ge(l, a, t, e), r.s < 0 ? new l(1).div(i) : C(i, e, n);
1808
+ return i = ze(l, a, t, e), r.s < 0 ? new l(1).div(i) : C(i, e, n);
1808
1809
  if (o = a.s, o < 0) {
1809
1810
  if (s < r.d.length - 1) return new l(NaN);
1810
1811
  if (r.d[s] & 1 || (o = 1), a.e == 0 && a.d[0] == 1 && a.d.length == 1)
@@ -1814,11 +1815,11 @@ v.toPower = v.pow = function(r) {
1814
1815
  };
1815
1816
  v.toPrecision = function(r, s) {
1816
1817
  var t, e = this, i = e.constructor;
1817
- return r === void 0 ? t = et(e, e.e <= i.toExpNeg || e.e >= i.toExpPos) : (U(r, 1, ut), s === void 0 ? s = i.rounding : U(s, 0, 8), e = C(new i(e), r, s), t = et(e, r <= e.e || e.e <= i.toExpNeg, r)), e.isNeg() && !e.isZero() ? "-" + t : t;
1818
+ return r === void 0 ? t = et(e, e.e <= i.toExpNeg || e.e >= i.toExpPos) : (G(r, 1, ut), s === void 0 ? s = i.rounding : G(s, 0, 8), e = C(new i(e), r, s), t = et(e, r <= e.e || e.e <= i.toExpNeg, r)), e.isNeg() && !e.isZero() ? "-" + t : t;
1818
1819
  };
1819
1820
  v.toSignificantDigits = v.toSD = function(r, s) {
1820
1821
  var t = this, e = t.constructor;
1821
- return r === void 0 ? (r = e.precision, s = e.rounding) : (U(r, 1, ut), s === void 0 ? s = e.rounding : U(s, 0, 8)), C(new e(t), r, s);
1822
+ return r === void 0 ? (r = e.precision, s = e.rounding) : (G(r, 1, ut), s === void 0 ? s = e.rounding : G(s, 0, 8)), C(new e(t), r, s);
1822
1823
  };
1823
1824
  v.toString = function() {
1824
1825
  var r = this, s = r.constructor, t = et(r, r.e <= s.toExpNeg || r.e >= s.toExpPos);
@@ -1842,7 +1843,7 @@ function N(r) {
1842
1843
  for (; o % 10 === 0; ) o /= 10;
1843
1844
  return n + o;
1844
1845
  }
1845
- function U(r, s, t) {
1846
+ function G(r, s, t) {
1846
1847
  if (r !== ~~r || r < s || r > t)
1847
1848
  throw Error(ht + r);
1848
1849
  }
@@ -1894,7 +1895,7 @@ var V = /* @__PURE__ */ function() {
1894
1895
  for (; !e[0] && e.length > 1; ) e.shift();
1895
1896
  }
1896
1897
  return function(e, i, n, o, a, l) {
1897
- var c, h, u, f, m, p, g, y, w, P, b, _, A, X, At, dt, rt, vt, z, Lt, Tt = e.constructor, ne = e.s == i.s ? 1 : -1, H = e.d, O = i.d;
1898
+ var c, h, u, f, m, p, g, y, w, P, b, _, A, U, At, dt, rt, vt, X, Lt, Tt = e.constructor, ne = e.s == i.s ? 1 : -1, H = e.d, O = i.d;
1898
1899
  if (!H || !H[0] || !O || !O[0])
1899
1900
  return new Tt(
1900
1901
  // Return NaN if either NaN, or both Infinity or 0.
@@ -1903,20 +1904,20 @@ var V = /* @__PURE__ */ function() {
1903
1904
  H && H[0] == 0 || !O ? ne * 0 : ne / 0
1904
1905
  )
1905
1906
  );
1906
- for (l ? (m = 1, h = e.e - i.e) : (l = Q, m = S, h = F(e.e / m) - F(i.e / m)), z = O.length, rt = H.length, w = new Tt(ne), P = w.d = [], u = 0; O[u] == (H[u] || 0); u++) ;
1907
- if (O[u] > (H[u] || 0) && h--, n == null ? (X = n = Tt.precision, o = Tt.rounding) : a ? X = n + (e.e - i.e) + 1 : X = n, X < 0)
1907
+ for (l ? (m = 1, h = e.e - i.e) : (l = Q, m = S, h = F(e.e / m) - F(i.e / m)), X = O.length, rt = H.length, w = new Tt(ne), P = w.d = [], u = 0; O[u] == (H[u] || 0); u++) ;
1908
+ if (O[u] > (H[u] || 0) && h--, n == null ? (U = n = Tt.precision, o = Tt.rounding) : a ? U = n + (e.e - i.e) + 1 : U = n, U < 0)
1908
1909
  P.push(1), p = !0;
1909
1910
  else {
1910
- if (X = X / m + 2 | 0, u = 0, z == 1) {
1911
- for (f = 0, O = O[0], X++; (u < rt || f) && X--; u++)
1911
+ if (U = U / m + 2 | 0, u = 0, X == 1) {
1912
+ for (f = 0, O = O[0], U++; (u < rt || f) && U--; u++)
1912
1913
  At = f * l + (H[u] || 0), P[u] = At / O | 0, f = At % O | 0;
1913
1914
  p = f || u < rt;
1914
1915
  } else {
1915
- for (f = l / (O[0] + 1) | 0, f > 1 && (O = r(O, f, l), H = r(H, f, l), z = O.length, rt = H.length), dt = z, b = H.slice(0, z), _ = b.length; _ < z; ) b[_++] = 0;
1916
+ for (f = l / (O[0] + 1) | 0, f > 1 && (O = r(O, f, l), H = r(H, f, l), X = O.length, rt = H.length), dt = X, b = H.slice(0, X), _ = b.length; _ < X; ) b[_++] = 0;
1916
1917
  Lt = O.slice(), Lt.unshift(0), vt = O[0], O[1] >= l / 2 && ++vt;
1917
1918
  do
1918
- f = 0, c = s(O, b, z, _), c < 0 ? (A = b[0], z != _ && (A = A * l + (b[1] || 0)), f = A / vt | 0, f > 1 ? (f >= l && (f = l - 1), g = r(O, f, l), y = g.length, _ = b.length, c = s(g, b, y, _), c == 1 && (f--, t(g, z < y ? Lt : O, y, l))) : (f == 0 && (c = f = 1), g = O.slice()), y = g.length, y < _ && g.unshift(0), t(b, g, _, l), c == -1 && (_ = b.length, c = s(O, b, z, _), c < 1 && (f++, t(b, z < _ ? Lt : O, _, l))), _ = b.length) : c === 0 && (f++, b = [0]), P[u++] = f, c && b[0] ? b[_++] = H[dt] || 0 : (b = [H[dt]], _ = 1);
1919
- while ((dt++ < rt || b[0] !== void 0) && X--);
1919
+ f = 0, c = s(O, b, X, _), c < 0 ? (A = b[0], X != _ && (A = A * l + (b[1] || 0)), f = A / vt | 0, f > 1 ? (f >= l && (f = l - 1), g = r(O, f, l), y = g.length, _ = b.length, c = s(g, b, y, _), c == 1 && (f--, t(g, X < y ? Lt : O, y, l))) : (f == 0 && (c = f = 1), g = O.slice()), y = g.length, y < _ && g.unshift(0), t(b, g, _, l), c == -1 && (_ = b.length, c = s(O, b, X, _), c < 1 && (f++, t(b, X < _ ? Lt : O, _, l))), _ = b.length) : c === 0 && (f++, b = [0]), P[u++] = f, c && b[0] ? b[_++] = H[dt] || 0 : (b = [H[dt]], _ = 1);
1920
+ while ((dt++ < rt || b[0] !== void 0) && U--);
1920
1921
  p = b[0] !== void 0;
1921
1922
  }
1922
1923
  P[0] || P.shift();
@@ -1966,7 +1967,7 @@ function C(r, s, t, e) {
1966
1967
  return E && (r.e > m.maxE ? (r.d = null, r.e = NaN) : r.e < m.minE && (r.e = 0, r.d = [0])), r;
1967
1968
  }
1968
1969
  function et(r, s, t) {
1969
- if (!r.isFinite()) return Xe(r);
1970
+ if (!r.isFinite()) return Ue(r);
1970
1971
  var e, i = r.e, n = N(r.d), o = n.length;
1971
1972
  return s ? (t && (e = t - o) > 0 ? n = n.charAt(0) + "." + n.slice(1) + ot(e) : o > 1 && (n = n.charAt(0) + "." + n.slice(1)), n = n + (r.e < 0 ? "e" : "e+") + r.e) : i < 0 ? (n = "0." + ot(-i - 1) + n, t && (e = t - o) > 0 && (n += ot(e))) : i >= o ? (n += ot(i + 1 - o), t && (e = t - i - 1) > 0 && (n = n + "." + ot(e))) : ((e = i + 1) < o && (n = n.slice(0, e) + "." + n.slice(e)), t && (e = t - o) > 0 && (i + 1 === o && (n += "."), n += ot(e))), n;
1972
1973
  }
@@ -1996,7 +1997,7 @@ function ot(r) {
1996
1997
  for (var s = ""; r--; ) s += "0";
1997
1998
  return s;
1998
1999
  }
1999
- function Ge(r, s, t, e) {
2000
+ function ze(r, s, t, e) {
2000
2001
  var i, n = new r(1), o = Math.ceil(e / S + 4);
2001
2002
  for (E = !1; ; ) {
2002
2003
  if (t % 2 && (n = n.times(s), Ee(n.d, o) && (i = !0)), t = F(t / 2), t === 0) {
@@ -2010,7 +2011,7 @@ function Ge(r, s, t, e) {
2010
2011
  function Se(r) {
2011
2012
  return r.d[r.d.length - 1] & 1;
2012
2013
  }
2013
- function Ue(r, s, t) {
2014
+ function Ge(r, s, t) {
2014
2015
  for (var e, i, n = new r(s[0]), o = 0; ++o < s.length; ) {
2015
2016
  if (i = new r(s[o]), !i.s) {
2016
2017
  n = i;
@@ -2062,7 +2063,7 @@ function at(r, s) {
2062
2063
  l = c, i += 2;
2063
2064
  }
2064
2065
  }
2065
- function Xe(r) {
2066
+ function Ue(r) {
2066
2067
  return String(r.s * r.s / 0);
2067
2068
  }
2068
2069
  function Bt(r, s) {
@@ -2095,7 +2096,7 @@ function ui(r, s) {
2095
2096
  t = 8;
2096
2097
  else
2097
2098
  throw Error(ht + s);
2098
- for (n = s.search(/p/i), n > 0 ? (l = +s.slice(n + 1), s = s.substring(2, n)) : s = s.slice(2), n = s.indexOf("."), o = n >= 0, e = r.constructor, o && (s = s.replace(".", ""), a = s.length, n = a - n, i = Ge(e, new e(t), n, n * 2)), c = Ft(s, t, Q), h = c.length - 1, n = h; c[n] === 0; --n) c.pop();
2099
+ for (n = s.search(/p/i), n > 0 ? (l = +s.slice(n + 1), s = s.substring(2, n)) : s = s.slice(2), n = s.indexOf("."), o = n >= 0, e = r.constructor, o && (s = s.replace(".", ""), a = s.length, n = a - n, i = ze(e, new e(t), n, n * 2)), c = Ft(s, t, Q), h = c.length - 1, n = h; c[n] === 0; --n) c.pop();
2099
2100
  return n < 0 ? new e(r.s * 0) : (r.e = ie(c, h), r.d = c, E = !1, o && (r = V(r, i, a * 4)), l && (r = r.times(Math.abs(l) < 54 ? I(2, l) : R.pow(2, l))), E = !0, r);
2100
2101
  }
2101
2102
  function di(r, s) {
@@ -2122,7 +2123,7 @@ function se(r, s) {
2122
2123
  for (var t = r; --s; ) t *= r;
2123
2124
  return t;
2124
2125
  }
2125
- function ze(r, s) {
2126
+ function Xe(r, s) {
2126
2127
  var t, e = s.s < 0, i = tt(r, r.precision, 1), n = i.times(0.5);
2127
2128
  if (s = s.abs(), s.lte(n))
2128
2129
  return nt = e ? 4 : 1, s;
@@ -2137,8 +2138,8 @@ function ze(r, s) {
2137
2138
  }
2138
2139
  function ye(r, s, t, e) {
2139
2140
  var i, n, o, a, l, c, h, u, f, m = r.constructor, p = t !== void 0;
2140
- if (p ? (U(t, 1, ut), e === void 0 ? e = m.rounding : U(e, 0, 8)) : (t = m.precision, e = m.rounding), !r.isFinite())
2141
- h = Xe(r);
2141
+ if (p ? (G(t, 1, ut), e === void 0 ? e = m.rounding : G(e, 0, 8)) : (t = m.precision, e = m.rounding), !r.isFinite())
2142
+ h = Ue(r);
2142
2143
  else {
2143
2144
  for (h = et(r), o = h.indexOf("."), p ? (i = 2, s == 16 ? t = t * 4 - 3 : s == 8 && (t = t * 3 - 2)) : i = s, o >= 0 && (h = h.replace(".", ""), f = new m(1), f.e = h.length - o, f.d = Ft(et(f), 10, i), f.e = f.d.length), u = Ft(h, 10, i), n = l = u.length; u[--l] == 0; ) u.pop();
2144
2145
  if (!u[0])
@@ -2289,7 +2290,7 @@ function Ye(r) {
2289
2290
  return n < 0 ? (n = -n, c.s = -1) : c.s = 1, Bt(c, n.toString());
2290
2291
  throw Error(ht + n);
2291
2292
  }
2292
- if (i.prototype = v, i.ROUND_UP = 0, i.ROUND_DOWN = 1, i.ROUND_CEIL = 2, i.ROUND_FLOOR = 3, i.ROUND_HALF_UP = 4, i.ROUND_HALF_DOWN = 5, i.ROUND_HALF_EVEN = 6, i.ROUND_HALF_CEIL = 7, i.ROUND_HALF_FLOOR = 8, i.EUCLID = 9, i.config = i.set = Ei, i.clone = Ye, i.isDecimal = _e, i.abs = fi, i.acos = mi, i.acosh = gi, i.add = pi, i.asin = vi, i.asinh = yi, i.atan = wi, i.atanh = xi, i.atan2 = Pi, i.cbrt = bi, i.ceil = Ci, i.clamp = Si, i.cos = _i, i.cosh = Mi, i.div = Di, i.exp = Ri, i.floor = ki, i.hypot = Vi, i.ln = Oi, i.log = Ai, i.log10 = Ti, i.log2 = Li, i.max = Ii, i.min = Ni, i.mod = Hi, i.mul = Fi, i.pow = Bi, i.random = Gi, i.round = Ui, i.sign = Xi, i.sin = zi, i.sinh = Yi, i.sqrt = ji, i.sub = Wi, i.sum = qi, i.tan = $i, i.tanh = Zi, i.trunc = Qi, r === void 0 && (r = {}), r && r.defaults !== !0)
2293
+ if (i.prototype = v, i.ROUND_UP = 0, i.ROUND_DOWN = 1, i.ROUND_CEIL = 2, i.ROUND_FLOOR = 3, i.ROUND_HALF_UP = 4, i.ROUND_HALF_DOWN = 5, i.ROUND_HALF_EVEN = 6, i.ROUND_HALF_CEIL = 7, i.ROUND_HALF_FLOOR = 8, i.EUCLID = 9, i.config = i.set = Ei, i.clone = Ye, i.isDecimal = _e, i.abs = fi, i.acos = mi, i.acosh = gi, i.add = pi, i.asin = vi, i.asinh = yi, i.atan = wi, i.atanh = xi, i.atan2 = Pi, i.cbrt = bi, i.ceil = Ci, i.clamp = Si, i.cos = _i, i.cosh = Mi, i.div = Di, i.exp = Ri, i.floor = ki, i.hypot = Vi, i.ln = Oi, i.log = Ai, i.log10 = Ti, i.log2 = Li, i.max = Ii, i.min = Ni, i.mod = Hi, i.mul = Fi, i.pow = Bi, i.random = zi, i.round = Gi, i.sign = Ui, i.sin = Xi, i.sinh = Yi, i.sqrt = ji, i.sub = Wi, i.sum = qi, i.tan = $i, i.tanh = Zi, i.trunc = Qi, r === void 0 && (r = {}), r && r.defaults !== !0)
2293
2294
  for (e = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], s = 0; s < e.length; ) r.hasOwnProperty(t = e[s++]) || (r[t] = this[t]);
2294
2295
  return i.config(r), i;
2295
2296
  }
@@ -2330,10 +2331,10 @@ function Ti(r) {
2330
2331
  return new this(r).log(10);
2331
2332
  }
2332
2333
  function Ii() {
2333
- return Ue(this, arguments, -1);
2334
+ return Ge(this, arguments, -1);
2334
2335
  }
2335
2336
  function Ni() {
2336
- return Ue(this, arguments, 1);
2337
+ return Ge(this, arguments, 1);
2337
2338
  }
2338
2339
  function Hi(r, s) {
2339
2340
  return new this(r).mod(s);
@@ -2344,9 +2345,9 @@ function Fi(r, s) {
2344
2345
  function Bi(r, s) {
2345
2346
  return new this(r).pow(s);
2346
2347
  }
2347
- function Gi(r) {
2348
+ function zi(r) {
2348
2349
  var s, t, e, i, n = 0, o = new this(1), a = [];
2349
- if (r === void 0 ? r = this.precision : U(r, 1, ut), e = Math.ceil(r / S), this.crypto)
2350
+ if (r === void 0 ? r = this.precision : G(r, 1, ut), e = Math.ceil(r / S), this.crypto)
2350
2351
  if (crypto.getRandomValues)
2351
2352
  for (s = crypto.getRandomValues(new Uint32Array(e)); n < e; )
2352
2353
  i = s[n], i >= 429e7 ? s[n] = crypto.getRandomValues(new Uint32Array(1))[0] : a[n++] = i % 1e7;
@@ -2367,13 +2368,13 @@ function Gi(r) {
2367
2368
  }
2368
2369
  return o.e = t, o.d = a, o;
2369
2370
  }
2370
- function Ui(r) {
2371
+ function Gi(r) {
2371
2372
  return C(r = new this(r), r.e + 1, this.rounding);
2372
2373
  }
2373
- function Xi(r) {
2374
+ function Ui(r) {
2374
2375
  return r = new this(r), r.d ? r.d[0] ? r.s : 0 * r.s : r.s || NaN;
2375
2376
  }
2376
- function zi(r) {
2377
+ function Xi(r) {
2377
2378
  return new this(r).sin();
2378
2379
  }
2379
2380
  function Yi(r) {
@@ -3605,7 +3606,7 @@ class D extends Vt {
3605
3606
  }
3606
3607
  }
3607
3608
  d(D, "ctx", document.createElement("canvas").getContext("2d"));
3608
- class Gt extends D {
3609
+ class zt extends D {
3609
3610
  constructor(t) {
3610
3611
  super(t);
3611
3612
  d(this, "_draw");
@@ -3713,7 +3714,7 @@ class k {
3713
3714
  return new R(s).div(t).toNumber();
3714
3715
  }
3715
3716
  }
3716
- class Ut extends D {
3717
+ class Gt extends D {
3717
3718
  constructor(t) {
3718
3719
  super(t);
3719
3720
  /** 文字偏差 */
@@ -4144,7 +4145,7 @@ function oe(r, s) {
4144
4145
  const { x: t, y: e } = $e(...r, ...s);
4145
4146
  return [t, e];
4146
4147
  }
4147
- class Xt extends je {
4148
+ class Ut extends je {
4148
4149
  constructor(t) {
4149
4150
  super(t);
4150
4151
  d(this, "_isInfinite");
@@ -4292,7 +4293,7 @@ function os(r, s, t, e) {
4292
4293
  }
4293
4294
  return m && p;
4294
4295
  }
4295
- class zt extends je {
4296
+ class Xt extends je {
4296
4297
  constructor(t) {
4297
4298
  super(t);
4298
4299
  d(this, "_isRect", !1);
@@ -5008,7 +5009,7 @@ class ls extends ns {
5008
5009
  if (a !== h) return h - a;
5009
5010
  if (l !== u)
5010
5011
  return u - l;
5011
- const m = (p) => p instanceof Gt ? 5 : p instanceof Ut ? 4 : p instanceof lt ? 3 : p instanceof Xt || p instanceof Yt || p instanceof jt ? 2 : p instanceof zt ? 1 : 0;
5012
+ const m = (p) => p instanceof zt ? 5 : p instanceof Gt ? 4 : p instanceof lt ? 3 : p instanceof Ut || p instanceof Yt || p instanceof jt ? 2 : p instanceof Xt ? 1 : 0;
5012
5013
  return m(f) - m(c);
5013
5014
  }
5014
5015
  ), this.currentDrawOverlays = t.map(
@@ -5303,8 +5304,13 @@ class Y extends Vt {
5303
5304
  super(t);
5304
5305
  /** 覆盖物集合 */
5305
5306
  d(this, "overlays", /* @__PURE__ */ new Set());
5307
+ d(this, "oldOverlaysSize", 0);
5306
5308
  this.setNotifyReload(t.notifyReload);
5307
5309
  }
5310
+ get overlaysSizeChange() {
5311
+ const t = this.oldOverlaysSize;
5312
+ return this.oldOverlaysSize = this.overlays.size, this.overlays.size !== t;
5313
+ }
5308
5314
  /** 设置主画布 */
5309
5315
  setMainCanvas(t) {
5310
5316
  var e;
@@ -5315,7 +5321,7 @@ class Y extends Vt {
5315
5321
  /** 设置覆盖物重新绘制方法 */
5316
5322
  setNotifyReload(t) {
5317
5323
  this.notifyReload = t ? (e) => {
5318
- e && (this.isRecalculate = !0), (e || this.shouldRender() && this.overlays.size) && t();
5324
+ e && (this.isRecalculate = !0), (e || this.overlaysSizeChange || this.shouldRender() && this.overlays.size) && t();
5319
5325
  } : void 0, this.overlays.forEach(
5320
5326
  (e) => e.setNotifyReload(this.notifyReload)
5321
5327
  );
@@ -5366,6 +5372,7 @@ class j extends Vt {
5366
5372
  /** 是否需要重新绘制 */
5367
5373
  d(this, "isReload", !1);
5368
5374
  d(this, "groups", /* @__PURE__ */ new Map());
5375
+ d(this, "oldGroupsSize", 0);
5369
5376
  /** 本次绘制的覆盖物 */
5370
5377
  d(this, "currentDrawOverlays", []);
5371
5378
  this.setNotifyReload(t.notifyReload), typeof t.zIndex == "number" && (this.zIndex = t.zIndex);
@@ -5378,6 +5385,10 @@ class j extends Vt {
5378
5385
  var e;
5379
5386
  this._zIndex != t && (this._zIndex = t, (e = this.notifyReload) == null || e.call(this));
5380
5387
  }
5388
+ get groupsSizeChange() {
5389
+ const t = this.oldGroupsSize;
5390
+ return this.oldGroupsSize = this.groups.size, this.groups.size !== t;
5391
+ }
5381
5392
  setMainCanvas(t) {
5382
5393
  super.setMainCanvas(t), this.canvas.width = (t == null ? void 0 : t.rect.width) || 0, this.canvas.height = (t == null ? void 0 : t.rect.height) || 0, this.groups.forEach((e) => {
5383
5394
  e.setMainCanvas(t), e.parent = this;
@@ -5385,7 +5396,7 @@ class j extends Vt {
5385
5396
  }
5386
5397
  setNotifyReload(t) {
5387
5398
  this.notifyReload = t ? (e) => {
5388
- e && (this.isRecalculate = !0), (e || this.shouldRender() && this.groups.size) && t();
5399
+ e && (this.isRecalculate = !0), (e || this.groupsSizeChange || this.shouldRender() && this.groups.size) && t();
5389
5400
  } : void 0, this.groups.forEach((e) => this.setGroupNotifyReload(e));
5390
5401
  }
5391
5402
  setGroupNotifyReload(t) {
@@ -5447,6 +5458,7 @@ class Rt extends Vt {
5447
5458
  super(t);
5448
5459
  /** 图层群组 */
5449
5460
  d(this, "layers", /* @__PURE__ */ new Map());
5461
+ d(this, "oldLlayersSize", 0);
5450
5462
  /** 地图的事件触发不需要传递 */
5451
5463
  d(this, "defaultContextmenu", (t, e) => t.stopPropagation());
5452
5464
  d(this, "defaultClick", (t, e) => t.stopPropagation());
@@ -5456,6 +5468,10 @@ class Rt extends Vt {
5456
5468
  d(this, "defaultDown", (t, e) => t.stopPropagation());
5457
5469
  this.inheritOpacity = !1, this.setNotifyReload(t.notifyReload), this.addEventListener("contextmenu", this.defaultContextmenu), this.addEventListener("click", this.defaultClick), this.addEventListener("doubleClick", this.defaultDoubleClick), this.addEventListener("hover", this.defaultHover), this.addEventListener("dragg", this.defaultDragg), this.addEventListener("down", this.defaultDown);
5458
5470
  }
5471
+ get layersSizeChange() {
5472
+ const t = this.oldLlayersSize;
5473
+ return this.oldLlayersSize = this.layers.size, this.layers.size !== t;
5474
+ }
5459
5475
  setMainCanvas(t) {
5460
5476
  super.setMainCanvas(t), this.layers.forEach((e) => {
5461
5477
  e.setMainCanvas(t), e.parent = this;
@@ -5463,7 +5479,7 @@ class Rt extends Vt {
5463
5479
  }
5464
5480
  setNotifyReload(t) {
5465
5481
  this.notifyReload = t ? (e) => {
5466
- e && (this.isRecalculate = !0), (e || this.shouldRender() && this.layers.size) && t();
5482
+ e && (this.isRecalculate = !0), (e || this.layersSizeChange || this.shouldRender() && this.layers.size) && t();
5467
5483
  } : void 0, this.layers.forEach((e) => e.setNotifyReload(this.notifyReload));
5468
5484
  }
5469
5485
  /** 获取图层 */
@@ -5640,8 +5656,8 @@ class ds extends us {
5640
5656
  const _ = Math.ceil(g / w);
5641
5657
  b = 1 - ((y * _ / g - a.min) / a.min + (_ - 2)) * P;
5642
5658
  } else {
5643
- const _ = (dt, rt, vt) => dt < rt ? vt - 1 : _(dt / 2, rt, vt + 1), A = _(w, g, 0), X = Math.pow(2, A);
5644
- b = 1 + ((y / X / g - a.min) / a.min + A) * P;
5659
+ const _ = (dt, rt, vt) => dt < rt ? vt - 1 : _(dt / 2, rt, vt + 1), A = _(w, g, 0), U = Math.pow(2, A);
5660
+ b = 1 + ((y / U / g - a.min) / a.min + A) * P;
5645
5661
  }
5646
5662
  return i !== void 0 && (b = Math.min(i, b)), b = new R(b).div(o).round().mul(o).toNumber(), b;
5647
5663
  }
@@ -5947,11 +5963,6 @@ class vs {
5947
5963
  });
5948
5964
  this.canvas = s, this.overlayLayer.addGroup(this.overlayGroup), this.layerGroup.addLayer(this.overlayLayer), s.setLayerGroup(this.layerGroup), s.addEventListener("click", this.handleClick), s.addEventListener("contextmenu", this.handleContextmenu), s.canvas.addEventListener("mousemove", this.handleMousemove);
5949
5965
  }
5950
- /** 按类型开始创建:多边形或线 */
5951
- create(s) {
5952
- if (s === "polygon") return this.createPolygon();
5953
- if (s === "line") return this.createLine();
5954
- }
5955
5966
  /** 禁用除创建层外的其他图层群组交互,并记录原始 isInteractive 以便复原 */
5956
5967
  disableOtherLayerGroups() {
5957
5968
  this.canvas.layerGroups.forEach((s) => {
@@ -5967,11 +5978,11 @@ class vs {
5967
5978
  t.isInteractive = s;
5968
5979
  }), this.savedLayerGroupInteractive.clear();
5969
5980
  }
5970
- createLine() {
5971
- return this.disableOtherLayerGroups(), this.overlay && this.overlayGroup.removeOverlay(this.overlay), this.axisValueList = [], this.overlay = new T.Line({}), this.overlayGroup.addOverlay(this.overlay), this.overlay;
5981
+ createLine(s) {
5982
+ return this.disableOtherLayerGroups(), this.overlay && this.overlayGroup.removeOverlay(this.overlay), this.axisValueList = [], this.overlay = new T.Line({ ...s }), this.overlayGroup.addOverlay(this.overlay), this.overlay;
5972
5983
  }
5973
- createPolygon() {
5974
- return this.disableOtherLayerGroups(), this.overlay && this.overlayGroup.removeOverlay(this.overlay), this.axisValueList = [], this.overlay = new T.Polygon({}), this.overlayGroup.addOverlay(this.overlay), this.overlay;
5984
+ createPolygon(s) {
5985
+ return this.disableOtherLayerGroups(), this.overlay && this.overlayGroup.removeOverlay(this.overlay), this.axisValueList = [], this.overlay = new T.Polygon({ ...s }), this.overlayGroup.addOverlay(this.overlay), this.overlay;
5975
5986
  }
5976
5987
  /** 从创建层中移除指定覆盖物,不传则清空该层全部 */
5977
5988
  removeOverlay(s) {
@@ -6258,7 +6269,7 @@ class T extends gs {
6258
6269
  overlays_other: c
6259
6270
  } = this.getDefaultOverlayGroup() || {};
6260
6271
  Ht(t).forEach((h) => {
6261
- h instanceof Ut ? e == null || e.addOverlay(h) : h instanceof lt ? i == null || i.addOverlay(h) : h instanceof Xt || h instanceof Yt || h instanceof jt ? n == null || n.addOverlay(h) : h instanceof zt ? o == null || o.addOverlay(h) : h instanceof Gt ? a == null || a.addOverlay(h) : h instanceof ae ? l == null || l.addOverlay(h) : c == null || c.addOverlay(h);
6272
+ h instanceof Gt ? e == null || e.addOverlay(h) : h instanceof lt ? i == null || i.addOverlay(h) : h instanceof Ut || h instanceof Yt || h instanceof jt ? n == null || n.addOverlay(h) : h instanceof Xt ? o == null || o.addOverlay(h) : h instanceof zt ? a == null || a.addOverlay(h) : h instanceof ae ? l == null || l.addOverlay(h) : c == null || c.addOverlay(h);
6262
6273
  });
6263
6274
  }
6264
6275
  /** 移除覆盖物 */
@@ -6273,7 +6284,7 @@ class T extends gs {
6273
6284
  overlays_other: c
6274
6285
  } = this.getDefaultOverlayGroup() || {};
6275
6286
  Ht(t).forEach((h) => {
6276
- h instanceof Ut ? e == null || e.removeOverlay(h) : h instanceof lt ? i == null || i.removeOverlay(h) : h instanceof Xt || h instanceof Yt || h instanceof jt ? n == null || n.removeOverlay(h) : h instanceof zt ? o == null || o.removeOverlay(h) : h instanceof Gt ? a == null || a.addOverlay(h) : h instanceof ae ? l == null || l.removeOverlay(h) : c == null || c.removeOverlay(h);
6287
+ h instanceof Gt ? e == null || e.removeOverlay(h) : h instanceof lt ? i == null || i.removeOverlay(h) : h instanceof Ut || h instanceof Yt || h instanceof jt ? n == null || n.removeOverlay(h) : h instanceof Xt ? o == null || o.removeOverlay(h) : h instanceof zt ? a == null || a.addOverlay(h) : h instanceof ae ? l == null || l.removeOverlay(h) : c == null || c.removeOverlay(h);
6277
6288
  });
6278
6289
  }
6279
6290
  /** 销毁 */
@@ -6286,11 +6297,11 @@ d(T, "ViewFit", ys), /** 图层群组 */
6286
6297
  d(T, "LayerGroup", Rt), /** 图层 */
6287
6298
  d(T, "Layer", j), /** 覆盖物群组 */
6288
6299
  d(T, "OverlayGroup", Y), /** 文字 */
6289
- d(T, "Text", Ut), /** 点位 */
6300
+ d(T, "Text", Gt), /** 点位 */
6290
6301
  d(T, "Point", lt), /** 线段 */
6291
- d(T, "Line", Xt), /** 多边形 */
6292
- d(T, "Polygon", zt), /** 自定义绘制 */
6293
- d(T, "Custom", Gt), /** 圆弧 */
6302
+ d(T, "Line", Ut), /** 多边形 */
6303
+ d(T, "Polygon", Xt), /** 自定义绘制 */
6304
+ d(T, "Custom", zt), /** 圆弧 */
6294
6305
  d(T, "Arc", Yt), /** 圆角 */
6295
6306
  d(T, "ArcTo", jt), /** 图片 */
6296
6307
  d(T, "Billboard", ae);
@@ -6316,7 +6327,7 @@ class xs {
6316
6327
  * @returns true 表示初始化成功;false 表示找不到 canvas 或上下文
6317
6328
  */
6318
6329
  init(s) {
6319
- return this.canvas = document.getElementById(this.id), this.canvas ? (this.ctx = this.canvas.getContext("2d"), this.ctx ? (this.syncCanvasSize(), this.setupResizeListener(s), !0) : (console.error("Failed to get canvas context"), !1)) : (console.error(`Canvas with id ${this.id} not found`), !1);
6330
+ return this.destroy(), this.canvas = document.getElementById(this.id), this.canvas ? (this.ctx = this.canvas.getContext("2d"), this.ctx ? (this.syncCanvasSize(), this.setupResizeListener(s), !0) : (console.error("Failed to get canvas context"), !1)) : (console.error(`Canvas with id ${this.id} not found`), !1);
6320
6331
  }
6321
6332
  /** 获取当前 CanvasRenderingContext2D */
6322
6333
  getContext() {
@@ -6690,7 +6701,10 @@ class fn extends Es {
6690
6701
  lineWidth: u = 1
6691
6702
  } = s, f = this.getCanvasXAtTime(i), p = this.getCanvasXAtTime(n) - f;
6692
6703
  if (!p) return;
6693
- const g = this.resolveFillStyle({ x: f, y: o, width: p, height: a }, c);
6704
+ const g = this.resolveFillStyle(
6705
+ { x: f, y: o, width: p, height: a },
6706
+ c
6707
+ );
6694
6708
  g && (t.fillStyle = g), h && (t.strokeStyle = h), t.lineWidth = u, t.beginPath(), typeof t.roundRect == "function" ? t.roundRect(f, o, p, a + o, l) : t.rect(f, o, p, a + o), c && t.fill(), h && t.stroke();
6695
6709
  }
6696
6710
  }
@@ -6868,7 +6882,7 @@ class wn {
6868
6882
  L(this, bt);
6869
6883
  }
6870
6884
  init(s, t) {
6871
- M(this, W, s), M(this, st, t == null ? void 0 : t.limit), M(this, bt, t == null ? void 0 : t.dragDom), M(this, mt, {
6885
+ this.finish(), M(this, W, s), M(this, st, t == null ? void 0 : t.limit), M(this, bt, t == null ? void 0 : t.dragDom), M(this, mt, {
6872
6886
  mousedown: this.mousedown.bind(this),
6873
6887
  mousemove: this.mousemove.bind(this),
6874
6888
  mouseup: this.mouseup.bind(this)
@@ -6902,7 +6916,7 @@ class wn {
6902
6916
  }
6903
6917
  }
6904
6918
  W = new WeakMap(), ft = new WeakMap(), mt = new WeakMap(), xt = new WeakMap(), Pt = new WeakMap(), J = new WeakMap(), K = new WeakMap(), st = new WeakMap(), bt = new WeakMap();
6905
- var q, gt, pt, Ct, St, $, Z, G, Et, _t;
6919
+ var q, gt, pt, Ct, St, $, Z, z, Et, _t;
6906
6920
  class xn {
6907
6921
  constructor() {
6908
6922
  L(this, q);
@@ -6912,12 +6926,12 @@ class xn {
6912
6926
  L(this, St, 0);
6913
6927
  L(this, $, 0);
6914
6928
  L(this, Z, 0);
6915
- L(this, G);
6929
+ L(this, z);
6916
6930
  L(this, Et);
6917
6931
  L(this, _t);
6918
6932
  }
6919
6933
  init(s, t = {}) {
6920
- M(this, q, s), M(this, G, t.limit), M(this, Et, t.update_move), M(this, _t, t.update_up), M(this, pt, {
6934
+ this.finish(), M(this, q, s), M(this, z, t.limit), M(this, Et, t.update_move), M(this, _t, t.update_up), M(this, pt, {
6921
6935
  mousedown: this.mousedown.bind(this),
6922
6936
  mousemove: this.mousemove.bind(this),
6923
6937
  mouseup: this.mouseup.bind(this)
@@ -6937,8 +6951,8 @@ class xn {
6937
6951
  left: x(this, Z),
6938
6952
  percentage: { top: 0, left: 0 }
6939
6953
  };
6940
- if (x(this, G)) {
6941
- const t = (e) => x(this, G) ? (s[e] - x(this, G).min[e]) / (x(this, G).max[e] - x(this, G).min[e]) : 0;
6954
+ if (x(this, z)) {
6955
+ const t = (e) => x(this, z) ? (s[e] - x(this, z).min[e]) / (x(this, z).max[e] - x(this, z).min[e]) : 0;
6942
6956
  s.percentage = {
6943
6957
  top: t("top") || 0,
6944
6958
  left: t("left") || 0
@@ -6948,7 +6962,7 @@ class xn {
6948
6962
  }
6949
6963
  alterLocation() {
6950
6964
  if (!x(this, q)) return console.error("No DOM");
6951
- x(this, G) && (M(this, $, Math.min(x(this, $), x(this, G).max.top)), M(this, $, Math.max(x(this, $), x(this, G).min.top)), M(this, Z, Math.min(x(this, Z), x(this, G).max.left)), M(this, Z, Math.max(x(this, Z), x(this, G).min.left))), x(this, Et) && x(this, Et).call(this, this.updateValue()), x(this, q).style.setProperty("--top", x(this, $) + "px"), x(this, q).style.setProperty("--left", x(this, Z) + "px");
6965
+ x(this, z) && (M(this, $, Math.min(x(this, $), x(this, z).max.top)), M(this, $, Math.max(x(this, $), x(this, z).min.top)), M(this, Z, Math.min(x(this, Z), x(this, z).max.left)), M(this, Z, Math.max(x(this, Z), x(this, z).min.left))), x(this, Et) && x(this, Et).call(this, this.updateValue()), x(this, q).style.setProperty("--top", x(this, $) + "px"), x(this, q).style.setProperty("--left", x(this, Z) + "px");
6952
6966
  }
6953
6967
  mousedown(s) {
6954
6968
  if (!x(this, q)) return console.error("No DOM");
@@ -6966,7 +6980,7 @@ class xn {
6966
6980
  x(this, gt) && (M(this, gt, !1), document.body.classList.remove("no-select"), x(this, _t) && x(this, _t).call(this, this.updateValue()));
6967
6981
  }
6968
6982
  }
6969
- q = new WeakMap(), gt = new WeakMap(), pt = new WeakMap(), Ct = new WeakMap(), St = new WeakMap(), $ = new WeakMap(), Z = new WeakMap(), G = new WeakMap(), Et = new WeakMap(), _t = new WeakMap();
6983
+ q = new WeakMap(), gt = new WeakMap(), pt = new WeakMap(), Ct = new WeakMap(), St = new WeakMap(), $ = new WeakMap(), Z = new WeakMap(), z = new WeakMap(), Et = new WeakMap(), _t = new WeakMap();
6970
6984
  function Pn(r, s) {
6971
6985
  if (typeof r == "number") return r;
6972
6986
  if (/px/.test(r)) return Number(r.replace(/px/, "")) || 0;
@@ -7305,15 +7319,15 @@ export {
7305
7319
  _n as _File_CreateAndDownload,
7306
7320
  _s as _File_Download,
7307
7321
  En as _File_Read,
7308
- Xs as _Format_CamelCase,
7322
+ Us as _Format_CamelCase,
7309
7323
  Fs as _Format_CapitalizeFirstLetter,
7310
7324
  Ws as _Format_ChunkArray,
7311
- zs as _Format_ExcludeSubstring,
7312
- Us as _Format_FileSize,
7325
+ Xs as _Format_ExcludeSubstring,
7326
+ Gs as _Format_FileSize,
7313
7327
  ce as _Format_HrefName,
7314
7328
  js as _Format_MillisecondToReadable,
7315
7329
  le as _Format_NumberWithCommas,
7316
- Gs as _Format_NumberWithUnit,
7330
+ zs as _Format_NumberWithUnit,
7317
7331
  Bs as _Format_Percentage,
7318
7332
  ti as _Format_Timestamp,
7319
7333
  Ys as _Format_ToggleInvisibleChars,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhanh-pure-function",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "纯函数工具",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.es.js",