@unicom-cloud/utils 0.1.4 → 0.1.10

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.
@@ -5,7 +5,7 @@
5
5
  * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
6
6
  * MIT Licence
7
7
  */
8
- var ue = 9e15, $ = 1e9, fe = "0123456789abcdef", x = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", y = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", ce = {
8
+ var G = 9e15, $ = 1e9, fe = "0123456789abcdef", y = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", ee = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", ce = {
9
9
  // These values must be integers within the stated ranges (inclusive).
10
10
  // Most of these values can be changed at run-time using the `Decimal.config` method.
11
11
  // The maximum number of significant digits of the result of a calculation or base conversion.
@@ -54,16 +54,16 @@ var ue = 9e15, $ = 1e9, fe = "0123456789abcdef", x = "2.302585092994045684017991
54
54
  // 0 to EXP_LIMIT
55
55
  // The minimum exponent value, beneath which underflow to zero occurs.
56
56
  // JavaScript numbers: -324 (5e-324)
57
- minE: -9e15,
57
+ minE: -G,
58
58
  // -1 to -EXP_LIMIT
59
59
  // The maximum exponent value, above which overflow to Infinity occurs.
60
60
  // JavaScript numbers: 308 (1.7976931348623157e+308)
61
- maxE: ue,
61
+ maxE: G,
62
62
  // 1 to EXP_LIMIT
63
63
  // Whether to use cryptographically-secure random number generation, if available.
64
64
  crypto: !1
65
65
  // true/false
66
- }, _, we, b, m = !0, ie = "[DecimalError] ", V = ie + "Invalid argument: ", me = ie + "Precision limit exceeded", Ne = ie + "crypto unavailable", ve = "[object Decimal]", L = Math.floor, C = Math.pow, Ae = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, Le = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, Fe = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, Ee = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, R = 1e7, w = 7, Oe = 9007199254740991, De = x.length - 1, le = y.length - 1, d = { toStringTag: ve };
66
+ }, _, we, b, m = !0, ne = "[DecimalError] ", V = ne + "Invalid argument: ", me = ne + "Precision limit exceeded", Ne = ne + "crypto unavailable", ve = "[object Decimal]", L = Math.floor, C = Math.pow, Ae = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, Le = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, Fe = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, Ee = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, R = 1e7, w = 7, Oe = 9007199254740991, De = y.length - 1, le = ee.length - 1, d = { toStringTag: ve };
67
67
  d.absoluteValue = d.abs = function() {
68
68
  var e = new this.constructor(this);
69
69
  return e.s < 0 && (e.s = 1), p(e);
@@ -145,7 +145,7 @@ d.hyperbolicCosine = d.cosh = function() {
145
145
  var e, i, n, r, s, t = this, o = t.constructor, u = new o(1);
146
146
  if (!t.isFinite()) return new o(t.s ? 1 / 0 : NaN);
147
147
  if (t.isZero()) return u;
148
- n = o.precision, r = o.rounding, o.precision = n + Math.max(t.e, t.sd()) + 4, o.rounding = 1, s = t.d.length, s < 32 ? (e = Math.ceil(s / 3), i = (1 / re(4, e)).toString()) : (e = 16, i = "2.3283064365386962890625e-10"), t = G(o, 1, t.times(i), new o(1), !0);
148
+ n = o.precision, r = o.rounding, o.precision = n + Math.max(t.e, t.sd()) + 4, o.rounding = 1, s = t.d.length, s < 32 ? (e = Math.ceil(s / 3), i = (1 / te(4, e)).toString()) : (e = 16, i = "2.3283064365386962890625e-10"), t = W(o, 1, t.times(i), new o(1), !0);
149
149
  for (var c, f = e, l = new o(8); f--; )
150
150
  c = t.times(t), t = u.minus(c.times(l.minus(c.times(l))));
151
151
  return p(t, o.precision = n, o.rounding = r, !0);
@@ -154,9 +154,9 @@ d.hyperbolicSine = d.sinh = function() {
154
154
  var e, i, n, r, s = this, t = s.constructor;
155
155
  if (!s.isFinite() || s.isZero()) return new t(s);
156
156
  if (i = t.precision, n = t.rounding, t.precision = i + Math.max(s.e, s.sd()) + 4, t.rounding = 1, r = s.d.length, r < 3)
157
- s = G(t, 2, s, s, !0);
157
+ s = W(t, 2, s, s, !0);
158
158
  else {
159
- e = 1.4 * Math.sqrt(r), e = e > 16 ? 16 : e | 0, s = s.times(1 / re(5, e)), s = G(t, 2, s, s, !0);
159
+ e = 1.4 * Math.sqrt(r), e = e > 16 ? 16 : e | 0, s = s.times(1 / te(5, e)), s = W(t, 2, s, s, !0);
160
160
  for (var o, u = new t(5), c = new t(16), f = new t(20); e--; )
161
161
  o = s.times(s), s = s.times(u.plus(o.times(c.times(o).plus(f))));
162
162
  }
@@ -255,13 +255,13 @@ d.logarithm = d.log = function(e) {
255
255
  for (s = n[0]; s % 10 === 0; ) s /= 10;
256
256
  t = s !== 1;
257
257
  }
258
- if (m = !1, u = a + g, o = H(f, u), r = i ? ee(l, u + 10) : H(e, u), c = k(o, r, u, 1), X(c.d, s = a, h))
258
+ if (m = !1, u = a + g, o = H(f, u), r = i ? ie(l, u + 10) : H(e, u), c = k(o, r, u, 1), J(c.d, s = a, h))
259
259
  do
260
- if (u += 10, o = H(f, u), r = i ? ee(l, u + 10) : H(e, u), c = k(o, r, u, 1), !t) {
260
+ if (u += 10, o = H(f, u), r = i ? ie(l, u + 10) : H(e, u), c = k(o, r, u, 1), !t) {
261
261
  +P(c.d).slice(s + 1, s + 15) + 1 == 1e14 && (c = p(c, a + 1, 0));
262
262
  break;
263
263
  }
264
- while (X(c.d, s += 10, h));
264
+ while (J(c.d, s += 10, h));
265
265
  return m = !0, p(c, a, h);
266
266
  };
267
267
  d.minus = d.sub = function(e) {
@@ -297,7 +297,7 @@ d.minus = d.sub = function(e) {
297
297
  }
298
298
  for (; f[--o] === 0; ) f.pop();
299
299
  for (; f[0] === 0; f.shift()) --n;
300
- return f[0] ? (e.d = f, e.e = ne(f, n), m ? p(e, u, c) : e) : new v(c === 3 ? -0 : 0);
300
+ return f[0] ? (e.d = f, e.e = re(f, n), m ? p(e, u, c) : e) : new v(c === 3 ? -0 : 0);
301
301
  };
302
302
  d.modulo = d.mod = function(e) {
303
303
  var i, n = this, r = n.constructor;
@@ -328,7 +328,7 @@ d.plus = d.add = function(e) {
328
328
  for (o = f.length, s = l.length, o - s < 0 && (s = o, n = l, l = f, f = n), i = 0; s; )
329
329
  i = (f[--s] = f[s] + l[s] + i) / R | 0, f[s] %= R;
330
330
  for (i && (f.unshift(i), ++r), o = f.length; f[--o] == 0; ) f.pop();
331
- return e.d = f, e.e = ne(f, r), m ? p(e, u, c) : e;
331
+ return e.d = f, e.e = re(f, r), m ? p(e, u, c) : e;
332
332
  };
333
333
  d.precision = d.sd = function(e) {
334
334
  var i, n = this;
@@ -387,7 +387,7 @@ d.times = d.mul = function(e) {
387
387
  t[s] = (t[s] + i) % R | 0;
388
388
  }
389
389
  for (; !t[--o]; ) t.pop();
390
- return i ? ++n : t.shift(), e.d = t, e.e = ne(t, n), m ? p(e, a.precision, a.rounding) : e;
390
+ return i ? ++n : t.shift(), e.d = t, e.e = re(t, n), m ? p(e, a.precision, a.rounding) : e;
391
391
  };
392
392
  d.toBinary = function(e, i) {
393
393
  return he(this, 2, e, i);
@@ -452,7 +452,7 @@ d.toPower = d.pow = function(e) {
452
452
  }
453
453
  return n = C(+u, f), i = n == 0 || !isFinite(n) ? L(
454
454
  f * (Math.log("0." + P(u.d)) / Math.LN10 + u.e + 1)
455
- ) : new c(n + "").e, i > c.maxE + 1 || i < c.minE - 1 ? new c(i > 0 ? o / 0 : 0) : (m = !1, c.rounding = u.s = 1, n = Math.min(12, (i + "").length), s = ae(e.times(H(u, r + n)), r), s.d && (s = p(s, r + 5, 1), X(s.d, r, t) && (i = r + 10, s = p(
455
+ ) : new c(n + "").e, i > c.maxE + 1 || i < c.minE - 1 ? new c(i > 0 ? o / 0 : 0) : (m = !1, c.rounding = u.s = 1, n = Math.min(12, (i + "").length), s = ae(e.times(H(u, r + n)), r), s.d && (s = p(s, r + 5, 1), J(s.d, r, t) && (i = r + 10, s = p(
456
456
  ae(e.times(H(u, i + n)), i),
457
457
  i + 5,
458
458
  1
@@ -492,12 +492,12 @@ function O(e, i, n) {
492
492
  if (e !== ~~e || e < i || e > n)
493
493
  throw Error(V + e);
494
494
  }
495
- function X(e, i, n, r) {
495
+ function J(e, i, n, r) {
496
496
  var s, t, o, u;
497
497
  for (t = e[0]; t >= 10; t /= 10) --i;
498
498
  return --i < 0 ? (i += w, s = 0) : (s = Math.ceil((i + 1) / w), i %= w), t = C(10, w - i), u = e[s] % t | 0, r == null ? i < 3 ? (i == 0 ? u = u / 100 | 0 : i == 1 && (u = u / 10 | 0), o = n < 4 && u == 99999 || n > 3 && u == 49999 || u == 5e4 || u == 0) : o = (n < 4 && u + 1 == t || n > 3 && u + 1 == t / 2) && (e[s + 1] / t / 100 | 0) == C(10, i - 2) - 1 || (u == t / 2 || u == 0) && (e[s + 1] / t / 100 | 0) == 0 : i < 4 ? (i == 0 ? u = u / 1e3 | 0 : i == 1 ? u = u / 100 | 0 : i == 2 && (u = u / 10 | 0), o = (r || n < 4) && u == 9999 || !r && n > 3 && u == 4999) : o = ((r || n < 4) && u + 1 == t || !r && n > 3 && u + 1 == t / 2) && (e[s + 1] / t / 1e3 | 0) == C(10, i - 3) - 1, o;
499
499
  }
500
- function j(e, i, n) {
500
+ function z(e, i, n) {
501
501
  for (var r, s = [0], t, o = 0, u = e.length; o < u; ) {
502
502
  for (t = s.length; t--; ) s[t] *= i;
503
503
  for (s[0] += fe.indexOf(e.charAt(o++)), r = 0; r < s.length; r++)
@@ -508,7 +508,7 @@ function j(e, i, n) {
508
508
  function Ie(e, i) {
509
509
  var n, r, s;
510
510
  if (i.isZero()) return i;
511
- r = i.d.length, r < 32 ? (n = Math.ceil(r / 3), s = (1 / re(4, n)).toString()) : (n = 16, s = "2.3283064365386962890625e-10"), e.precision += n, i = G(e, 1, i.times(s), new e(1));
511
+ r = i.d.length, r < 32 ? (n = Math.ceil(r / 3), s = (1 / te(4, n)).toString()) : (n = 16, s = "2.3283064365386962890625e-10"), e.precision += n, i = W(e, 1, i.times(s), new e(1));
512
512
  for (var t = n; t--; ) {
513
513
  var o = i.times(i);
514
514
  i = o.times(o).minus(o).times(8).plus(1);
@@ -540,29 +540,29 @@ var k = /* @__PURE__ */ function() {
540
540
  for (; !r[0] && r.length > 1; ) r.shift();
541
541
  }
542
542
  return function(r, s, t, o, u, c) {
543
- var f, l, a, h, g, v, N, F, q, D, E, S, J, U, te, K, W, se, I, Q, Y = r.constructor, oe = r.s == s.s ? 1 : -1, A = r.d, M = s.d;
543
+ var f, l, a, h, g, v, N, F, q, D, E, S, K, U, se, Q, X, oe, I, Y, j = r.constructor, ue = r.s == s.s ? 1 : -1, A = r.d, M = s.d;
544
544
  if (!A || !A[0] || !M || !M[0])
545
- return new Y(
545
+ return new j(
546
546
  // Return NaN if either NaN, or both Infinity or 0.
547
547
  !r.s || !s.s || (A ? M && A[0] == M[0] : !M) ? NaN : (
548
548
  // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
549
- A && A[0] == 0 || !M ? oe * 0 : oe / 0
549
+ A && A[0] == 0 || !M ? ue * 0 : ue / 0
550
550
  )
551
551
  );
552
- for (c ? (g = 1, l = r.e - s.e) : (c = R, g = w, l = L(r.e / g) - L(s.e / g)), I = M.length, W = A.length, q = new Y(oe), D = q.d = [], a = 0; M[a] == (A[a] || 0); a++) ;
553
- if (M[a] > (A[a] || 0) && l--, t == null ? (U = t = Y.precision, o = Y.rounding) : u ? U = t + (r.e - s.e) + 1 : U = t, U < 0)
552
+ for (c ? (g = 1, l = r.e - s.e) : (c = R, g = w, l = L(r.e / g) - L(s.e / g)), I = M.length, X = A.length, q = new j(ue), D = q.d = [], a = 0; M[a] == (A[a] || 0); a++) ;
553
+ if (M[a] > (A[a] || 0) && l--, t == null ? (U = t = j.precision, o = j.rounding) : u ? U = t + (r.e - s.e) + 1 : U = t, U < 0)
554
554
  D.push(1), v = !0;
555
555
  else {
556
556
  if (U = U / g + 2 | 0, a = 0, I == 1) {
557
- for (h = 0, M = M[0], U++; (a < W || h) && U--; a++)
558
- te = h * c + (A[a] || 0), D[a] = te / M | 0, h = te % M | 0;
559
- v = h || a < W;
557
+ for (h = 0, M = M[0], U++; (a < X || h) && U--; a++)
558
+ se = h * c + (A[a] || 0), D[a] = se / M | 0, h = se % M | 0;
559
+ v = h || a < X;
560
560
  } else {
561
- for (h = c / (M[0] + 1) | 0, h > 1 && (M = e(M, h, c), A = e(A, h, c), I = M.length, W = A.length), K = I, E = A.slice(0, I), S = E.length; S < I; ) E[S++] = 0;
562
- Q = M.slice(), Q.unshift(0), se = M[0], M[1] >= c / 2 && ++se;
561
+ for (h = c / (M[0] + 1) | 0, h > 1 && (M = e(M, h, c), A = e(A, h, c), I = M.length, X = A.length), Q = I, E = A.slice(0, I), S = E.length; S < I; ) E[S++] = 0;
562
+ Y = M.slice(), Y.unshift(0), oe = M[0], M[1] >= c / 2 && ++oe;
563
563
  do
564
- h = 0, f = i(M, E, I, S), f < 0 ? (J = E[0], I != S && (J = J * c + (E[1] || 0)), h = J / se | 0, h > 1 ? (h >= c && (h = c - 1), N = e(M, h, c), F = N.length, S = E.length, f = i(N, E, F, S), f == 1 && (h--, n(N, I < F ? Q : M, F, c))) : (h == 0 && (f = h = 1), N = M.slice()), F = N.length, F < S && N.unshift(0), n(E, N, S, c), f == -1 && (S = E.length, f = i(M, E, I, S), f < 1 && (h++, n(E, I < S ? Q : M, S, c))), S = E.length) : f === 0 && (h++, E = [0]), D[a++] = h, f && E[0] ? E[S++] = A[K] || 0 : (E = [A[K]], S = 1);
565
- while ((K++ < W || E[0] !== void 0) && U--);
564
+ h = 0, f = i(M, E, I, S), f < 0 ? (K = E[0], I != S && (K = K * c + (E[1] || 0)), h = K / oe | 0, h > 1 ? (h >= c && (h = c - 1), N = e(M, h, c), F = N.length, S = E.length, f = i(N, E, F, S), f == 1 && (h--, n(N, I < F ? Y : M, F, c))) : (h == 0 && (f = h = 1), N = M.slice()), F = N.length, F < S && N.unshift(0), n(E, N, S, c), f == -1 && (S = E.length, f = i(M, E, I, S), f < 1 && (h++, n(E, I < S ? Y : M, S, c))), S = E.length) : f === 0 && (h++, E = [0]), D[a++] = h, f && E[0] ? E[S++] = A[Q] || 0 : (E = [A[Q]], S = 1);
565
+ while ((Q++ < X || E[0] !== void 0) && U--);
566
566
  v = E[0] !== void 0;
567
567
  }
568
568
  D[0] || D.shift();
@@ -616,19 +616,19 @@ function Z(e, i, n) {
616
616
  var r, s = e.e, t = P(e.d), o = t.length;
617
617
  return i ? (n && (r = n - o) > 0 ? t = t.charAt(0) + "." + t.slice(1) + B(r) : o > 1 && (t = t.charAt(0) + "." + t.slice(1)), t = t + (e.e < 0 ? "e" : "e+") + e.e) : s < 0 ? (t = "0." + B(-s - 1) + t, n && (r = n - o) > 0 && (t += B(r))) : s >= o ? (t += B(s + 1 - o), n && (r = n - s - 1) > 0 && (t = t + "." + B(r))) : ((r = s + 1) < o && (t = t.slice(0, r) + "." + t.slice(r)), n && (r = n - o) > 0 && (s + 1 === o && (t += "."), t += B(r))), t;
618
618
  }
619
- function ne(e, i) {
619
+ function re(e, i) {
620
620
  var n = e[0];
621
621
  for (i *= w; n >= 10; n /= 10) i++;
622
622
  return i;
623
623
  }
624
- function ee(e, i, n) {
624
+ function ie(e, i, n) {
625
625
  if (i > De)
626
626
  throw m = !0, n && (e.precision = n), Error(me);
627
- return p(new e(x), i, 1, !0);
627
+ return p(new e(y), i, 1, !0);
628
628
  }
629
629
  function T(e, i, n) {
630
630
  if (i > le) throw Error(me);
631
- return p(new e(y), i, n, !0);
631
+ return p(new e(ee), i, n, !0);
632
632
  }
633
633
  function ke(e) {
634
634
  var i = e.length - 1, n = i * w + 1;
@@ -678,7 +678,7 @@ function ae(e, i) {
678
678
  if (t = p(t.times(e), c, 1), n = n.times(++l), u = o.plus(k(t, n, c, 1)), P(u.d).slice(0, c) === P(o.d).slice(0, c)) {
679
679
  for (s = a; s--; ) o = p(o.times(o), c, 1);
680
680
  if (i == null)
681
- if (f < 3 && X(o.d, c - r, g, f))
681
+ if (f < 3 && J(o.d, c - r, g, f))
682
682
  h.precision = c += 10, n = t = u = new h(1), l = 0, f++;
683
683
  else
684
684
  return p(o, h.precision = v, g, m = !0);
@@ -697,11 +697,11 @@ function H(e, i) {
697
697
  N = N.times(e), n = P(N.d), r = n.charAt(0), g++;
698
698
  t = N.e, r > 1 ? (N = new q("0." + n), t++) : N = new q(r + "." + n.slice(1));
699
699
  } else
700
- return f = ee(q, l + 2, E).times(t + ""), N = H(new q(r + "." + n.slice(1)), l - v).plus(f), q.precision = E, i == null ? p(N, E, D, m = !0) : N;
700
+ return f = ie(q, l + 2, E).times(t + ""), N = H(new q(r + "." + n.slice(1)), l - v).plus(f), q.precision = E, i == null ? p(N, E, D, m = !0) : N;
701
701
  for (a = N, c = o = N = k(N.minus(1), N.plus(1), l, 1), h = p(N.times(N), l, 1), s = 3; ; ) {
702
702
  if (o = p(o.times(h), l, 1), f = c.plus(k(o, new q(s), l, 1)), P(f.d).slice(0, l) === P(c.d).slice(0, l))
703
- if (c = c.times(2), t !== 0 && (c = c.plus(ee(q, l + 2, E).times(t + ""))), c = k(c, new q(g), l, 1), i == null)
704
- if (X(c.d, l - v, D, u))
703
+ if (c = c.times(2), t !== 0 && (c = c.plus(ie(q, l + 2, E).times(t + ""))), c = k(c, new q(g), l, 1), i == null)
704
+ if (J(c.d, l - v, D, u))
705
705
  q.precision = l += v, f = o = N = k(a.minus(1), a.plus(1), l, 1), h = p(N.times(N), l, 1), s = u = 1;
706
706
  else
707
707
  return p(c, q.precision = E, D, m = !0);
@@ -713,7 +713,7 @@ function H(e, i) {
713
713
  function Ce(e) {
714
714
  return String(e.s * e.s / 0);
715
715
  }
716
- function z(e, i) {
716
+ function x(e, i) {
717
717
  var n, r, s;
718
718
  for ((n = i.indexOf(".")) > -1 && (i = i.replace(".", "")), (r = i.search(/e/i)) > 0 ? (n < 0 && (n = r), n += +i.slice(r + 1), i = i.substring(0, r)) : n < 0 && (n = i.length), r = 0; i.charCodeAt(r) === 48; r++) ;
719
719
  for (s = i.length; i.charCodeAt(s - 1) === 48; --s) ;
@@ -732,7 +732,7 @@ function z(e, i) {
732
732
  function _e(e, i) {
733
733
  var n, r, s, t, o, u, c, f, l;
734
734
  if (i.indexOf("_") > -1) {
735
- if (i = i.replace(/(\d)_(?=\d)/g, "$1"), Ee.test(i)) return z(e, i);
735
+ if (i = i.replace(/(\d)_(?=\d)/g, "$1"), Ee.test(i)) return x(e, i);
736
736
  } else if (i === "Infinity" || i === "NaN")
737
737
  return +i || (e.s = NaN), e.e = NaN, e.d = null, e;
738
738
  if (Le.test(i))
@@ -743,19 +743,19 @@ function _e(e, i) {
743
743
  n = 8;
744
744
  else
745
745
  throw Error(V + i);
746
- for (t = i.search(/p/i), t > 0 ? (c = +i.slice(t + 1), i = i.substring(2, t)) : i = i.slice(2), t = i.indexOf("."), o = t >= 0, r = e.constructor, o && (i = i.replace(".", ""), u = i.length, t = u - t, s = Me(r, new r(n), t, t * 2)), f = j(i, n, R), l = f.length - 1, t = l; f[t] === 0; --t) f.pop();
747
- return t < 0 ? new r(e.s * 0) : (e.e = ne(f, l), e.d = f, m = !1, o && (e = k(e, s, u * 4)), c && (e = e.times(Math.abs(c) < 54 ? C(2, c) : _.pow(2, c))), m = !0, e);
746
+ for (t = i.search(/p/i), t > 0 ? (c = +i.slice(t + 1), i = i.substring(2, t)) : i = i.slice(2), t = i.indexOf("."), o = t >= 0, r = e.constructor, o && (i = i.replace(".", ""), u = i.length, t = u - t, s = Me(r, new r(n), t, t * 2)), f = z(i, n, R), l = f.length - 1, t = l; f[t] === 0; --t) f.pop();
747
+ return t < 0 ? new r(e.s * 0) : (e.e = re(f, l), e.d = f, m = !1, o && (e = k(e, s, u * 4)), c && (e = e.times(Math.abs(c) < 54 ? C(2, c) : _.pow(2, c))), m = !0, e);
748
748
  }
749
749
  function Re(e, i) {
750
750
  var n, r = i.d.length;
751
751
  if (r < 3)
752
- return i.isZero() ? i : G(e, 2, i, i);
753
- n = 1.4 * Math.sqrt(r), n = n > 16 ? 16 : n | 0, i = i.times(1 / re(5, n)), i = G(e, 2, i, i);
752
+ return i.isZero() ? i : W(e, 2, i, i);
753
+ n = 1.4 * Math.sqrt(r), n = n > 16 ? 16 : n | 0, i = i.times(1 / te(5, n)), i = W(e, 2, i, i);
754
754
  for (var s, t = new e(5), o = new e(16), u = new e(20); n--; )
755
755
  s = i.times(i), i = i.times(t.plus(s.times(o.times(s).minus(u))));
756
756
  return i;
757
757
  }
758
- function G(e, i, n, r, s) {
758
+ function W(e, i, n, r, s) {
759
759
  var t, o, u, c, f = e.precision, l = Math.ceil(f / w);
760
760
  for (m = !1, c = n.times(n), u = new e(r); ; ) {
761
761
  if (o = k(u.times(c), new e(i++ * i++), f, 1), u = s ? r.plus(o) : r.minus(o), r = k(o.times(c), new e(i++ * i++), f, 1), o = u.plus(r), o.d[l] !== void 0) {
@@ -766,7 +766,7 @@ function G(e, i, n, r, s) {
766
766
  }
767
767
  return m = !0, o.d.length = l + 1, o;
768
768
  }
769
- function re(e, i) {
769
+ function te(e, i) {
770
770
  for (var n = e; --i; ) n *= e;
771
771
  return n;
772
772
  }
@@ -788,7 +788,7 @@ function he(e, i, n, r) {
788
788
  if (v ? (O(n, 1, $), r === void 0 ? r = g.rounding : O(r, 0, 8)) : (n = g.precision, r = g.rounding), !e.isFinite())
789
789
  l = Ce(e);
790
790
  else {
791
- for (l = Z(e), o = l.indexOf("."), v ? (s = 2, i == 16 ? n = n * 4 - 3 : i == 8 && (n = n * 3 - 2)) : s = i, o >= 0 && (l = l.replace(".", ""), h = new g(1), h.e = l.length - o, h.d = j(Z(h), 10, s), h.e = h.d.length), a = j(l, 10, s), t = c = a.length; a[--c] == 0; ) a.pop();
791
+ for (l = Z(e), o = l.indexOf("."), v ? (s = 2, i == 16 ? n = n * 4 - 3 : i == 8 && (n = n * 3 - 2)) : s = i, o >= 0 && (l = l.replace(".", ""), h = new g(1), h.e = l.length - o, h.d = z(Z(h), 10, s), h.e = h.d.length), a = z(l, 10, s), t = c = a.length; a[--c] == 0; ) a.pop();
792
792
  if (!a[0])
793
793
  l = v ? "0p+0" : "0";
794
794
  else {
@@ -801,7 +801,7 @@ function he(e, i, n, r) {
801
801
  if (c > 1)
802
802
  if (i == 16 || i == 8) {
803
803
  for (o = i == 16 ? 4 : 3, --c; c % o; c++) l += "0";
804
- for (a = j(l, s, i), c = a.length; !a[c - 1]; --c) ;
804
+ for (a = z(l, s, i), c = a.length; !a[c - 1]; --c) ;
805
805
  for (o = 1, l = "1."; o < c; o++) l += fe.charAt(a[o]);
806
806
  } else
807
807
  l = l.charAt(0) + "." + l.slice(1);
@@ -860,7 +860,7 @@ function Je(e, i, n) {
860
860
  }
861
861
  function Ke(e) {
862
862
  if (!e || typeof e != "object")
863
- throw Error(ie + "Object expected");
863
+ throw Error(ne + "Object expected");
864
864
  var i, n, r, s = e.defaults === !0, t = [
865
865
  "precision",
866
866
  1,
@@ -869,16 +869,16 @@ function Ke(e) {
869
869
  0,
870
870
  8,
871
871
  "toExpNeg",
872
- -9e15,
872
+ -G,
873
873
  0,
874
874
  "toExpPos",
875
875
  0,
876
- ue,
876
+ G,
877
877
  "maxE",
878
878
  0,
879
- ue,
879
+ G,
880
880
  "minE",
881
- -9e15,
881
+ -G,
882
882
  0,
883
883
  "modulo",
884
884
  0,
@@ -930,12 +930,12 @@ function Se(e) {
930
930
  t || (f.s = NaN), f.e = NaN, f.d = null;
931
931
  return;
932
932
  }
933
- return z(f, t.toString());
933
+ return x(f, t.toString());
934
934
  }
935
935
  if (c === "string")
936
- return (u = t.charCodeAt(0)) === 45 ? (t = t.slice(1), f.s = -1) : (u === 43 && (t = t.slice(1)), f.s = 1), Ee.test(t) ? z(f, t) : _e(f, t);
936
+ return (u = t.charCodeAt(0)) === 45 ? (t = t.slice(1), f.s = -1) : (u === 43 && (t = t.slice(1)), f.s = 1), Ee.test(t) ? x(f, t) : _e(f, t);
937
937
  if (c === "bigint")
938
- return t < 0 ? (t = -t, f.s = -1) : f.s = 1, z(f, t.toString());
938
+ return t < 0 ? (t = -t, f.s = -1) : f.s = 1, x(f, t.toString());
939
939
  throw Error(V + t);
940
940
  }
941
941
  if (s.prototype = d, s.ROUND_UP = 0, s.ROUND_DOWN = 1, s.ROUND_CEIL = 2, s.ROUND_FLOOR = 3, s.ROUND_HALF_UP = 4, s.ROUND_HALF_DOWN = 5, s.ROUND_HALF_EVEN = 6, s.ROUND_HALF_CEIL = 7, s.ROUND_HALF_FLOOR = 8, s.EUCLID = 9, s.config = s.set = Ke, s.clone = Se, s.isDecimal = ge, s.abs = Te, s.acos = Ze, s.acosh = Ue, s.add = be, s.asin = Be, s.asinh = He, s.atan = Ve, s.atanh = $e, s.atan2 = Ge, s.cbrt = We, s.ceil = Xe, s.clamp = Je, s.cos = Qe, s.cosh = Ye, s.div = je, s.exp = ze, s.floor = xe, s.hypot = ye, s.ln = ei, s.log = ii, s.log10 = ri, s.log2 = ni, s.max = ti, s.min = si, s.mod = oi, s.mul = ui, s.pow = fi, s.random = ci, s.round = li, s.sign = ai, s.sin = hi, s.sinh = di, s.sqrt = pi, s.sub = gi, s.sum = wi, s.tan = mi, s.tanh = Ni, s.trunc = vi, e === void 0 && (e = {}), e && e.defaults !== !0)
@@ -1061,8 +1061,8 @@ function vi(e) {
1061
1061
  _ = Se(ce);
1062
1062
  _.prototype.constructor = _;
1063
1063
  _.default = _.Decimal = _;
1064
- x = new _(x);
1065
1064
  y = new _(y);
1065
+ ee = new _(ee);
1066
1066
  const Ei = _;
1067
1067
  export {
1068
1068
  _ as Decimal,
@@ -1,57 +1,48 @@
1
- var o = (i) => {
2
- throw TypeError(i);
3
- };
4
- var a = (i, t, e) => t.has(i) || o("Cannot " + e);
5
- var h = (i, t, e) => (a(i, t, "read from private field"), e ? e.call(i) : t.get(i)), l = (i, t, e) => t.has(i) ? o("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e);
6
- var r;
7
- class u {
1
+ class h {
8
2
  constructor() {
9
- l(this, r, /* @__PURE__ */ new Map());
10
3
  if (!new.target) throw new Error("必须使用 new 命令生成实例");
11
4
  this.addListener = this.addEventListener = this.on, this.removeListener = this.removeEventListener = this.off, this.removeAllListeners = this.removeAllEventListeners = this.offAll, this.dispatch = this.dispatchEvent = this.emit;
12
5
  }
6
+ #t = /* @__PURE__ */ new Map();
13
7
  once(t, e) {
14
8
  if (!t || !e)
15
9
  return;
16
10
  this.off(t);
17
- const s = (...n) => {
18
- this.off(t, s), e(...n);
11
+ const s = (...i) => {
12
+ this.off(t, s), e(...i);
19
13
  };
20
14
  this.on(t, s);
21
15
  }
22
16
  on(t, e) {
23
17
  if (!t || !e)
24
18
  return;
25
- const s = h(this, r).get(t) || [];
26
- s.push(e), h(this, r).set(t, s);
19
+ const s = this.#t.get(t) || [];
20
+ s.push(e), this.#t.set(t, s);
27
21
  }
28
22
  off(t, e) {
29
23
  if (!t)
30
24
  return;
31
25
  if (!e) {
32
- h(this, r).delete(t);
26
+ this.#t.delete(t);
33
27
  return;
34
28
  }
35
- const s = h(this, r).get(t);
29
+ const s = this.#t.get(t);
36
30
  if (!s)
37
31
  return;
38
32
  if (s.length === 0) {
39
- h(this, r).delete(t);
33
+ this.#t.delete(t);
40
34
  return;
41
35
  }
42
- const n = s.indexOf(e);
43
- n !== -1 && (s.splice(n, 1), h(this, r).set(t, s), this.off(t, e));
36
+ const i = s.indexOf(e);
37
+ i !== -1 && (s.splice(i, 1), this.#t.set(t, s), this.off(t, e));
44
38
  }
45
39
  offAll(t) {
46
- var e, s;
47
- t ? (s = (e = h(this, r).get(t)) == null ? void 0 : e.forEach) == null || s.call(e, (n) => this.off(t, n)) : h(this, r).clear();
40
+ t ? this.#t.get(t)?.forEach?.((e) => this.off(t, e)) : this.#t.clear();
48
41
  }
49
42
  emit(t, ...e) {
50
- var s, n;
51
- (n = (s = h(this, r).get(t)) == null ? void 0 : s.forEach) == null || n.call(s, (f) => f == null ? void 0 : f(...e));
43
+ this.#t.get(t)?.forEach?.((s) => s?.(...e));
52
44
  }
53
45
  }
54
- r = new WeakMap();
55
46
  export {
56
- u as default
47
+ h as default
57
48
  };
package/file/fileToURL.js CHANGED
@@ -1,18 +1,17 @@
1
1
  import "../is/index.js";
2
- import l from "lodash/isString";
3
- function u(r) {
2
+ import s from "lodash/isString";
3
+ function d(r) {
4
4
  return new Promise((n, e) => {
5
5
  if (r)
6
- if (l(r.url))
6
+ if (s(r.url))
7
7
  n(r.url);
8
8
  else if (r instanceof File) {
9
- const s = "文件解析出错", o = new FileReader();
9
+ const i = "文件解析出错", o = new FileReader();
10
10
  o.onload = (t) => {
11
- var i;
12
- const a = (i = t.target) == null ? void 0 : i.result;
11
+ const a = t.target?.result;
13
12
  a ? n(a) : e(new Error(t)), o.abort();
14
13
  }, o.onerror = () => {
15
- e(new Error(s));
14
+ e(new Error(i));
16
15
  }, o.readAsDataURL(r);
17
16
  } else
18
17
  e(new Error("file 不是 File 的实例"));
@@ -21,6 +20,6 @@ function u(r) {
21
20
  });
22
21
  }
23
22
  export {
24
- u as default,
25
- u as fileToURL
23
+ d as default,
24
+ d as fileToURL
26
25
  };
package/file/saveAs.js CHANGED
@@ -22,7 +22,7 @@ function a(n) {
22
22
  }
23
23
  async function i(n, t) {
24
24
  const e = document.createElementNS("http://www.w3.org/1999/xhtml", "a");
25
- e.rel = "noopener", typeof n == "string" && (e.href = n, e.origin === location.origin || (a(n) ? s(n, t) : e.target = "_blank")), n instanceof Blob && (e.href = await r(n)), n instanceof File && (t || (t = n.name)), t || (t = "download"), e.download = t, setTimeout(() => {
25
+ e.rel = "noopener", typeof n == "string" && (e.href = n, e.origin === location.origin || (a(n) ? s(n, t) : e.target = "_blank")), n instanceof Blob && (e.href = await r(n)), n instanceof File && (t ||= n.name), t ||= "download", e.download = t, setTimeout(() => {
26
26
  e.dispatchEvent(new MouseEvent("click"));
27
27
  }, 0);
28
28
  }
package/index.js CHANGED
@@ -1,47 +1,52 @@
1
- import * as o from "./is/index.js";
2
- import * as e from "./math/index.js";
3
- import * as r from "./tree/index.js";
4
- import * as t from "./turbo-stream/index.js";
1
+ import * as e from "./is/index.js";
2
+ import * as o from "./math/index.js";
3
+ import * as t from "./tree/index.js";
4
+ import * as r from "./turbo-stream/index.js";
5
5
  import * as a from "./url-toolkit/index.js";
6
6
  import { default as p } from "./case-name/index.js";
7
7
  import { default as l } from "./class-name/index.js";
8
- import { default as n } from "./clipboard-copy/index.js";
9
- import { splitCookiesString as c } from "./cookie/index.js";
10
- import { default as b } from "./decimal/decimal.js";
11
- import { default as k } from "./event-emitter/index.js";
12
- import { fileToURL as S } from "./file/fileToURL.js";
13
- import { saveAs as C } from "./file/saveAs.js";
8
+ import { default as d } from "./clipboard-copy/index.js";
9
+ import { default as c, getContentDispositionFromHeader as C, getContentDispositionParametersFilenameFromHeader as _, getContentDispositionParametersFromHeader as b } from "./content-disposition/index.js";
10
+ import { splitCookiesString as h } from "./cookie/index.js";
11
+ import { default as z } from "./decimal/decimal.js";
12
+ import { default as F } from "./event-emitter/index.js";
13
+ import { fileToURL as v } from "./file/fileToURL.js";
14
+ import { saveAs as T } from "./file/saveAs.js";
14
15
  import * as s from "./filesize/src/constants.js";
15
- import { filesize as y, partial as N } from "./filesize/src/filesize.js";
16
- import { default as j } from "./invariant/index.js";
17
- import { default as E } from "./md5/index.js";
18
- import { default as L } from "./normalize-wheel/index.js";
19
- import { default as U } from "./nzh/nzh.js";
20
- import { default as q } from "./objectKeysSort.js";
21
- import { default as B } from "./screenfull/index.js";
22
- import * as m from "./cookie/src/index.js";
16
+ import { filesize as N, partial as P } from "./filesize/src/filesize.js";
17
+ import { default as A } from "./invariant/index.js";
18
+ import { default as K } from "./md5/index.js";
19
+ import { default as R } from "./normalize-wheel/index.js";
20
+ import { default as W } from "./nzh/nzh.js";
21
+ import { default as w } from "./objectKeysSort.js";
22
+ import { default as G } from "./screenfull/index.js";
23
+ import * as i from "./cookie/src/index.js";
23
24
  export {
24
25
  p as caseName,
25
26
  l as className,
26
- n as clipboardCopy,
27
- m as cookie,
28
- b as decimal,
29
- k as eventEmitter,
30
- S as fileToURL,
31
- y as filesize,
27
+ d as clipboardCopy,
28
+ c as contentDisposition,
29
+ i as cookie,
30
+ z as decimal,
31
+ F as eventEmitter,
32
+ v as fileToURL,
33
+ N as filesize,
32
34
  s as filesizeConstants,
33
- j as invariant,
34
- o as is,
35
- e as math,
36
- E as md5,
37
- L as normalizeWheel,
38
- U as nzh,
39
- q as objectKeysSort,
40
- N as partial,
41
- C as saveAs,
42
- B as screenfull,
43
- c as splitCookiesString,
44
- r as tree,
45
- t as turboStream,
35
+ C as getContentDispositionFromHeader,
36
+ _ as getContentDispositionParametersFilenameFromHeader,
37
+ b as getContentDispositionParametersFromHeader,
38
+ A as invariant,
39
+ e as is,
40
+ o as math,
41
+ K as md5,
42
+ R as normalizeWheel,
43
+ W as nzh,
44
+ w as objectKeysSort,
45
+ P as partial,
46
+ T as saveAs,
47
+ G as screenfull,
48
+ h as splitCookiesString,
49
+ t as tree,
50
+ r as turboStream,
46
51
  a as urlToolkit
47
52
  };