@tolki/num 2.2.3 → 2.2.4

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/README.md CHANGED
@@ -278,6 +278,10 @@ const result = pairs(25, 10);
278
278
  const result2 = pairs(25, 10, 0, 0);
279
279
 
280
280
  // result2 is [[0, 10], [10, 20], [20, 25]]
281
+
282
+ const result3 = pairs(20, 10);
283
+
284
+ // result3 is [[0, 9], [10, 19], [20, 20]]
281
285
  ```
282
286
 
283
287
  #### parse
package/dist/num.d.ts CHANGED
@@ -143,6 +143,7 @@ export declare function clamp(value: number, min: number, max: number): number;
143
143
  * @param start - The starting value.
144
144
  * @param offset - The offset to apply to the upper bound of each pair.
145
145
  * @returns An array of [min, max] pairs.
146
+ * @throws InvalidArgumentException if by is zero.
146
147
  *
147
148
  * @see https://tolki.abe.dev/numbers/number-utilities-list.html#pairs
148
149
  */
package/dist/num.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"num.d.ts","sourceRoot":"","sources":["../src/num.ts"],"names":[],"mappings":"AAUA;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACtB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAAU,EACrB,YAAY,GAAE,MAAM,GAAG,IAAW,GACnC,MAAM,GAAG,KAAK,CAEhB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,YAAY,GAAE,MAAM,GAAG,IAAW,EAClC,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,GAAG,KAAK,CAqBhB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CA2DzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE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,KAAK,GAAE,OAAc,GACtB,MAAM,CAoDR;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,OAAO,GACxB,OAAO,GAAG,IAAI,CAUhB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,OAAO,GACxB,OAAO,GAAG,IAAI,CAUhB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
package/dist/num.js CHANGED
@@ -1,60 +1,61 @@
1
- let g = "en", N = "USD";
2
- function B(t, n = 0, e = null) {
3
- return D(t, n, e, !0);
1
+ import { InvalidArgumentException as D } from "@tolki/utils";
2
+ let p = "en", N = "USD";
3
+ function I(t, n = 0, e = null) {
4
+ return E(t, n, e, !0);
4
5
  }
5
6
  function a(t, n = null, e = null, r = null) {
6
- r = r ?? g;
7
+ r = r ?? p;
7
8
  const o = {
8
9
  style: "decimal",
9
10
  useGrouping: !0
10
11
  };
11
12
  e != null ? (o.maximumFractionDigits = e, o.minimumFractionDigits = 0) : n != null && (o.minimumFractionDigits = n, o.maximumFractionDigits = n);
12
- const u = new Intl.NumberFormat(r, o);
13
- return u.format(w(t, u.format));
13
+ const s = new Intl.NumberFormat(r, o);
14
+ return s.format(w(t, s.format));
14
15
  }
15
16
  function y(t, n = null) {
16
- n = n ?? g;
17
+ n = n ?? p;
17
18
  const r = new Intl.NumberFormat(n).formatToParts(12345.6), o = /* @__PURE__ */ new Set();
18
- let u = ".";
19
+ let s = ".";
19
20
  for (const i of r)
20
- i.type === "group" ? o.add(i.value) : i.type === "decimal" && (u = i.value);
21
+ i.type === "group" ? o.add(i.value) : i.type === "decimal" && (s = i.value);
21
22
  const l = [" ", " ", " "];
22
23
  for (const i of l) o.add(i);
23
- let s = t;
24
+ let u = t;
24
25
  for (const i of o) {
25
26
  const c = new RegExp(
26
27
  i.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"),
27
28
  "g"
28
29
  );
29
- s = s.replace(c, "");
30
+ u = u.replace(c, "");
30
31
  }
31
- if (u !== ".") {
32
+ if (s !== ".") {
32
33
  const i = new RegExp(
33
- u.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"),
34
+ s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"),
34
35
  "g"
35
- ), c = s.lastIndexOf(u);
36
- c !== -1 && (s = s.slice(0, c).replace(i, "") + "." + s.slice(c + u.length));
36
+ ), c = u.lastIndexOf(s);
37
+ c !== -1 && (u = u.slice(0, c).replace(i, "") + "." + u.slice(c + s.length));
37
38
  }
38
- return s = s.replace(/[\s\u00A0\u202F\u2009]+/g, "").trim(), globalThis.Number(s);
39
+ return u = u.replace(/[\s\u00A0\u202F\u2009]+/g, "").trim(), globalThis.Number(u);
39
40
  }
40
- function x(t, n = null) {
41
+ function O(t, n = null) {
41
42
  const e = y(t, n);
42
43
  return Number.isNaN(e) ? !1 : e < 0 ? Math.ceil(e) : Math.floor(e);
43
44
  }
44
- function O(t, n = null) {
45
+ function T(t, n = null) {
45
46
  return y(t, n);
46
47
  }
47
- function I(t, n = null) {
48
- const e = n ?? g;
48
+ function R(t, n = null) {
49
+ const e = n ?? p;
49
50
  try {
50
- const o = new Intl.PluralRules(e, { type: "ordinal" }).select(t), u = String(e.split("-")[0]), l = {
51
+ const o = new Intl.PluralRules(e, { type: "ordinal" }).select(t), s = String(e.split("-")[0]), l = {
51
52
  one: "st",
52
53
  two: "nd",
53
54
  few: "rd",
54
55
  other: "th"
55
56
  }, f = {
56
57
  en: l
57
- }[u] ?? l, i = f[o] ?? f.other;
58
+ }[s] ?? l, i = f[o] ?? f.other;
58
59
  return `${t}${i}`;
59
60
  } catch {
60
61
  const r = Math.abs(t), o = r % 100;
@@ -72,26 +73,26 @@ function I(t, n = null) {
72
73
  }
73
74
  }
74
75
  }
75
- function T(t, n = 0, e = null, r = null) {
76
- const o = r ?? g, u = typeof t == "string" ? y(t, o) : t, l = {
76
+ function z(t, n = 0, e = null, r = null) {
77
+ const o = r ?? p, s = typeof t == "string" ? y(t, o) : t, l = {
77
78
  style: "percent",
78
79
  useGrouping: !0
79
80
  };
80
81
  e != null ? (l.maximumFractionDigits = e, l.minimumFractionDigits = 0) : (l.minimumFractionDigits = n, l.maximumFractionDigits = n);
81
- const s = new Intl.NumberFormat(o, l);
82
- return s.format(w(u / 100, s.format));
82
+ const u = new Intl.NumberFormat(o, l);
83
+ return u.format(w(s / 100, u.format));
83
84
  }
84
- function R(t, n = "", e = null, r = null) {
85
- const o = e ?? g, u = typeof t == "string" ? y(t, o) : t, s = {
85
+ function A(t, n = "", e = null, r = null) {
86
+ const o = e ?? p, s = typeof t == "string" ? y(t, o) : t, u = {
86
87
  style: "currency",
87
88
  currency: n && n.length ? n : N,
88
89
  useGrouping: !0
89
90
  };
90
- r != null && (s.minimumFractionDigits = r, s.maximumFractionDigits = r);
91
- const f = new Intl.NumberFormat(o, s);
92
- return f.format(w(u, f.format));
91
+ r != null && (u.minimumFractionDigits = r, u.maximumFractionDigits = r);
92
+ const f = new Intl.NumberFormat(o, u);
93
+ return f.format(w(s, f.format));
93
94
  }
94
- function z(t, n = 0, e = null) {
95
+ function G(t, n = 0, e = null) {
95
96
  let r = typeof t == "string" ? Number(t) : t;
96
97
  if (!Number.isFinite(r))
97
98
  return `${a(r, n, e)} B`;
@@ -105,13 +106,13 @@ function z(t, n = 0, e = null) {
105
106
  "EB",
106
107
  "ZB",
107
108
  "YB"
108
- ], u = o.length;
109
+ ], s = o.length;
109
110
  let l = 0;
110
- for (; Math.abs(r) / 1024 > 0.9 && l < u - 1; )
111
+ for (; Math.abs(r) / 1024 > 0.9 && l < s - 1; )
111
112
  r /= 1024, l++;
112
113
  return `${a(r, n, e)} ${o[l]}`;
113
114
  }
114
- function D(t, n = 0, e = null, r = !1) {
115
+ function E(t, n = 0, e = null, r = !1) {
115
116
  return $(
116
117
  t,
117
118
  n,
@@ -151,86 +152,90 @@ function $(t, n = 0, e = null, r = {}) {
151
152
  return i === c ? i : `-${i}`;
152
153
  }
153
154
  if (t >= 1e15) {
154
- const i = Object.keys(r).map((m) => Number(m)).filter((m) => !Number.isNaN(m)).sort((m, d) => m - d), c = i[i.length - 1], p = r[c];
155
+ const i = Object.keys(r).map((m) => Number(m)).filter((m) => !Number.isNaN(m)).sort((m, d) => m - d), c = i[i.length - 1], h = r[c];
155
156
  return `${$(
156
157
  t / 1e15,
157
158
  n,
158
159
  e,
159
160
  r
160
- )}${p}`.trim();
161
+ )}${h}`.trim();
161
162
  }
