es-toolkit 1.9.0-dev.197 → 1.9.0-dev.199
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/array/index.mjs +16 -16
- package/dist/chunk-236H5JZJ.mjs +1 -0
- package/dist/chunk-5G67ICEW.mjs +9 -0
- package/dist/chunk-5G67ICEW.mjs.map +1 -0
- package/dist/chunk-ASJF5D6C.mjs +1 -0
- package/dist/chunk-JYSV56US.mjs +41 -0
- package/dist/chunk-JYSV56US.mjs.map +1 -0
- package/dist/function/index.d.mts +1 -0
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.js +7 -0
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +7 -3
- package/dist/function/negate.d.mts +3 -0
- package/dist/function/negate.d.ts +3 -0
- package/dist/function/negate.js +33 -0
- package/dist/function/negate.js.map +1 -0
- package/dist/function/negate.mjs +8 -0
- package/dist/function/negate.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +49 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -72
- package/dist/math/index.mjs +6 -6
- package/dist/object/index.mjs +3 -3
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +45 -0
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +13 -7
- package/dist/predicate/isEqual.d.mts +17 -0
- package/dist/predicate/isEqual.d.ts +17 -0
- package/dist/predicate/isEqual.js +73 -0
- package/dist/predicate/isEqual.js.map +1 -0
- package/dist/predicate/isEqual.mjs +10 -0
- package/dist/predicate/isEqual.mjs.map +1 -0
- package/dist/string/index.mjs +7 -7
- package/package.json +1 -1
- package/dist/chunk-MAJSPFA6.mjs +0 -1
- package/dist/chunk-N6EM6ETS.mjs +0 -1
- /package/dist/{chunk-MAJSPFA6.mjs.map → chunk-236H5JZJ.mjs.map} +0 -0
- /package/dist/{chunk-N6EM6ETS.mjs.map → chunk-ASJF5D6C.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -3,36 +3,42 @@ import {
|
|
|
3
3
|
delay
|
|
4
4
|
} from "./chunk-O64NE2P4.mjs";
|
|
5
5
|
import "./chunk-QKYYOLJ6.mjs";
|
|
6
|
+
import {
|
|
7
|
+
kebabCase
|
|
8
|
+
} from "./chunk-EYYZQFOP.mjs";
|
|
9
|
+
import {
|
|
10
|
+
lowerCase
|
|
11
|
+
} from "./chunk-5IKVJGHO.mjs";
|
|
6
12
|
import {
|
|
7
13
|
snakeCase
|
|
8
14
|
} from "./chunk-F3WCQQET.mjs";
|
|
9
15
|
import {
|
|
10
16
|
camelCase
|
|
11
17
|
} from "./chunk-XGCYC4YA.mjs";
|
|
18
|
+
import "./chunk-WVQ7YVRK.mjs";
|
|
12
19
|
import {
|
|
13
20
|
capitalize
|
|
14
21
|
} from "./chunk-U56ZOM7L.mjs";
|
|
22
|
+
import "./chunk-ASJF5D6C.mjs";
|
|
15
23
|
import {
|
|
16
|
-
|
|
17
|
-
} from "./chunk-
|
|
24
|
+
isNotNil
|
|
25
|
+
} from "./chunk-BMRTZMRE.mjs";
|
|
18
26
|
import {
|
|
19
|
-
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-WVQ7YVRK.mjs";
|
|
22
|
-
import "./chunk-MAJSPFA6.mjs";
|
|
27
|
+
isNull
|
|
28
|
+
} from "./chunk-AIRSKN47.mjs";
|
|
23
29
|
import {
|
|
24
30
|
isUndefined
|
|
25
31
|
} from "./chunk-VH2PV426.mjs";
|
|
32
|
+
import {
|
|
33
|
+
isEqual
|
|
34
|
+
} from "./chunk-JYSV56US.mjs";
|
|
26
35
|
import {
|
|
27
36
|
isNil
|
|
28
37
|
} from "./chunk-WMM7TZLG.mjs";
|
|
29
|
-
import {
|
|
30
|
-
isNotNil
|
|
31
|
-
} from "./chunk-BMRTZMRE.mjs";
|
|
32
|
-
import {
|
|
33
|
-
isNull
|
|
34
|
-
} from "./chunk-AIRSKN47.mjs";
|
|
35
38
|
import "./chunk-OSOLEQLZ.mjs";
|
|
39
|
+
import {
|
|
40
|
+
invert
|
|
41
|
+
} from "./chunk-74WWMNZS.mjs";
|
|
36
42
|
import {
|
|
37
43
|
omit
|
|
38
44
|
} from "./chunk-4E4D3BMI.mjs";
|
|
@@ -48,10 +54,48 @@ import {
|
|
|
48
54
|
import {
|
|
49
55
|
clone
|
|
50
56
|
} from "./chunk-U4JGKZ56.mjs";
|
|
57
|
+
import "./chunk-TLVQSNOE.mjs";
|
|
51
58
|
import {
|
|
52
|
-
|
|
53
|
-
} from "./chunk-
|
|
59
|
+
meanBy
|
|
60
|
+
} from "./chunk-IZAD2S7R.mjs";
|
|
61
|
+
import {
|
|
62
|
+
range
|
|
63
|
+
} from "./chunk-DPH2KE6O.mjs";
|
|
64
|
+
import {
|
|
65
|
+
round
|
|
66
|
+
} from "./chunk-5PMKOZ2F.mjs";
|
|
67
|
+
import {
|
|
68
|
+
clamp
|
|
69
|
+
} from "./chunk-MLCL773E.mjs";
|
|
70
|
+
import {
|
|
71
|
+
inRange
|
|
72
|
+
} from "./chunk-BH6HLGBA.mjs";
|
|
73
|
+
import {
|
|
74
|
+
mean
|
|
75
|
+
} from "./chunk-GDC64SYJ.mjs";
|
|
76
|
+
import {
|
|
77
|
+
sum
|
|
78
|
+
} from "./chunk-2SLTL4KL.mjs";
|
|
79
|
+
import "./chunk-236H5JZJ.mjs";
|
|
80
|
+
import {
|
|
81
|
+
negate
|
|
82
|
+
} from "./chunk-5G67ICEW.mjs";
|
|
83
|
+
import {
|
|
84
|
+
noop
|
|
85
|
+
} from "./chunk-LKXCOLNY.mjs";
|
|
86
|
+
import {
|
|
87
|
+
once
|
|
88
|
+
} from "./chunk-CMBC4MXG.mjs";
|
|
89
|
+
import {
|
|
90
|
+
throttle
|
|
91
|
+
} from "./chunk-QOJGMVVR.mjs";
|
|
92
|
+
import {
|
|
93
|
+
debounce
|
|
94
|
+
} from "./chunk-3IP4JVLL.mjs";
|
|
54
95
|
import "./chunk-2MRZANXZ.mjs";
|
|
96
|
+
import {
|
|
97
|
+
xor
|
|
98
|
+
} from "./chunk-L7FQX5MN.mjs";
|
|
55
99
|
import {
|
|
56
100
|
xorBy
|
|
57
101
|
} from "./chunk-Q47NGNXT.mjs";
|
|
@@ -67,6 +111,9 @@ import {
|
|
|
67
111
|
import {
|
|
68
112
|
zipWith
|
|
69
113
|
} from "./chunk-4KYXHZ4R.mjs";
|
|
114
|
+
import {
|
|
115
|
+
unionBy
|
|
116
|
+
} from "./chunk-NFS7RWWE.mjs";
|
|
70
117
|
import {
|
|
71
118
|
unionWith
|
|
72
119
|
} from "./chunk-2ZCITDMK.mjs";
|
|
@@ -86,8 +133,8 @@ import {
|
|
|
86
133
|
without
|
|
87
134
|
} from "./chunk-PYEYV7BY.mjs";
|
|
88
135
|
import {
|
|
89
|
-
|
|
90
|
-
} from "./chunk-
|
|
136
|
+
shuffle
|
|
137
|
+
} from "./chunk-G7UQ5PUR.mjs";
|
|
91
138
|
import {
|
|
92
139
|
tail
|
|
93
140
|
} from "./chunk-OF6NM4G7.mjs";
|
|
@@ -113,8 +160,8 @@ import {
|
|
|
113
160
|
uniq
|
|
114
161
|
} from "./chunk-DVK2N4KC.mjs";
|
|
115
162
|
import {
|
|
116
|
-
|
|
117
|
-
} from "./chunk-
|
|
163
|
+
keyBy
|
|
164
|
+
} from "./chunk-AJKZMN2V.mjs";
|
|
118
165
|
import {
|
|
119
166
|
last
|
|
120
167
|
} from "./chunk-KPBQ7OUY.mjs";
|
|
@@ -137,8 +184,14 @@ import {
|
|
|
137
184
|
sampleSize
|
|
138
185
|
} from "./chunk-EHSKB6DF.mjs";
|
|
139
186
|
import {
|
|
140
|
-
|
|
141
|
-
} from "./chunk-
|
|
187
|
+
randomInt
|
|
188
|
+
} from "./chunk-GIWAOOFY.mjs";
|
|
189
|
+
import {
|
|
190
|
+
random
|
|
191
|
+
} from "./chunk-SYWMYQYJ.mjs";
|
|
192
|
+
import {
|
|
193
|
+
forEachRight
|
|
194
|
+
} from "./chunk-IEA53J7P.mjs";
|
|
142
195
|
import {
|
|
143
196
|
groupBy
|
|
144
197
|
} from "./chunk-E6E4RZLN.mjs";
|
|
@@ -158,8 +211,8 @@ import {
|
|
|
158
211
|
intersectionWith
|
|
159
212
|
} from "./chunk-XI7KRD2C.mjs";
|
|
160
213
|
import {
|
|
161
|
-
|
|
162
|
-
} from "./chunk-
|
|
214
|
+
differenceWith
|
|
215
|
+
} from "./chunk-6NVQAHXP.mjs";
|
|
163
216
|
import {
|
|
164
217
|
drop
|
|
165
218
|
} from "./chunk-S3CORED5.mjs";
|
|
@@ -181,9 +234,10 @@ import {
|
|
|
181
234
|
import {
|
|
182
235
|
flatten
|
|
183
236
|
} from "./chunk-33MSBDC6.mjs";
|
|
237
|
+
import "./chunk-FZEZH22H.mjs";
|
|
184
238
|
import {
|
|
185
|
-
|
|
186
|
-
} from "./chunk-
|
|
239
|
+
AbortError
|
|
240
|
+
} from "./chunk-DXB7EZUQ.mjs";
|
|
187
241
|
import {
|
|
188
242
|
chunk
|
|
189
243
|
} from "./chunk-E6C5EZQA.mjs";
|
|
@@ -199,54 +253,6 @@ import {
|
|
|
199
253
|
import {
|
|
200
254
|
differenceBy
|
|
201
255
|
} from "./chunk-LVWX5B43.mjs";
|
|
202
|
-
import {
|
|
203
|
-
differenceWith
|
|
204
|
-
} from "./chunk-6NVQAHXP.mjs";
|
|
205
|
-
import "./chunk-TLVQSNOE.mjs";
|
|
206
|
-
import {
|
|
207
|
-
round
|
|
208
|
-
} from "./chunk-5PMKOZ2F.mjs";
|
|
209
|
-
import {
|
|
210
|
-
clamp
|
|
211
|
-
} from "./chunk-MLCL773E.mjs";
|
|
212
|
-
import {
|
|
213
|
-
inRange
|
|
214
|
-
} from "./chunk-BH6HLGBA.mjs";
|
|
215
|
-
import {
|
|
216
|
-
meanBy
|
|
217
|
-
} from "./chunk-IZAD2S7R.mjs";
|
|
218
|
-
import {
|
|
219
|
-
mean
|
|
220
|
-
} from "./chunk-GDC64SYJ.mjs";
|
|
221
|
-
import {
|
|
222
|
-
sum
|
|
223
|
-
} from "./chunk-2SLTL4KL.mjs";
|
|
224
|
-
import {
|
|
225
|
-
randomInt
|
|
226
|
-
} from "./chunk-GIWAOOFY.mjs";
|
|
227
|
-
import {
|
|
228
|
-
random
|
|
229
|
-
} from "./chunk-SYWMYQYJ.mjs";
|
|
230
|
-
import {
|
|
231
|
-
range
|
|
232
|
-
} from "./chunk-DPH2KE6O.mjs";
|
|
233
|
-
import "./chunk-FZEZH22H.mjs";
|
|
234
|
-
import {
|
|
235
|
-
AbortError
|
|
236
|
-
} from "./chunk-DXB7EZUQ.mjs";
|
|
237
|
-
import "./chunk-N6EM6ETS.mjs";
|
|
238
|
-
import {
|
|
239
|
-
debounce
|
|
240
|
-
} from "./chunk-3IP4JVLL.mjs";
|
|
241
|
-
import {
|
|
242
|
-
noop
|
|
243
|
-
} from "./chunk-LKXCOLNY.mjs";
|
|
244
|
-
import {
|
|
245
|
-
once
|
|
246
|
-
} from "./chunk-CMBC4MXG.mjs";
|
|
247
|
-
import {
|
|
248
|
-
throttle
|
|
249
|
-
} from "./chunk-QOJGMVVR.mjs";
|
|
250
256
|
import "./chunk-2HIMLZE3.mjs";
|
|
251
257
|
export {
|
|
252
258
|
AbortError,
|
|
@@ -278,6 +284,7 @@ export {
|
|
|
278
284
|
intersectionBy,
|
|
279
285
|
intersectionWith,
|
|
280
286
|
invert,
|
|
287
|
+
isEqual,
|
|
281
288
|
isNil,
|
|
282
289
|
isNotNil,
|
|
283
290
|
isNull,
|
|
@@ -290,6 +297,7 @@ export {
|
|
|
290
297
|
mean,
|
|
291
298
|
meanBy,
|
|
292
299
|
minBy,
|
|
300
|
+
negate,
|
|
293
301
|
noop,
|
|
294
302
|
omit,
|
|
295
303
|
omitBy,
|
package/dist/math/index.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import "../chunk-TLVQSNOE.mjs";
|
|
2
|
+
import {
|
|
3
|
+
meanBy
|
|
4
|
+
} from "../chunk-IZAD2S7R.mjs";
|
|
5
|
+
import {
|
|
6
|
+
range
|
|
7
|
+
} from "../chunk-DPH2KE6O.mjs";
|
|
2
8
|
import {
|
|
3
9
|
round
|
|
4
10
|
} from "../chunk-5PMKOZ2F.mjs";
|
|
@@ -8,9 +14,6 @@ import {
|
|
|
8
14
|
import {
|
|
9
15
|
inRange
|
|
10
16
|
} from "../chunk-BH6HLGBA.mjs";
|
|
11
|
-
import {
|
|
12
|
-
meanBy
|
|
13
|
-
} from "../chunk-IZAD2S7R.mjs";
|
|
14
17
|
import {
|
|
15
18
|
mean
|
|
16
19
|
} from "../chunk-GDC64SYJ.mjs";
|
|
@@ -23,9 +26,6 @@ import {
|
|
|
23
26
|
import {
|
|
24
27
|
random
|
|
25
28
|
} from "../chunk-SYWMYQYJ.mjs";
|
|
26
|
-
import {
|
|
27
|
-
range
|
|
28
|
-
} from "../chunk-DPH2KE6O.mjs";
|
|
29
29
|
import "../chunk-2HIMLZE3.mjs";
|
|
30
30
|
export {
|
|
31
31
|
clamp,
|
package/dist/object/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-OSOLEQLZ.mjs";
|
|
2
|
+
import {
|
|
3
|
+
invert
|
|
4
|
+
} from "../chunk-74WWMNZS.mjs";
|
|
2
5
|
import {
|
|
3
6
|
omit
|
|
4
7
|
} from "../chunk-4E4D3BMI.mjs";
|
|
@@ -14,9 +17,6 @@ import {
|
|
|
14
17
|
import {
|
|
15
18
|
clone
|
|
16
19
|
} from "../chunk-U4JGKZ56.mjs";
|
|
17
|
-
import {
|
|
18
|
-
invert
|
|
19
|
-
} from "../chunk-74WWMNZS.mjs";
|
|
20
20
|
import "../chunk-2HIMLZE3.mjs";
|
|
21
21
|
export {
|
|
22
22
|
clone,
|
package/dist/predicate/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/predicate/index.ts
|
|
21
21
|
var predicate_exports = {};
|
|
22
22
|
__export(predicate_exports, {
|
|
23
|
+
isEqual: () => isEqual,
|
|
23
24
|
isNil: () => isNil,
|
|
24
25
|
isNotNil: () => isNotNil,
|
|
25
26
|
isNull: () => isNull,
|
|
@@ -27,6 +28,49 @@ __export(predicate_exports, {
|
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(predicate_exports);
|
|
29
30
|
|
|
31
|
+
// src/array/uniq.ts
|
|
32
|
+
function uniq(arr) {
|
|
33
|
+
return Array.from(new Set(arr));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/array/union.ts
|
|
37
|
+
function union(arr1, arr2) {
|
|
38
|
+
return uniq(arr1.concat(arr2));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/predicate/isEqual.ts
|
|
42
|
+
function isEqual(a, b) {
|
|
43
|
+
if (Object.is(a, b)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (a instanceof Date && b instanceof Date) {
|
|
47
|
+
return a.getTime() === b.getTime();
|
|
48
|
+
}
|
|
49
|
+
if (a instanceof RegExp && b instanceof RegExp) {
|
|
50
|
+
return a.source === b.source && a.flags === b.flags;
|
|
51
|
+
}
|
|
52
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const aKeys = Object.keys(a);
|
|
56
|
+
const bKeys = Object.keys(b);
|
|
57
|
+
if (aKeys.length !== bKeys.length) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (union(aKeys, bKeys).length !== aKeys.length) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
64
|
+
const propKey = aKeys[i];
|
|
65
|
+
const aProp = a[propKey];
|
|
66
|
+
const bProp = b[propKey];
|
|
67
|
+
if (!isEqual(aProp, bProp)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
30
74
|
// src/predicate/isNil.ts
|
|
31
75
|
function isNil(x) {
|
|
32
76
|
return x == null;
|
|
@@ -48,6 +92,7 @@ function isUndefined(x) {
|
|
|
48
92
|
}
|
|
49
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
94
|
0 && (module.exports = {
|
|
95
|
+
isEqual,
|
|
51
96
|
isNil,
|
|
52
97
|
isNotNil,
|
|
53
98
|
isNull,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predicate/index.ts","../../src/predicate/isNil.ts","../../src/predicate/isNotNil.ts","../../src/predicate/isNull.ts","../../src/predicate/isUndefined.ts"],"sourcesContent":["export { isNil } from './isNil.ts';\nexport { isNotNil } from './isNotNil.ts';\nexport { isNull } from './isNull.ts';\nexport { isUndefined } from './isUndefined.ts';\n","/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x == null;\n}\n","/**\n * Checks if the given value is not null nor undefined.\n *\n * The main use of this function is to be used with TypeScript as a type predicate.\n *\n * @template T - The type of value.\n * @param {T | null | undefined} x - The value to test if it is not null nor undefined.\n * @returns {x is T} True if the value is not null nor undefined, false otherwise.\n *\n * @example\n * // Here the type of `arr` is (number | undefined)[]\n * const arr = [1, undefined, 3];\n * // Here the type of `result` is number[]\n * const result = arr.filter(isNotNil);\n * // result will be [1, 3]\n */\nexport function isNotNil<T>(x: T | null | undefined): x is T {\n return x !== null && x !== undefined;\n}\n","/**\n * Checks if the given value is null.\n *\n * This function tests whether the provided value is strictly equal to `null`.\n * It returns `true` if the value is `null`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.\n *\n * @param {unknown} x - The value to test if it is null.\n * @returns {x is null} True if the value is null, false otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n *\n * console.log(isNull(value1)); // true\n * console.log(isNull(value2)); // false\n * console.log(isNull(value3)); // false\n */\nexport function isNull(x: unknown): x is null {\n return x === null;\n}\n","/**\n * Checks if the given value is undefined.\n *\n * This function tests whether the provided value is strictly equal to `undefined`.\n * It returns `true` if the value is `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.\n *\n * @param {unknown} x - The value to test if it is undefined.\n * @returns {x is undefined} true if the value is undefined, false otherwise.\n *\n * @example\n * const value1 = undefined;\n * const value2 = null;\n * const value3 = 42;\n *\n * console.log(isUndefined(value1)); // true\n * console.log(isUndefined(value2)); // false\n * console.log(isUndefined(value3)); // false\n */\nexport function isUndefined(x: unknown): x is undefined {\n return x === undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../src/predicate/index.ts","../../src/array/uniq.ts","../../src/array/union.ts","../../src/predicate/isEqual.ts","../../src/predicate/isNil.ts","../../src/predicate/isNotNil.ts","../../src/predicate/isNull.ts","../../src/predicate/isUndefined.ts"],"sourcesContent":["export { isEqual } from './isEqual.ts';\nexport { isNil } from './isNil.ts';\nexport { isNotNil } from './isNotNil.ts';\nexport { isNull } from './isNull.ts';\nexport { isUndefined } from './isUndefined.ts';\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","import { uniq } from './uniq.ts';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","import { union } from \"../array/union.ts\";\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @returns {boolean} `true` if the values are equal, otherwise `false`.\n *\n * @example\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n return false;\n }\n\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n // check if all keys in both arrays match\n if (union(aKeys, bKeys).length !== aKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const propKey = aKeys[i];\n const aProp = (a as any)[propKey];\n const bProp = (b as any)[propKey];\n \n if (!isEqual(aProp, bProp)) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x == null;\n}\n","/**\n * Checks if the given value is not null nor undefined.\n *\n * The main use of this function is to be used with TypeScript as a type predicate.\n *\n * @template T - The type of value.\n * @param {T | null | undefined} x - The value to test if it is not null nor undefined.\n * @returns {x is T} True if the value is not null nor undefined, false otherwise.\n *\n * @example\n * // Here the type of `arr` is (number | undefined)[]\n * const arr = [1, undefined, 3];\n * // Here the type of `result` is number[]\n * const result = arr.filter(isNotNil);\n * // result will be [1, 3]\n */\nexport function isNotNil<T>(x: T | null | undefined): x is T {\n return x !== null && x !== undefined;\n}\n","/**\n * Checks if the given value is null.\n *\n * This function tests whether the provided value is strictly equal to `null`.\n * It returns `true` if the value is `null`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.\n *\n * @param {unknown} x - The value to test if it is null.\n * @returns {x is null} True if the value is null, false otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n *\n * console.log(isNull(value1)); // true\n * console.log(isNull(value2)); // false\n * console.log(isNull(value3)); // false\n */\nexport function isNull(x: unknown): x is null {\n return x === null;\n}\n","/**\n * Checks if the given value is undefined.\n *\n * This function tests whether the provided value is strictly equal to `undefined`.\n * It returns `true` if the value is `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.\n *\n * @param {unknown} x - The value to test if it is undefined.\n * @returns {x is undefined} true if the value is undefined, false otherwise.\n *\n * @example\n * const value1 = undefined;\n * const value2 = null;\n * const value3 = 42;\n *\n * console.log(isUndefined(value1)); // true\n * console.log(isUndefined(value2)); // false\n * console.log(isUndefined(value3)); // false\n */\nexport function isUndefined(x: unknown): x is undefined {\n return x === undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;;;ACEO,SAAS,MAAS,MAAoB,MAAyB;AACpE,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;;;ACLO,SAAS,QAAQ,GAAY,GAAqB;AACvD,MAAI,OAAO,GAAG,GAAG,CAAC,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,QAAQ,aAAa,MAAM;AAC1C,WAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;AAAA,EACnC;AAEA,MAAI,aAAa,UAAU,aAAa,QAAQ;AAC9C,WAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE;AAAA,EAChD;AAEA,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,MAAM;AAC9E,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,OAAO,KAAK,CAAW;AACrC,QAAM,QAAQ,OAAO,KAAK,CAAW;AAErC,MAAI,MAAM,WAAW,MAAM,QAAQ;AACjC,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,OAAO,KAAK,EAAE,WAAW,MAAM,QAAQ;AAC/C,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,UAAU,MAAM,CAAC;AACvB,UAAM,QAAS,EAAU,OAAO;AAChC,UAAM,QAAS,EAAU,OAAO;AAEhC,QAAI,CAAC,QAAQ,OAAO,KAAK,GAAG;AAC1B,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;;;ACrCO,SAAS,MAAM,GAAmC;AACvD,SAAO,KAAK;AACd;;;ACLO,SAAS,SAAY,GAAiC;AAC3D,SAAO,MAAM,QAAQ,MAAM;AAC7B;;;ACEO,SAAS,OAAO,GAAuB;AAC5C,SAAO,MAAM;AACf;;;ACFO,SAAS,YAAY,GAA4B;AACtD,SAAO,MAAM;AACf;","names":[]}
|
package/dist/predicate/index.mjs
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import "../chunk-
|
|
2
|
-
import {
|
|
3
|
-
isUndefined
|
|
4
|
-
} from "../chunk-VH2PV426.mjs";
|
|
5
|
-
import {
|
|
6
|
-
isNil
|
|
7
|
-
} from "../chunk-WMM7TZLG.mjs";
|
|
1
|
+
import "../chunk-ASJF5D6C.mjs";
|
|
8
2
|
import {
|
|
9
3
|
isNotNil
|
|
10
4
|
} from "../chunk-BMRTZMRE.mjs";
|
|
11
5
|
import {
|
|
12
6
|
isNull
|
|
13
7
|
} from "../chunk-AIRSKN47.mjs";
|
|
8
|
+
import {
|
|
9
|
+
isUndefined
|
|
10
|
+
} from "../chunk-VH2PV426.mjs";
|
|
11
|
+
import {
|
|
12
|
+
isEqual
|
|
13
|
+
} from "../chunk-JYSV56US.mjs";
|
|
14
|
+
import {
|
|
15
|
+
isNil
|
|
16
|
+
} from "../chunk-WMM7TZLG.mjs";
|
|
17
|
+
import "../chunk-R6QA7PLZ.mjs";
|
|
18
|
+
import "../chunk-DVK2N4KC.mjs";
|
|
14
19
|
import "../chunk-2HIMLZE3.mjs";
|
|
15
20
|
export {
|
|
21
|
+
isEqual,
|
|
16
22
|
isNil,
|
|
17
23
|
isNotNil,
|
|
18
24
|
isNull,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} a - The first value to compare.
|
|
5
|
+
* @param {unknown} b - The second value to compare.
|
|
6
|
+
* @returns {boolean} `true` if the values are equal, otherwise `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* isEqual(1, 1); // true
|
|
10
|
+
* isEqual({ a: 1 }, { a: 1 }); // true
|
|
11
|
+
* isEqual(/abc/g, /abc/g); // true
|
|
12
|
+
* isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true
|
|
13
|
+
* isEqual([1, 2, 3], [1, 2, 3]); // true
|
|
14
|
+
*/
|
|
15
|
+
declare function isEqual(a: unknown, b: unknown): boolean;
|
|
16
|
+
|
|
17
|
+
export { isEqual };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.
|
|
3
|
+
*
|
|
4
|
+
* @param {unknown} a - The first value to compare.
|
|
5
|
+
* @param {unknown} b - The second value to compare.
|
|
6
|
+
* @returns {boolean} `true` if the values are equal, otherwise `false`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* isEqual(1, 1); // true
|
|
10
|
+
* isEqual({ a: 1 }, { a: 1 }); // true
|
|
11
|
+
* isEqual(/abc/g, /abc/g); // true
|
|
12
|
+
* isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true
|
|
13
|
+
* isEqual([1, 2, 3], [1, 2, 3]); // true
|
|
14
|
+
*/
|
|
15
|
+
declare function isEqual(a: unknown, b: unknown): boolean;
|
|
16
|
+
|
|
17
|
+
export { isEqual };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/predicate/isEqual.ts
|
|
21
|
+
var isEqual_exports = {};
|
|
22
|
+
__export(isEqual_exports, {
|
|
23
|
+
isEqual: () => isEqual
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(isEqual_exports);
|
|
26
|
+
|
|
27
|
+
// src/array/uniq.ts
|
|
28
|
+
function uniq(arr) {
|
|
29
|
+
return Array.from(new Set(arr));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/array/union.ts
|
|
33
|
+
function union(arr1, arr2) {
|
|
34
|
+
return uniq(arr1.concat(arr2));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/predicate/isEqual.ts
|
|
38
|
+
function isEqual(a, b) {
|
|
39
|
+
if (Object.is(a, b)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (a instanceof Date && b instanceof Date) {
|
|
43
|
+
return a.getTime() === b.getTime();
|
|
44
|
+
}
|
|
45
|
+
if (a instanceof RegExp && b instanceof RegExp) {
|
|
46
|
+
return a.source === b.source && a.flags === b.flags;
|
|
47
|
+
}
|
|
48
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const aKeys = Object.keys(a);
|
|
52
|
+
const bKeys = Object.keys(b);
|
|
53
|
+
if (aKeys.length !== bKeys.length) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (union(aKeys, bKeys).length !== aKeys.length) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
60
|
+
const propKey = aKeys[i];
|
|
61
|
+
const aProp = a[propKey];
|
|
62
|
+
const bProp = b[propKey];
|
|
63
|
+
if (!isEqual(aProp, bProp)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
isEqual
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=isEqual.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/predicate/isEqual.ts","../../src/array/uniq.ts","../../src/array/union.ts"],"sourcesContent":["import { union } from \"../array/union.ts\";\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @returns {boolean} `true` if the values are equal, otherwise `false`.\n *\n * @example\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n if (a instanceof RegExp && b instanceof RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {\n return false;\n }\n\n const aKeys = Object.keys(a as object);\n const bKeys = Object.keys(b as object);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n // check if all keys in both arrays match\n if (union(aKeys, bKeys).length !== aKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const propKey = aKeys[i];\n const aProp = (a as any)[propKey];\n const bProp = (b as any)[propKey];\n \n if (!isEqual(aProp, bProp)) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","import { uniq } from './uniq.ts';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;;;ACEO,SAAS,MAAS,MAAoB,MAAyB;AACpE,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;;;AFLO,SAAS,QAAQ,GAAY,GAAqB;AACvD,MAAI,OAAO,GAAG,GAAG,CAAC,GAAG;AACnB,WAAO;AAAA,EACT;AAEA,MAAI,aAAa,QAAQ,aAAa,MAAM;AAC1C,WAAO,EAAE,QAAQ,MAAM,EAAE,QAAQ;AAAA,EACnC;AAEA,MAAI,aAAa,UAAU,aAAa,QAAQ;AAC9C,WAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE;AAAA,EAChD;AAEA,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,MAAM;AAC9E,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,OAAO,KAAK,CAAW;AACrC,QAAM,QAAQ,OAAO,KAAK,CAAW;AAErC,MAAI,MAAM,WAAW,MAAM,QAAQ;AACjC,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,OAAO,KAAK,EAAE,WAAW,MAAM,QAAQ;AAC/C,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,UAAU,MAAM,CAAC;AACvB,UAAM,QAAS,EAAU,OAAO;AAChC,UAAM,QAAS,EAAU,OAAO;AAEhC,QAAI,CAAC,QAAQ,OAAO,KAAK,GAAG;AAC1B,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/string/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import "../chunk-QKYYOLJ6.mjs";
|
|
2
|
+
import {
|
|
3
|
+
kebabCase
|
|
4
|
+
} from "../chunk-EYYZQFOP.mjs";
|
|
5
|
+
import {
|
|
6
|
+
lowerCase
|
|
7
|
+
} from "../chunk-5IKVJGHO.mjs";
|
|
2
8
|
import {
|
|
3
9
|
snakeCase
|
|
4
10
|
} from "../chunk-F3WCQQET.mjs";
|
|
5
11
|
import {
|
|
6
12
|
camelCase
|
|
7
13
|
} from "../chunk-XGCYC4YA.mjs";
|
|
14
|
+
import "../chunk-WVQ7YVRK.mjs";
|
|
8
15
|
import {
|
|
9
16
|
capitalize
|
|
10
17
|
} from "../chunk-U56ZOM7L.mjs";
|
|
11
|
-
import {
|
|
12
|
-
kebabCase
|
|
13
|
-
} from "../chunk-EYYZQFOP.mjs";
|
|
14
|
-
import {
|
|
15
|
-
lowerCase
|
|
16
|
-
} from "../chunk-5IKVJGHO.mjs";
|
|
17
|
-
import "../chunk-WVQ7YVRK.mjs";
|
|
18
18
|
import "../chunk-2HIMLZE3.mjs";
|
|
19
19
|
export {
|
|
20
20
|
camelCase,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.9.0-dev.
|
|
4
|
+
"version": "1.9.0-dev.199+bda3bef5",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
package/dist/chunk-MAJSPFA6.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-MAJSPFA6.mjs.map
|
package/dist/chunk-N6EM6ETS.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-N6EM6ETS.mjs.map
|
|
File without changes
|
|
File without changes
|