@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/sorting.js
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { phpIntCast as g } from "./cast.js";
|
|
2
|
+
import { compareValues as C } from "./equality.js";
|
|
3
|
+
import { isArray as a, isFunction as S, isUndefined as h, isBoolean as A, isNumber as l } from "./guards.js";
|
|
4
|
+
function B(r) {
|
|
5
|
+
return function(n, t) {
|
|
6
|
+
if (c(n))
|
|
7
|
+
return n;
|
|
8
|
+
if (a(n) && c(n[0]))
|
|
9
|
+
return n[0];
|
|
10
|
+
const [u, o] = a(n) ? n : [n, void 0], m = h(o) || o === !0 || o === "asc" || o === "Ascending", s = t || !m;
|
|
11
|
+
return (p, d) => {
|
|
12
|
+
const e = C(r(p, u), r(d, u));
|
|
13
|
+
return s ? -e : e;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
16
|
}
|
|
17
|
+
function c(r) {
|
|
18
|
+
return S(r);
|
|
19
|
+
}
|
|
20
|
+
function D(r) {
|
|
21
|
+
return (i, n) => {
|
|
22
|
+
const t = r(i, n);
|
|
23
|
+
return t === !1 ? -f(r(n, i)) : f(t);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function f(r) {
|
|
27
|
+
return A(r) ? r ? 1 : 0 : l(r) ? Math.sign(g(r)) : 0;
|
|
28
|
+
}
|
|
16
29
|
export {
|
|
17
|
-
|
|
30
|
+
B as createSortSpecComparator,
|
|
31
|
+
D as phpSortComparator
|
|
18
32
|
};
|
package/dist/utils.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
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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.9.0"
|
|
19
19
|
},
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"files": [
|