es-toolkit 1.9.0-dev.197 → 1.9.0-dev.198
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 +33 -33
- package/dist/chunk-ASJF5D6C.mjs +1 -0
- package/dist/chunk-JYSV56US.mjs +41 -0
- package/dist/chunk-JYSV56US.mjs.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +37 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -67
- package/dist/math/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 +10 -4
- 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 +3 -3
- package/package.json +1 -1
- package/dist/chunk-MAJSPFA6.mjs +0 -1
- /package/dist/{chunk-MAJSPFA6.mjs.map → chunk-ASJF5D6C.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,9 @@ import {
|
|
|
3
3
|
delay
|
|
4
4
|
} from "./chunk-O64NE2P4.mjs";
|
|
5
5
|
import "./chunk-QKYYOLJ6.mjs";
|
|
6
|
+
import {
|
|
7
|
+
lowerCase
|
|
8
|
+
} from "./chunk-5IKVJGHO.mjs";
|
|
6
9
|
import {
|
|
7
10
|
snakeCase
|
|
8
11
|
} from "./chunk-F3WCQQET.mjs";
|
|
@@ -15,23 +18,23 @@ import {
|
|
|
15
18
|
import {
|
|
16
19
|
kebabCase
|
|
17
20
|
} from "./chunk-EYYZQFOP.mjs";
|
|
18
|
-
import {
|
|
19
|
-
lowerCase
|
|
20
|
-
} from "./chunk-5IKVJGHO.mjs";
|
|
21
21
|
import "./chunk-WVQ7YVRK.mjs";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-ASJF5D6C.mjs";
|
|
23
|
+
import {
|
|
24
|
+
isNull
|
|
25
|
+
} from "./chunk-AIRSKN47.mjs";
|
|
23
26
|
import {
|
|
24
27
|
isUndefined
|
|
25
28
|
} from "./chunk-VH2PV426.mjs";
|
|
29
|
+
import {
|
|
30
|
+
isEqual
|
|
31
|
+
} from "./chunk-JYSV56US.mjs";
|
|
26
32
|
import {
|
|
27
33
|
isNil
|
|
28
34
|
} from "./chunk-WMM7TZLG.mjs";
|
|
29
35
|
import {
|
|
30
36
|
isNotNil
|
|
31
37
|
} from "./chunk-BMRTZMRE.mjs";
|
|
32
|
-
import {
|
|
33
|
-
isNull
|
|
34
|
-
} from "./chunk-AIRSKN47.mjs";
|
|
35
38
|
import "./chunk-OSOLEQLZ.mjs";
|
|
36
39
|
import {
|
|
37
40
|
omit
|
|
@@ -51,13 +54,29 @@ import {
|
|
|
51
54
|
import {
|
|
52
55
|
invert
|
|
53
56
|
} from "./chunk-74WWMNZS.mjs";
|
|
54
|
-
import "./chunk-
|
|
57
|
+
import "./chunk-TLVQSNOE.mjs";
|
|
55
58
|
import {
|
|
56
|
-
|
|
57
|
-
} from "./chunk-
|
|
59
|
+
range
|
|
60
|
+
} from "./chunk-DPH2KE6O.mjs";
|
|
58
61
|
import {
|
|
59
|
-
|
|
60
|
-
} from "./chunk-
|
|
62
|
+
round
|
|
63
|
+
} from "./chunk-5PMKOZ2F.mjs";
|
|
64
|
+
import {
|
|
65
|
+
clamp
|
|
66
|
+
} from "./chunk-MLCL773E.mjs";
|
|
67
|
+
import {
|
|
68
|
+
inRange
|
|
69
|
+
} from "./chunk-BH6HLGBA.mjs";
|
|
70
|
+
import {
|
|
71
|
+
meanBy
|
|
72
|
+
} from "./chunk-IZAD2S7R.mjs";
|
|
73
|
+
import {
|
|
74
|
+
mean
|
|
75
|
+
} from "./chunk-GDC64SYJ.mjs";
|
|
76
|
+
import {
|
|
77
|
+
sum
|
|
78
|
+
} from "./chunk-2SLTL4KL.mjs";
|
|
79
|
+
import "./chunk-2MRZANXZ.mjs";
|
|
61
80
|
import {
|
|
62
81
|
zip
|
|
63
82
|
} from "./chunk-IDCUZVJL.mjs";
|
|
@@ -67,15 +86,9 @@ import {
|
|
|
67
86
|
import {
|
|
68
87
|
zipWith
|
|
69
88
|
} from "./chunk-4KYXHZ4R.mjs";
|
|
70
|
-
import {
|
|
71
|
-
unionWith
|
|
72
|
-
} from "./chunk-2ZCITDMK.mjs";
|
|
73
89
|
import {
|
|
74
90
|
uniqBy
|
|
75
91
|
} from "./chunk-OXAZEEGP.mjs";
|
|
76
|
-
import {
|
|
77
|
-
uniqWith
|
|
78
|
-
} from "./chunk-237HGSZS.mjs";
|
|
79
92
|
import {
|
|
80
93
|
unzip
|
|
81
94
|
} from "./chunk-UYZKMBDO.mjs";
|
|
@@ -89,11 +102,11 @@ import {
|
|
|
89
102
|
xor
|
|
90
103
|
} from "./chunk-L7FQX5MN.mjs";
|
|
91
104
|
import {
|
|
92
|
-
|
|
93
|
-
} from "./chunk-
|
|
105
|
+
xorBy
|
|
106
|
+
} from "./chunk-Q47NGNXT.mjs";
|
|
94
107
|
import {
|
|
95
|
-
|
|
96
|
-
} from "./chunk-
|
|
108
|
+
xorWith
|
|
109
|
+
} from "./chunk-QRSJBBFY.mjs";
|
|
97
110
|
import {
|
|
98
111
|
takeRight
|
|
99
112
|
} from "./chunk-IQLKIDXF.mjs";
|
|
@@ -109,18 +122,18 @@ import {
|
|
|
109
122
|
import {
|
|
110
123
|
union
|
|
111
124
|
} from "./chunk-R6QA7PLZ.mjs";
|
|
112
|
-
import {
|
|
113
|
-
uniq
|
|
114
|
-
} from "./chunk-DVK2N4KC.mjs";
|
|
115
125
|
import {
|
|
116
126
|
unionBy
|
|
117
127
|
} from "./chunk-NFS7RWWE.mjs";
|
|
118
128
|
import {
|
|
119
|
-
|
|
120
|
-
} from "./chunk-
|
|
129
|
+
unionWith
|
|
130
|
+
} from "./chunk-2ZCITDMK.mjs";
|
|
121
131
|
import {
|
|
122
|
-
|
|
123
|
-
} from "./chunk-
|
|
132
|
+
uniqWith
|
|
133
|
+
} from "./chunk-237HGSZS.mjs";
|
|
134
|
+
import {
|
|
135
|
+
uniq
|
|
136
|
+
} from "./chunk-DVK2N4KC.mjs";
|
|
124
137
|
import {
|
|
125
138
|
minBy
|
|
126
139
|
} from "./chunk-IJD7FE2Z.mjs";
|
|
@@ -136,15 +149,21 @@ import {
|
|
|
136
149
|
import {
|
|
137
150
|
sampleSize
|
|
138
151
|
} from "./chunk-EHSKB6DF.mjs";
|
|
152
|
+
import {
|
|
153
|
+
randomInt
|
|
154
|
+
} from "./chunk-GIWAOOFY.mjs";
|
|
155
|
+
import {
|
|
156
|
+
random
|
|
157
|
+
} from "./chunk-SYWMYQYJ.mjs";
|
|
139
158
|
import {
|
|
140
159
|
shuffle
|
|
141
160
|
} from "./chunk-G7UQ5PUR.mjs";
|
|
142
161
|
import {
|
|
143
|
-
|
|
144
|
-
} from "./chunk-
|
|
162
|
+
tail
|
|
163
|
+
} from "./chunk-OF6NM4G7.mjs";
|
|
145
164
|
import {
|
|
146
|
-
|
|
147
|
-
} from "./chunk-
|
|
165
|
+
take
|
|
166
|
+
} from "./chunk-ME352XO7.mjs";
|
|
148
167
|
import {
|
|
149
168
|
initial
|
|
150
169
|
} from "./chunk-XPSOKBRZ.mjs";
|
|
@@ -161,11 +180,11 @@ import {
|
|
|
161
180
|
keyBy
|
|
162
181
|
} from "./chunk-AJKZMN2V.mjs";
|
|
163
182
|
import {
|
|
164
|
-
|
|
165
|
-
} from "./chunk-
|
|
183
|
+
last
|
|
184
|
+
} from "./chunk-KPBQ7OUY.mjs";
|
|
166
185
|
import {
|
|
167
|
-
|
|
168
|
-
} from "./chunk-
|
|
186
|
+
maxBy
|
|
187
|
+
} from "./chunk-OOKNBU4V.mjs";
|
|
169
188
|
import {
|
|
170
189
|
dropRightWhile
|
|
171
190
|
} from "./chunk-JE6JKZU3.mjs";
|
|
@@ -184,6 +203,12 @@ import {
|
|
|
184
203
|
import {
|
|
185
204
|
forEachRight
|
|
186
205
|
} from "./chunk-IEA53J7P.mjs";
|
|
206
|
+
import {
|
|
207
|
+
groupBy
|
|
208
|
+
} from "./chunk-E6E4RZLN.mjs";
|
|
209
|
+
import {
|
|
210
|
+
head
|
|
211
|
+
} from "./chunk-HM2JT2RX.mjs";
|
|
187
212
|
import {
|
|
188
213
|
chunk
|
|
189
214
|
} from "./chunk-E6C5EZQA.mjs";
|
|
@@ -202,38 +227,12 @@ import {
|
|
|
202
227
|
import {
|
|
203
228
|
differenceWith
|
|
204
229
|
} 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
230
|
import {
|
|
228
|
-
|
|
229
|
-
} from "./chunk-
|
|
230
|
-
import {
|
|
231
|
-
range
|
|
232
|
-
} from "./chunk-DPH2KE6O.mjs";
|
|
233
|
-
import "./chunk-FZEZH22H.mjs";
|
|
231
|
+
drop
|
|
232
|
+
} from "./chunk-S3CORED5.mjs";
|
|
234
233
|
import {
|
|
235
|
-
|
|
236
|
-
} from "./chunk-
|
|
234
|
+
dropRight
|
|
235
|
+
} from "./chunk-JEKUA56R.mjs";
|
|
237
236
|
import "./chunk-N6EM6ETS.mjs";
|
|
238
237
|
import {
|
|
239
238
|
debounce
|
|
@@ -247,6 +246,10 @@ import {
|
|
|
247
246
|
import {
|
|
248
247
|
throttle
|
|
249
248
|
} from "./chunk-QOJGMVVR.mjs";
|
|
249
|
+
import "./chunk-FZEZH22H.mjs";
|
|
250
|
+
import {
|
|
251
|
+
AbortError
|
|
252
|
+
} from "./chunk-DXB7EZUQ.mjs";
|
|
250
253
|
import "./chunk-2HIMLZE3.mjs";
|
|
251
254
|
export {
|
|
252
255
|
AbortError,
|
|
@@ -278,6 +281,7 @@ export {
|
|
|
278
281
|
intersectionBy,
|
|
279
282
|
intersectionWith,
|
|
280
283
|
invert,
|
|
284
|
+
isEqual,
|
|
281
285
|
isNil,
|
|
282
286
|
isNotNil,
|
|
283
287
|
isNull,
|
package/dist/math/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-TLVQSNOE.mjs";
|
|
2
|
+
import {
|
|
3
|
+
range
|
|
4
|
+
} from "../chunk-DPH2KE6O.mjs";
|
|
2
5
|
import {
|
|
3
6
|
round
|
|
4
7
|
} from "../chunk-5PMKOZ2F.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/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-
|
|
1
|
+
import "../chunk-ASJF5D6C.mjs";
|
|
2
|
+
import {
|
|
3
|
+
isNull
|
|
4
|
+
} from "../chunk-AIRSKN47.mjs";
|
|
2
5
|
import {
|
|
3
6
|
isUndefined
|
|
4
7
|
} from "../chunk-VH2PV426.mjs";
|
|
8
|
+
import {
|
|
9
|
+
isEqual
|
|
10
|
+
} from "../chunk-JYSV56US.mjs";
|
|
5
11
|
import {
|
|
6
12
|
isNil
|
|
7
13
|
} from "../chunk-WMM7TZLG.mjs";
|
|
8
14
|
import {
|
|
9
15
|
isNotNil
|
|
10
16
|
} from "../chunk-BMRTZMRE.mjs";
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
} from "../chunk-AIRSKN47.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,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-QKYYOLJ6.mjs";
|
|
2
|
+
import {
|
|
3
|
+
lowerCase
|
|
4
|
+
} from "../chunk-5IKVJGHO.mjs";
|
|
2
5
|
import {
|
|
3
6
|
snakeCase
|
|
4
7
|
} from "../chunk-F3WCQQET.mjs";
|
|
@@ -11,9 +14,6 @@ import {
|
|
|
11
14
|
import {
|
|
12
15
|
kebabCase
|
|
13
16
|
} from "../chunk-EYYZQFOP.mjs";
|
|
14
|
-
import {
|
|
15
|
-
lowerCase
|
|
16
|
-
} from "../chunk-5IKVJGHO.mjs";
|
|
17
17
|
import "../chunk-WVQ7YVRK.mjs";
|
|
18
18
|
import "../chunk-2HIMLZE3.mjs";
|
|
19
19
|
export {
|
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.198+4b003793",
|
|
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
|
|
File without changes
|