es-toolkit 1.10.1-dev.229 → 1.10.1-dev.231
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 +31 -31
- package/dist/chunk-54TK5BIS.mjs +1 -0
- package/dist/chunk-GL7PPRA4.mjs +25 -0
- package/dist/chunk-GL7PPRA4.mjs.map +1 -0
- package/dist/chunk-MJA7DAOJ.mjs +25 -0
- package/dist/chunk-MJA7DAOJ.mjs.map +1 -0
- package/dist/chunk-XT74R35S.mjs +1 -0
- package/dist/compat/index.d.mts +2 -0
- package/dist/compat/index.d.ts +2 -0
- package/dist/compat/index.js +42 -0
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +66 -58
- package/dist/compat/index.mjs.map +1 -1
- package/dist/function/index.mjs +6 -6
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -58
- package/dist/object/index.d.mts +1 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +25 -2
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +6 -2
- package/dist/object/set.d.mts +32 -0
- package/dist/object/set.d.ts +32 -0
- package/dist/object/set.js +49 -0
- package/dist/object/set.js.map +1 -0
- package/dist/object/set.mjs +8 -0
- package/dist/object/set.mjs.map +1 -0
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +21 -2
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +6 -2
- package/dist/string/startCase.d.mts +16 -0
- package/dist/string/startCase.d.ts +16 -0
- package/dist/string/startCase.js +54 -0
- package/dist/string/startCase.js.map +1 -0
- package/dist/string/startCase.mjs +9 -0
- package/dist/string/startCase.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-OSOLEQLZ.mjs +0 -1
- package/dist/chunk-QKYYOLJ6.mjs +0 -1
- /package/dist/{chunk-OSOLEQLZ.mjs.map → chunk-54TK5BIS.mjs.map} +0 -0
- /package/dist/{chunk-QKYYOLJ6.mjs.map → chunk-XT74R35S.mjs.map} +0 -0
package/dist/array/index.mjs
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import "../chunk-DDH7K4QM.mjs";
|
|
2
|
-
import {
|
|
3
|
-
unzipWith
|
|
4
|
-
} from "../chunk-IFNXROZR.mjs";
|
|
5
|
-
import {
|
|
6
|
-
without
|
|
7
|
-
} from "../chunk-PYEYV7BY.mjs";
|
|
8
2
|
import {
|
|
9
3
|
xor
|
|
10
4
|
} from "../chunk-L7FQX5MN.mjs";
|
|
@@ -23,21 +17,12 @@ import {
|
|
|
23
17
|
import {
|
|
24
18
|
zipWith
|
|
25
19
|
} from "../chunk-4KYXHZ4R.mjs";
|
|
26
|
-
import {
|
|
27
|
-
toFilled
|
|
28
|
-
} from "../chunk-OP4OAKQJ.mjs";
|
|
29
|
-
import {
|
|
30
|
-
union
|
|
31
|
-
} from "../chunk-R6QA7PLZ.mjs";
|
|
32
20
|
import {
|
|
33
21
|
unionBy
|
|
34
22
|
} from "../chunk-NFS7RWWE.mjs";
|
|
35
23
|
import {
|
|
36
24
|
unionWith
|
|
37
25
|
} from "../chunk-2ZCITDMK.mjs";
|
|
38
|
-
import {
|
|
39
|
-
uniq
|
|
40
|
-
} from "../chunk-DVK2N4KC.mjs";
|
|
41
26
|
import {
|
|
42
27
|
uniqBy
|
|
43
28
|
} from "../chunk-OXAZEEGP.mjs";
|
|
@@ -48,13 +33,11 @@ import {
|
|
|
48
33
|
unzip
|
|
49
34
|
} from "../chunk-UYZKMBDO.mjs";
|
|
50
35
|
import {
|
|
51
|
-
|
|
52
|
-
} from "../chunk-
|
|
36
|
+
unzipWith
|
|
37
|
+
} from "../chunk-IFNXROZR.mjs";
|
|
53
38
|
import {
|
|
54
|
-
|
|
55
|
-
} from "../chunk-
|
|
56
|
-
import "../chunk-GIWAOOFY.mjs";
|
|
57
|
-
import "../chunk-SYWMYQYJ.mjs";
|
|
39
|
+
without
|
|
40
|
+
} from "../chunk-PYEYV7BY.mjs";
|
|
58
41
|
import {
|
|
59
42
|
shuffle
|
|
60
43
|
} from "../chunk-G7UQ5PUR.mjs";
|
|
@@ -74,11 +57,14 @@ import {
|
|
|
74
57
|
takeWhile
|
|
75
58
|
} from "../chunk-2IXFGSUA.mjs";
|
|
76
59
|
import {
|
|
77
|
-
|
|
78
|
-
} from "../chunk-
|
|
60
|
+
toFilled
|
|
61
|
+
} from "../chunk-OP4OAKQJ.mjs";
|
|
79
62
|
import {
|
|
80
|
-
|
|
81
|
-
} from "../chunk-
|
|
63
|
+
union
|
|
64
|
+
} from "../chunk-R6QA7PLZ.mjs";
|
|
65
|
+
import {
|
|
66
|
+
uniq
|
|
67
|
+
} from "../chunk-DVK2N4KC.mjs";
|
|
82
68
|
import {
|
|
83
69
|
keyBy
|
|
84
70
|
} from "../chunk-AJKZMN2V.mjs";
|
|
@@ -98,8 +84,13 @@ import {
|
|
|
98
84
|
partition
|
|
99
85
|
} from "../chunk-DN3NOZ3H.mjs";
|
|
100
86
|
import {
|
|
101
|
-
|
|
102
|
-
} from "../chunk-
|
|
87
|
+
sample
|
|
88
|
+
} from "../chunk-2KNLZB7V.mjs";
|
|
89
|
+
import {
|
|
90
|
+
sampleSize
|
|
91
|
+
} from "../chunk-EHSKB6DF.mjs";
|
|
92
|
+
import "../chunk-GIWAOOFY.mjs";
|
|
93
|
+
import "../chunk-SYWMYQYJ.mjs";
|
|
103
94
|
import {
|
|
104
95
|
forEachRight
|
|
105
96
|
} from "../chunk-IEA53J7P.mjs";
|
|
@@ -116,11 +107,11 @@ import {
|
|
|
116
107
|
intersection
|
|
117
108
|
} from "../chunk-FVVSE2F2.mjs";
|
|
118
109
|
import {
|
|
119
|
-
|
|
120
|
-
} from "../chunk-
|
|
110
|
+
intersectionBy
|
|
111
|
+
} from "../chunk-O6UXZR3U.mjs";
|
|
121
112
|
import {
|
|
122
|
-
|
|
123
|
-
} from "../chunk-
|
|
113
|
+
intersectionWith
|
|
114
|
+
} from "../chunk-XI7KRD2C.mjs";
|
|
124
115
|
import {
|
|
125
116
|
drop
|
|
126
117
|
} from "../chunk-S3CORED5.mjs";
|
|
@@ -139,6 +130,9 @@ import {
|
|
|
139
130
|
import {
|
|
140
131
|
flatMap
|
|
141
132
|
} from "../chunk-KBXHURLW.mjs";
|
|
133
|
+
import {
|
|
134
|
+
flattenDeep
|
|
135
|
+
} from "../chunk-ML727RRJ.mjs";
|
|
142
136
|
import {
|
|
143
137
|
flatten
|
|
144
138
|
} from "../chunk-33MSBDC6.mjs";
|
|
@@ -154,6 +148,12 @@ import {
|
|
|
154
148
|
import {
|
|
155
149
|
difference
|
|
156
150
|
} from "../chunk-JPUKH67K.mjs";
|
|
151
|
+
import {
|
|
152
|
+
differenceBy
|
|
153
|
+
} from "../chunk-LVWX5B43.mjs";
|
|
154
|
+
import {
|
|
155
|
+
differenceWith
|
|
156
|
+
} from "../chunk-6NVQAHXP.mjs";
|
|
157
157
|
import "../chunk-2MM5EJJX.mjs";
|
|
158
158
|
export {
|
|
159
159
|
chunk,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-54TK5BIS.mjs.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/object/set.ts
|
|
2
|
+
function set(obj, path, value) {
|
|
3
|
+
if (obj instanceof Map || obj instanceof Set) {
|
|
4
|
+
throw new TypeError("Set or Map is not supported");
|
|
5
|
+
}
|
|
6
|
+
const keys = Array.isArray(path) ? path : String(path).replace(/\[|\]/g, (match) => {
|
|
7
|
+
return match === "[" ? "." : "";
|
|
8
|
+
}).split(".");
|
|
9
|
+
let pointer = obj;
|
|
10
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
11
|
+
const key = keys[i];
|
|
12
|
+
const nextKey = keys[i + 1];
|
|
13
|
+
if (pointer[key] == null || typeof pointer[key] !== "object") {
|
|
14
|
+
pointer[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
15
|
+
}
|
|
16
|
+
pointer = pointer[key];
|
|
17
|
+
}
|
|
18
|
+
pointer[keys[keys.length - 1]] = value;
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
set
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-GL7PPRA4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/object/set.ts"],"sourcesContent":["/**\n * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.\n *\n * @template T - The type of the object.\n * @param {Settable} obj - The object to modify.\n * @param {Path} path - The path of the property to set.\n * @param {any} value - The value to set.\n * @returns {T} - The modified object.\n *\n * @example\n * // Set a value in a nested object\n * const obj = { a: { b: { c: 3 } } };\n * set(obj, 'a.b.c', 4);\n * console.log(obj.a.b.c); // 4\n *\n * @example\n * // Set a value in an array\n * const arr = [1, 2, 3];\n * set(arr, 1, 4);\n * console.log(arr[1]); // 4\n *\n * @example\n * // Create non-existent path and set value\n * const obj = {};\n * set(obj, 'a.b.c', 4);\n * console.log(obj); // { a: { b: { c: 4 } } }\n */\nexport function set<T>(obj: Settable, path: Path, value: any): T {\n if (obj instanceof Map || obj instanceof Set) {\n throw new TypeError('Set or Map is not supported');\n }\n //TODO: memoize\n const keys = Array.isArray(path)\n ? path\n : String(path as string)\n .replace(/\\[|\\]/g, match => {\n return match === '[' ? '.' : '';\n })\n .split('.');\n\n let pointer: any = obj;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const nextKey = keys[i + 1];\n if (pointer[key] == null || typeof pointer[key] !== 'object') {\n pointer[key] = /^\\d+$/.test(nextKey as string) ? [] : {};\n }\n pointer = pointer[key];\n }\n\n pointer[keys[keys.length - 1]] = value;\n return obj as T;\n}\n\ntype Settable = object | any[];\ntype Path = string | number | Array<string | number>;\n"],"mappings":";AA2BO,SAAS,IAAO,KAAe,MAAY,OAAe;AAC/D,MAAI,eAAe,OAAO,eAAe,KAAK;AAC5C,UAAM,IAAI,UAAU,6BAA6B;AAAA,EACnD;AAEA,QAAM,OAAO,MAAM,QAAQ,IAAI,IAC3B,OACA,OAAO,IAAc,EAClB,QAAQ,UAAU,WAAS;AAC1B,WAAO,UAAU,MAAM,MAAM;AAAA,EAC/B,CAAC,EACA,MAAM,GAAG;AAEhB,MAAI,UAAe;AAEnB,WAAS,IAAI,GAAG,IAAI,KAAK,SAAS,GAAG,KAAK;AACxC,UAAM,MAAM,KAAK,CAAC;AAClB,UAAM,UAAU,KAAK,IAAI,CAAC;AAC1B,QAAI,QAAQ,GAAG,KAAK,QAAQ,OAAO,QAAQ,GAAG,MAAM,UAAU;AAC5D,cAAQ,GAAG,IAAI,QAAQ,KAAK,OAAiB,IAAI,CAAC,IAAI,CAAC;AAAA,IACzD;AACA,cAAU,QAAQ,GAAG;AAAA,EACvB;AAEA,UAAQ,KAAK,KAAK,SAAS,CAAC,CAAC,IAAI;AACjC,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getWords
|
|
3
|
+
} from "./chunk-WVQ7YVRK.mjs";
|
|
4
|
+
|
|
5
|
+
// src/string/startCase.ts
|
|
6
|
+
function startCase(str) {
|
|
7
|
+
const words = getWords(str.trim());
|
|
8
|
+
let result = "";
|
|
9
|
+
for (const word of words) {
|
|
10
|
+
if (result) {
|
|
11
|
+
result += " ";
|
|
12
|
+
}
|
|
13
|
+
if (word === word.toUpperCase()) {
|
|
14
|
+
result += word;
|
|
15
|
+
} else {
|
|
16
|
+
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
startCase
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-MJA7DAOJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/startCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords';\n\n/**\n * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.\n *\n * Start case is the naming convention in which each word is written with an initial capital letter.\n * @param {string} str - The string to convert.\n * @returns {string} The converted string.\n *\n * @example\n * const result1 = startCase('hello world'); // result will be 'Hello World'\n * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'\n * const result3 = startCase('hello-world'); // result will be 'Hello World'\n * const result4 = startCase('hello_world'); // result will be 'Hello World'\n */\nexport function startCase(str: string): string {\n const words = getWords(str.trim());\n let result = '';\n for (const word of words) {\n if (result) {\n result += ' ';\n }\n if (word === word.toUpperCase()) {\n result += word;\n } else {\n result += word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n return result;\n}\n"],"mappings":";;;;;AAeO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,IAAI,KAAK,CAAC;AACjC,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACxB,QAAI,QAAQ;AACV,gBAAU;AAAA,IACZ;AACA,QAAI,SAAS,KAAK,YAAY,GAAG;AAC/B,gBAAU;AAAA,IACZ,OAAO;AACL,gBAAU,KAAK,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAAA,IAC9D;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-XT74R35S.mjs.map
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -70,6 +70,7 @@ export { pick } from '../object/pick.mjs';
|
|
|
70
70
|
export { pickBy } from '../object/pickBy.mjs';
|
|
71
71
|
export { invert } from '../object/invert.mjs';
|
|
72
72
|
export { clone } from '../object/clone.mjs';
|
|
73
|
+
export { set } from '../object/set.mjs';
|
|
73
74
|
export { isEqual } from '../predicate/isEqual.mjs';
|
|
74
75
|
export { isNil } from '../predicate/isNil.mjs';
|
|
75
76
|
export { isNotNil } from '../predicate/isNotNil.mjs';
|
|
@@ -80,6 +81,7 @@ export { camelCase } from '../string/camelCase.mjs';
|
|
|
80
81
|
export { snakeCase } from '../string/snakeCase.mjs';
|
|
81
82
|
export { kebabCase } from '../string/kebabCase.mjs';
|
|
82
83
|
export { lowerCase } from '../string/lowerCase.mjs';
|
|
84
|
+
export { startCase } from '../string/startCase.mjs';
|
|
83
85
|
export { capitalize } from '../string/capitalize.mjs';
|
|
84
86
|
|
|
85
87
|
/**
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export { pick } from '../object/pick.js';
|
|
|
70
70
|
export { pickBy } from '../object/pickBy.js';
|
|
71
71
|
export { invert } from '../object/invert.js';
|
|
72
72
|
export { clone } from '../object/clone.js';
|
|
73
|
+
export { set } from '../object/set.js';
|
|
73
74
|
export { isEqual } from '../predicate/isEqual.js';
|
|
74
75
|
export { isNil } from '../predicate/isNil.js';
|
|
75
76
|
export { isNotNil } from '../predicate/isNotNil.js';
|
|
@@ -80,6 +81,7 @@ export { camelCase } from '../string/camelCase.js';
|
|
|
80
81
|
export { snakeCase } from '../string/snakeCase.js';
|
|
81
82
|
export { kebabCase } from '../string/kebabCase.js';
|
|
82
83
|
export { lowerCase } from '../string/lowerCase.js';
|
|
84
|
+
export { startCase } from '../string/startCase.js';
|
|
83
85
|
export { capitalize } from '../string/capitalize.js';
|
|
84
86
|
|
|
85
87
|
/**
|
package/dist/compat/index.js
CHANGED
|
@@ -92,8 +92,10 @@ __export(compat_exports, {
|
|
|
92
92
|
round: () => round,
|
|
93
93
|
sample: () => sample,
|
|
94
94
|
sampleSize: () => sampleSize,
|
|
95
|
+
set: () => set,
|
|
95
96
|
shuffle: () => shuffle,
|
|
96
97
|
snakeCase: () => snakeCase,
|
|
98
|
+
startCase: () => startCase,
|
|
97
99
|
sum: () => sum,
|
|
98
100
|
sumBy: () => sumBy,
|
|
99
101
|
tail: () => tail,
|
|
@@ -880,6 +882,27 @@ function isPrimitive(value) {
|
|
|
880
882
|
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
881
883
|
}
|
|
882
884
|
|
|
885
|
+
// src/object/set.ts
|
|
886
|
+
function set(obj, path, value) {
|
|
887
|
+
if (obj instanceof Map || obj instanceof Set) {
|
|
888
|
+
throw new TypeError("Set or Map is not supported");
|
|
889
|
+
}
|
|
890
|
+
const keys = Array.isArray(path) ? path : String(path).replace(/\[|\]/g, (match) => {
|
|
891
|
+
return match === "[" ? "." : "";
|
|
892
|
+
}).split(".");
|
|
893
|
+
let pointer = obj;
|
|
894
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
895
|
+
const key = keys[i];
|
|
896
|
+
const nextKey = keys[i + 1];
|
|
897
|
+
if (pointer[key] == null || typeof pointer[key] !== "object") {
|
|
898
|
+
pointer[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
899
|
+
}
|
|
900
|
+
pointer = pointer[key];
|
|
901
|
+
}
|
|
902
|
+
pointer[keys[keys.length - 1]] = value;
|
|
903
|
+
return obj;
|
|
904
|
+
}
|
|
905
|
+
|
|
883
906
|
// src/predicate/isEqual.ts
|
|
884
907
|
function isEqual(a, b) {
|
|
885
908
|
if (Object.is(a, b)) {
|
|
@@ -991,6 +1014,23 @@ var lowerCase = (str) => {
|
|
|
991
1014
|
return words.map((word) => word.toLowerCase()).join(" ");
|
|
992
1015
|
};
|
|
993
1016
|
|
|
1017
|
+
// src/string/startCase.ts
|
|
1018
|
+
function startCase(str) {
|
|
1019
|
+
const words = getWords(str.trim());
|
|
1020
|
+
let result = "";
|
|
1021
|
+
for (const word of words) {
|
|
1022
|
+
if (result) {
|
|
1023
|
+
result += " ";
|
|
1024
|
+
}
|
|
1025
|
+
if (word === word.toUpperCase()) {
|
|
1026
|
+
result += word;
|
|
1027
|
+
} else {
|
|
1028
|
+
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
return result;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
994
1034
|
// src/compat/array/chunk.ts
|
|
995
1035
|
function chunk2(arr, size = 1) {
|
|
996
1036
|
size = Math.max(Math.floor(size), 0);
|
|
@@ -1059,8 +1099,10 @@ function chunk2(arr, size = 1) {
|
|
|
1059
1099
|
round,
|
|
1060
1100
|
sample,
|
|
1061
1101
|
sampleSize,
|
|
1102
|
+
set,
|
|
1062
1103
|
shuffle,
|
|
1063
1104
|
snakeCase,
|
|
1105
|
+
startCase,
|
|
1064
1106
|
sum,
|
|
1065
1107
|
sumBy,
|
|
1066
1108
|
tail,
|