@tolki/utils 1.4.0 → 1.6.0
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 +47 -5
- package/dist/cast.d.ts.map +1 -1
- package/dist/cast.js +93 -67
- package/dist/equality.d.ts +1 -4
- package/dist/equality.d.ts.map +1 -1
- package/dist/equality.js +79 -78
- package/dist/exceptions.d.ts +32 -4
- package/dist/exceptions.d.ts.map +1 -1
- package/dist/exceptions.js +34 -4
- package/dist/guards.d.ts +29 -2
- package/dist/guards.d.ts.map +1 -1
- package/dist/guards.js +88 -80
- package/dist/index.js +97 -76
- package/dist/keys.d.ts +110 -2
- package/dist/keys.d.ts.map +1 -1
- package/dist/keys.js +118 -61
- package/dist/range.d.ts +70 -0
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js +103 -5
- package/dist/reflect.d.ts +16 -2
- package/dist/reflect.d.ts.map +1 -1
- package/dist/reflect.js +19 -9
- package/dist/sorting.d.ts +16 -2
- package/dist/sorting.d.ts.map +1 -1
- package/dist/sorting.js +27 -13
- package/dist/utils.js +97 -76
- package/package.json +2 -2
package/dist/exceptions.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
class n extends Error {
|
|
2
|
+
/**
|
|
3
|
+
* Create a new exception instance.
|
|
4
|
+
*
|
|
5
|
+
* @param message - The exception message
|
|
6
|
+
*/
|
|
7
|
+
constructor(e) {
|
|
8
|
+
super(e), this.name = "InvalidArgumentException";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
1
11
|
class o extends Error {
|
|
2
12
|
/**
|
|
3
13
|
* Create a new exception instance.
|
|
@@ -6,7 +16,7 @@ class o extends Error {
|
|
|
6
16
|
super(""), this.name = "ItemNotFoundException";
|
|
7
17
|
}
|
|
8
18
|
}
|
|
9
|
-
class
|
|
19
|
+
class r extends Error {
|
|
10
20
|
/** The number of items found, as Laravel's public `$count`. */
|
|
11
21
|
count;
|
|
12
22
|
/**
|
|
@@ -14,11 +24,31 @@ class n extends Error {
|
|
|
14
24
|
*
|
|
15
25
|
* @param count - The number of items the lookup matched
|
|
16
26
|
*/
|
|
17
|
-
constructor(
|
|
18
|
-
super(`${
|
|
27
|
+
constructor(e) {
|
|
28
|
+
super(`${e} items were found.`), this.name = "MultipleItemsFoundException", this.count = e;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the number of items found.
|
|
32
|
+
*
|
|
33
|
+
* @returns The number of items the lookup matched
|
|
34
|
+
*/
|
|
35
|
+
getCount() {
|
|
36
|
+
return this.count;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
class s extends Error {
|
|
40
|
+
/**
|
|
41
|
+
* Create a new exception instance.
|
|
42
|
+
*
|
|
43
|
+
* @param message - The exception message
|
|
44
|
+
*/
|
|
45
|
+
constructor(e) {
|
|
46
|
+
super(e), this.name = "UnexpectedValueException";
|
|
19
47
|
}
|
|
20
48
|
}
|
|
21
49
|
export {
|
|
50
|
+
n as InvalidArgumentException,
|
|
22
51
|
o as ItemNotFoundException,
|
|
23
|
-
|
|
52
|
+
r as MultipleItemsFoundException,
|
|
53
|
+
s as UnexpectedValueException
|
|
24
54
|
};
|
package/dist/guards.d.ts
CHANGED
|
@@ -34,6 +34,18 @@ export declare function isObject<T, K extends PropertyKey = PropertyKey>(value:
|
|
|
34
34
|
* isPlainObject([1, 2]); -> false
|
|
35
35
|
*/
|
|
36
36
|
export declare function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a value is an `@tolki/enum` case, the shape `from()` and `cases()` build.
|
|
39
|
+
*
|
|
40
|
+
* @param value - The value to check
|
|
41
|
+
* @returns True for a plain object with its own string `name` and its own string or number `value`
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
*
|
|
45
|
+
* isEnumCase({ value: 1, backed: true, name: "A" }); -> true
|
|
46
|
+
* isEnumCase({ value: 1 }); -> false
|
|
47
|
+
*/
|
|
48
|
+
export declare function isEnumCase(value: unknown): value is Record<"name" | "value", string | number>;
|
|
37
49
|
/**
|
|
38
50
|
* Check if a value is any object (including arrays, null).
|
|
39
51
|
*
|
|
@@ -148,6 +160,19 @@ export declare function isInteger(value: unknown): value is number;
|
|
|
148
160
|
* @returns True if the value is a float
|
|
149
161
|
*/
|
|
150
162
|
export declare function isFloat(value: unknown): value is number;
|
|
163
|
+
/**
|
|
164
|
+
* Check if a value is a number PHP holds as an int: an integer within its 64-bit range, and never -0.
|
|
165
|
+
*
|
|
166
|
+
* @param value - The value to check
|
|
167
|
+
* @returns True if PHP would hold the number as an int, false for a float PHP holds, such as 1.5, 1e19 or -0.0
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
*
|
|
171
|
+
* isPhpInt(2 ** 62); -> true
|
|
172
|
+
* isPhpInt(1e19); -> false
|
|
173
|
+
* isPhpInt(-0); -> false
|
|
174
|
+
*/
|
|
175
|
+
export declare function isPhpInt(value: unknown): value is number;
|
|
151
176
|
/**
|
|
152
177
|
* Check if a value is a positive number.
|
|
153
178
|
*
|
|
@@ -333,8 +358,9 @@ export declare function isTruthy(value: unknown): boolean;
|
|
|
333
358
|
* Determine whether a value is falsy the way PHP's `array_filter()` (no
|
|
334
359
|
* callback) treats it — PHP's own truthiness, not JS's.
|
|
335
360
|
*
|
|
336
|
-
* Drops `false`, `null`/`undefined`, `0`, `""`, `"0"`, and an empty array
|
|
337
|
-
* plain object
|
|
361
|
+
* Drops `false`, `null`/`undefined`, `0`, `0n`, `""`, `"0"`, and an empty array,
|
|
362
|
+
* plain object, `Map` or `Set`; keeps `"00"`, `"0.0"`, `NaN` and every other
|
|
363
|
+
* object, however empty, as PHP keeps every object.
|
|
338
364
|
*
|
|
339
365
|
* @param value - The value to check
|
|
340
366
|
* @returns True if the value is falsy under PHP's rules
|
|
@@ -343,6 +369,7 @@ export declare function isTruthy(value: unknown): boolean;
|
|
|
343
369
|
*
|
|
344
370
|
* isPhpFalsy("0"); -> true
|
|
345
371
|
* isPhpFalsy("00"); -> false
|
|
372
|
+
* isPhpFalsy(new Date(0)); -> false
|
|
346
373
|
*/
|
|
347
374
|
export declare function isPhpFalsy(value: unknown): boolean;
|
|
348
375
|
/**
|
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;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,GAAG,KAAK,IAAI,CAAC,EAAE,CAE5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,GAAG,WAAW,EAC3D,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,GACjC,KAAK,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAEvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CACzB,KAAK,EAAE,OAAO,GACf,KAAK,IAAI,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAQvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE3D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE9D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAczD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;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AgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAEvD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE/D;AAkCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAe7D;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,SAAS,OAAO,EAAE,GAC3B,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAuB7B"}
|
package/dist/guards.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
function
|
|
1
|
+
function b(t) {
|
|
2
2
|
return Array.isArray(t);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return !
|
|
4
|
+
function y(t) {
|
|
5
|
+
return !o(t) && typeof t == "object" && !b(t);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
if (!
|
|
7
|
+
function m(t) {
|
|
8
|
+
if (!y(t))
|
|
9
9
|
return !1;
|
|
10
10
|
const n = Object.getPrototypeOf(t);
|
|
11
11
|
return n === Object.prototype || n === null;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function w(t) {
|
|
14
|
+
return m(t) && Object.hasOwn(t, "name") && e(t.name) && Object.hasOwn(t, "value") && (e(t.value) || r(t.value));
|
|
15
|
+
}
|
|
16
|
+
function j(t) {
|
|
14
17
|
return typeof t == "object";
|
|
15
18
|
}
|
|
16
19
|
function P(t) {
|
|
17
|
-
return !
|
|
20
|
+
return !o(t) && !c(t) && j(t);
|
|
18
21
|
}
|
|
19
|
-
function
|
|
22
|
+
function E(t) {
|
|
20
23
|
if (!P(t) && !u(t))
|
|
21
24
|
return !1;
|
|
22
25
|
const n = Object.getOwnPropertyDescriptor(
|
|
@@ -25,29 +28,32 @@ function T(t) {
|
|
|
25
28
|
)?.value;
|
|
26
29
|
return u(n) && n.prototype === t;
|
|
27
30
|
}
|
|
28
|
-
function
|
|
31
|
+
function e(t) {
|
|
29
32
|
return typeof t == "string";
|
|
30
33
|
}
|
|
31
34
|
function W(t) {
|
|
32
|
-
return !!(
|
|
35
|
+
return !!(e(t) || r(t) || S(t));
|
|
33
36
|
}
|
|
34
|
-
function
|
|
35
|
-
return !!(
|
|
37
|
+
function S(t) {
|
|
38
|
+
return !!(y(t) && u(t.toString));
|
|
36
39
|
}
|
|
37
|
-
function
|
|
40
|
+
function r(t) {
|
|
38
41
|
return typeof t == "number" && !isNaN(t);
|
|
39
42
|
}
|
|
40
|
-
function
|
|
41
|
-
return
|
|
43
|
+
function d(t) {
|
|
44
|
+
return r(t) && Number.isInteger(t);
|
|
45
|
+
}
|
|
46
|
+
function z(t) {
|
|
47
|
+
return r(t) && !Number.isInteger(t);
|
|
42
48
|
}
|
|
43
49
|
function R(t) {
|
|
44
|
-
return
|
|
50
|
+
return d(t) && t >= -9223372036854776e3 && t < 2 ** 63 && !Object.is(t, -0);
|
|
45
51
|
}
|
|
46
52
|
function _(t) {
|
|
47
|
-
return
|
|
53
|
+
return r(t) && t >= 0;
|
|
48
54
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
55
|
+
function B(t) {
|
|
56
|
+
return r(t) && t < 0;
|
|
51
57
|
}
|
|
52
58
|
function N(t) {
|
|
53
59
|
return typeof t == "boolean";
|
|
@@ -58,63 +64,63 @@ function u(t) {
|
|
|
58
64
|
function c(t) {
|
|
59
65
|
return typeof t > "u";
|
|
60
66
|
}
|
|
61
|
-
function
|
|
67
|
+
function A(t) {
|
|
62
68
|
return typeof t == "symbol";
|
|
63
69
|
}
|
|
64
|
-
function
|
|
70
|
+
function o(t) {
|
|
65
71
|
return t === null;
|
|
66
72
|
}
|
|
67
|
-
function
|
|
73
|
+
function h(t) {
|
|
68
74
|
return t instanceof Map;
|
|
69
75
|
}
|
|
70
|
-
function
|
|
76
|
+
function g(t) {
|
|
71
77
|
return t instanceof Set;
|
|
72
78
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
79
|
+
function C(t) {
|
|
80
|
+
return o(t) || c(t) || e(t) ? !1 : u(
|
|
75
81
|
t[Symbol.iterator]
|
|
76
82
|
);
|
|
77
83
|
}
|
|
78
|
-
function
|
|
84
|
+
function D(t) {
|
|
79
85
|
return t instanceof WeakMap;
|
|
80
86
|
}
|
|
81
|
-
function
|
|
87
|
+
function U(t) {
|
|
82
88
|
return t instanceof WeakSet;
|
|
83
89
|
}
|
|
84
|
-
function
|
|
85
|
-
return Number.isNaN(t) ? !0 :
|
|
86
|
-
}
|
|
87
|
-
function U(t) {
|
|
88
|
-
return !A(t);
|
|
90
|
+
function k(t) {
|
|
91
|
+
return Number.isNaN(t) ? !0 : r(t) ? t === 0 : c(t) || o(t) ? !0 : N(t) ? t === !1 : e(t) ? t.trim() === "" : h(t) || g(t) ? t.size === 0 : b(t) ? t.length === 0 : y(t) ? Object.keys(t).length === 0 : !1;
|
|
89
92
|
}
|
|
90
93
|
function V(t) {
|
|
91
|
-
return
|
|
94
|
+
return !k(t);
|
|
92
95
|
}
|
|
93
|
-
const k = /^[ \t\n\r\v\f]*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[ \t\n\r\v\f]*$/;
|
|
94
96
|
function x(t) {
|
|
95
|
-
return
|
|
97
|
+
return t === !1 || t === null || c(t) || t === 0 || t === 0n || t === "" || t === "0" ? !0 : b(t) ? t.length === 0 : h(t) || g(t) ? t.size === 0 : m(t) ? Object.keys(t).length === 0 : !1;
|
|
98
|
+
}
|
|
99
|
+
const I = /^[ \t\n\r\v\f]*[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[ \t\n\r\v\f]*$/;
|
|
100
|
+
function G(t) {
|
|
101
|
+
return typeof t == "number" ? !0 : e(t) ? I.test(t) : !1;
|
|
96
102
|
}
|
|
97
103
|
function M(t) {
|
|
98
|
-
return
|
|
104
|
+
return o(t) || N(t) || r(t) || e(t) || A(t) || c(t);
|
|
99
105
|
}
|
|
100
|
-
function
|
|
106
|
+
function H(t) {
|
|
101
107
|
return !M(t);
|
|
102
108
|
}
|
|
103
109
|
function F(t) {
|
|
104
|
-
return
|
|
110
|
+
return r(t) && Number.isFinite(t);
|
|
105
111
|
}
|
|
106
|
-
function
|
|
112
|
+
function $(t) {
|
|
107
113
|
return Array.isArray(t);
|
|
108
114
|
}
|
|
109
|
-
function
|
|
110
|
-
return
|
|
115
|
+
function q(t) {
|
|
116
|
+
return b(t) || m(t) || h(t);
|
|
111
117
|
}
|
|
112
118
|
function p(t) {
|
|
113
|
-
if (
|
|
119
|
+
if (e(t))
|
|
114
120
|
return t;
|
|
115
121
|
if (N(t))
|
|
116
122
|
return t ? "1" : "";
|
|
117
|
-
if (
|
|
123
|
+
if (o(t))
|
|
118
124
|
return "";
|
|
119
125
|
if (F(t)) {
|
|
120
126
|
const n = String(t);
|
|
@@ -122,55 +128,57 @@ function p(t) {
|
|
|
122
128
|
}
|
|
123
129
|
return null;
|
|
124
130
|
}
|
|
125
|
-
function
|
|
126
|
-
const f = p(t),
|
|
127
|
-
return f !== null &&
|
|
131
|
+
function T(t, n) {
|
|
132
|
+
const f = p(t), i = p(n);
|
|
133
|
+
return f !== null && i !== null ? f === i : t === n || typeof t == "number" && typeof n == "number" && Number.isNaN(t) && Number.isNaN(n);
|
|
128
134
|
}
|
|
129
|
-
function
|
|
135
|
+
function J(t) {
|
|
130
136
|
const n = /* @__PURE__ */ new Set(), f = [];
|
|
131
|
-
for (const
|
|
132
|
-
const s = p(
|
|
133
|
-
|
|
137
|
+
for (const i of t) {
|
|
138
|
+
const s = p(i);
|
|
139
|
+
o(s) ? f.push(i) : n.add(s);
|
|
134
140
|
}
|
|
135
|
-
return (
|
|
136
|
-
const s = p(
|
|
137
|
-
return
|
|
141
|
+
return (i) => {
|
|
142
|
+
const s = p(i);
|
|
143
|
+
return o(s) ? f.some((O) => T(i, O)) : n.has(s);
|
|
138
144
|
};
|
|
139
145
|
}
|
|
140
146
|
export {
|
|
141
|
-
|
|
142
|
-
|
|
147
|
+
$ as isAccessibleData,
|
|
148
|
+
b as isArray,
|
|
143
149
|
N as isBoolean,
|
|
144
|
-
|
|
150
|
+
w as isEnumCase,
|
|
151
|
+
k as isFalsy,
|
|
145
152
|
F as isFiniteNumber,
|
|
146
|
-
|
|
153
|
+
z as isFloat,
|
|
147
154
|
u as isFunction,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
d as isInteger,
|
|
156
|
+
C as isIterable,
|
|
157
|
+
h as isMap,
|
|
158
|
+
B as isNegativeNumber,
|
|
159
|
+
H as isNonPrimitive,
|
|
160
|
+
o as isNull,
|
|
161
|
+
r as isNumber,
|
|
162
|
+
y as isObject,
|
|
163
|
+
j as isObjectAny,
|
|
164
|
+
q as isPhpAccessible,
|
|
165
|
+
x as isPhpFalsy,
|
|
166
|
+
R as isPhpInt,
|
|
167
|
+
G as isPhpNumeric,
|
|
168
|
+
m as isPlainObject,
|
|
161
169
|
_ as isPositiveNumber,
|
|
162
170
|
M as isPrimitive,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
E as isPrototypeObject,
|
|
172
|
+
g as isSet,
|
|
173
|
+
e as isString,
|
|
166
174
|
W as isStringable,
|
|
167
|
-
|
|
168
|
-
|
|
175
|
+
A as isSymbol,
|
|
176
|
+
V as isTruthy,
|
|
169
177
|
P as isTruthyObject,
|
|
170
178
|
c as isUndefined,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
D as isWeakMap,
|
|
180
|
+
U as isWeakSet,
|
|
181
|
+
S as objectToString,
|
|
182
|
+
T as phpValueMatch,
|
|
183
|
+
J as phpValueMatcher
|
|
176
184
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,81 +1,102 @@
|
|
|
1
|
-
import { arrayableItems as
|
|
2
|
-
import { compareValues as
|
|
3
|
-
import { ItemNotFoundException as
|
|
4
|
-
import { isAccessibleData as
|
|
5
|
-
import { defineKey as
|
|
6
|
-
import { resolveSliceRange as
|
|
7
|
-
import { phpTypeName as
|
|
8
|
-
import { createSortSpecComparator as
|
|
9
|
-
import { arrayValueMessage as
|
|
1
|
+
import { arrayableItems as t, arrayableValues as i, castableToArray as s, cssListItemToString as a, getAccessibleValues as o, normalizeToArray as p, phpIntArgument as n, phpIntCast as l, phpStringCast as y, toArrayable as m, toJsonSerializable as u, toJsonable as c, toPhpKeyString as b } from "./cast.js";
|
|
2
|
+
import { compareValues as g, looseEqual as x, operatorMatch as S, strictEqual as f } from "./equality.js";
|
|
3
|
+
import { InvalidArgumentException as K, ItemNotFoundException as d, MultipleItemsFoundException as P, UnexpectedValueException as A } from "./exceptions.js";
|
|
4
|
+
import { isAccessibleData as E, isArray as M, isBoolean as N, isEnumCase as T, isFalsy as F, isFiniteNumber as O, isFloat as V, isFunction as C, isInteger as j, isIterable as k, isMap as w, isNegativeNumber as L, isNonPrimitive as U, isNull as z, isNumber as D, isObject as R, isObjectAny as q, isPhpAccessible as J, isPhpFalsy as W, isPhpInt as B, isPhpNumeric as G, isPlainObject as H, isPositiveNumber as Q, isPrimitive as X, isPrototypeObject as Y, isSet as Z, isString as _, isStringable as $, isSymbol as ee, isTruthy as re, isTruthyObject as te, isUndefined as ie, isWeakMap as se, isWeakSet as ae, objectToString as oe, phpValueMatch as pe, phpValueMatcher as ne } from "./guards.js";
|
|
5
|
+
import { arrayKeyExistsError as ye, defineKey as me, deleteMapKey as ue, entriesKeyValue as ce, hasOwnToString as be, isIllegalOffset as he, isIntegerLikeKey as ge, isPhpArrayKey as xe, isUnsafeKey as Se, keyedEntries as fe, nextIntegerKey as Ie, phpArrayKey as Ke, phpComputedKey as de, readMapKey as Pe, reindexIntegerKeys as Ae, renumberPhpIntegerKeys as ve, writeMapKey as Ee } from "./keys.js";
|
|
6
|
+
import { resolvePadLength as Ne, resolveRangeSize as Te, resolveSliceRange as Fe, resolveSpliceRange as Oe, resolveTakeCount as Ve } from "./range.js";
|
|
7
|
+
import { phpDebugType as je, phpTypeName as ke, resolveDefault as we, typeOf as Le } from "./reflect.js";
|
|
8
|
+
import { createSortSpecComparator as ze, phpSortComparator as De } from "./sorting.js";
|
|
9
|
+
import { arrayValueMessage as qe, lowerFirst as Je, toLower as We, toUpper as Be, upperFirst as Ge } from "./string.js";
|
|
10
10
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
K as InvalidArgumentException,
|
|
12
|
+
d as ItemNotFoundException,
|
|
13
|
+
P as MultipleItemsFoundException,
|
|
14
|
+
A as UnexpectedValueException,
|
|
15
|
+
ye as arrayKeyExistsError,
|
|
16
|
+
qe as arrayValueMessage,
|
|
17
|
+
t as arrayableItems,
|
|
18
|
+
i as arrayableValues,
|
|
16
19
|
s as castableToArray,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
L as
|
|
39
|
-
U as
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
W as
|
|
47
|
-
B as
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
20
|
+
g as compareValues,
|
|
21
|
+
ze as createSortSpecComparator,
|
|
22
|
+
a as cssListItemToString,
|
|
23
|
+
me as defineKey,
|
|
24
|
+
ue as deleteMapKey,
|
|
25
|
+
ce as entriesKeyValue,
|
|
26
|
+
o as getAccessibleValues,
|
|
27
|
+
be as hasOwnToString,
|
|
28
|
+
E as isAccessibleData,
|
|
29
|
+
M as isArray,
|
|
30
|
+
N as isBoolean,
|
|
31
|
+
T as isEnumCase,
|
|
32
|
+
F as isFalsy,
|
|
33
|
+
O as isFiniteNumber,
|
|
34
|
+
V as isFloat,
|
|
35
|
+
C as isFunction,
|
|
36
|
+
he as isIllegalOffset,
|
|
37
|
+
j as isInteger,
|
|
38
|
+
ge as isIntegerLikeKey,
|
|
39
|
+
k as isIterable,
|
|
40
|
+
w as isMap,
|
|
41
|
+
L as isNegativeNumber,
|
|
42
|
+
U as isNonPrimitive,
|
|
43
|
+
z as isNull,
|
|
44
|
+
D as isNumber,
|
|
45
|
+
R as isObject,
|
|
46
|
+
q as isObjectAny,
|
|
47
|
+
J as isPhpAccessible,
|
|
48
|
+
xe as isPhpArrayKey,
|
|
49
|
+
W as isPhpFalsy,
|
|
50
|
+
B as isPhpInt,
|
|
51
|
+
G as isPhpNumeric,
|
|
52
|
+
H as isPlainObject,
|
|
53
|
+
Q as isPositiveNumber,
|
|
54
|
+
X as isPrimitive,
|
|
55
|
+
Y as isPrototypeObject,
|
|
56
|
+
Z as isSet,
|
|
57
|
+
_ as isString,
|
|
58
|
+
$ as isStringable,
|
|
59
|
+
ee as isSymbol,
|
|
60
|
+
re as isTruthy,
|
|
61
|
+
te as isTruthyObject,
|
|
62
|
+
ie as isUndefined,
|
|
63
|
+
Se as isUnsafeKey,
|
|
64
|
+
se as isWeakMap,
|
|
65
|
+
ae as isWeakSet,
|
|
66
|
+
fe as keyedEntries,
|
|
67
|
+
x as looseEqual,
|
|
68
|
+
Je as lowerFirst,
|
|
69
|
+
Ie as nextIntegerKey,
|
|
61
70
|
p as normalizeToArray,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
oe as objectToString,
|
|
72
|
+
S as operatorMatch,
|
|
73
|
+
Ke as phpArrayKey,
|
|
74
|
+
de as phpComputedKey,
|
|
75
|
+
je as phpDebugType,
|
|
76
|
+
n as phpIntArgument,
|
|
77
|
+
l as phpIntCast,
|
|
78
|
+
De as phpSortComparator,
|
|
79
|
+
y as phpStringCast,
|
|
80
|
+
ke as phpTypeName,
|
|
81
|
+
pe as phpValueMatch,
|
|
82
|
+
ne as phpValueMatcher,
|
|
83
|
+
Pe as readMapKey,
|
|
84
|
+
Ae as reindexIntegerKeys,
|
|
85
|
+
ve as renumberPhpIntegerKeys,
|
|
86
|
+
we as resolveDefault,
|
|
87
|
+
Ne as resolvePadLength,
|
|
88
|
+
Te as resolveRangeSize,
|
|
89
|
+
Fe as resolveSliceRange,
|
|
90
|
+
Oe as resolveSpliceRange,
|
|
91
|
+
Ve as resolveTakeCount,
|
|
72
92
|
f as strictEqual,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
93
|
+
m as toArrayable,
|
|
94
|
+
u as toJsonSerializable,
|
|
95
|
+
c as toJsonable,
|
|
96
|
+
We as toLower,
|
|
97
|
+
b as toPhpKeyString,
|
|
98
|
+
Be as toUpper,
|
|
99
|
+
Le as typeOf,
|
|
100
|
+
Ge as upperFirst,
|
|
101
|
+
Ee as writeMapKey
|
|
81
102
|
};
|