es-toolkit 1.10.1-dev.242 → 1.10.1-dev.244
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/fill.d.mts +9 -6
- package/dist/array/fill.d.ts +9 -6
- package/dist/array/fill.js +7 -6
- package/dist/array/fill.js.map +1 -1
- package/dist/array/fill.mjs +1 -1
- package/dist/array/index.js +7 -6
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +32 -32
- package/dist/{chunk-MJA7DAOJ.mjs → chunk-QXTNZR7B.mjs} +1 -1
- package/dist/chunk-QXTNZR7B.mjs.map +1 -0
- package/dist/chunk-YFN6KOC4.mjs +15 -0
- package/dist/chunk-YFN6KOC4.mjs.map +1 -0
- package/dist/compat/index.js +7 -6
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +57 -57
- package/dist/compat/index.mjs.map +1 -1
- package/dist/function/index.mjs +6 -6
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -57
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +1 -1
- package/dist/string/startCase.js.map +1 -1
- package/dist/string/startCase.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-6KP7CLVJ.mjs +0 -14
- package/dist/chunk-6KP7CLVJ.mjs.map +0 -1
- package/dist/chunk-MJA7DAOJ.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "./chunk-F3WCQQET.mjs";
|
|
18
18
|
import {
|
|
19
19
|
startCase
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-QXTNZR7B.mjs";
|
|
21
21
|
import "./chunk-WVQ7YVRK.mjs";
|
|
22
22
|
import "./chunk-ASJF5D6C.mjs";
|
|
23
23
|
import {
|
|
@@ -77,6 +77,22 @@ import {
|
|
|
77
77
|
import {
|
|
78
78
|
sum
|
|
79
79
|
} from "./chunk-2SLTL4KL.mjs";
|
|
80
|
+
import "./chunk-236H5JZJ.mjs";
|
|
81
|
+
import {
|
|
82
|
+
debounce
|
|
83
|
+
} from "./chunk-3IP4JVLL.mjs";
|
|
84
|
+
import {
|
|
85
|
+
negate
|
|
86
|
+
} from "./chunk-BOOQBJN2.mjs";
|
|
87
|
+
import {
|
|
88
|
+
noop
|
|
89
|
+
} from "./chunk-LKXCOLNY.mjs";
|
|
90
|
+
import {
|
|
91
|
+
once
|
|
92
|
+
} from "./chunk-CMBC4MXG.mjs";
|
|
93
|
+
import {
|
|
94
|
+
throttle
|
|
95
|
+
} from "./chunk-QOJGMVVR.mjs";
|
|
80
96
|
import {
|
|
81
97
|
clamp
|
|
82
98
|
} from "./chunk-MLCL773E.mjs";
|
|
@@ -84,6 +100,12 @@ import {
|
|
|
84
100
|
inRange
|
|
85
101
|
} from "./chunk-BH6HLGBA.mjs";
|
|
86
102
|
import "./chunk-DDH7K4QM.mjs";
|
|
103
|
+
import {
|
|
104
|
+
unzipWith
|
|
105
|
+
} from "./chunk-IFNXROZR.mjs";
|
|
106
|
+
import {
|
|
107
|
+
without
|
|
108
|
+
} from "./chunk-PYEYV7BY.mjs";
|
|
87
109
|
import {
|
|
88
110
|
xor
|
|
89
111
|
} from "./chunk-L7FQX5MN.mjs";
|
|
@@ -102,12 +124,21 @@ import {
|
|
|
102
124
|
import {
|
|
103
125
|
zipWith
|
|
104
126
|
} from "./chunk-4KYXHZ4R.mjs";
|
|
127
|
+
import {
|
|
128
|
+
toFilled
|
|
129
|
+
} from "./chunk-OP4OAKQJ.mjs";
|
|
130
|
+
import {
|
|
131
|
+
union
|
|
132
|
+
} from "./chunk-R6QA7PLZ.mjs";
|
|
105
133
|
import {
|
|
106
134
|
unionBy
|
|
107
135
|
} from "./chunk-NFS7RWWE.mjs";
|
|
108
136
|
import {
|
|
109
137
|
unionWith
|
|
110
138
|
} from "./chunk-2ZCITDMK.mjs";
|
|
139
|
+
import {
|
|
140
|
+
uniq
|
|
141
|
+
} from "./chunk-DVK2N4KC.mjs";
|
|
111
142
|
import {
|
|
112
143
|
uniqBy
|
|
113
144
|
} from "./chunk-OXAZEEGP.mjs";
|
|
@@ -118,11 +149,17 @@ import {
|
|
|
118
149
|
unzip
|
|
119
150
|
} from "./chunk-UYZKMBDO.mjs";
|
|
120
151
|
import {
|
|
121
|
-
|
|
122
|
-
} from "./chunk-
|
|
152
|
+
sample
|
|
153
|
+
} from "./chunk-2KNLZB7V.mjs";
|
|
123
154
|
import {
|
|
124
|
-
|
|
125
|
-
} from "./chunk-
|
|
155
|
+
sampleSize
|
|
156
|
+
} from "./chunk-EHSKB6DF.mjs";
|
|
157
|
+
import {
|
|
158
|
+
randomInt
|
|
159
|
+
} from "./chunk-GIWAOOFY.mjs";
|
|
160
|
+
import {
|
|
161
|
+
random
|
|
162
|
+
} from "./chunk-SYWMYQYJ.mjs";
|
|
126
163
|
import {
|
|
127
164
|
shuffle
|
|
128
165
|
} from "./chunk-G7UQ5PUR.mjs";
|
|
@@ -142,14 +179,11 @@ import {
|
|
|
142
179
|
takeWhile
|
|
143
180
|
} from "./chunk-2IXFGSUA.mjs";
|
|
144
181
|
import {
|
|
145
|
-
|
|
146
|
-
} from "./chunk-
|
|
147
|
-
import {
|
|
148
|
-
union
|
|
149
|
-
} from "./chunk-R6QA7PLZ.mjs";
|
|
182
|
+
intersectionBy
|
|
183
|
+
} from "./chunk-O6UXZR3U.mjs";
|
|
150
184
|
import {
|
|
151
|
-
|
|
152
|
-
} from "./chunk-
|
|
185
|
+
intersectionWith
|
|
186
|
+
} from "./chunk-XI7KRD2C.mjs";
|
|
153
187
|
import {
|
|
154
188
|
keyBy
|
|
155
189
|
} from "./chunk-AJKZMN2V.mjs";
|
|
@@ -169,17 +203,8 @@ import {
|
|
|
169
203
|
partition
|
|
170
204
|
} from "./chunk-DN3NOZ3H.mjs";
|
|
171
205
|
import {
|
|
172
|
-
|
|
173
|
-
} from "./chunk-
|
|
174
|
-
import {
|
|
175
|
-
sampleSize
|
|
176
|
-
} from "./chunk-EHSKB6DF.mjs";
|
|
177
|
-
import {
|
|
178
|
-
randomInt
|
|
179
|
-
} from "./chunk-GIWAOOFY.mjs";
|
|
180
|
-
import {
|
|
181
|
-
random
|
|
182
|
-
} from "./chunk-SYWMYQYJ.mjs";
|
|
206
|
+
flattenDeep
|
|
207
|
+
} from "./chunk-ML727RRJ.mjs";
|
|
183
208
|
import {
|
|
184
209
|
forEachRight
|
|
185
210
|
} from "./chunk-IEA53J7P.mjs";
|
|
@@ -196,11 +221,11 @@ import {
|
|
|
196
221
|
intersection
|
|
197
222
|
} from "./chunk-FVVSE2F2.mjs";
|
|
198
223
|
import {
|
|
199
|
-
|
|
200
|
-
} from "./chunk-
|
|
224
|
+
differenceBy
|
|
225
|
+
} from "./chunk-LVWX5B43.mjs";
|
|
201
226
|
import {
|
|
202
|
-
|
|
203
|
-
} from "./chunk-
|
|
227
|
+
differenceWith
|
|
228
|
+
} from "./chunk-6NVQAHXP.mjs";
|
|
204
229
|
import {
|
|
205
230
|
drop
|
|
206
231
|
} from "./chunk-S3CORED5.mjs";
|
|
@@ -215,16 +240,17 @@ import {
|
|
|
215
240
|
} from "./chunk-LJ2C6MVP.mjs";
|
|
216
241
|
import {
|
|
217
242
|
fill
|
|
218
|
-
} from "./chunk-
|
|
243
|
+
} from "./chunk-YFN6KOC4.mjs";
|
|
219
244
|
import {
|
|
220
245
|
flatMap
|
|
221
246
|
} from "./chunk-UY76KTPE.mjs";
|
|
222
|
-
import {
|
|
223
|
-
flattenDeep
|
|
224
|
-
} from "./chunk-ML727RRJ.mjs";
|
|
225
247
|
import {
|
|
226
248
|
flatten
|
|
227
249
|
} from "./chunk-33MSBDC6.mjs";
|
|
250
|
+
import "./chunk-FZEZH22H.mjs";
|
|
251
|
+
import {
|
|
252
|
+
AbortError
|
|
253
|
+
} from "./chunk-DXB7EZUQ.mjs";
|
|
228
254
|
import {
|
|
229
255
|
chunk
|
|
230
256
|
} from "./chunk-E6C5EZQA.mjs";
|
|
@@ -237,32 +263,6 @@ import {
|
|
|
237
263
|
import {
|
|
238
264
|
difference
|
|
239
265
|
} from "./chunk-JPUKH67K.mjs";
|
|
240
|
-
import {
|
|
241
|
-
differenceBy
|
|
242
|
-
} from "./chunk-LVWX5B43.mjs";
|
|
243
|
-
import {
|
|
244
|
-
differenceWith
|
|
245
|
-
} from "./chunk-6NVQAHXP.mjs";
|
|
246
|
-
import "./chunk-FZEZH22H.mjs";
|
|
247
|
-
import {
|
|
248
|
-
AbortError
|
|
249
|
-
} from "./chunk-DXB7EZUQ.mjs";
|
|
250
|
-
import "./chunk-236H5JZJ.mjs";
|
|
251
|
-
import {
|
|
252
|
-
once
|
|
253
|
-
} from "./chunk-CMBC4MXG.mjs";
|
|
254
|
-
import {
|
|
255
|
-
throttle
|
|
256
|
-
} from "./chunk-QOJGMVVR.mjs";
|
|
257
|
-
import {
|
|
258
|
-
debounce
|
|
259
|
-
} from "./chunk-3IP4JVLL.mjs";
|
|
260
|
-
import {
|
|
261
|
-
negate
|
|
262
|
-
} from "./chunk-BOOQBJN2.mjs";
|
|
263
|
-
import {
|
|
264
|
-
noop
|
|
265
|
-
} from "./chunk-LKXCOLNY.mjs";
|
|
266
266
|
import "./chunk-2MM5EJJX.mjs";
|
|
267
267
|
export {
|
|
268
268
|
AbortError,
|
package/dist/string/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/string/index.ts","../../src/string/capitalize.ts","../../src/string/_internal/getWords.ts","../../src/string/camelCase.ts","../../src/string/snakeCase.ts","../../src/string/kebabCase.ts","../../src/string/lowerCase.ts","../../src/string/startCase.ts"],"sourcesContent":["export { camelCase } from './camelCase.ts';\nexport { snakeCase } from './snakeCase.ts';\nexport { kebabCase } from './kebabCase.ts';\nexport { lowerCase } from './lowerCase.ts';\nexport { startCase } from './startCase.ts';\nexport { capitalize } from './capitalize.ts';\n","/**\n * Converts the first character of string to upper case and the remaining to lower case.\n *\n * @template T - Literal type of the string.\n * @param {T} str - The string to be converted to uppercase.\n * @returns {Capitalize<T>} - The capitalized string.\n *\n * @example\n * const result = capitalize('fred') // returns 'Fred'\n * const result2 = capitalize('FRED') // returns 'Fred'\n */\n\nexport const capitalize = <T extends string>(str: T): Capitalize<T> => {\n return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize<T>;\n};\n","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n","import { capitalize } from \"./capitalize.ts\";\nimport { getWords } from \"./_internal/getWords.ts\";\n\n/**\n * Converts a string to camel case.\n *\n * camel case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to camel case.\n * @returns {string} - The converted string to camel case.\n *\n * @example\n * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'\n * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'\n * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'\n * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'\n */\n\nexport function camelCase(str: string): string {\n const words = getWords(str);\n\n if (words.length === 0) {\n return \"\";\n }\n\n const [first, ...rest] = words;\n\n return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join(\"\")\n }`;\n}\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('_');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to kebab case.\n *\n * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.\n *\n * @param {string} str - The string that is to be changed to kebab case.\n * @returns {string} - The converted string to kebab case.\n *\n * @example\n * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'\n * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'\n * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'\n * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'\n */\n\nexport const kebabCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('-');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to lower case.\n *\n * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.\n *\n * @param {string} str - The string that is to be changed to lower case.\n * @returns {string} - The converted string to lower case.\n *\n * @example\n * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'\n * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'\n * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'\n * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'\n */\nexport const lowerCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join(' ');\n};\n","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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,aAAa,CAAmB,QAA0B;AACrE,SAAQ,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,EAAE,YAAY;AACjE;;;ACEA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ACFO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,GAAG;AAE1B,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAEzB,SAAO,GAAG,MAAM,YAAY,CAAC,GAAG,KAAK,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,EAAE,KAAK,EAAE,CAC1E;AACJ;;;ACZO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACHO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACJO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACJO,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":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/string/index.ts","../../src/string/capitalize.ts","../../src/string/_internal/getWords.ts","../../src/string/camelCase.ts","../../src/string/snakeCase.ts","../../src/string/kebabCase.ts","../../src/string/lowerCase.ts","../../src/string/startCase.ts"],"sourcesContent":["export { camelCase } from './camelCase.ts';\nexport { snakeCase } from './snakeCase.ts';\nexport { kebabCase } from './kebabCase.ts';\nexport { lowerCase } from './lowerCase.ts';\nexport { startCase } from './startCase.ts';\nexport { capitalize } from './capitalize.ts';\n","/**\n * Converts the first character of string to upper case and the remaining to lower case.\n *\n * @template T - Literal type of the string.\n * @param {T} str - The string to be converted to uppercase.\n * @returns {Capitalize<T>} - The capitalized string.\n *\n * @example\n * const result = capitalize('fred') // returns 'Fred'\n * const result2 = capitalize('FRED') // returns 'Fred'\n */\n\nexport const capitalize = <T extends string>(str: T): Capitalize<T> => {\n return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize<T>;\n};\n","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n","import { capitalize } from \"./capitalize.ts\";\nimport { getWords } from \"./_internal/getWords.ts\";\n\n/**\n * Converts a string to camel case.\n *\n * camel case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to camel case.\n * @returns {string} - The converted string to camel case.\n *\n * @example\n * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'\n * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'\n * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'\n * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'\n */\n\nexport function camelCase(str: string): string {\n const words = getWords(str);\n\n if (words.length === 0) {\n return \"\";\n }\n\n const [first, ...rest] = words;\n\n return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join(\"\")\n }`;\n}\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport const snakeCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('_');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to kebab case.\n *\n * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.\n *\n * @param {string} str - The string that is to be changed to kebab case.\n * @returns {string} - The converted string to kebab case.\n *\n * @example\n * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'\n * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'\n * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'\n * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'\n */\n\nexport const kebabCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('-');\n};\n","import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to lower case.\n *\n * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.\n *\n * @param {string} str - The string that is to be changed to lower case.\n * @returns {string} - The converted string to lower case.\n *\n * @example\n * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'\n * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'\n * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'\n * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'\n */\nexport const lowerCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join(' ');\n};\n","import { getWords } from './_internal/getWords.ts';\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,aAAa,CAAmB,QAA0B;AACrE,SAAQ,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC,EAAE,YAAY;AACjE;;;ACEA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ACFO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,GAAG;AAE1B,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAEzB,SAAO,GAAG,MAAM,YAAY,CAAC,GAAG,KAAK,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,EAAE,KAAK,EAAE,CAC1E;AACJ;;;ACZO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACHO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACJO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;;;ACJO,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":[]}
|
package/dist/string/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/string/startCase.ts","../../src/string/_internal/getWords.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","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ADLO,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":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/string/startCase.ts","../../src/string/_internal/getWords.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\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","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matchs sequences of characters in a string, considering the following case:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digis\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n * // matchs: ['camel', 'Case', 'HTTP', 'Request']\n */\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;\n\nexport function getWords(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBA,IAAM,qBAAqB;AAEpB,SAAS,SAAS,KAAuB;AAlBhD;AAmBE,SAAO,MAAM,MAAK,SAAI,MAAM,kBAAkB,MAA5B,YAAiC,CAAC,CAAC;AACvD;;;ADLO,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":[]}
|
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.10.1-dev.
|
|
4
|
+
"version": "1.10.1-dev.244+8e5a4f32",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
package/dist/chunk-6KP7CLVJ.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// src/array/fill.ts
|
|
2
|
-
function fill(arr, value, start = 0, end = arr.length) {
|
|
3
|
-
start = Math.max(start, 0);
|
|
4
|
-
end = Math.min(end, arr.length);
|
|
5
|
-
for (let i = start; i < end; i++) {
|
|
6
|
-
arr[i] = value;
|
|
7
|
-
}
|
|
8
|
-
return arr;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
fill
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=chunk-6KP7CLVJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/fill.ts"],"sourcesContent":["/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @param {Array<T | P>} arr - The array to fill.\n * @param {P} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | P>} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n */\n\nexport function fill<T>(arr: unknown[], value: T): T[];\nexport function fill<T, P>(arr: Array<T | P>, value: P, start: number): Array<T | P>;\nexport function fill<T, P>(arr: Array<T | P>, value: P, start: number, end: number): Array<T | P>;\nexport function fill<T, P>(arr: Array<T | P>, value: P, start = 0, end = arr.length): Array<T | P> {\n start = Math.max(start, 0);\n end = Math.min(end, arr.length);\n\n for (let i = start; i < end; i++) {\n arr[i] = value;\n }\n\n return arr;\n}\n"],"mappings":";AA4BO,SAAS,KAAW,KAAmB,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AACjG,UAAQ,KAAK,IAAI,OAAO,CAAC;AACzB,QAAM,KAAK,IAAI,KAAK,IAAI,MAAM;AAE9B,WAAS,IAAI,OAAO,IAAI,KAAK,KAAK;AAChC,QAAI,CAAC,IAAI;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|