@tolki/utils 1.6.2 → 1.6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"cast.d.ts","sourceRoot":"","sources":["../src/cast.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAYrD;AAqFD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,OAAO,IAAI,CAAC,EAAE,CAAA;CAAE,CAM1E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,CAAC,EACxB,KAAK,EAAE,OAAO,GACf,KAAK,IAAI;IAAE,MAAM,IAAI,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,IAAI,CAAC,CAAA;CAAE,CAS5C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAChC,KAAK,EAAE,OAAO,GACf,KAAK,IAAI;IAAE,aAAa,IAAI,CAAC,CAAA;CAAE,CAMjC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAG7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAC9B,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,GACjC,CAAC,EAAE,GAAG,IAAI,CAKZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,CAG5E;AAwBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GA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EAAE,GAAG,IAAI,CAG7D;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,gBAAgB,CAAC,CAAC,EAC9B,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,GACjC,CAAC,EAAE,GAAG,IAAI,CAKZ;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,CAG5E;AAwBD;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,CAyBtD;AAED;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkCtE;AAED;;;;;;;GAOG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAU1D;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOrE;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAahD;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAiBpD"}
package/dist/cast.js CHANGED
@@ -1,130 +1,112 @@
1
- import { isNull as s, isUndefined as a, isArray as b, isObject as c, isMap as d, isWeakMap as l, isWeakSet as A, isIterable as y, isBoolean as I, isFiniteNumber as m, isPhpAccessible as $, isFunction as f, isNumber as O, isPlainObject as w } from "./guards.js";
2
- import { keyedEntries as S, defineKey as T, hasOwnToString as j, isPhpArrayKey as B } from "./keys.js";
3
- import { phpDebugType as E } from "./reflect.js";
4
- const g = 14;
5
- function F(r) {
6
- return s(r) || a(r) || r === !1 ? "" : r === !0 ? "1" : O(r) || Number.isNaN(r) ? J(r) : String(r);
7
- }
8
- function J(r) {
9
- if (Number.isNaN(r))
10
- return "NAN";
11
- if (!Number.isFinite(r))
12
- return r > 0 ? "INF" : "-INF";
13
- if (B(r) && !Object.is(r, -0))
14
- return BigInt(r).toString();
15
- const [t, n] = P(Math.abs(r)), e = r < 0 || Object.is(r, -0) ? "-" : "";
16
- if (n < -3 || n > g) {
17
- const i = n - 1, p = `${t.charAt(0)}.${t.slice(1) || "0"}`;
18
- return `${e}${p}E${i < 0 ? "-" : "+"}${Math.abs(i)}`;
19
- }
20
- if (n <= 0)
21
- return `${e}0.${"0".repeat(-n)}${t}`;
22
- const o = t.slice(0, n).padEnd(n, "0"), u = t.slice(n);
23
- return u === "" ? `${e}${o}` : `${e}${o}.${u}`;
24
- }
25
- function P(r) {
26
- if (r === 0)
27
- return ["0", 1];
28
- let t = r, n = 0;
29
- for (; !Number.isInteger(t); )
30
- t *= 2, n++;
31
- const e = (BigInt(t) * 5n ** BigInt(n)).toString(), o = e.slice(g), u = "5".padEnd(o.length, "0");
32
- let i = e.slice(0, g), p = e.length - n;
33
- if (o > u || o === u && Number(i.at(-1)) % 2 === 1) {
34
- const N = String(BigInt(i) + 1n);
35
- p += N.length - i.length, i = N;
36
- }
37
- for (; i.endsWith("0"); )
38
- i = i.slice(0, -1);
39
- return [i, p];
40
- }
41
- function C(r) {
42
- return c(r) && !s(r) && f(r.toArray);
43
- }
44
- function K(r) {
45
- if (!c(r) || s(r))
46
- return !1;
47
- const t = f(r.toJson), n = f(r.toJSON);
48
- return t || n;
49
- }
50
- function W(r) {
51
- return c(r) && !s(r) && f(r.jsonSerialize);
52
- }
53
- function D(r) {
54
- return b(r) ? r : null;
55
- }
56
- function M(r) {
57
- return Array.isArray(r) ? r.slice() : null;
58
- }
59
- function L(r) {
60
- return M(r) || [];
61
- }
62
- function h(r) {
63
- if (w(r) || !c(r))
64
- return r;
65
- for (const t of ["all", "toArray", "toJSON"])
66
- if (f(r[t]))
67
- return h(r[t]());
68
- return r;
69
- }
70
- function V(r) {
71
- const t = h(r);
72
- return s(t) || a(t) ? [] : b(t) ? t.slice() : c(t) ? d(t) ? S(t).map(([, n]) => n) : y(t) ? [...t] : Object.values(t) : [t];
73
- }
74
- function _(r) {
75
- const t = h(r);
76
- if (s(t) || a(t))
77
- return {};
78
- if (b(t))
79
- return { ...t };
80
- if (c(t)) {
81
- if (d(t)) {
82
- const n = {};
83
- for (const [e, o] of S(t))
84
- T(n, e, o);
85
- return n;
86
- }
87
- return l(t) || A(t) ? {} : y(t) ? { ...[...t] } : t;
88
- }
89
- return { 0: t };
90
- }
91
- function H(r) {
92
- return s(r) || a(r) ? "" : I(r) ? r ? "1" : "" : String(r);
93
- }
94
- function R(r, t) {
95
- if (!m(r) || r < -9223372036854776e3 || r >= 2 ** 63)
96
- throw new TypeError(t);
97
- return Math.trunc(r);
98
- }
99
- function U(r) {
100
- if (!m(r))
101
- return 0;
102
- const t = Math.trunc(r);
103
- return t >= -9223372036854776e3 && t < 2 ** 63 ? t === 0 ? 0 : t : Number(BigInt.asIntN(64, BigInt(t)));
104
- }
105
- function q(r) {
106
- if ($(r))
107
- return "Array";
108
- if (j(r))
109
- return String(r.toString());
110
- if (c(r) || f(r))
111
- throw new Error(
112
- `Object of class ${E(r)} could not be converted to string`
113
- );
114
- return F(r);
115
- }
116
- export {
117
- _ as arrayableItems,
118
- V as arrayableValues,
119
- D as castableToArray,
120
- H as cssListItemToString,
121
- L as getAccessibleValues,
122
- M as normalizeToArray,
123
- R as phpIntArgument,
124
- U as phpIntCast,
125
- q as phpStringCast,
126
- C as toArrayable,
127
- W as toJsonSerializable,
128
- K as toJsonable,
129
- F as toPhpKeyString
130
- };
1
+ import { isArray as e, isBoolean as t, isFiniteNumber as n, isFunction as r, isIterable as i, isMap as a, isNull as o, isNumber as s, isObject as c, isPhpAccessible as l, isPlainObject as u, isUndefined as d, isWeakMap as f, isWeakSet as p } from "./guards.js";
2
+ import { phpDebugType as m } from "./reflect.js";
3
+ import { defineKey as h, hasOwnToString as g, isPhpArrayKey as _, keyedEntries as v } from "./keys.js";
4
+ // src/cast.ts
5
+ var y = 14;
6
+ /* @__NO_SIDE_EFFECTS__ */
7
+ function b(e) {
8
+ return /* @__PURE__ */ o(e) || /* @__PURE__ */ d(e) || e === !1 ? "" : e === !0 ? "1" : /* @__PURE__ */ s(e) || Number.isNaN(e) ? x(e) : String(e);
9
+ }
10
+ function x(e) {
11
+ if (Number.isNaN(e)) return "NAN";
12
+ if (!Number.isFinite(e)) return e > 0 ? "INF" : "-INF";
13
+ if (/* @__PURE__ */ _(e) && !Object.is(e, -0)) return BigInt(e).toString();
14
+ let [t, n] = S(Math.abs(e)), r = e < 0 || Object.is(e, -0) ? "-" : "";
15
+ if (n < -3 || n > y) {
16
+ let e = n - 1;
17
+ return `${r}${`${t.charAt(0)}.${t.slice(1) || "0"}`}E${e < 0 ? "-" : "+"}${Math.abs(e)}`;
18
+ }
19
+ if (n <= 0) return `${r}0.${"0".repeat(-n)}${t}`;
20
+ let i = t.slice(0, n).padEnd(n, "0"), a = t.slice(n);
21
+ return a === "" ? `${r}${i}` : `${r}${i}.${a}`;
22
+ }
23
+ function S(e) {
24
+ if (e === 0) return ["0", 1];
25
+ let t = e, n = 0;
26
+ for (; !Number.isInteger(t);) t *= 2, n++;
27
+ let r = (BigInt(t) * 5n ** BigInt(n)).toString(), i = r.slice(y), a = "5".padEnd(i.length, "0"), o = r.slice(0, y), s = r.length - n;
28
+ if (i > a || i === a && Number(o.at(-1)) % 2 == 1) {
29
+ let e = String(BigInt(o) + 1n);
30
+ s += e.length - o.length, o = e;
31
+ }
32
+ for (; o.endsWith("0");) o = o.slice(0, -1);
33
+ return [o, s];
34
+ }
35
+ /* @__NO_SIDE_EFFECTS__ */
36
+ function C(e) {
37
+ return /* @__PURE__ */ c(e) && !/* @__PURE__ */ o(e) && /* @__PURE__ */ r(e.toArray);
38
+ }
39
+ /* @__NO_SIDE_EFFECTS__ */
40
+ function w(e) {
41
+ if (!/* @__PURE__ */ c(e) || /* @__PURE__ */ o(e)) return !1;
42
+ let t = /* @__PURE__ */ r(e.toJson), n = /* @__PURE__ */ r(e.toJSON);
43
+ return t || n;
44
+ }
45
+ /* @__NO_SIDE_EFFECTS__ */
46
+ function T(e) {
47
+ return /* @__PURE__ */ c(e) && !/* @__PURE__ */ o(e) && /* @__PURE__ */ r(e.jsonSerialize);
48
+ }
49
+ /* @__NO_SIDE_EFFECTS__ */
50
+ function E(t) {
51
+ return /* @__PURE__ */ e(t) ? t : null;
52
+ }
53
+ /* @__NO_SIDE_EFFECTS__ */
54
+ function D(e) {
55
+ return Array.isArray(e) ? e.slice() : null;
56
+ }
57
+ /* @__NO_SIDE_EFFECTS__ */
58
+ function O(e) {
59
+ return /* @__PURE__ */ D(e) || [];
60
+ }
61
+ function k(e) {
62
+ if (/* @__PURE__ */ u(e) || !/* @__PURE__ */ c(e)) return e;
63
+ for (let t of [
64
+ "all",
65
+ "toArray",
66
+ "toJSON"
67
+ ]) if (/* @__PURE__ */ r(e[t])) return k(e[t]());
68
+ return e;
69
+ }
70
+ /* @__NO_SIDE_EFFECTS__ */
71
+ function A(t) {
72
+ let n = k(t);
73
+ return /* @__PURE__ */ o(n) || /* @__PURE__ */ d(n) ? [] : /* @__PURE__ */ e(n) ? n.slice() : /* @__PURE__ */ c(n) ? /* @__PURE__ */ a(n) ? (/* @__PURE__ */ v(n)).map(([, e]) => e) : /* @__PURE__ */ i(n) ? [...n] : Object.values(n) : [n];
74
+ }
75
+ /* @__NO_SIDE_EFFECTS__ */
76
+ function j(t) {
77
+ let n = k(t);
78
+ if (/* @__PURE__ */ o(n) || /* @__PURE__ */ d(n)) return {};
79
+ if (/* @__PURE__ */ e(n)) return { ...n };
80
+ if (/* @__PURE__ */ c(n)) {
81
+ if (/* @__PURE__ */ a(n)) {
82
+ let e = {};
83
+ for (let [t, r] of /* @__PURE__ */ v(n)) h(e, t, r);
84
+ return e;
85
+ }
86
+ return /* @__PURE__ */ f(n) || /* @__PURE__ */ p(n) ? {} : /* @__PURE__ */ i(n) ? { ...[...n] } : n;
87
+ }
88
+ return { 0: n };
89
+ }
90
+ /* @__NO_SIDE_EFFECTS__ */
91
+ function M(e) {
92
+ return /* @__PURE__ */ o(e) || /* @__PURE__ */ d(e) ? "" : /* @__PURE__ */ t(e) ? e ? "1" : "" : String(e);
93
+ }
94
+ /* @__NO_SIDE_EFFECTS__ */
95
+ function N(e, t) {
96
+ if (!/* @__PURE__ */ n(e) || e < -(2 ** 63) || e >= 2 ** 63) throw TypeError(t);
97
+ return Math.trunc(e);
98
+ }
99
+ /* @__NO_SIDE_EFFECTS__ */
100
+ function P(e) {
101
+ if (!/* @__PURE__ */ n(e)) return 0;
102
+ let t = Math.trunc(e);
103
+ return t >= -(2 ** 63) && t < 2 ** 63 ? t === 0 ? 0 : t : Number(BigInt.asIntN(64, BigInt(t)));
104
+ }
105
+ /* @__NO_SIDE_EFFECTS__ */
106
+ function F(e) {
107
+ if (/* @__PURE__ */ l(e)) return "Array";
108
+ if (/* @__PURE__ */ g(e)) return String(e.toString());
109
+ if (/* @__PURE__ */ c(e) || /* @__PURE__ */ r(e)) throw Error(`Object of class ${/* @__PURE__ */ m(e)} could not be converted to string`);
110
+ return /* @__PURE__ */ b(e);
111
+ }
112
+ export { j as arrayableItems, A as arrayableValues, E as castableToArray, M as cssListItemToString, O as getAccessibleValues, D as normalizeToArray, N as phpIntArgument, P as phpIntCast, F as phpStringCast, C as toArrayable, T as toJsonSerializable, w as toJsonable, b as toPhpKeyString };
@@ -1 +1 @@
1
- {"version":3,"file":"equality.d.ts","sourceRoot":"","sources":["../src/equality.ts"],"names":[],"mappings":"AAmIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAE5D;AAgJD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAgH1D;AA8FD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAqE3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,GACf,OAAO,CA2DT"}
1
+ {"version":3,"file":"equality.d.ts","sourceRoot":"","sources":["../src/equality.ts"],"names":[],"mappings":"AAmIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAE5D;AAgJD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAgH1D;AA8FD;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAqE3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,wBAAgB,aAAa,CACzB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,GACf,OAAO,CA2DT"}