162
163
  const o = Math.floor(Math.log10(t));
163
- let u = Math.max(0, o - o % 3);
164
- const l = t / 10 ** u;
165
- let s;
164
+ let s = Math.max(0, o - o % 3);
165
+ const l = t / 10 ** s;
166
+ let u;
166
167
  if (e != null)
167
- s = a(l, null, e);
168
+ u = a(l, null, e);
168
169
  else if (n > 0)
169
- s = a(l, n, null);
170
+ u = a(l, n, null);
170
171
  else {
171
172
  const i = Math.abs(t);
172
- s = u === 3 && l < 10 && i % 10 === 0 ? a(l, null, 1) : a(l, 0, null);
173
+ u = s === 3 && l < 10 && i % 10 === 0 ? a(l, null, 1) : a(l, 0, null);
173
174
  }
174
- if (y(s) >= 1e3 && r[u + 3] !== void 0) {
175
- u += 3;
175
+ if (y(u) >= 1e3 && r[s + 3] !== void 0) {
176
+ s += 3;
176
177
  const i = l / 1e3;
177
- e != null ? s = a(i, null, e) : n > 0 ? s = a(i, n, null) : s = a(i, 0, null);
178
+ e != null ? u = a(i, null, e) : n > 0 ? u = a(i, n, null) : u = a(i, 0, null);
178
179
  }
179
- const f = r[u] ?? "";
180
- return `${s}${f}`.trim();
180
+ const f = r[s] ?? "";
181
+ return `${u}${f}`.trim();
181
182
  }
