@tolki/utils 1.6.3 → 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.
- package/dist/cast.d.ts.map +1 -1
- package/dist/cast.js +37 -24
- package/dist/equality.d.ts.map +1 -1
- package/dist/equality.js +36 -32
- package/dist/guards.d.ts.map +1 -1
- package/dist/guards.js +65 -28
- package/dist/keys.d.ts +3 -0
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +34 -20
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js +16 -11
- package/dist/reflect.d.ts.map +1 -1
- package/dist/reflect.js +8 -4
- package/dist/sorting.d.ts.map +1 -1
- package/dist/sorting.js +8 -6
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +8 -1
- package/package.json +2 -2
package/dist/cast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cast.d.ts","sourceRoot":"","sources":["../src/cast.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"cast.d.ts","sourceRoot":"","sources":["../src/cast.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAYrD;AAqFD;;;;;;;;;;;GAWG;AAEH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,OAAO,IAAI,CAAC,EAAE,CAAA;CAAE,CAM1E;AAED;;;;;;;;;;GAUG;AAEH,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;AAEH,wBAAgB,kBAAkB,CAAC,CAAC,EAChC,KAAK,EAAE,OAAO,GACf,KAAK,IAAI;IAAE,aAAa,IAAI,CAAC,CAAA;CAAE,CAMjC;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,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
|
@@ -3,13 +3,14 @@ import { phpDebugType as m } from "./reflect.js";
|
|
|
3
3
|
import { defineKey as h, hasOwnToString as g, isPhpArrayKey as _, keyedEntries as v } from "./keys.js";
|
|
4
4
|
// src/cast.ts
|
|
5
5
|
var y = 14;
|
|
6
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6
7
|
function b(e) {
|
|
7
|
-
return o(e) || d(e) || e === !1 ? "" : e === !0 ? "1" : s(e) || Number.isNaN(e) ? x(e) : String(e);
|
|
8
|
+
return /* @__PURE__ */ o(e) || /* @__PURE__ */ d(e) || e === !1 ? "" : e === !0 ? "1" : /* @__PURE__ */ s(e) || Number.isNaN(e) ? x(e) : String(e);
|
|
8
9
|
}
|
|
9
10
|
function x(e) {
|
|
10
11
|
if (Number.isNaN(e)) return "NAN";
|
|
11
12
|
if (!Number.isFinite(e)) return e > 0 ? "INF" : "-INF";
|
|
12
|
-
if (_(e) && !Object.is(e, -0)) return BigInt(e).toString();
|
|
13
|
+
if (/* @__PURE__ */ _(e) && !Object.is(e, -0)) return BigInt(e).toString();
|
|
13
14
|
let [t, n] = S(Math.abs(e)), r = e < 0 || Object.is(e, -0) ? "-" : "";
|
|
14
15
|
if (n < -3 || n > y) {
|
|
15
16
|
let e = n - 1;
|
|
@@ -31,69 +32,81 @@ function S(e) {
|
|
|
31
32
|
for (; o.endsWith("0");) o = o.slice(0, -1);
|
|
32
33
|
return [o, s];
|
|
33
34
|
}
|
|
35
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
34
36
|
function C(e) {
|
|
35
|
-
return c(e) &&
|
|
37
|
+
return /* @__PURE__ */ c(e) && !/* @__PURE__ */ o(e) && /* @__PURE__ */ r(e.toArray);
|
|
36
38
|
}
|
|
39
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
37
40
|
function w(e) {
|
|
38
|
-
if (
|
|
39
|
-
let t = r(e.toJson), n = r(e.toJSON);
|
|
41
|
+
if (!/* @__PURE__ */ c(e) || /* @__PURE__ */ o(e)) return !1;
|
|
42
|
+
let t = /* @__PURE__ */ r(e.toJson), n = /* @__PURE__ */ r(e.toJSON);
|
|
40
43
|
return t || n;
|
|
41
44
|
}
|
|
45
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
42
46
|
function T(e) {
|
|
43
|
-
return c(e) &&
|
|
47
|
+
return /* @__PURE__ */ c(e) && !/* @__PURE__ */ o(e) && /* @__PURE__ */ r(e.jsonSerialize);
|
|
44
48
|
}
|
|
49
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
45
50
|
function E(t) {
|
|
46
|
-
return e(t) ? t : null;
|
|
51
|
+
return /* @__PURE__ */ e(t) ? t : null;
|
|
47
52
|
}
|
|
53
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
48
54
|
function D(e) {
|
|
49
55
|
return Array.isArray(e) ? e.slice() : null;
|
|
50
56
|
}
|
|
57
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
51
58
|
function O(e) {
|
|
52
|
-
return D(e) || [];
|
|
59
|
+
return /* @__PURE__ */ D(e) || [];
|
|
53
60
|
}
|
|
54
61
|
function k(e) {
|
|
55
|
-
if (u(e) ||
|
|
62
|
+
if (/* @__PURE__ */ u(e) || !/* @__PURE__ */ c(e)) return e;
|
|
56
63
|
for (let t of [
|
|
57
64
|
"all",
|
|
58
65
|
"toArray",
|
|
59
66
|
"toJSON"
|
|
60
|
-
]) if (r(e[t])) return k(e[t]());
|
|
67
|
+
]) if (/* @__PURE__ */ r(e[t])) return k(e[t]());
|
|
61
68
|
return e;
|
|
62
69
|
}
|
|
70
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
63
71
|
function A(t) {
|
|
64
72
|
let n = k(t);
|
|
65
|
-
return o(n) || d(n) ? [] : e(n) ? n.slice() : c(n) ? a(n) ? v(n).map(([, e]) => e) : i(n) ? [...n] : Object.values(n) : [n];
|
|
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];
|
|
66
74
|
}
|
|
75
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
67
76
|
function j(t) {
|
|
68
77
|
let n = k(t);
|
|
69
|
-
if (o(n) || d(n)) return {};
|
|
70
|
-
if (e(n)) return { ...n };
|
|
71
|
-
if (c(n)) {
|
|
72
|
-
if (a(n)) {
|
|
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)) {
|
|
73
82
|
let e = {};
|
|
74
|
-
for (let [t, r] of v(n)) h(e, t, r);
|
|
83
|
+
for (let [t, r] of /* @__PURE__ */ v(n)) h(e, t, r);
|
|
75
84
|
return e;
|
|
76
85
|
}
|
|
77
|
-
return f(n) || p(n) ? {} : i(n) ? { ...[...n] } : n;
|
|
86
|
+
return /* @__PURE__ */ f(n) || /* @__PURE__ */ p(n) ? {} : /* @__PURE__ */ i(n) ? { ...[...n] } : n;
|
|
78
87
|
}
|
|
79
88
|
return { 0: n };
|
|
80
89
|
}
|
|
90
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
81
91
|
function M(e) {
|
|
82
|
-
return o(e) || d(e) ? "" : t(e) ? e ? "1" : "" : String(e);
|
|
92
|
+
return /* @__PURE__ */ o(e) || /* @__PURE__ */ d(e) ? "" : /* @__PURE__ */ t(e) ? e ? "1" : "" : String(e);
|
|
83
93
|
}
|
|
94
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
84
95
|
function N(e, t) {
|
|
85
|
-
if (
|
|
96
|
+
if (!/* @__PURE__ */ n(e) || e < -(2 ** 63) || e >= 2 ** 63) throw TypeError(t);
|
|
86
97
|
return Math.trunc(e);
|
|
87
98
|
}
|
|
99
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
88
100
|
function P(e) {
|
|
89
|
-
if (
|
|
101
|
+
if (!/* @__PURE__ */ n(e)) return 0;
|
|
90
102
|
let t = Math.trunc(e);
|
|
91
103
|
return t >= -(2 ** 63) && t < 2 ** 63 ? t === 0 ? 0 : t : Number(BigInt.asIntN(64, BigInt(t)));
|
|
92
104
|
}
|
|
105
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
93
106
|
function F(e) {
|
|
94
|
-
if (l(e)) return "Array";
|
|
95
|
-
if (g(e)) return String(e.toString());
|
|
96
|
-
if (c(e) || r(e)) throw Error(`Object of class ${m(e)} could not be converted to string`);
|
|
97
|
-
return b(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);
|
|
98
111
|
}
|
|
99
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 };
|
package/dist/equality.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equality.d.ts","sourceRoot":"","sources":["../src/equality.ts"],"names":[],"mappings":"AAmIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;
|
|
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"}
|
package/dist/equality.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isArray as e, isBoolean as t, isNull as n, isNumber as r, isObject as i, isPhpFalsy as a, isPhpNumeric as o, isPlainObject as s, isString as c, isUndefined as l } from "./guards.js";
|
|
2
2
|
// src/equality.ts
|
|
3
3
|
function u(e) {
|
|
4
|
-
return n(e) || l(e);
|
|
4
|
+
return /* @__PURE__ */ n(e) || /* @__PURE__ */ l(e);
|
|
5
5
|
}
|
|
6
6
|
function d(e, t) {
|
|
7
7
|
return e < t ? -1 : +(e > t);
|
|
@@ -19,15 +19,16 @@ function g(e, t) {
|
|
|
19
19
|
return n === r && !Number.isFinite(n) ? d(e, t) : n < r ? -1 : +(n > r);
|
|
20
20
|
}
|
|
21
21
|
function _(e) {
|
|
22
|
-
return
|
|
22
|
+
return !/* @__PURE__ */ a(e);
|
|
23
23
|
}
|
|
24
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
24
25
|
function v(e, t) {
|
|
25
26
|
return y(e, t, void 0);
|
|
26
27
|
}
|
|
27
28
|
function y(e, n, r) {
|
|
28
|
-
if (u(e) && c(n)) return d("", n);
|
|
29
|
-
if (c(e) && u(n)) return d(e, "");
|
|
30
|
-
if (u(e) || u(n) || t(e) || t(n)) {
|
|
29
|
+
if (u(e) && /* @__PURE__ */ c(n)) return d("", n);
|
|
30
|
+
if (/* @__PURE__ */ c(e) && u(n)) return d(e, "");
|
|
31
|
+
if (u(e) || u(n) || /* @__PURE__ */ t(e) || /* @__PURE__ */ t(n)) {
|
|
31
32
|
let t = _(e);
|
|
32
33
|
return t === _(n) ? 0 : t ? 1 : -1;
|
|
33
34
|
}
|
|
@@ -36,13 +37,13 @@ function y(e, n, r) {
|
|
|
36
37
|
return t < r ? -1 : +(t > r);
|
|
37
38
|
}
|
|
38
39
|
if (typeof e == "object" && typeof n == "object") return b(e, n, r ?? /* @__PURE__ */ new Map());
|
|
39
|
-
if ((typeof e == "number" || c(e)) && (typeof n == "number" || c(n)) && (Number.isNaN(e) || Number.isNaN(n))) return 1;
|
|
40
|
-
if (o(e) && o(n)) {
|
|
41
|
-
if (c(e) && c(n)) return g(e, n);
|
|
40
|
+
if ((typeof e == "number" || /* @__PURE__ */ c(e)) && (typeof n == "number" || /* @__PURE__ */ c(n)) && (Number.isNaN(e) || Number.isNaN(n))) return 1;
|
|
41
|
+
if (/* @__PURE__ */ o(e) && /* @__PURE__ */ o(n)) {
|
|
42
|
+
if (/* @__PURE__ */ c(e) && /* @__PURE__ */ c(n)) return g(e, n);
|
|
42
43
|
let t = Number(e), r = Number(n);
|
|
43
44
|
return t < r ? -1 : +(t > r);
|
|
44
45
|
}
|
|
45
|
-
return c(e) || c(n) ? d(String(e), String(n)) : e < n ? -1 : +(e > n);
|
|
46
|
+
return /* @__PURE__ */ c(e) || /* @__PURE__ */ c(n) ? d(String(e), String(n)) : e < n ? -1 : +(e > n);
|
|
46
47
|
}
|
|
47
48
|
function b(e, t, n) {
|
|
48
49
|
let r = n.get(e);
|
|
@@ -63,32 +64,33 @@ function x(e, t, n) {
|
|
|
63
64
|
}
|
|
64
65
|
return 0;
|
|
65
66
|
}
|
|
67
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
66
68
|
function S(n, a) {
|
|
67
69
|
if (n === a) return !0;
|
|
68
|
-
if (r(n) && r(a)) return !1;
|
|
69
|
-
if (c(n) && c(a)) return o(n) && o(a) && g(n, a) === 0;
|
|
70
|
+
if (/* @__PURE__ */ r(n) && /* @__PURE__ */ r(a)) return !1;
|
|
71
|
+
if (/* @__PURE__ */ c(n) && /* @__PURE__ */ c(a)) return /* @__PURE__ */ o(n) && /* @__PURE__ */ o(a) && g(n, a) === 0;
|
|
70
72
|
let l = u(n), d = u(a);
|
|
71
73
|
if (l && d) return !0;
|
|
72
74
|
if (l || d) {
|
|
73
75
|
let e = l ? a : n;
|
|
74
|
-
return c(e) ? e === "" : !_(e);
|
|
76
|
+
return /* @__PURE__ */ c(e) ? e === "" : !_(e);
|
|
75
77
|
}
|
|
76
|
-
if (t(n) || t(a)) return _(n) === _(a);
|
|
78
|
+
if (/* @__PURE__ */ t(n) || /* @__PURE__ */ t(a)) return _(n) === _(a);
|
|
77
79
|
if (E(n) || E(a)) return !1;
|
|
78
|
-
if (c(n) !== c(a)) {
|
|
79
|
-
let e = c(n) ? a : n;
|
|
80
|
-
if (i(e) &&
|
|
80
|
+
if (/* @__PURE__ */ c(n) !== /* @__PURE__ */ c(a)) {
|
|
81
|
+
let e = /* @__PURE__ */ c(n) ? a : n;
|
|
82
|
+
if (/* @__PURE__ */ i(e) && !/* @__PURE__ */ s(e) && D(e)) return String(e) === (/* @__PURE__ */ c(n) ? n : a);
|
|
81
83
|
}
|
|
82
|
-
let f = C(n) || c(n), p = C(a) || c(a);
|
|
84
|
+
let f = C(n) || /* @__PURE__ */ c(n), p = C(a) || /* @__PURE__ */ c(a);
|
|
83
85
|
if (f && p) return w(n) && w(a) ? T(n) && T(a) ? BigInt(n) === BigInt(a) : Number(n) === Number(a) : O(n) === O(a);
|
|
84
|
-
if (e(n) && e(a)) {
|
|
86
|
+
if (/* @__PURE__ */ e(n) && /* @__PURE__ */ e(a)) {
|
|
85
87
|
if (n.length !== a.length) return !1;
|
|
86
|
-
for (let e = 0; e < n.length; e++) if (
|
|
88
|
+
for (let e = 0; e < n.length; e++) if (!/* @__PURE__ */ S(n[e], a[e])) return !1;
|
|
87
89
|
return !0;
|
|
88
90
|
}
|
|
89
|
-
if (i(n) && i(a)) {
|
|
91
|
+
if (/* @__PURE__ */ i(n) && /* @__PURE__ */ i(a)) {
|
|
90
92
|
let e = Object.keys(n), t = Object.keys(a);
|
|
91
|
-
return e.length === t.length && e.every((e) => t.includes(e) && S(n[e], a[e]));
|
|
93
|
+
return e.length === t.length && e.every((e) => t.includes(e) && /* @__PURE__ */ S(n[e], a[e]));
|
|
92
94
|
}
|
|
93
95
|
return !1;
|
|
94
96
|
}
|
|
@@ -96,7 +98,7 @@ function C(e) {
|
|
|
96
98
|
return typeof e == "number" || typeof e == "bigint";
|
|
97
99
|
}
|
|
98
100
|
function w(e) {
|
|
99
|
-
return typeof e == "bigint" || o(e);
|
|
101
|
+
return typeof e == "bigint" || /* @__PURE__ */ o(e);
|
|
100
102
|
}
|
|
101
103
|
function T(e) {
|
|
102
104
|
return typeof e == "bigint" ? !0 : typeof e == "number" ? Number.isInteger(e) && e >= -p && e < p : f.test(e) && h(BigInt(e)) === 0;
|
|
@@ -115,11 +117,12 @@ function O(e) {
|
|
|
115
117
|
}
|
|
116
118
|
return String(e);
|
|
117
119
|
}
|
|
120
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
118
121
|
function k(e, t) {
|
|
119
122
|
if (e === t) return !0;
|
|
120
123
|
if (Array.isArray(e) && Array.isArray(t)) {
|
|
121
124
|
if (e.length !== t.length) return !1;
|
|
122
|
-
for (let n = 0; n < e.length; n++) if (
|
|
125
|
+
for (let n = 0; n < e.length; n++) if (!/* @__PURE__ */ k(e[n], t[n])) return !1;
|
|
123
126
|
return !0;
|
|
124
127
|
}
|
|
125
128
|
if (e !== null && t !== null && typeof e == "object" && typeof t == "object" && !Array.isArray(e) && !Array.isArray(t)) {
|
|
@@ -127,30 +130,31 @@ function k(e, t) {
|
|
|
127
130
|
if (!n || !r) return !1;
|
|
128
131
|
let i = Object.keys(e), a = Object.keys(t);
|
|
129
132
|
if (i.length !== a.length) return !1;
|
|
130
|
-
for (let [n, r] of i.entries()) if (r !== a[n] ||
|
|
133
|
+
for (let [n, r] of i.entries()) if (r !== a[n] || !/* @__PURE__ */ k(e[r], t[r])) return !1;
|
|
131
134
|
return !0;
|
|
132
135
|
}
|
|
133
136
|
return !1;
|
|
134
137
|
}
|
|
138
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
135
139
|
function A(e, n, r) {
|
|
136
|
-
let a = [e, r], o = (e) => i(e) &&
|
|
137
|
-
if (a.filter((e) => c(e) || o(e) && D(e)).length < 2 && a.filter(o).length === 1) return [
|
|
140
|
+
let a = [e, r], o = (e) => /* @__PURE__ */ i(e) && !/* @__PURE__ */ s(e);
|
|
141
|
+
if (a.filter((e) => /* @__PURE__ */ c(e) || o(e) && D(e)).length < 2 && a.filter(o).length === 1) return [
|
|
138
142
|
"!=",
|
|
139
143
|
"<>",
|
|
140
144
|
"!=="
|
|
141
145
|
].includes(n);
|
|
142
|
-
let l = !(t(e) || t(r) || u(e) || u(r)) && (E(e) || E(r)), d = (t) => !l && t(v(e, r));
|
|
146
|
+
let l = !(/* @__PURE__ */ t(e) || /* @__PURE__ */ t(r) || u(e) || u(r)) && (E(e) || E(r)), d = (t) => !l && t(/* @__PURE__ */ v(e, r));
|
|
143
147
|
switch (n) {
|
|
144
148
|
case "!=":
|
|
145
|
-
case "<>": return
|
|
149
|
+
case "<>": return !/* @__PURE__ */ S(e, r);
|
|
146
150
|
case "<": return d((e) => e < 0);
|
|
147
151
|
case ">": return d((e) => e > 0);
|
|
148
152
|
case "<=": return d((e) => e <= 0);
|
|
149
153
|
case ">=": return d((e) => e >= 0);
|
|
150
|
-
case "===": return k(e, r);
|
|
151
|
-
case "!==": return
|
|
152
|
-
case "<=>": return l || v(e, r) !== 0;
|
|
153
|
-
default: return S(e, r);
|
|
154
|
+
case "===": return /* @__PURE__ */ k(e, r);
|
|
155
|
+
case "!==": return !/* @__PURE__ */ k(e, r);
|
|
156
|
+
case "<=>": return l || /* @__PURE__ */ v(e, r) !== 0;
|
|
157
|
+
default: return /* @__PURE__ */ S(e, r);
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
160
|
export { v as compareValues, S as looseEqual, A as operatorMatch, k as strictEqual };
|
package/dist/guards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"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"}
|
package/dist/guards.js
CHANGED
|
@@ -1,137 +1,174 @@
|
|
|
1
1
|
// src/guards.ts
|
|
2
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2
3
|
function e(e) {
|
|
3
4
|
return Array.isArray(e);
|
|
4
5
|
}
|
|
6
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5
7
|
function t(t) {
|
|
6
|
-
return
|
|
8
|
+
return !/* @__PURE__ */ b(t) && typeof t == "object" && !/* @__PURE__ */ e(t);
|
|
7
9
|
}
|
|
10
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
8
11
|
function n(e) {
|
|
9
|
-
if (
|
|
12
|
+
if (!/* @__PURE__ */ t(e)) return !1;
|
|
10
13
|
let n = Object.getPrototypeOf(e);
|
|
11
14
|
return n === Object.prototype || n === null;
|
|
12
15
|
}
|
|
16
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
13
17
|
function r(e) {
|
|
14
|
-
return n(e) && Object.hasOwn(e, "name") && s(e.name) && Object.hasOwn(e, "value") && (s(e.value) || u(e.value));
|
|
18
|
+
return /* @__PURE__ */ n(e) && Object.hasOwn(e, "name") && /* @__PURE__ */ s(e.name) && Object.hasOwn(e, "value") && (/* @__PURE__ */ s(e.value) || /* @__PURE__ */ u(e.value));
|
|
15
19
|
}
|
|
20
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
16
21
|
function i(e) {
|
|
17
22
|
return typeof e == "object";
|
|
18
23
|
}
|
|
24
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
19
25
|
function a(e) {
|
|
20
|
-
return
|
|
26
|
+
return !/* @__PURE__ */ b(e) && !/* @__PURE__ */ v(e) && /* @__PURE__ */ i(e);
|
|
21
27
|
}
|
|
28
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
22
29
|
function o(e) {
|
|
23
|
-
if (
|
|
30
|
+
if (!/* @__PURE__ */ a(e) && !/* @__PURE__ */ _(e)) return !1;
|
|
24
31
|
let t = Object.getOwnPropertyDescriptor(e, "constructor")?.value;
|
|
25
|
-
return _(t) && t.prototype === e;
|
|
32
|
+
return /* @__PURE__ */ _(t) && t.prototype === e;
|
|
26
33
|
}
|
|
34
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
27
35
|
function s(e) {
|
|
28
36
|
return typeof e == "string";
|
|
29
37
|
}
|
|
38
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
30
39
|
function c(e) {
|
|
31
|
-
return !!(s(e) || u(e) || l(e));
|
|
40
|
+
return !!(/* @__PURE__ */ s(e) || /* @__PURE__ */ u(e) || /* @__PURE__ */ l(e));
|
|
32
41
|
}
|
|
42
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
33
43
|
function l(e) {
|
|
34
|
-
return !!(t(e) && _(e.toString));
|
|
44
|
+
return !!(/* @__PURE__ */ t(e) && /* @__PURE__ */ _(e.toString));
|
|
35
45
|
}
|
|
46
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
36
47
|
function u(e) {
|
|
37
48
|
return typeof e == "number" && !isNaN(e);
|
|
38
49
|
}
|
|
50
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
39
51
|
function d(e) {
|
|
40
|
-
return u(e) && Number.isInteger(e);
|
|
52
|
+
return /* @__PURE__ */ u(e) && Number.isInteger(e);
|
|
41
53
|
}
|
|
54
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
42
55
|
function f(e) {
|
|
43
|
-
return u(e) && !Number.isInteger(e);
|
|
56
|
+
return /* @__PURE__ */ u(e) && !Number.isInteger(e);
|
|
44
57
|
}
|
|
58
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
45
59
|
function p(e) {
|
|
46
|
-
return d(e) && e >= -(2 ** 63) && e < 2 ** 63 && !Object.is(e, -0);
|
|
60
|
+
return /* @__PURE__ */ d(e) && e >= -(2 ** 63) && e < 2 ** 63 && !Object.is(e, -0);
|
|
47
61
|
}
|
|
62
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
48
63
|
function m(e) {
|
|
49
|
-
return u(e) && e >= 0;
|
|
64
|
+
return /* @__PURE__ */ u(e) && e >= 0;
|
|
50
65
|
}
|
|
66
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
51
67
|
function h(e) {
|
|
52
|
-
return u(e) && e < 0;
|
|
68
|
+
return /* @__PURE__ */ u(e) && e < 0;
|
|
53
69
|
}
|
|
70
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
54
71
|
function g(e) {
|
|
55
72
|
return typeof e == "boolean";
|
|
56
73
|
}
|
|
74
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
57
75
|
function _(e) {
|
|
58
76
|
return typeof e == "function";
|
|
59
77
|
}
|
|
78
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
60
79
|
function v(e) {
|
|
61
80
|
return e === void 0;
|
|
62
81
|
}
|
|
82
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
63
83
|
function y(e) {
|
|
64
84
|
return typeof e == "symbol";
|
|
65
85
|
}
|
|
86
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
66
87
|
function b(e) {
|
|
67
88
|
return e === null;
|
|
68
89
|
}
|
|
90
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
69
91
|
function x(e) {
|
|
70
92
|
return e instanceof Map;
|
|
71
93
|
}
|
|
94
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
72
95
|
function S(e) {
|
|
73
96
|
return e instanceof Set;
|
|
74
97
|
}
|
|
98
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
75
99
|
function C(e) {
|
|
76
|
-
return b(e) || v(e) || s(e) ? !1 : _(e[Symbol.iterator]);
|
|
100
|
+
return /* @__PURE__ */ b(e) || /* @__PURE__ */ v(e) || /* @__PURE__ */ s(e) ? !1 : /* @__PURE__ */ _(e[Symbol.iterator]);
|
|
77
101
|
}
|
|
102
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
78
103
|
function w(e) {
|
|
79
104
|
return e instanceof WeakMap;
|
|
80
105
|
}
|
|
106
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
81
107
|
function T(e) {
|
|
82
108
|
return e instanceof WeakSet;
|
|
83
109
|
}
|
|
110
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
84
111
|
function E(n) {
|
|
85
|
-
return Number.isNaN(n) ? !0 : u(n) ? n === 0 : v(n) || b(n) ? !0 : g(n) ? n === !1 : s(n) ? n.trim() === "" : x(n) || S(n) ? n.size === 0 : e(n) ? n.length === 0 : t(n) ? Object.keys(n).length === 0 : !1;
|
|
112
|
+
return Number.isNaN(n) ? !0 : /* @__PURE__ */ u(n) ? n === 0 : /* @__PURE__ */ v(n) || /* @__PURE__ */ b(n) ? !0 : /* @__PURE__ */ g(n) ? n === !1 : /* @__PURE__ */ s(n) ? n.trim() === "" : /* @__PURE__ */ x(n) || /* @__PURE__ */ S(n) ? n.size === 0 : /* @__PURE__ */ e(n) ? n.length === 0 : /* @__PURE__ */ t(n) ? Object.keys(n).length === 0 : !1;
|
|
86
113
|
}
|
|
114
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
87
115
|
function D(e) {
|
|
88
|
-
return
|
|
116
|
+
return !/* @__PURE__ */ E(e);
|
|
89
117
|
}
|
|
118
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
90
119
|
function O(t) {
|
|
91
|
-
return t === !1 || t === null || v(t) || t === 0 || t === 0n || t === "" || t === "0" ? !0 : e(t) ? t.length === 0 : x(t) || S(t) ? t.size === 0 : n(t) ? Object.keys(t).length === 0 : !1;
|
|
120
|
+
return t === !1 || t === null || /* @__PURE__ */ v(t) || t === 0 || t === 0n || t === "" || t === "0" ? !0 : /* @__PURE__ */ e(t) ? t.length === 0 : /* @__PURE__ */ x(t) || /* @__PURE__ */ S(t) ? t.size === 0 : /* @__PURE__ */ n(t) ? Object.keys(t).length === 0 : !1;
|
|
92
121
|
}
|
|
93
122
|
var k = /^[ \t\n\r\v\f]*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[ \t\n\r\v\f]*$/;
|
|
123
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
94
124
|
function A(e) {
|
|
95
|
-
return typeof e == "number" ? !0 : s(e) ? k.test(e) : !1;
|
|
125
|
+
return typeof e == "number" ? !0 : /* @__PURE__ */ s(e) ? k.test(e) : !1;
|
|
96
126
|
}
|
|
127
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
97
128
|
function j(e) {
|
|
98
|
-
return b(e) || g(e) || u(e) || s(e) || y(e) || v(e);
|
|
129
|
+
return /* @__PURE__ */ b(e) || /* @__PURE__ */ g(e) || /* @__PURE__ */ u(e) || /* @__PURE__ */ s(e) || /* @__PURE__ */ y(e) || /* @__PURE__ */ v(e);
|
|
99
130
|
}
|
|
131
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
100
132
|
function M(e) {
|
|
101
|
-
return
|
|
133
|
+
return !/* @__PURE__ */ j(e);
|
|
102
134
|
}
|
|
135
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
103
136
|
function N(e) {
|
|
104
|
-
return u(e) && Number.isFinite(e);
|
|
137
|
+
return /* @__PURE__ */ u(e) && Number.isFinite(e);
|
|
105
138
|
}
|
|
139
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
106
140
|
function P(e) {
|
|
107
141
|
return Array.isArray(e);
|
|
108
142
|
}
|
|
143
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
109
144
|
function F(t) {
|
|
110
|
-
return e(t) || n(t) || x(t);
|
|
145
|
+
return /* @__PURE__ */ e(t) || /* @__PURE__ */ n(t) || /* @__PURE__ */ x(t);
|
|
111
146
|
}
|
|
112
147
|
function I(e) {
|
|
113
|
-
if (s(e)) return e;
|
|
114
|
-
if (g(e)) return e ? "1" : "";
|
|
115
|
-
if (b(e)) return "";
|
|
116
|
-
if (N(e)) {
|
|
148
|
+
if (/* @__PURE__ */ s(e)) return e;
|
|
149
|
+
if (/* @__PURE__ */ g(e)) return e ? "1" : "";
|
|
150
|
+
if (/* @__PURE__ */ b(e)) return "";
|
|
151
|
+
if (/* @__PURE__ */ N(e)) {
|
|
117
152
|
let t = String(e);
|
|
118
153
|
return t.includes("e") ? null : t;
|
|
119
154
|
}
|
|
120
155
|
return null;
|
|
121
156
|
}
|
|
157
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
122
158
|
function L(e, t) {
|
|
123
159
|
let n = I(e), r = I(t);
|
|
124
160
|
return n !== null && r !== null ? n === r : e === t || typeof e == "number" && typeof t == "number" && Number.isNaN(e) && Number.isNaN(t);
|
|
125
161
|
}
|
|
162
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
126
163
|
function R(e) {
|
|
127
164
|
let t = /* @__PURE__ */ new Set(), n = [];
|
|
128
165
|
for (let r of e) {
|
|
129
166
|
let e = I(r);
|
|
130
|
-
b(e) ? n.push(r) : t.add(e);
|
|
167
|
+
/* @__PURE__ */ b(e) ? n.push(r) : t.add(e);
|
|
131
168
|
}
|
|
132
169
|
return (e) => {
|
|
133
170
|
let r = I(e);
|
|
134
|
-
return b(r) ? n.some((t) => L(e, t)) : t.has(r);
|
|
171
|
+
return /* @__PURE__ */ b(r) ? n.some((t) => /* @__PURE__ */ L(e, t)) : t.has(r);
|
|
135
172
|
};
|
|
136
173
|
}
|
|
137
174
|
export { P as isAccessibleData, e as isArray, g as isBoolean, r as isEnumCase, E as isFalsy, N as isFiniteNumber, f as isFloat, _ as isFunction, d as isInteger, C as isIterable, x as isMap, h as isNegativeNumber, M as isNonPrimitive, b as isNull, u as isNumber, t as isObject, i as isObjectAny, F as isPhpAccessible, O as isPhpFalsy, p as isPhpInt, A as isPhpNumeric, n as isPlainObject, m as isPositiveNumber, j as isPrimitive, o as isPrototypeObject, S as isSet, s as isString, c as isStringable, y as isSymbol, D as isTruthy, a as isTruthyObject, v as isUndefined, w as isWeakMap, T as isWeakSet, l as objectToString, L as phpValueMatch, R as phpValueMatcher };
|
package/dist/keys.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ export declare function readMapKey(map: ReadonlyMap<unknown, unknown>, key: stri
|
|
|
140
140
|
*
|
|
141
141
|
* An existing key keeps its place, and any later key PHP stores as the same one is removed.
|
|
142
142
|
*
|
|
143
|
+
* @sideEffects mutates - Writes the key into the given Map.
|
|
143
144
|
* @param map - The Map to write into, changed in place.
|
|
144
145
|
* @param key - The key to write, cast as PHP casts an array key.
|
|
145
146
|
* @param value - The value to store.
|
|
@@ -153,6 +154,7 @@ export declare function writeMapKey(map: Map<unknown, unknown>, key: string | nu
|
|
|
153
154
|
/**
|
|
154
155
|
* Delete every Map entry whose key PHP stores as the given key.
|
|
155
156
|
*
|
|
157
|
+
* @sideEffects mutates - Deletes the key from the given Map.
|
|
156
158
|
* @param map - The Map to remove from, changed in place.
|
|
157
159
|
* @param key - The key to remove, cast as PHP casts an array key.
|
|
158
160
|
*
|
|
@@ -205,6 +207,7 @@ export declare function renumberPhpIntegerKeys<TValue>(entries: [string, TValue]
|
|
|
205
207
|
* plain `result[key] = value` lets a `"__proto__"` key reparent `result`. A key that is already
|
|
206
208
|
* non-configurable keeps its attributes and only takes the new value.
|
|
207
209
|
*
|
|
210
|
+
* @sideEffects mutates - Defines the key on the given target object.
|
|
208
211
|
* @param target - The object to define the key on
|
|
209
212
|
* @param key - The key to define
|
|
210
213
|
* @param value - The value to store under the key
|
package/dist/keys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AA0BA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"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"}
|
package/dist/keys.js
CHANGED
|
@@ -2,60 +2,71 @@ import { isArray as e, isBoolean as t, isEnumCase as n, isFunction as r, isInteg
|
|
|
2
2
|
import { phpDebugType as m } from "./reflect.js";
|
|
3
3
|
// src/keys.ts
|
|
4
4
|
var h = 2 ** 63;
|
|
5
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5
6
|
function g(e) {
|
|
6
7
|
return !isNaN(Number(e)) && !isNaN(parseFloat(String(e))) ? Number(e) : e;
|
|
7
8
|
}
|
|
9
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
8
10
|
function _(e) {
|
|
9
11
|
return e === "__proto__" || e === "constructor" || e === "prototype";
|
|
10
12
|
}
|
|
13
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
11
14
|
function v(e) {
|
|
12
|
-
return u(e) ? !0 : i(e) ? e >= -h && e < h : !1;
|
|
15
|
+
return /* @__PURE__ */ u(e) ? !0 : /* @__PURE__ */ i(e) ? e >= -h && e < h : !1;
|
|
13
16
|
}
|
|
17
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
14
18
|
function y(e) {
|
|
15
19
|
return /^(0|[1-9]\d*)$/.test(e);
|
|
16
20
|
}
|
|
21
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
17
22
|
function b(e) {
|
|
18
|
-
if (u(e)) {
|
|
23
|
+
if (/* @__PURE__ */ u(e)) {
|
|
19
24
|
if (/^(0|-?[1-9]\d*)$/.test(e)) {
|
|
20
25
|
let t = Number(e);
|
|
21
26
|
if (Number.isSafeInteger(t)) return t;
|
|
22
27
|
}
|
|
23
28
|
return e;
|
|
24
29
|
}
|
|
25
|
-
if (o(e) || p(e)) return "";
|
|
26
|
-
if (t(e)) return +!!e;
|
|
27
|
-
if (s(e) || Number.isNaN(e)) {
|
|
30
|
+
if (/* @__PURE__ */ o(e) || /* @__PURE__ */ p(e)) return "";
|
|
31
|
+
if (/* @__PURE__ */ t(e)) return +!!e;
|
|
32
|
+
if (/* @__PURE__ */ s(e) || Number.isNaN(e)) {
|
|
28
33
|
let t = Number.isFinite(e) ? BigInt.asIntN(64, BigInt(Math.trunc(e))) : 0n;
|
|
29
34
|
return Number.isSafeInteger(Number(t)) ? Number(t) : String(t);
|
|
30
35
|
}
|
|
31
36
|
return String(e);
|
|
32
37
|
}
|
|
38
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
33
39
|
function x(e, t = {}) {
|
|
34
40
|
let { enumCases: r = !1, stringables: i = !1 } = t, a = e;
|
|
35
|
-
if (r && n(a) && (a = a.value), i && w(a) && (a = String(a.toString())), S(a)) throw (t.invalid ?? T)(m(a));
|
|
36
|
-
return b(a);
|
|
41
|
+
if (r && /* @__PURE__ */ n(a) && (a = a.value), i && /* @__PURE__ */ w(a) && (a = String(a.toString())), /* @__PURE__ */ S(a)) throw (t.invalid ?? T)(/* @__PURE__ */ m(a));
|
|
42
|
+
return /* @__PURE__ */ b(a);
|
|
37
43
|
}
|
|
44
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
38
45
|
function S(t) {
|
|
39
|
-
return e(t) || c(t) || r(t);
|
|
46
|
+
return /* @__PURE__ */ e(t) || /* @__PURE__ */ c(t) || /* @__PURE__ */ r(t);
|
|
40
47
|
}
|
|
48
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
41
49
|
function C() {
|
|
42
50
|
return /* @__PURE__ */ TypeError("array_key_exists(): Argument #1 ($key) must be a valid array offset type");
|
|
43
51
|
}
|
|
52
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
44
53
|
function w(e) {
|
|
45
|
-
return c(e) && !(e instanceof Date) && r(e.toString) && e.toString !== Object.prototype.toString;
|
|
54
|
+
return /* @__PURE__ */ c(e) && !(e instanceof Date) && /* @__PURE__ */ r(e.toString) && e.toString !== Object.prototype.toString;
|
|
46
55
|
}
|
|
47
56
|
function T(e) {
|
|
48
57
|
return /* @__PURE__ */ TypeError(`Cannot access offset of type ${e} on array`);
|
|
49
58
|
}
|
|
59
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
50
60
|
function E(e) {
|
|
51
|
-
if (
|
|
61
|
+
if (!/* @__PURE__ */ a(e)) return Object.entries(e);
|
|
52
62
|
let t = /* @__PURE__ */ new Map();
|
|
53
63
|
for (let [n, r] of e) {
|
|
54
|
-
let e = M(n) ? String(b(n)) : void 0;
|
|
64
|
+
let e = M(n) ? String(/* @__PURE__ */ b(n)) : void 0;
|
|
55
65
|
t.set(e ?? n, [e ?? String(n), r]);
|
|
56
66
|
}
|
|
57
67
|
return [...t.values()];
|
|
58
68
|
}
|
|
69
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
59
70
|
function D(e, t) {
|
|
60
71
|
let n = { found: !1 };
|
|
61
72
|
for (let [r, i] of e) j(r, t) && (n = {
|
|
@@ -67,35 +78,38 @@ function D(e, t) {
|
|
|
67
78
|
function O(e, t, n) {
|
|
68
79
|
let r = !1;
|
|
69
80
|
for (let i of [...e.keys()]) j(i, t) && (r ? e.delete(i) : (e.set(i, n), r = !0));
|
|
70
|
-
r || e.set(b(t), n);
|
|
81
|
+
r || e.set(/* @__PURE__ */ b(t), n);
|
|
71
82
|
}
|
|
72
83
|
function k(e, t) {
|
|
73
84
|
for (let n of [...e.keys()]) j(n, t) && e.delete(n);
|
|
74
85
|
}
|
|
86
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
75
87
|
function A(e) {
|
|
76
88
|
let t;
|
|
77
|
-
for (let [n] of E(e)) {
|
|
78
|
-
let e = b(n);
|
|
79
|
-
s(e) && (t === void 0 || e > t) && (t = e);
|
|
89
|
+
for (let [n] of /* @__PURE__ */ E(e)) {
|
|
90
|
+
let e = /* @__PURE__ */ b(n);
|
|
91
|
+
/* @__PURE__ */ s(e) && (t === void 0 || e > t) && (t = e);
|
|
80
92
|
}
|
|
81
93
|
return t === void 0 ? 0 : t + 1;
|
|
82
94
|
}
|
|
83
95
|
function j(e, t) {
|
|
84
|
-
return M(e) && String(b(e)) === String(b(t));
|
|
96
|
+
return M(e) && String(/* @__PURE__ */ b(e)) === String(/* @__PURE__ */ b(t));
|
|
85
97
|
}
|
|
86
98
|
function M(e) {
|
|
87
|
-
return
|
|
99
|
+
return !/* @__PURE__ */ f(e) && !/* @__PURE__ */ r(e) && !/* @__PURE__ */ d(e);
|
|
88
100
|
}
|
|
101
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
89
102
|
function N(e) {
|
|
90
103
|
let t = 0;
|
|
91
|
-
return e.map(([e, n]) => y(e) ? [String(t++), n] : [e, n]);
|
|
104
|
+
return e.map(([e, n]) => /* @__PURE__ */ y(e) ? [String(t++), n] : [e, n]);
|
|
92
105
|
}
|
|
106
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
93
107
|
function P(e) {
|
|
94
108
|
let t = 0;
|
|
95
|
-
return e.map(([e, n]) => s(b(e)) ? [String(t++), n] : [e, n]);
|
|
109
|
+
return e.map(([e, n]) => /* @__PURE__ */ s(/* @__PURE__ */ b(e)) ? [String(t++), n] : [e, n]);
|
|
96
110
|
}
|
|
97
111
|
function F(e, t, n) {
|
|
98
|
-
l(e) || (Object.getOwnPropertyDescriptor(e, t)?.configurable === !1 ? Object.defineProperty(e, t, { value: n }) : Object.defineProperty(e, t, {
|
|
112
|
+
/* @__PURE__ */ l(e) || (Object.getOwnPropertyDescriptor(e, t)?.configurable === !1 ? Object.defineProperty(e, t, { value: n }) : Object.defineProperty(e, t, {
|
|
99
113
|
value: n,
|
|
100
114
|
enumerable: !0,
|
|
101
115
|
writable: !0,
|
package/dist/range.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../src/range.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D;;;;;;;;;;;;GAYG;AAEH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,IAAI,GACtB,UAAU,CASZ;AAED;;;;;;;;;;;;;GAaG;AAEH,wBAAgB,kBAAkB,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAClC,WAAW,CAoBb;AAED;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAWpE;AAED;;;;;;;;;;;GAWG;AAEH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAarD;AAED;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACb,MAAM,CAgDR"}
|
package/dist/range.js
CHANGED
|
@@ -2,40 +2,45 @@ import { isFiniteNumber as e, isInteger as t, isNull as n, isPhpInt as r, isUnde
|
|
|
2
2
|
import { phpIntArgument as a } from "./cast.js";
|
|
3
3
|
// src/range.ts
|
|
4
4
|
var o = 2 ** 30;
|
|
5
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5
6
|
function s(e, t, r) {
|
|
6
7
|
let i = t < 0 ? Math.max(e + t, 0) : t;
|
|
7
8
|
return {
|
|
8
9
|
start: i,
|
|
9
|
-
end: n(r) ? void 0 : r >= 0 ? i + r : Math.max(i, e + r)
|
|
10
|
+
end: /* @__PURE__ */ n(r) ? void 0 : r >= 0 ? i + r : Math.max(i, e + r)
|
|
10
11
|
};
|
|
11
12
|
}
|
|
13
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
12
14
|
function c(e, t, r) {
|
|
13
|
-
let o = a(t, "array_splice(): Argument #2 ($offset) must be of type int, float given"), s = o < 0 ? Math.max(e + o, 0) : Math.min(o, e);
|
|
14
|
-
if (n(r) || i(r)) return {
|
|
15
|
+
let o = /* @__PURE__ */ a(t, "array_splice(): Argument #2 ($offset) must be of type int, float given"), s = o < 0 ? Math.max(e + o, 0) : Math.min(o, e);
|
|
16
|
+
if (/* @__PURE__ */ n(r) || /* @__PURE__ */ i(r)) return {
|
|
15
17
|
start: s,
|
|
16
18
|
count: e - s
|
|
17
19
|
};
|
|
18
|
-
let c = a(r, "array_splice(): Argument #3 ($length) must be of type ?int, float given");
|
|
20
|
+
let c = /* @__PURE__ */ a(r, "array_splice(): Argument #3 ($length) must be of type ?int, float given");
|
|
19
21
|
return {
|
|
20
22
|
start: s,
|
|
21
23
|
count: c < 0 ? Math.max(e + c - s, 0) : c
|
|
22
24
|
};
|
|
23
25
|
}
|
|
26
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
24
27
|
function l(e, n) {
|
|
25
28
|
let r = Number.isNaN(e) ? n : Math.min(e, n);
|
|
26
|
-
if (
|
|
29
|
+
if (!/* @__PURE__ */ t(r) && r < 2) throw Error("range(): Argument #3 ($step) must be less than the range spanned by argument #1 ($start) and argument #2 ($end)");
|
|
27
30
|
return Math.floor(r);
|
|
28
31
|
}
|
|
32
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
29
33
|
function u(e) {
|
|
30
|
-
let t = a(e, "array_pad(): Argument #2 ($length) must be of type int, float given");
|
|
34
|
+
let t = /* @__PURE__ */ a(e, "array_pad(): Argument #2 ($length) must be of type int, float given");
|
|
31
35
|
if (Math.abs(t) > o) throw Error("array_pad(): Argument #2 ($length) must not exceed the maximum allowed array size");
|
|
32
36
|
return t;
|
|
33
37
|
}
|
|
38
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
34
39
|
function d(t, n, i) {
|
|
35
|
-
if (
|
|
40
|
+
if (!/* @__PURE__ */ e(i)) throw f("#3 ($step)", i);
|
|
36
41
|
if (i === 0) throw Error("range(): Argument #3 ($step) cannot be 0");
|
|
37
|
-
if (
|
|
38
|
-
if (
|
|
42
|
+
if (!/* @__PURE__ */ e(t)) throw f("#1 ($start)", t);
|
|
43
|
+
if (!/* @__PURE__ */ e(n)) throw f("#2 ($end)", n);
|
|
39
44
|
if (n > t && i < 0) throw Error("range(): Argument #3 ($step) must be greater than 0 for increasing ranges");
|
|
40
45
|
let a = Math.abs(i), s = Math.abs(n - t);
|
|
41
46
|
if (s !== 0 && s < a) throw Error("range(): Argument #3 ($step) must be less than the range spanned by argument #1 ($start) and argument #2 ($end)");
|
|
@@ -43,7 +48,7 @@ function d(t, n, i) {
|
|
|
43
48
|
t,
|
|
44
49
|
n,
|
|
45
50
|
i
|
|
46
|
-
].every((e) => r(e));
|
|
51
|
+
].every((e) => /* @__PURE__ */ r(e));
|
|
47
52
|
if (c >= o) throw p(Math.min(t, n), Math.max(t, n), a, l);
|
|
48
53
|
let u = Math.floor(c);
|
|
49
54
|
return l && c - u >= .5 ? u + 1 : u;
|
|
@@ -60,7 +65,7 @@ function p(e, t, n, r) {
|
|
|
60
65
|
return /* @__PURE__ */ Error(`The supplied range exceeds the maximum array size by ${i + 1n - BigInt(o)} elements: start=${e}, end=${t}, step=${n}. Calculated size: ${i}. Maximum size: ${o}.`);
|
|
61
66
|
}
|
|
62
67
|
function m(t) {
|
|
63
|
-
if (
|
|
68
|
+
if (!/* @__PURE__ */ e(t)) return "inf";
|
|
64
69
|
let n = Math.abs(t), r = 0;
|
|
65
70
|
for (; !Number.isInteger(n);) n *= 2, r++;
|
|
66
71
|
let i = 2n ** BigInt(r), a = BigInt(n) * 10n, o = a % i * 2n, s = a / i;
|
package/dist/reflect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../src/reflect.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../src/reflect.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;GAWG;AAEH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CASzC;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAOxE;AAED;;;;;GAKG;AAEH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA6BlD;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkCnD"}
|
package/dist/reflect.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { isArray as e, isBoolean as t, isFunction as n, isInteger as r, isNull as i, isNumber as a, isObject as o, isPhpInt as s, isPlainObject as c, isString as l, isUndefined as u } from "./guards.js";
|
|
2
2
|
// src/reflect.ts
|
|
3
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3
4
|
function d(t) {
|
|
4
|
-
return i(t) ? "object" : e(t) ? "array" : typeof t;
|
|
5
|
+
return /* @__PURE__ */ i(t) ? "object" : /* @__PURE__ */ e(t) ? "array" : typeof t;
|
|
5
6
|
}
|
|
7
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6
8
|
function f(e) {
|
|
7
9
|
return e === void 0 ? null : typeof e == "function" ? e() : e;
|
|
8
10
|
}
|
|
11
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
9
12
|
function p(t) {
|
|
10
|
-
return i(t) ? "NULL" : a(t) ? r(t) ? "integer" : "double" : e(t) ? "array" : Number.isNaN(t) ? "double" : n(t) ? "object" : u(t) ? "NULL" : typeof t;
|
|
13
|
+
return /* @__PURE__ */ i(t) ? "NULL" : /* @__PURE__ */ a(t) ? /* @__PURE__ */ r(t) ? "integer" : "double" : /* @__PURE__ */ e(t) ? "array" : Number.isNaN(t) ? "double" : /* @__PURE__ */ n(t) ? "object" : /* @__PURE__ */ u(t) ? "NULL" : typeof t;
|
|
11
14
|
}
|
|
15
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
12
16
|
function m(r) {
|
|
13
|
-
return i(r) || u(r) ? "null" : d(r) === "number" ? s(r) ? "int" : "float" : l(r) ? "string" : t(r) ? "bool" : e(r) || c(r) ? "array" : n(r) ? "Closure" : o(r) && n(r.constructor) ? h(r.constructor) : d(r);
|
|
17
|
+
return /* @__PURE__ */ i(r) || /* @__PURE__ */ u(r) ? "null" : /* @__PURE__ */ d(r) === "number" ? /* @__PURE__ */ s(r) ? "int" : "float" : /* @__PURE__ */ l(r) ? "string" : /* @__PURE__ */ t(r) ? "bool" : /* @__PURE__ */ e(r) || /* @__PURE__ */ c(r) ? "array" : /* @__PURE__ */ n(r) ? "Closure" : /* @__PURE__ */ o(r) && /* @__PURE__ */ n(r.constructor) ? h(r.constructor) : /* @__PURE__ */ d(r);
|
|
14
18
|
}
|
|
15
19
|
function h(e) {
|
|
16
20
|
if (e.name) return e.name;
|
|
17
21
|
let t = Object.getPrototypeOf(e);
|
|
18
|
-
return `${n(t) && t.name ? t.name : "class"}@anonymous`;
|
|
22
|
+
return `${/* @__PURE__ */ n(t) && t.name ? t.name : "class"}@anonymous`;
|
|
19
23
|
}
|
|
20
24
|
export { m as phpDebugType, p as phpTypeName, f as resolveDefault, d as typeOf };
|
package/dist/sorting.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sorting.d.ts","sourceRoot":"","sources":["../src/sorting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAYtD;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;AAEzE;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"sorting.d.ts","sourceRoot":"","sources":["../src/sorting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAYtD;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;AAEzE;;;;;;;;GAQG;AAEH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,IAC5B,MAAM,EACrC,MAAM,QAAQ,CAAC,MAAM,CAAC,EACtB,iBAAiB,OAAO,KACzB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAkChD;AAcD;;;;;;;;;;;;GAYG;AAEH,wBAAgB,iBAAiB,CAAC,MAAM,EACpC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,GAC3C,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAUlC"}
|
package/dist/sorting.js
CHANGED
|
@@ -2,20 +2,22 @@ import { isArray as e, isBoolean as t, isFunction as n, isNumber as r, isUndefin
|
|
|
2
2
|
import { phpIntCast as a } from "./cast.js";
|
|
3
3
|
import { compareValues as o } from "./equality.js";
|
|
4
4
|
// src/sorting.ts
|
|
5
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5
6
|
function s(t) {
|
|
6
7
|
return function(n, r) {
|
|
7
8
|
if (c(n)) return n;
|
|
8
|
-
if (e(n) && c(n[0])) return n[0];
|
|
9
|
-
let [a, s] = e(n) ? n : [n, void 0], l = i(s) || s === !0 || s === "asc" || s === "Ascending"
|
|
9
|
+
if (/* @__PURE__ */ e(n) && c(n[0])) return n[0];
|
|
10
|
+
let [a, s] = /* @__PURE__ */ e(n) ? n : [n, void 0], l = r || !(/* @__PURE__ */ i(s) || s === !0 || s === "asc" || s === "Ascending");
|
|
10
11
|
return (e, n) => {
|
|
11
|
-
let r = o(t(e, a), t(n, a));
|
|
12
|
-
return
|
|
12
|
+
let r = /* @__PURE__ */ o(t(e, a), t(n, a));
|
|
13
|
+
return l ? -r : r;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
function c(e) {
|
|
17
|
-
return n(e);
|
|
18
|
+
return /* @__PURE__ */ n(e);
|
|
18
19
|
}
|
|
20
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
19
21
|
function l(e) {
|
|
20
22
|
return (t, n) => {
|
|
21
23
|
let r = e(t, n);
|
|
@@ -23,6 +25,6 @@ function l(e) {
|
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
function u(e) {
|
|
26
|
-
return t(e) ? +!!e : r(e) ? Math.sign(a(e)) : 0;
|
|
28
|
+
return /* @__PURE__ */ t(e) ? +!!e : /* @__PURE__ */ r(e) ? Math.sign(/* @__PURE__ */ a(e)) : 0;
|
|
27
29
|
}
|
|
28
30
|
export { s as createSortSpecComparator, l as phpSortComparator };
|
package/dist/string.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C;;GAEG;
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C;;GAEG;AAEH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AAEH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AAEH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED;;GAEG;AAEH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAEtE;AAID;;;;;;;;GAQG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUpD;AAED;;;;;;;GAOG;AAEH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA2B3D"}
|
package/dist/string.js
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
import { phpTypeName as e } from "./reflect.js";
|
|
2
2
|
// src/string.ts
|
|
3
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3
4
|
function t(e) {
|
|
4
5
|
return e.toLowerCase();
|
|
5
6
|
}
|
|
7
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6
8
|
function n(e) {
|
|
7
9
|
return e.toUpperCase();
|
|
8
10
|
}
|
|
11
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
9
12
|
function r(e) {
|
|
10
13
|
let t = [...e];
|
|
11
14
|
return t.length === 0 ? e : (t[0] = t[0].toLowerCase(), t.join(""));
|
|
12
15
|
}
|
|
16
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
13
17
|
function i(e) {
|
|
14
18
|
let t = [...e];
|
|
15
19
|
return t.length === 0 ? e : (t[0] = t[0].toUpperCase(), t.join(""));
|
|
16
20
|
}
|
|
21
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
17
22
|
function a(t, n) {
|
|
18
|
-
return `Array value for key [${String(n)}] must be an array, ${e(t)} found.`;
|
|
23
|
+
return `Array value for key [${String(n)}] must be an array, ${/* @__PURE__ */ e(t)} found.`;
|
|
19
24
|
}
|
|
20
25
|
var o = /^[\w@%+=:,./-]+$/;
|
|
26
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
21
27
|
function s(e) {
|
|
22
28
|
return e === "" ? "''" : o.test(e) ? e : "'" + e.replace(/'/g, "'\\''") + "'";
|
|
23
29
|
}
|
|
30
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
24
31
|
function c(e) {
|
|
25
32
|
if (e === "") return "\"\"";
|
|
26
33
|
if (o.test(e)) return e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/utils",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "A set of utility functions for the @tolki packages.",
|
|
5
5
|
"author": "Abraham Arango <https://github.com/abetwothree>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"main": "dist/index.js",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@tolki/types": "^1.
|
|
18
|
+
"@tolki/types": "^1.12.0"
|
|
19
19
|
},
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"files": [
|