@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.
- package/dist/cast.d.ts.map +1 -1
- package/dist/cast.js +112 -130
- package/dist/equality.d.ts.map +1 -1
- package/dist/equality.js +160 -211
- package/dist/exceptions.js +22 -53
- package/dist/guards.d.ts.map +1 -1
- package/dist/guards.js +163 -173
- package/dist/index.js +11 -104
- package/dist/keys.d.ts +3 -0
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +113 -132
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js +66 -98
- package/dist/reflect.d.ts.map +1 -1
- package/dist/reflect.js +19 -20
- package/dist/sorting.d.ts.map +1 -1
- package/dist/sorting.js +26 -28
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +31 -39
- package/dist/utils.js +10 -104
- package/package.json +4 -3
package/dist/keys.js
CHANGED
|
@@ -1,138 +1,119 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { phpDebugType as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return e === "__proto__" || e === "constructor" || e === "prototype";
|
|
9
|
-
}
|
|
10
|
-
function C(e) {
|
|
11
|
-
return p(e) ? !0 : y(e) ? e >= -c && e < c : !1;
|
|
12
|
-
}
|
|
13
|
-
function P(e) {
|
|
14
|
-
return /^(0|[1-9]\d*)$/.test(e);
|
|
15
|
-
}
|
|
16
|
-
function o(e) {
|
|
17
|
-
if (p(e)) {
|
|
18
|
-
if (/^(0|-?[1-9]\d*)$/.test(e)) {
|
|
19
|
-
const t = Number(e);
|
|
20
|
-
if (Number.isSafeInteger(t))
|
|
21
|
-
return t;
|
|
22
|
-
}
|
|
23
|
-
return e;
|
|
24
|
-
}
|
|
25
|
-
if (m(e) || K(e))
|
|
26
|
-
return "";
|
|
27
|
-
if (S(e))
|
|
28
|
-
return e ? 1 : 0;
|
|
29
|
-
if (f(e) || Number.isNaN(e)) {
|
|
30
|
-
const t = Number.isFinite(e) ? BigInt.asIntN(64, BigInt(Math.trunc(e))) : 0n;
|
|
31
|
-
return Number.isSafeInteger(Number(t)) ? Number(t) : String(t);
|
|
32
|
-
}
|
|
33
|
-
return String(e);
|
|
34
|
-
}
|
|
35
|
-
function D(e, t = {}) {
|
|
36
|
-
const { enumCases: r = !1, stringables: n = !1 } = t;
|
|
37
|
-
let i = e;
|
|
38
|
-
if (r && N(i) && (i = i.value), n && x(i) && (i = String(i.toString())), w(i))
|
|
39
|
-
throw (t.invalid ?? j)(O(i));
|
|
40
|
-
return o(i);
|
|
1
|
+
import { isArray as e, isBoolean as t, isEnumCase as n, isFunction as r, isInteger as i, isMap as a, isNull as o, isNumber as s, isObject as c, isPrototypeObject as l, isString as u, isSymbol as d, isTruthyObject as f, isUndefined as p } from "./guards.js";
|
|
2
|
+
import { phpDebugType as m } from "./reflect.js";
|
|
3
|
+
// src/keys.ts
|
|
4
|
+
var h = 2 ** 63;
|
|
5
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6
|
+
function g(e) {
|
|
7
|
+
return !isNaN(Number(e)) && !isNaN(parseFloat(String(e))) ? Number(e) : e;
|
|
41
8
|
}
|
|
9
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
10
|
+
function _(e) {
|
|
11
|
+
return e === "__proto__" || e === "constructor" || e === "prototype";
|
|
12
|
+
}
|
|
13
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
14
|
+
function v(e) {
|
|
15
|
+
return /* @__PURE__ */ u(e) ? !0 : /* @__PURE__ */ i(e) ? e >= -h && e < h : !1;
|
|
16
|
+
}
|
|
17
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
18
|
+
function y(e) {
|
|
19
|
+
return /^(0|[1-9]\d*)$/.test(e);
|
|
20
|
+
}
|
|
21
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
22
|
+
function b(e) {
|
|
23
|
+
if (/* @__PURE__ */ u(e)) {
|
|
24
|
+
if (/^(0|-?[1-9]\d*)$/.test(e)) {
|
|
25
|
+
let t = Number(e);
|
|
26
|
+
if (Number.isSafeInteger(t)) return t;
|
|
27
|
+
}
|
|
28
|
+
return e;
|
|
29
|
+
}
|
|
30
|
+
if (/* @__PURE__ */ o(e) || /* @__PURE__ */ p(e)) return "";
|
|
31
|
+
if (/* @__PURE__ */ t(e)) return +!!e;
|
|
32
|
+
if (/* @__PURE__ */ s(e) || Number.isNaN(e)) {
|
|
33
|
+
let t = Number.isFinite(e) ? BigInt.asIntN(64, BigInt(Math.trunc(e))) : 0n;
|
|
34
|
+
return Number.isSafeInteger(Number(t)) ? Number(t) : String(t);
|
|
35
|
+
}
|
|
36
|
+
return String(e);
|
|
37
|
+
}
|
|
38
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
39
|
+
function x(e, t = {}) {
|
|
40
|
+
let { enumCases: r = !1, stringables: i = !1 } = t, a = e;
|
|
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);
|
|
43
|
+
}
|
|
44
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
45
|
+
function S(t) {
|
|
46
|
+
return /* @__PURE__ */ e(t) || /* @__PURE__ */ c(t) || /* @__PURE__ */ r(t);
|
|
47
|
+
}
|
|
48
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
49
|
+
function C() {
|
|
50
|
+
return /* @__PURE__ */ TypeError("array_key_exists(): Argument #1 ($key) must be a valid array offset type");
|
|
51
|
+
}
|
|
52
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
42
53
|
function w(e) {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
return /* @__PURE__ */ c(e) && !(e instanceof Date) && /* @__PURE__ */ r(e.toString) && e.toString !== Object.prototype.toString;
|
|
55
|
+
}
|
|
56
|
+
function T(e) {
|
|
57
|
+
return /* @__PURE__ */ TypeError(`Cannot access offset of type ${e} on array`);
|
|
58
|
+
}
|
|
59
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
60
|
+
function E(e) {
|
|
61
|
+
if (!/* @__PURE__ */ a(e)) return Object.entries(e);
|
|
62
|
+
let t = /* @__PURE__ */ new Map();
|
|
63
|
+
for (let [n, r] of e) {
|
|
64
|
+
let e = M(n) ? String(/* @__PURE__ */ b(n)) : void 0;
|
|
65
|
+
t.set(e ?? n, [e ?? String(n), r]);
|
|
66
|
+
}
|
|
67
|
+
return [...t.values()];
|
|
68
|
+
}
|
|
69
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
70
|
+
function D(e, t) {
|
|
71
|
+
let n = { found: !1 };
|
|
72
|
+
for (let [r, i] of e) j(r, t) && (n = {
|
|
73
|
+
found: !0,
|
|
74
|
+
value: i
|
|
75
|
+
});
|
|
76
|
+
return n;
|
|
77
|
+
}
|
|
78
|
+
function O(e, t, n) {
|
|
79
|
+
let r = !1;
|
|
80
|
+
for (let i of [...e.keys()]) j(i, t) && (r ? e.delete(i) : (e.set(i, n), r = !0));
|
|
81
|
+
r || e.set(/* @__PURE__ */ b(t), n);
|
|
82
|
+
}
|
|
83
|
+
function k(e, t) {
|
|
84
|
+
for (let n of [...e.keys()]) j(n, t) && e.delete(n);
|
|
85
|
+
}
|
|
86
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
87
|
+
function A(e) {
|
|
88
|
+
let t;
|
|
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);
|
|
92
|
+
}
|
|
93
|
+
return t === void 0 ? 0 : t + 1;
|
|
49
94
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
95
|
+
function j(e, t) {
|
|
96
|
+
return M(e) && String(/* @__PURE__ */ b(e)) === String(/* @__PURE__ */ b(t));
|
|
52
97
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
98
|
+
function M(e) {
|
|
99
|
+
return !/* @__PURE__ */ f(e) && !/* @__PURE__ */ r(e) && !/* @__PURE__ */ d(e);
|
|
55
100
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
for (const [r, n] of e) {
|
|
61
|
-
const i = g(r) ? String(o(r)) : void 0;
|
|
62
|
-
t.set(i ?? r, [i ?? String(r), n]);
|
|
63
|
-
}
|
|
64
|
-
return [...t.values()];
|
|
65
|
-
}
|
|
66
|
-
function F(e, t) {
|
|
67
|
-
let r = { found: !1 };
|
|
68
|
-
for (const [n, i] of e)
|
|
69
|
-
u(n, t) && (r = { found: !0, value: i });
|
|
70
|
-
return r;
|
|
71
|
-
}
|
|
72
|
-
function U(e, t, r) {
|
|
73
|
-
let n = !1;
|
|
74
|
-
for (const i of [...e.keys()])
|
|
75
|
-
u(i, t) && (n ? e.delete(i) : (e.set(i, r), n = !0));
|
|
76
|
-
n || e.set(o(t), r);
|
|
77
|
-
}
|
|
78
|
-
function H(e, t) {
|
|
79
|
-
for (const r of [...e.keys()])
|
|
80
|
-
u(r, t) && e.delete(r);
|
|
81
|
-
}
|
|
82
|
-
function L(e) {
|
|
83
|
-
let t;
|
|
84
|
-
for (const [r] of _(e)) {
|
|
85
|
-
const n = o(r);
|
|
86
|
-
f(n) && (t === void 0 || n > t) && (t = n);
|
|
87
|
-
}
|
|
88
|
-
return t === void 0 ? 0 : t + 1;
|
|
89
|
-
}
|
|
90
|
-
function u(e, t) {
|
|
91
|
-
return g(e) && String(o(e)) === String(o(t));
|
|
101
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
102
|
+
function N(e) {
|
|
103
|
+
let t = 0;
|
|
104
|
+
return e.map(([e, n]) => /* @__PURE__ */ y(e) ? [String(t++), n] : [e, n]);
|
|
92
105
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (!b(e)) {
|
|
108
|
-
if (Object.getOwnPropertyDescriptor(e, t)?.configurable === !1) {
|
|
109
|
-
Object.defineProperty(e, t, { value: r });
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
Object.defineProperty(e, t, {
|
|
113
|
-
value: r,
|
|
114
|
-
enumerable: !0,
|
|
115
|
-
writable: !0,
|
|
116
|
-
configurable: !0
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
export {
|
|
121
|
-
$ as arrayKeyExistsError,
|
|
122
|
-
z as defineKey,
|
|
123
|
-
H as deleteMapKey,
|
|
124
|
-
A as entriesKeyValue,
|
|
125
|
-
x as hasOwnToString,
|
|
126
|
-
w as isIllegalOffset,
|
|
127
|
-
P as isIntegerLikeKey,
|
|
128
|
-
C as isPhpArrayKey,
|
|
129
|
-
B as isUnsafeKey,
|
|
130
|
-
_ as keyedEntries,
|
|
131
|
-
L as nextIntegerKey,
|
|
132
|
-
o as phpArrayKey,
|
|
133
|
-
D as phpComputedKey,
|
|
134
|
-
F as readMapKey,
|
|
135
|
-
V as reindexIntegerKeys,
|
|
136
|
-
q as renumberPhpIntegerKeys,
|
|
137
|
-
U as writeMapKey
|
|
138
|
-
};
|
|
106
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
107
|
+
function P(e) {
|
|
108
|
+
let t = 0;
|
|
109
|
+
return e.map(([e, n]) => /* @__PURE__ */ s(/* @__PURE__ */ b(e)) ? [String(t++), n] : [e, n]);
|
|
110
|
+
}
|
|
111
|
+
function F(e, t, n) {
|
|
112
|
+
/* @__PURE__ */ l(e) || (Object.getOwnPropertyDescriptor(e, t)?.configurable === !1 ? Object.defineProperty(e, t, { value: n }) : Object.defineProperty(e, t, {
|
|
113
|
+
value: n,
|
|
114
|
+
enumerable: !0,
|
|
115
|
+
writable: !0,
|
|
116
|
+
configurable: !0
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
export { C as arrayKeyExistsError, F as defineKey, k as deleteMapKey, g as entriesKeyValue, w as hasOwnToString, S as isIllegalOffset, y as isIntegerLikeKey, v as isPhpArrayKey, _ as isUnsafeKey, E as keyedEntries, A as nextIntegerKey, b as phpArrayKey, x as phpComputedKey, D as readMapKey, N as reindexIntegerKeys, P as renumberPhpIntegerKeys, O as writeMapKey };
|
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
|
@@ -1,106 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { isFiniteNumber as e, isInteger as t, isNull as n, isPhpInt as r, isUndefined as i } from "./guards.js";
|
|
2
|
+
import { phpIntArgument as a } from "./cast.js";
|
|
3
|
+
// src/range.ts
|
|
4
|
+
var o = 2 ** 30;
|
|
5
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6
|
+
function s(e, t, r) {
|
|
7
|
+
let i = t < 0 ? Math.max(e + t, 0) : t;
|
|
8
|
+
return {
|
|
9
|
+
start: i,
|
|
10
|
+
end: /* @__PURE__ */ n(r) ? void 0 : r >= 0 ? i + r : Math.max(i, e + r)
|
|
11
|
+
};
|
|
7
12
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
start: a,
|
|
21
|
-
count: i < 0 ? Math.max(e + i - a, 0) : i
|
|
22
|
-
};
|
|
13
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
14
|
+
function c(e, t, r) {
|
|
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 {
|
|
17
|
+
start: s,
|
|
18
|
+
count: e - s
|
|
19
|
+
};
|
|
20
|
+
let c = /* @__PURE__ */ a(r, "array_splice(): Argument #3 ($length) must be of type ?int, float given");
|
|
21
|
+
return {
|
|
22
|
+
start: s,
|
|
23
|
+
count: c < 0 ? Math.max(e + c - s, 0) : c
|
|
24
|
+
};
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
return Math.floor(t);
|
|
26
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
27
|
+
function l(e, n) {
|
|
28
|
+
let r = Number.isNaN(e) ? n : Math.min(e, n);
|
|
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)");
|
|
30
|
+
return Math.floor(r);
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (Math.abs(n) > s)
|
|
38
|
-
throw new Error(
|
|
39
|
-
"array_pad(): Argument #2 ($length) must not exceed the maximum allowed array size"
|
|
40
|
-
);
|
|
41
|
-
return n;
|
|
32
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
33
|
+
function u(e) {
|
|
34
|
+
let t = /* @__PURE__ */ a(e, "array_pad(): Argument #2 ($length) must be of type int, float given");
|
|
35
|
+
if (Math.abs(t) > o) throw Error("array_pad(): Argument #2 ($length) must not exceed the maximum allowed array size");
|
|
36
|
+
return t;
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
61
|
-
const i = a / r + 1, o = ![e, n, t].every(($) => d($));
|
|
62
|
-
if (i >= s)
|
|
63
|
-
throw b(
|
|
64
|
-
Math.min(e, n),
|
|
65
|
-
Math.max(e, n),
|
|
66
|
-
r,
|
|
67
|
-
o
|
|
68
|
-
);
|
|
69
|
-
const c = Math.floor(i);
|
|
70
|
-
return o && i - c >= 0.5 ? c + 1 : c;
|
|
38
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
39
|
+
function d(t, n, i) {
|
|
40
|
+
if (!/* @__PURE__ */ e(i)) throw f("#3 ($step)", i);
|
|
41
|
+
if (i === 0) throw Error("range(): Argument #3 ($step) cannot be 0");
|
|
42
|
+
if (!/* @__PURE__ */ e(t)) throw f("#1 ($start)", t);
|
|
43
|
+
if (!/* @__PURE__ */ e(n)) throw f("#2 ($end)", n);
|
|
44
|
+
if (n > t && i < 0) throw Error("range(): Argument #3 ($step) must be greater than 0 for increasing ranges");
|
|
45
|
+
let a = Math.abs(i), s = Math.abs(n - t);
|
|
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)");
|
|
47
|
+
let c = s / a + 1, l = ![
|
|
48
|
+
t,
|
|
49
|
+
n,
|
|
50
|
+
i
|
|
51
|
+
].every((e) => /* @__PURE__ */ r(e));
|
|
52
|
+
if (c >= o) throw p(Math.min(t, n), Math.max(t, n), a, l);
|
|
53
|
+
let u = Math.floor(c);
|
|
54
|
+
return l && c - u >= .5 ? u + 1 : u;
|
|
71
55
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
return new Error(
|
|
75
|
-
`range(): Argument ${e} must be a finite number, ${t} provided`
|
|
76
|
-
);
|
|
56
|
+
function f(e, t) {
|
|
57
|
+
return /* @__PURE__ */ Error(`range(): Argument ${e} must be a finite number, ${Number.isNaN(t) ? "NAN" : "INF"} provided`);
|
|
77
58
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const a = (BigInt(n) - BigInt(e)) / BigInt(t);
|
|
86
|
-
return new Error(
|
|
87
|
-
`The supplied range exceeds the maximum array size by ${a + 1n - BigInt(s)} elements: start=${e}, end=${n}, step=${t}. Calculated size: ${a}. Maximum size: ${s}.`
|
|
88
|
-
);
|
|
59
|
+
function p(e, t, n, r) {
|
|
60
|
+
if (r) {
|
|
61
|
+
let r = (t - e) / n + 1;
|
|
62
|
+
return /* @__PURE__ */ Error(`The supplied range exceeds the maximum array size by ${m(r - o)} elements: start=${m(e)}, end=${m(t)}, step=${m(n)}. Max size: ${o}`);
|
|
63
|
+
}
|
|
64
|
+
let i = (BigInt(t) - BigInt(e)) / BigInt(n);
|
|
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}.`);
|
|
89
66
|
}
|
|
90
|
-
function m(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const r = 2n ** BigInt(t), a = BigInt(n) * 10n, i = a % r * 2n;
|
|
97
|
-
let o = a / r;
|
|
98
|
-
return (i > r || i === r && o % 2n === 1n) && (o += 1n), `${e < 0 ? "-" : ""}${o / 10n}.${o % 10n}`;
|
|
67
|
+
function m(t) {
|
|
68
|
+
if (!/* @__PURE__ */ e(t)) return "inf";
|
|
69
|
+
let n = Math.abs(t), r = 0;
|
|
70
|
+
for (; !Number.isInteger(n);) n *= 2, r++;
|
|
71
|
+
let i = 2n ** BigInt(r), a = BigInt(n) * 10n, o = a % i * 2n, s = a / i;
|
|
72
|
+
return (o > i || o === i && s % 2n == 1n) && (s += 1n), `${t < 0 ? "-" : ""}${s / 10n}.${s % 10n}`;
|
|
99
73
|
}
|
|
100
|
-
export {
|
|
101
|
-
v as resolvePadLength,
|
|
102
|
-
I as resolveRangeSize,
|
|
103
|
-
x as resolveSliceRange,
|
|
104
|
-
y as resolveSpliceRange,
|
|
105
|
-
A as resolveTakeCount
|
|
106
|
-
};
|
|
74
|
+
export { u as resolvePadLength, d as resolveRangeSize, s as resolveSliceRange, c as resolveSpliceRange, l as resolveTakeCount };
|
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,25 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
// src/reflect.ts
|
|
3
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
4
|
+
function d(t) {
|
|
5
|
+
return /* @__PURE__ */ i(t) ? "object" : /* @__PURE__ */ e(t) ? "array" : typeof t;
|
|
4
6
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
8
|
+
function f(e) {
|
|
9
|
+
return e === void 0 ? null : typeof e == "function" ? e() : e;
|
|
7
10
|
}
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
12
|
+
function p(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;
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
16
|
+
function m(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);
|
|
13
18
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return `${n(t) && t.name ? t.name : "class"}@anonymous`;
|
|
19
|
+
function h(e) {
|
|
20
|
+
if (e.name) return e.name;
|
|
21
|
+
let t = Object.getPrototypeOf(e);
|
|
22
|
+
return `${/* @__PURE__ */ n(t) && t.name ? t.name : "class"}@anonymous`;
|
|
19
23
|
}
|
|
20
|
-
export {
|
|
21
|
-
L as phpDebugType,
|
|
22
|
-
O as phpTypeName,
|
|
23
|
-
j as resolveDefault,
|
|
24
|
-
o as typeOf
|
|
25
|
-
};
|
|
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
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { isArray as e, isBoolean as t, isFunction as n, isNumber as r, isUndefined as i } from "./guards.js";
|
|
2
|
+
import { phpIntCast as a } from "./cast.js";
|
|
3
|
+
import { compareValues as o } from "./equality.js";
|
|
4
|
+
// src/sorting.ts
|
|
5
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6
|
+
function s(t) {
|
|
7
|
+
return function(n, r) {
|
|
8
|
+
if (c(n)) return n;
|
|
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");
|
|
11
|
+
return (e, n) => {
|
|
12
|
+
let r = /* @__PURE__ */ o(t(e, a), t(n, a));
|
|
13
|
+
return l ? -r : r;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
16
|
}
|
|
17
|
-
function c(
|
|
18
|
-
|
|
17
|
+
function c(e) {
|
|
18
|
+
return /* @__PURE__ */ n(e);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
21
|
+
function l(e) {
|
|
22
|
+
return (t, n) => {
|
|
23
|
+
let r = e(t, n);
|
|
24
|
+
return r === !1 ? -u(e(n, t)) : u(r);
|
|
25
|
+
};
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
27
|
+
function u(e) {
|
|
28
|
+
return /* @__PURE__ */ t(e) ? +!!e : /* @__PURE__ */ r(e) ? Math.sign(/* @__PURE__ */ a(e)) : 0;
|
|
28
29
|
}
|
|
29
|
-
export {
|
|
30
|
-
B as createSortSpecComparator,
|
|
31
|
-
D as phpSortComparator
|
|
32
|
-
};
|
|
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,46 +1,38 @@
|
|
|
1
|
-
import { phpTypeName as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { phpTypeName as e } from "./reflect.js";
|
|
2
|
+
// src/string.ts
|
|
3
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
4
|
+
function t(e) {
|
|
5
|
+
return e.toLowerCase();
|
|
4
6
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
8
|
+
function n(e) {
|
|
9
|
+
return e.toUpperCase();
|
|
7
10
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
12
|
+
function r(e) {
|
|
13
|
+
let t = [...e];
|
|
14
|
+
return t.length === 0 ? e : (t[0] = t[0].toLowerCase(), t.join(""));
|
|
11
15
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
17
|
+
function i(e) {
|
|
18
|
+
let t = [...e];
|
|
19
|
+
return t.length === 0 ? e : (t[0] = t[0].toUpperCase(), t.join(""));
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
22
|
+
function a(t, n) {
|
|
23
|
+
return `Array value for key [${String(n)}] must be an array, ${/* @__PURE__ */ e(t)} found.`;
|
|
18
24
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
var o = /^[\w@%+=:,./-]+$/;
|
|
26
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
27
|
+
function s(e) {
|
|
28
|
+
return e === "" ? "''" : o.test(e) ? e : "'" + e.replace(/'/g, "'\\''") + "'";
|
|
22
29
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (n === "\\") {
|
|
31
|
-
t++;
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
e += n === '"' ? `${"\\".repeat(t * 2 + 1)}"` : `${"\\".repeat(t)}${n}`, t = 0;
|
|
35
|
-
}
|
|
36
|
-
return `"${e}${"\\".repeat(t * 2)}"`;
|
|
30
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
31
|
+
function c(e) {
|
|
32
|
+
if (e === "") return "\"\"";
|
|
33
|
+
if (o.test(e)) return e;
|
|
34
|
+
let t = "", n = 0;
|
|
35
|
+
for (let r of e) r === "\\" ? n++ : (t += r === "\"" ? `${"\\".repeat(n * 2 + 1)}"` : `${"\\".repeat(n)}${r}`, n = 0);
|
|
36
|
+
return `"${t}${"\\".repeat(n * 2)}"`;
|
|
37
37
|
}
|
|
38
|
-
export {
|
|
39
|
-
u as arrayValueMessage,
|
|
40
|
-
h as escapeShellArg,
|
|
41
|
-
$ as escapeWindowsShellArg,
|
|
42
|
-
f as lowerFirst,
|
|
43
|
-
c as toLower,
|
|
44
|
-
p as toUpper,
|
|
45
|
-
a as upperFirst
|
|
46
|
-
};
|
|
38
|
+
export { a as arrayValueMessage, s as escapeShellArg, c as escapeWindowsShellArg, r as lowerFirst, t as toLower, n as toUpper, i as upperFirst };
|