182
- function G(t, n, e) {
183
+ function H(t, n, e) {
183
184
  return Math.min(Math.max(t, n), e);
184
185
  }
185
- function H(t, n, e = 0, r = 1) {
186
+ function k(t, n, e = 0, r = 1) {
186
187
  if (n === 0)
187
- throw new Error("The 'by' argument must not be zero.");
188
+ throw new D(
189
+ "The $by argument must not be zero."
190
+ );
188
191
  n = Math.abs(n);
189
192
  const o = [];
190
- for (let u = e; u < t; u += n) {
191
- let l = u + n - r;
192
- l > t && (l = t), o.push([u, l]);
193
+ let s = e;
194
+ for (; s < t; s += n) {
195
+ let u = s + n - r;
196
+ u > t && (u = t), o.push([s, u]);
193
197
  }
194
- return o;
198
+ const l = o.at(-1);
199
+ return l !== void 0 && s === t && l[1] < t && o.push([s, t]), o;
195
200
  }
196
- function k(t) {
201
+ function C(t) {
197
202
  return isFinite(t) ? JSON.parse(JSON.stringify(t)) : t;
198
203
  }
199
- function A(t, n = !0) {
204
+ function K(t, n = !0) {
200
205
  const e = Number(t) * 60;
201
- return E(e, n);
206
+ return x(e, n);
202
207
  }
203
- function E(t, n = !0) {
208
+ function x(t, n = !0) {
204
209
  let e = Number(t);
205
210
  if ((!Number.isFinite(e) || e < 0) && (e = 0), e === 0) return "0 seconds";
206
- const r = 1, o = 60 * r, u = 60 * o, l = 24 * u, s = 7 * l, f = 4 * s, c = [
211
+ const r = 1, o = 60 * r, s = 60 * o, l = 24 * s, u = 7 * l, f = 4 * u, c = [
207
212
  ["year", 12 * f],
208
213
  ["month", f],
209
- ["week", s],
214
+ ["week", u],
210
215
  ["day", l],
211
- ["hour", u],
216
+ ["hour", s],
212
217
  ["minute", o],
213
218
  ["second", r]
214
219
  ];
215
220
  if (n)
216
221
  for (const [m, d] of c) {
217
- const h = e / d;
218
- if (h >= 0.5 || d === r) {
219
- const F = Math.round(h);
222
+ const g = e / d;
223
+ if (g >= 0.5 || d === r) {
224
+ const F = Math.round(g);
220
225
  return `${F} ${m}${F === 1 ? "" : "s"}`;
221
226
  }
222
227
  }
223
- let p = e;
228
+ let h = e;
224
229
  const b = [];
225
230
  for (const [m, d] of c)
226
- if (p >= d) {
227
- const h = Math.floor(p / d);
228
- p -= h * d, b.push(`${h} ${m}${h === 1 ? "" : "s"}`);
231
+ if (h >= d) {
232
+ const g = Math.floor(h / d);
233
+ h -= g * d, b.push(`${g} ${m}${g === 1 ? "" : "s"}`);
229
234
  }
230
235
  return b.join(", ");
231
236
  }
232
- function C(t, n) {
233
- const e = g;
237
+ function L(t, n) {
238
+ const e = p;
234
239
  M(t);
235
240
  try {
236
241
  return n();
@@ -238,7 +243,7 @@ function C(t, n) {
238
243
  M(e);
239
244
  }
240
245
  }
241
- function K(t, n) {
246
+ function Y(t, n) {
242
247
  const e = N;
243
248
  S(t);
244
249
  try {
@@ -248,41 +253,41 @@ function K(t, n) {
248
253
  }
249
254
  }
250
255
  function M(t) {
251
- g = t;
256
+ p = t;
252
257
  }
253
258
  function S(t) {
254
259
  N = t;
255
260
  }
256
- function L() {
257
- return g;
261
+ function j() {
262
+ return p;
258
263
  }
259
- function Y() {
264
+ function U() {
260
265
  return N;
261
266
  }
262
267
  function w(t, n) {
263
268
  return t === 0 || t < 0 && n(Math.abs(t)) === n(0) ? 0 : t;
264
269
  }
265
270
  export {
266
- B as abbreviate,
267
- G as clamp,
268
- R as currency,
269
- Y as defaultCurrency,
270
- L as defaultLocale,
271
- z as fileSize,
272
- D as forHumans,
271
+ I as abbreviate,
272
+ H as clamp,
273
+ A as currency,
274
+ U as defaultCurrency,
275
+ j as defaultLocale,
276
+ G as fileSize,
277
+ E as forHumans,
273
278
  a as format,
274
- A as minutesToHuman,
275
- I as ordinal,
276
- H as pairs,
279
+ K as minutesToHuman,
280
+ R as ordinal,
281
+ k as pairs,
277
282
  y as parse,
278
- O as parseFloat,
279
- x as parseInt,
280
- T as percentage,
281
- E as secondsToHuman,
283
+ T as parseFloat,
284
+ O as parseInt,
285
+ z as percentage,
286
+ x as secondsToHuman,
282
287
  $ as summarize,
283
- k as trim,
288
+ C as trim,
284
289
  S as useCurrency,
285
290
  M as useLocale,
286
- K as withCurrency,
287
- C as withLocale
291
+ Y as withCurrency,
292
+ L as withLocale
288
293
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolki/num",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "Utilities for working with numbers similar to Laravel's Num class facade.",
5
5
  "author": "Abraham Arango <https://github.com/abetwothree>",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "sideEffects": false,
27
27
  "dependencies": {
28
28
  "to-words": "^5.0.0",
29
- "@tolki/utils": "^1.4.0"
29
+ "@tolki/utils": "^1.6.0"
30
30
  },
31
31
  "files": [
32
32
  "dist"