es-toolkit 1.9.0-dev.195 → 1.9.0-dev.196
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-NY33CVEY.mjs +27 -0
- package/dist/chunk-NY33CVEY.mjs.map +1 -0
- package/dist/chunk-OSOLEQLZ.mjs +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -69
- package/dist/math/index.mjs +3 -3
- package/dist/object/clone.d.mts +31 -0
- package/dist/object/clone.d.ts +31 -0
- package/dist/object/clone.js +51 -0
- package/dist/object/clone.js.map +1 -0
- package/dist/object/clone.mjs +8 -0
- package/dist/object/clone.mjs.map +1 -0
- package/dist/object/index.d.mts +1 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +25 -0
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +8 -4
- package/dist/predicate/index.mjs +3 -3
- package/dist/string/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-PMHULJNL.mjs +0 -1
- /package/dist/{chunk-PMHULJNL.mjs.map → chunk-OSOLEQLZ.mjs.map} +0 -0
package/dist/array/index.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import "../chunk-2MRZANXZ.mjs";
|
|
2
|
+
import {
|
|
3
|
+
xorBy
|
|
4
|
+
} from "../chunk-Q47NGNXT.mjs";
|
|
5
|
+
import {
|
|
6
|
+
xorWith
|
|
7
|
+
} from "../chunk-QRSJBBFY.mjs";
|
|
2
8
|
import {
|
|
3
9
|
zip
|
|
4
10
|
} from "../chunk-IDCUZVJL.mjs";
|
|
@@ -8,9 +14,15 @@ import {
|
|
|
8
14
|
import {
|
|
9
15
|
zipWith
|
|
10
16
|
} from "../chunk-4KYXHZ4R.mjs";
|
|
17
|
+
import {
|
|
18
|
+
unionWith
|
|
19
|
+
} from "../chunk-2ZCITDMK.mjs";
|
|
11
20
|
import {
|
|
12
21
|
uniqBy
|
|
13
22
|
} from "../chunk-OXAZEEGP.mjs";
|
|
23
|
+
import {
|
|
24
|
+
uniqWith
|
|
25
|
+
} from "../chunk-237HGSZS.mjs";
|
|
14
26
|
import {
|
|
15
27
|
unzip
|
|
16
28
|
} from "../chunk-UYZKMBDO.mjs";
|
|
@@ -24,11 +36,11 @@ import {
|
|
|
24
36
|
xor
|
|
25
37
|
} from "../chunk-L7FQX5MN.mjs";
|
|
26
38
|
import {
|
|
27
|
-
|
|
28
|
-
} from "../chunk-
|
|
39
|
+
tail
|
|
40
|
+
} from "../chunk-OF6NM4G7.mjs";
|
|
29
41
|
import {
|
|
30
|
-
|
|
31
|
-
} from "../chunk-
|
|
42
|
+
take
|
|
43
|
+
} from "../chunk-ME352XO7.mjs";
|
|
32
44
|
import {
|
|
33
45
|
takeRight
|
|
34
46
|
} from "../chunk-IQLKIDXF.mjs";
|
|
@@ -44,18 +56,18 @@ import {
|
|
|
44
56
|
import {
|
|
45
57
|
union
|
|
46
58
|
} from "../chunk-R6QA7PLZ.mjs";
|
|
59
|
+
import {
|
|
60
|
+
uniq
|
|
61
|
+
} from "../chunk-DVK2N4KC.mjs";
|
|
47
62
|
import {
|
|
48
63
|
unionBy
|
|
49
64
|
} from "../chunk-NFS7RWWE.mjs";
|
|
50
65
|
import {
|
|
51
|
-
|
|
52
|
-
} from "../chunk-
|
|
53
|
-
import {
|
|
54
|
-
uniqWith
|
|
55
|
-
} from "../chunk-237HGSZS.mjs";
|
|
66
|
+
last
|
|
67
|
+
} from "../chunk-KPBQ7OUY.mjs";
|
|
56
68
|
import {
|
|
57
|
-
|
|
58
|
-
} from "../chunk-
|
|
69
|
+
maxBy
|
|
70
|
+
} from "../chunk-OOKNBU4V.mjs";
|
|
59
71
|
import {
|
|
60
72
|
minBy
|
|
61
73
|
} from "../chunk-IJD7FE2Z.mjs";
|
|
@@ -71,17 +83,15 @@ import {
|
|
|
71
83
|
import {
|
|
72
84
|
sampleSize
|
|
73
85
|
} from "../chunk-EHSKB6DF.mjs";
|
|
74
|
-
import "../chunk-GIWAOOFY.mjs";
|
|
75
|
-
import "../chunk-SYWMYQYJ.mjs";
|
|
76
86
|
import {
|
|
77
87
|
shuffle
|
|
78
88
|
} from "../chunk-G7UQ5PUR.mjs";
|
|
79
89
|
import {
|
|
80
|
-
|
|
81
|
-
} from "../chunk-
|
|
90
|
+
groupBy
|
|
91
|
+
} from "../chunk-E6E4RZLN.mjs";
|
|
82
92
|
import {
|
|
83
|
-
|
|
84
|
-
} from "../chunk-
|
|
93
|
+
head
|
|
94
|
+
} from "../chunk-HM2JT2RX.mjs";
|
|
85
95
|
import {
|
|
86
96
|
initial
|
|
87
97
|
} from "../chunk-XPSOKBRZ.mjs";
|
|
@@ -98,11 +108,11 @@ import {
|
|
|
98
108
|
keyBy
|
|
99
109
|
} from "../chunk-AJKZMN2V.mjs";
|
|
100
110
|
import {
|
|
101
|
-
|
|
102
|
-
} from "../chunk-
|
|
111
|
+
drop
|
|
112
|
+
} from "../chunk-S3CORED5.mjs";
|
|
103
113
|
import {
|
|
104
|
-
|
|
105
|
-
} from "../chunk-
|
|
114
|
+
dropRight
|
|
115
|
+
} from "../chunk-JEKUA56R.mjs";
|
|
106
116
|
import {
|
|
107
117
|
dropRightWhile
|
|
108
118
|
} from "../chunk-JE6JKZU3.mjs";
|
|
@@ -121,12 +131,6 @@ import {
|
|
|
121
131
|
import {
|
|
122
132
|
forEachRight
|
|
123
133
|
} from "../chunk-IEA53J7P.mjs";
|
|
124
|
-
import {
|
|
125
|
-
groupBy
|
|
126
|
-
} from "../chunk-E6E4RZLN.mjs";
|
|
127
|
-
import {
|
|
128
|
-
head
|
|
129
|
-
} from "../chunk-HM2JT2RX.mjs";
|
|
130
134
|
import {
|
|
131
135
|
chunk
|
|
132
136
|
} from "../chunk-E6C5EZQA.mjs";
|
|
@@ -145,12 +149,8 @@ import {
|
|
|
145
149
|
import {
|
|
146
150
|
differenceWith
|
|
147
151
|
} from "../chunk-6NVQAHXP.mjs";
|
|
148
|
-
import
|
|
149
|
-
|
|
150
|
-
} from "../chunk-S3CORED5.mjs";
|
|
151
|
-
import {
|
|
152
|
-
dropRight
|
|
153
|
-
} from "../chunk-JEKUA56R.mjs";
|
|
152
|
+
import "../chunk-GIWAOOFY.mjs";
|
|
153
|
+
import "../chunk-SYWMYQYJ.mjs";
|
|
154
154
|
import "../chunk-2HIMLZE3.mjs";
|
|
155
155
|
export {
|
|
156
156
|
chunk,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/object/clone.ts
|
|
2
|
+
function clone(obj) {
|
|
3
|
+
if (isPrimitive(obj)) {
|
|
4
|
+
return obj;
|
|
5
|
+
}
|
|
6
|
+
if (Array.isArray(obj)) {
|
|
7
|
+
return obj.slice();
|
|
8
|
+
}
|
|
9
|
+
if (obj instanceof Date) {
|
|
10
|
+
return new Date(obj.getTime());
|
|
11
|
+
}
|
|
12
|
+
if (obj instanceof RegExp) {
|
|
13
|
+
return new RegExp(obj.source, obj.flags);
|
|
14
|
+
}
|
|
15
|
+
if (typeof obj === "object") {
|
|
16
|
+
return Object.assign({}, obj);
|
|
17
|
+
}
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
function isPrimitive(value) {
|
|
21
|
+
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
clone
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=chunk-NY33CVEY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/object/clone.ts"],"sourcesContent":["/**\n * Creates a shallow clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A shallow clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n */\nexport function clone<T>(obj: T): T {\n if (isPrimitive(obj)) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.slice() as T;\n }\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as T;\n }\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as T;\n }\n if (typeof obj === 'object') {\n return Object.assign({}, obj) as T;\n }\n return obj;\n}\n\ntype Primitive = null | undefined | string | number | boolean | symbol | bigint;\n\nfunction isPrimitive(value: unknown): value is Primitive {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n"],"mappings":";AA4BO,SAAS,MAAS,KAAW;AAClC,MAAI,YAAY,GAAG,GAAG;AACpB,WAAO;AAAA,EACT;AACA,MAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,WAAO,IAAI,MAAM;AAAA,EACnB;AACA,MAAI,eAAe,MAAM;AACvB,WAAO,IAAI,KAAK,IAAI,QAAQ,CAAC;AAAA,EAC/B;AACA,MAAI,eAAe,QAAQ;AACzB,WAAO,IAAI,OAAO,IAAI,QAAQ,IAAI,KAAK;AAAA,EACzC;AACA,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO,OAAO,OAAO,CAAC,GAAG,GAAG;AAAA,EAC9B;AACA,SAAO;AACT;AAIA,SAAS,YAAY,OAAoC;AACvD,SAAO,SAAS,QAAS,OAAO,UAAU,YAAY,OAAO,UAAU;AACzE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-OSOLEQLZ.mjs.map
|
package/dist/index.d.mts
CHANGED
|
@@ -67,6 +67,7 @@ export { omitBy } from './object/omitBy.mjs';
|
|
|
67
67
|
export { pick } from './object/pick.mjs';
|
|
68
68
|
export { pickBy } from './object/pickBy.mjs';
|
|
69
69
|
export { invert } from './object/invert.mjs';
|
|
70
|
+
export { clone } from './object/clone.mjs';
|
|
70
71
|
export { isNil } from './predicate/isNil.mjs';
|
|
71
72
|
export { isNotNil } from './predicate/isNotNil.mjs';
|
|
72
73
|
export { isNull } from './predicate/isNull.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export { omitBy } from './object/omitBy.js';
|
|
|
67
67
|
export { pick } from './object/pick.js';
|
|
68
68
|
export { pickBy } from './object/pickBy.js';
|
|
69
69
|
export { invert } from './object/invert.js';
|
|
70
|
+
export { clone } from './object/clone.js';
|
|
70
71
|
export { isNil } from './predicate/isNil.js';
|
|
71
72
|
export { isNotNil } from './predicate/isNotNil.js';
|
|
72
73
|
export { isNull } from './predicate/isNull.js';
|
package/dist/index.js
CHANGED
|
@@ -3619,15 +3619,15 @@ var require_lodash = __commonJS({
|
|
|
3619
3619
|
function wrapperPlant(value) {
|
|
3620
3620
|
var result2, parent2 = this;
|
|
3621
3621
|
while (parent2 instanceof baseLodash) {
|
|
3622
|
-
var
|
|
3623
|
-
|
|
3624
|
-
|
|
3622
|
+
var clone3 = wrapperClone(parent2);
|
|
3623
|
+
clone3.__index__ = 0;
|
|
3624
|
+
clone3.__values__ = undefined2;
|
|
3625
3625
|
if (result2) {
|
|
3626
|
-
previous.__wrapped__ =
|
|
3626
|
+
previous.__wrapped__ = clone3;
|
|
3627
3627
|
} else {
|
|
3628
|
-
result2 =
|
|
3628
|
+
result2 = clone3;
|
|
3629
3629
|
}
|
|
3630
|
-
var previous =
|
|
3630
|
+
var previous = clone3;
|
|
3631
3631
|
parent2 = parent2.__wrapped__;
|
|
3632
3632
|
}
|
|
3633
3633
|
previous.__wrapped__ = value;
|
|
@@ -4062,7 +4062,7 @@ var require_lodash = __commonJS({
|
|
|
4062
4062
|
var value = arguments[0];
|
|
4063
4063
|
return isArray(value) ? value : [value];
|
|
4064
4064
|
}
|
|
4065
|
-
function
|
|
4065
|
+
function clone2(value) {
|
|
4066
4066
|
return baseClone(value, CLONE_SYMBOLS_FLAG);
|
|
4067
4067
|
}
|
|
4068
4068
|
function cloneWith(value, customizer) {
|
|
@@ -5194,7 +5194,7 @@ var require_lodash = __commonJS({
|
|
|
5194
5194
|
lodash.capitalize = capitalize3;
|
|
5195
5195
|
lodash.ceil = ceil;
|
|
5196
5196
|
lodash.clamp = clamp2;
|
|
5197
|
-
lodash.clone =
|
|
5197
|
+
lodash.clone = clone2;
|
|
5198
5198
|
lodash.cloneDeep = cloneDeep;
|
|
5199
5199
|
lodash.cloneDeepWith = cloneDeepWith;
|
|
5200
5200
|
lodash.cloneWith = cloneWith;
|
|
@@ -5533,6 +5533,7 @@ __export(src_exports, {
|
|
|
5533
5533
|
capitalize: () => capitalize2,
|
|
5534
5534
|
chunk: () => chunk,
|
|
5535
5535
|
clamp: () => clamp,
|
|
5536
|
+
clone: () => clone,
|
|
5536
5537
|
compact: () => compact,
|
|
5537
5538
|
countBy: () => countBy,
|
|
5538
5539
|
debounce: () => debounce,
|
|
@@ -6311,6 +6312,29 @@ function invert(obj) {
|
|
|
6311
6312
|
return result;
|
|
6312
6313
|
}
|
|
6313
6314
|
|
|
6315
|
+
// src/object/clone.ts
|
|
6316
|
+
function clone(obj) {
|
|
6317
|
+
if (isPrimitive(obj)) {
|
|
6318
|
+
return obj;
|
|
6319
|
+
}
|
|
6320
|
+
if (Array.isArray(obj)) {
|
|
6321
|
+
return obj.slice();
|
|
6322
|
+
}
|
|
6323
|
+
if (obj instanceof Date) {
|
|
6324
|
+
return new Date(obj.getTime());
|
|
6325
|
+
}
|
|
6326
|
+
if (obj instanceof RegExp) {
|
|
6327
|
+
return new RegExp(obj.source, obj.flags);
|
|
6328
|
+
}
|
|
6329
|
+
if (typeof obj === "object") {
|
|
6330
|
+
return Object.assign({}, obj);
|
|
6331
|
+
}
|
|
6332
|
+
return obj;
|
|
6333
|
+
}
|
|
6334
|
+
function isPrimitive(value) {
|
|
6335
|
+
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
6336
|
+
}
|
|
6337
|
+
|
|
6314
6338
|
// src/predicate/isNil.ts
|
|
6315
6339
|
function isNil(x) {
|
|
6316
6340
|
return x == null;
|
|
@@ -6398,6 +6422,7 @@ var capitalize2 = (str) => {
|
|
|
6398
6422
|
capitalize,
|
|
6399
6423
|
chunk,
|
|
6400
6424
|
clamp,
|
|
6425
|
+
clone,
|
|
6401
6426
|
compact,
|
|
6402
6427
|
countBy,
|
|
6403
6428
|
debounce,
|