@tolki/utils 1.6.1 → 1.6.3
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.js +99 -130
- package/dist/equality.js +156 -211
- package/dist/exceptions.js +22 -53
- package/dist/guards.js +104 -151
- package/dist/index.js +11 -102
- package/dist/keys.js +97 -130
- package/dist/range.js +61 -98
- package/dist/reflect.js +15 -20
- package/dist/sorting.js +24 -28
- package/dist/string.d.ts +19 -0
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +26 -20
- package/dist/utils.js +10 -102
- package/package.json +4 -3
package/dist/cast.js
CHANGED
|
@@ -1,130 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
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
|
+
function b(e) {
|
|
7
|
+
return o(e) || d(e) || e === !1 ? "" : e === !0 ? "1" : s(e) || Number.isNaN(e) ? x(e) : String(e);
|
|
8
|
+
}
|
|
9
|
+
function x(e) {
|
|
10
|
+
if (Number.isNaN(e)) return "NAN";
|
|
11
|
+
if (!Number.isFinite(e)) return e > 0 ? "INF" : "-INF";
|
|
12
|
+
if (_(e) && !Object.is(e, -0)) return BigInt(e).toString();
|
|
13
|
+
let [t, n] = S(Math.abs(e)), r = e < 0 || Object.is(e, -0) ? "-" : "";
|
|
14
|
+
if (n < -3 || n > y) {
|
|
15
|
+
let e = n - 1;
|
|
16
|
+
return `${r}${`${t.charAt(0)}.${t.slice(1) || "0"}`}E${e < 0 ? "-" : "+"}${Math.abs(e)}`;
|
|
17
|
+
}
|
|
18
|
+
if (n <= 0) return `${r}0.${"0".repeat(-n)}${t}`;
|
|
19
|
+
let i = t.slice(0, n).padEnd(n, "0"), a = t.slice(n);
|
|
20
|
+
return a === "" ? `${r}${i}` : `${r}${i}.${a}`;
|
|
21
|
+
}
|
|
22
|
+
function S(e) {
|
|
23
|
+
if (e === 0) return ["0", 1];
|
|
24
|
+
let t = e, n = 0;
|
|
25
|
+
for (; !Number.isInteger(t);) t *= 2, n++;
|
|
26
|
+
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;
|
|
27
|
+
if (i > a || i === a && Number(o.at(-1)) % 2 == 1) {
|
|
28
|
+
let e = String(BigInt(o) + 1n);
|
|
29
|
+
s += e.length - o.length, o = e;
|
|
30
|
+
}
|
|
31
|
+
for (; o.endsWith("0");) o = o.slice(0, -1);
|
|
32
|
+
return [o, s];
|
|
33
|
+
}
|
|
34
|
+
function C(e) {
|
|
35
|
+
return c(e) && !o(e) && r(e.toArray);
|
|
36
|
+
}
|
|
37
|
+
function w(e) {
|
|
38
|
+
if (!c(e) || o(e)) return !1;
|
|
39
|
+
let t = r(e.toJson), n = r(e.toJSON);
|
|
40
|
+
return t || n;
|
|
41
|
+
}
|
|
42
|
+
function T(e) {
|
|
43
|
+
return c(e) && !o(e) && r(e.jsonSerialize);
|
|
44
|
+
}
|
|
45
|
+
function E(t) {
|
|
46
|
+
return e(t) ? t : null;
|
|
47
|
+
}
|
|
48
|
+
function D(e) {
|
|
49
|
+
return Array.isArray(e) ? e.slice() : null;
|
|
50
|
+
}
|
|
51
|
+
function O(e) {
|
|
52
|
+
return D(e) || [];
|
|
53
|
+
}
|
|
54
|
+
function k(e) {
|
|
55
|
+
if (u(e) || !c(e)) return e;
|
|
56
|
+
for (let t of [
|
|
57
|
+
"all",
|
|
58
|
+
"toArray",
|
|
59
|
+
"toJSON"
|
|
60
|
+
]) if (r(e[t])) return k(e[t]());
|
|
61
|
+
return e;
|
|
62
|
+
}
|
|
63
|
+
function A(t) {
|
|
64
|
+
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];
|
|
66
|
+
}
|
|
67
|
+
function j(t) {
|
|
68
|
+
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)) {
|
|
73
|
+
let e = {};
|
|
74
|
+
for (let [t, r] of v(n)) h(e, t, r);
|
|
75
|
+
return e;
|
|
76
|
+
}
|
|
77
|
+
return f(n) || p(n) ? {} : i(n) ? { ...[...n] } : n;
|
|
78
|
+
}
|
|
79
|
+
return { 0: n };
|
|
80
|
+
}
|
|
81
|
+
function M(e) {
|
|
82
|
+
return o(e) || d(e) ? "" : t(e) ? e ? "1" : "" : String(e);
|
|
83
|
+
}
|
|
84
|
+
function N(e, t) {
|
|
85
|
+
if (!n(e) || e < -(2 ** 63) || e >= 2 ** 63) throw TypeError(t);
|
|
86
|
+
return Math.trunc(e);
|
|
87
|
+
}
|
|
88
|
+
function P(e) {
|
|
89
|
+
if (!n(e)) return 0;
|
|
90
|
+
let t = Math.trunc(e);
|
|
91
|
+
return t >= -(2 ** 63) && t < 2 ** 63 ? t === 0 ? 0 : t : Number(BigInt.asIntN(64, BigInt(t)));
|
|
92
|
+
}
|
|
93
|
+
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);
|
|
98
|
+
}
|
|
99
|
+
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.js
CHANGED
|
@@ -1,211 +1,156 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (!n || !o)
|
|
158
|
-
return !1;
|
|
159
|
-
const e = Object.keys(t), i = Object.keys(r);
|
|
160
|
-
if (e.length !== i.length)
|
|
161
|
-
return !1;
|
|
162
|
-
for (const [s, f] of e.entries())
|
|
163
|
-
if (f !== i[s] || !O(
|
|
164
|
-
t[f],
|
|
165
|
-
r[f]
|
|
166
|
-
))
|
|
167
|
-
return !1;
|
|
168
|
-
return !0;
|
|
169
|
-
}
|
|
170
|
-
return !1;
|
|
171
|
-
}
|
|
172
|
-
function Y(t, r, n) {
|
|
173
|
-
const o = [t, n], e = (c) => m(c) && !V(c);
|
|
174
|
-
if (o.filter(
|
|
175
|
-
(c) => u(c) || e(c) && x(c)
|
|
176
|
-
).length < 2 && o.filter(e).length === 1)
|
|
177
|
-
return ["!=", "<>", "!=="].includes(r);
|
|
178
|
-
const f = !(N(t) || N(n) || g(t) || g(n)) && (P(t) || P(n)), l = (c) => !f && c(_(t, n));
|
|
179
|
-
switch (r) {
|
|
180
|
-
case "!=":
|
|
181
|
-
case "<>":
|
|
182
|
-
return !I(t, n);
|
|
183
|
-
case "<":
|
|
184
|
-
return l((c) => c < 0);
|
|
185
|
-
case ">":
|
|
186
|
-
return l((c) => c > 0);
|
|
187
|
-
case "<=":
|
|
188
|
-
return l((c) => c <= 0);
|
|
189
|
-
case ">=":
|
|
190
|
-
return l((c) => c >= 0);
|
|
191
|
-
// PHP's `===` compares an array by value — same keys, same order, same types — and only a real object by
|
|
192
|
-
// identity. strictEqual is that rule; JS's own `===` would call every pair of equal arrays unequal
|
|
193
|
-
// (docs/php-parity/Collection/contains.json, "r4-strict-operators").
|
|
194
|
-
case "===":
|
|
195
|
-
return O(t, n);
|
|
196
|
-
case "!==":
|
|
197
|
-
return !O(t, n);
|
|
198
|
-
// PHP's `<=>` is truthy for any non-zero result, so only an equal pair is
|
|
199
|
-
// falsy; an uncomparable one answers 1, not 0, and so counts as unequal.
|
|
200
|
-
case "<=>":
|
|
201
|
-
return f || _(t, n) !== 0;
|
|
202
|
-
default:
|
|
203
|
-
return I(t, n);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
export {
|
|
207
|
-
_ as compareValues,
|
|
208
|
-
I as looseEqual,
|
|
209
|
-
Y as operatorMatch,
|
|
210
|
-
O as strictEqual
|
|
211
|
-
};
|
|
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
|
+
// src/equality.ts
|
|
3
|
+
function u(e) {
|
|
4
|
+
return n(e) || l(e);
|
|
5
|
+
}
|
|
6
|
+
function d(e, t) {
|
|
7
|
+
return e < t ? -1 : +(e > t);
|
|
8
|
+
}
|
|
9
|
+
var f = /^[ \t\n\r\v\f]*[+-]?\d+[ \t\n\r\v\f]*$/, p = 2 ** 63, m = 2n ** 63n;
|
|
10
|
+
function h(e) {
|
|
11
|
+
return e >= m ? 1 : e < -m ? -1 : 0;
|
|
12
|
+
}
|
|
13
|
+
function g(e, t) {
|
|
14
|
+
if (f.test(e) && f.test(t)) {
|
|
15
|
+
let n = BigInt(e), r = BigInt(t), i = h(n);
|
|
16
|
+
return i !== 0 && i === h(r) && Number(e) === Number(t) ? d(e, t) : n < r ? -1 : +(n > r);
|
|
17
|
+
}
|
|
18
|
+
let n = Number(e), r = Number(t);
|
|
19
|
+
return n === r && !Number.isFinite(n) ? d(e, t) : n < r ? -1 : +(n > r);
|
|
20
|
+
}
|
|
21
|
+
function _(e) {
|
|
22
|
+
return !a(e);
|
|
23
|
+
}
|
|
24
|
+
function v(e, t) {
|
|
25
|
+
return y(e, t, void 0);
|
|
26
|
+
}
|
|
27
|
+
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)) {
|
|
31
|
+
let t = _(e);
|
|
32
|
+
return t === _(n) ? 0 : t ? 1 : -1;
|
|
33
|
+
}
|
|
34
|
+
if (e instanceof Date && n instanceof Date) {
|
|
35
|
+
let t = e.getTime(), r = n.getTime();
|
|
36
|
+
return t < r ? -1 : +(t > r);
|
|
37
|
+
}
|
|
38
|
+
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);
|
|
42
|
+
let t = Number(e), r = Number(n);
|
|
43
|
+
return t < r ? -1 : +(t > r);
|
|
44
|
+
}
|
|
45
|
+
return c(e) || c(n) ? d(String(e), String(n)) : e < n ? -1 : +(e > n);
|
|
46
|
+
}
|
|
47
|
+
function b(e, t, n) {
|
|
48
|
+
let r = n.get(e);
|
|
49
|
+
if (r?.has(t)) return 0;
|
|
50
|
+
let i = r ?? /* @__PURE__ */ new Set();
|
|
51
|
+
r || n.set(e, i), i.add(t);
|
|
52
|
+
let a = x(e, t, n);
|
|
53
|
+
return i.delete(t), a;
|
|
54
|
+
}
|
|
55
|
+
function x(e, t, n) {
|
|
56
|
+
let r = Object.keys(e), i = Object.keys(t).length;
|
|
57
|
+
if (r.length !== i) return r.length < i ? -1 : 1;
|
|
58
|
+
let a = e, o = t;
|
|
59
|
+
for (let e of r) {
|
|
60
|
+
if (!Object.hasOwn(t, e)) return 1;
|
|
61
|
+
let r = y(a[e], o[e], n);
|
|
62
|
+
if (r !== 0) return r;
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
function S(n, a) {
|
|
67
|
+
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
|
+
let l = u(n), d = u(a);
|
|
71
|
+
if (l && d) return !0;
|
|
72
|
+
if (l || d) {
|
|
73
|
+
let e = l ? a : n;
|
|
74
|
+
return c(e) ? e === "" : !_(e);
|
|
75
|
+
}
|
|
76
|
+
if (t(n) || t(a)) return _(n) === _(a);
|
|
77
|
+
if (E(n) || E(a)) return !1;
|
|
78
|
+
if (c(n) !== c(a)) {
|
|
79
|
+
let e = c(n) ? a : n;
|
|
80
|
+
if (i(e) && !s(e) && D(e)) return String(e) === (c(n) ? n : a);
|
|
81
|
+
}
|
|
82
|
+
let f = C(n) || c(n), p = C(a) || c(a);
|
|
83
|
+
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)) {
|
|
85
|
+
if (n.length !== a.length) return !1;
|
|
86
|
+
for (let e = 0; e < n.length; e++) if (!S(n[e], a[e])) return !1;
|
|
87
|
+
return !0;
|
|
88
|
+
}
|
|
89
|
+
if (i(n) && i(a)) {
|
|
90
|
+
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]));
|
|
92
|
+
}
|
|
93
|
+
return !1;
|
|
94
|
+
}
|
|
95
|
+
function C(e) {
|
|
96
|
+
return typeof e == "number" || typeof e == "bigint";
|
|
97
|
+
}
|
|
98
|
+
function w(e) {
|
|
99
|
+
return typeof e == "bigint" || o(e);
|
|
100
|
+
}
|
|
101
|
+
function T(e) {
|
|
102
|
+
return typeof e == "bigint" ? !0 : typeof e == "number" ? Number.isInteger(e) && e >= -p && e < p : f.test(e) && h(BigInt(e)) === 0;
|
|
103
|
+
}
|
|
104
|
+
function E(e) {
|
|
105
|
+
return typeof e == "number" && Number.isNaN(e);
|
|
106
|
+
}
|
|
107
|
+
function D(e) {
|
|
108
|
+
let t = e.toString;
|
|
109
|
+
return typeof t == "function" && t !== Object.prototype.toString;
|
|
110
|
+
}
|
|
111
|
+
function O(e) {
|
|
112
|
+
if (typeof e == "number") {
|
|
113
|
+
if (e === Infinity) return "INF";
|
|
114
|
+
if (e === -Infinity) return "-INF";
|
|
115
|
+
}
|
|
116
|
+
return String(e);
|
|
117
|
+
}
|
|
118
|
+
function k(e, t) {
|
|
119
|
+
if (e === t) return !0;
|
|
120
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
121
|
+
if (e.length !== t.length) return !1;
|
|
122
|
+
for (let n = 0; n < e.length; n++) if (!k(e[n], t[n])) return !1;
|
|
123
|
+
return !0;
|
|
124
|
+
}
|
|
125
|
+
if (e !== null && t !== null && typeof e == "object" && typeof t == "object" && !Array.isArray(e) && !Array.isArray(t)) {
|
|
126
|
+
let n = e.constructor === Object || e.constructor === void 0, r = t.constructor === Object || t.constructor === void 0;
|
|
127
|
+
if (!n || !r) return !1;
|
|
128
|
+
let i = Object.keys(e), a = Object.keys(t);
|
|
129
|
+
if (i.length !== a.length) return !1;
|
|
130
|
+
for (let [n, r] of i.entries()) if (r !== a[n] || !k(e[r], t[r])) return !1;
|
|
131
|
+
return !0;
|
|
132
|
+
}
|
|
133
|
+
return !1;
|
|
134
|
+
}
|
|
135
|
+
function A(e, n, r) {
|
|
136
|
+
let a = [e, r], o = (e) => i(e) && !s(e);
|
|
137
|
+
if (a.filter((e) => c(e) || o(e) && D(e)).length < 2 && a.filter(o).length === 1) return [
|
|
138
|
+
"!=",
|
|
139
|
+
"<>",
|
|
140
|
+
"!=="
|
|
141
|
+
].includes(n);
|
|
142
|
+
let l = !(t(e) || t(r) || u(e) || u(r)) && (E(e) || E(r)), d = (t) => !l && t(v(e, r));
|
|
143
|
+
switch (n) {
|
|
144
|
+
case "!=":
|
|
145
|
+
case "<>": return !S(e, r);
|
|
146
|
+
case "<": return d((e) => e < 0);
|
|
147
|
+
case ">": return d((e) => e > 0);
|
|
148
|
+
case "<=": return d((e) => e <= 0);
|
|
149
|
+
case ">=": return d((e) => e >= 0);
|
|
150
|
+
case "===": return k(e, r);
|
|
151
|
+
case "!==": return !k(e, r);
|
|
152
|
+
case "<=>": return l || v(e, r) !== 0;
|
|
153
|
+
default: return S(e, r);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export { v as compareValues, S as looseEqual, A as operatorMatch, k as strictEqual };
|