es-toolkit 1.10.1-dev.229 → 1.10.1-dev.230

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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./chunk-NKLIE2OI.mjs";
2
- import "./chunk-QKYYOLJ6.mjs";
2
+ import "./chunk-XT74R35S.mjs";
3
3
  import {
4
4
  camelCase
5
5
  } from "./chunk-Y5V7UAZZ.mjs";
@@ -15,6 +15,9 @@ import {
15
15
  import {
16
16
  snakeCase
17
17
  } from "./chunk-F3WCQQET.mjs";
18
+ import {
19
+ startCase
20
+ } from "./chunk-MJA7DAOJ.mjs";
18
21
  import "./chunk-WVQ7YVRK.mjs";
19
22
  import "./chunk-ASJF5D6C.mjs";
20
23
  import {
@@ -74,22 +77,6 @@ import {
74
77
  import {
75
78
  sum
76
79
  } from "./chunk-2SLTL4KL.mjs";
77
- import "./chunk-236H5JZJ.mjs";
78
- import {
79
- debounce
80
- } from "./chunk-3IP4JVLL.mjs";
81
- import {
82
- negate
83
- } from "./chunk-BOOQBJN2.mjs";
84
- import {
85
- noop
86
- } from "./chunk-LKXCOLNY.mjs";
87
- import {
88
- once
89
- } from "./chunk-CMBC4MXG.mjs";
90
- import {
91
- throttle
92
- } from "./chunk-QOJGMVVR.mjs";
93
80
  import {
94
81
  clamp
95
82
  } from "./chunk-MLCL773E.mjs";
@@ -97,12 +84,6 @@ import {
97
84
  inRange
98
85
  } from "./chunk-BH6HLGBA.mjs";
99
86
  import "./chunk-DDH7K4QM.mjs";
100
- import {
101
- unzipWith
102
- } from "./chunk-IFNXROZR.mjs";
103
- import {
104
- without
105
- } from "./chunk-PYEYV7BY.mjs";
106
87
  import {
107
88
  xor
108
89
  } from "./chunk-L7FQX5MN.mjs";
@@ -121,21 +102,12 @@ import {
121
102
  import {
122
103
  zipWith
123
104
  } from "./chunk-4KYXHZ4R.mjs";
124
- import {
125
- toFilled
126
- } from "./chunk-OP4OAKQJ.mjs";
127
- import {
128
- union
129
- } from "./chunk-R6QA7PLZ.mjs";
130
105
  import {
131
106
  unionBy
132
107
  } from "./chunk-NFS7RWWE.mjs";
133
108
  import {
134
109
  unionWith
135
110
  } from "./chunk-2ZCITDMK.mjs";
136
- import {
137
- uniq
138
- } from "./chunk-DVK2N4KC.mjs";
139
111
  import {
140
112
  uniqBy
141
113
  } from "./chunk-OXAZEEGP.mjs";
@@ -146,17 +118,11 @@ import {
146
118
  unzip
147
119
  } from "./chunk-UYZKMBDO.mjs";
148
120
  import {
149
- sample
150
- } from "./chunk-2KNLZB7V.mjs";
151
- import {
152
- sampleSize
153
- } from "./chunk-EHSKB6DF.mjs";
154
- import {
155
- randomInt
156
- } from "./chunk-GIWAOOFY.mjs";
121
+ unzipWith
122
+ } from "./chunk-IFNXROZR.mjs";
157
123
  import {
158
- random
159
- } from "./chunk-SYWMYQYJ.mjs";
124
+ without
125
+ } from "./chunk-PYEYV7BY.mjs";
160
126
  import {
161
127
  shuffle
162
128
  } from "./chunk-G7UQ5PUR.mjs";
@@ -176,11 +142,14 @@ import {
176
142
  takeWhile
177
143
  } from "./chunk-2IXFGSUA.mjs";
178
144
  import {
179
- intersectionBy
180
- } from "./chunk-O6UXZR3U.mjs";
145
+ toFilled
146
+ } from "./chunk-OP4OAKQJ.mjs";
181
147
  import {
182
- intersectionWith
183
- } from "./chunk-XI7KRD2C.mjs";
148
+ union
149
+ } from "./chunk-R6QA7PLZ.mjs";
150
+ import {
151
+ uniq
152
+ } from "./chunk-DVK2N4KC.mjs";
184
153
  import {
185
154
  keyBy
186
155
  } from "./chunk-AJKZMN2V.mjs";
@@ -200,8 +169,17 @@ import {
200
169
  partition
201
170
  } from "./chunk-DN3NOZ3H.mjs";
202
171
  import {
203
- flattenDeep
204
- } from "./chunk-ML727RRJ.mjs";
172
+ sample
173
+ } from "./chunk-2KNLZB7V.mjs";
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";
205
183
  import {
206
184
  forEachRight
207
185
  } from "./chunk-IEA53J7P.mjs";
@@ -218,11 +196,11 @@ import {
218
196
  intersection
219
197
  } from "./chunk-FVVSE2F2.mjs";
220
198
  import {
221
- differenceBy
222
- } from "./chunk-LVWX5B43.mjs";
199
+ intersectionBy
200
+ } from "./chunk-O6UXZR3U.mjs";
223
201
  import {
224
- differenceWith
225
- } from "./chunk-6NVQAHXP.mjs";
202
+ intersectionWith
203
+ } from "./chunk-XI7KRD2C.mjs";
226
204
  import {
227
205
  drop
228
206
  } from "./chunk-S3CORED5.mjs";
@@ -241,13 +219,12 @@ import {
241
219
  import {
242
220
  flatMap
243
221
  } from "./chunk-KBXHURLW.mjs";
222
+ import {
223
+ flattenDeep
224
+ } from "./chunk-ML727RRJ.mjs";
244
225
  import {
245
226
  flatten
246
227
  } from "./chunk-33MSBDC6.mjs";
247
- import "./chunk-FZEZH22H.mjs";
248
- import {
249
- AbortError
250
- } from "./chunk-DXB7EZUQ.mjs";
251
228
  import {
252
229
  chunk
253
230
  } from "./chunk-E6C5EZQA.mjs";
@@ -260,6 +237,32 @@ import {
260
237
  import {
261
238
  difference
262
239
  } 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";
263
266
  import "./chunk-2MM5EJJX.mjs";
264
267
  export {
265
268
  AbortError,
@@ -322,6 +325,7 @@ export {
322
325
  sampleSize,
323
326
  shuffle,
324
327
  snakeCase,
328
+ startCase,
325
329
  sum,
326
330
  sumBy,
327
331
  tail,
@@ -2,4 +2,5 @@ export { camelCase } from './camelCase.mjs';
2
2
  export { snakeCase } from './snakeCase.mjs';
3
3
  export { kebabCase } from './kebabCase.mjs';
4
4
  export { lowerCase } from './lowerCase.mjs';
5
+ export { startCase } from './startCase.mjs';
5
6
  export { capitalize } from './capitalize.mjs';
@@ -2,4 +2,5 @@ export { camelCase } from './camelCase.js';
2
2
  export { snakeCase } from './snakeCase.js';
3
3
  export { kebabCase } from './kebabCase.js';
4
4
  export { lowerCase } from './lowerCase.js';
5
+ export { startCase } from './startCase.js';
5
6
  export { capitalize } from './capitalize.js';
@@ -24,7 +24,8 @@ __export(string_exports, {
24
24
  capitalize: () => capitalize,
25
25
  kebabCase: () => kebabCase,
26
26
  lowerCase: () => lowerCase,
27
- snakeCase: () => snakeCase
27
+ snakeCase: () => snakeCase,
28
+ startCase: () => startCase
28
29
  });
29
30
  module.exports = __toCommonJS(string_exports);
30
31
 
@@ -67,12 +68,30 @@ var lowerCase = (str) => {
67
68
  const words = getWords(str);
68
69
  return words.map((word) => word.toLowerCase()).join(" ");
69
70
  };
71
+
72
+ // src/string/startCase.ts
73
+ function startCase(str) {
74
+ const words = getWords(str.trim());
75
+ let result = "";
76
+ for (const word of words) {
77
+ if (result) {
78
+ result += " ";
79
+ }
80
+ if (word === word.toUpperCase()) {
81
+ result += word;
82
+ } else {
83
+ result += word[0].toUpperCase() + word.slice(1).toLowerCase();
84
+ }
85
+ }
86
+ return result;
87
+ }
70
88
  // Annotate the CommonJS export names for ESM import in node:
71
89
  0 && (module.exports = {
72
90
  camelCase,
73
91
  capitalize,
74
92
  kebabCase,
75
93
  lowerCase,
76
- snakeCase
94
+ snakeCase,
95
+ startCase
77
96
  });
78
97
  //# sourceMappingURL=index.js.map
@@ -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"],"sourcesContent":["export { camelCase } from './camelCase.ts';\nexport { snakeCase } from './snakeCase.ts';\nexport { kebabCase } from './kebabCase.ts';\nexport { lowerCase } from './lowerCase.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"],"mappings":";;;;;;;;;;;;;;;;;;;;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;","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';\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,4 +1,4 @@
1
- import "../chunk-QKYYOLJ6.mjs";
1
+ import "../chunk-XT74R35S.mjs";
2
2
  import {
3
3
  camelCase
4
4
  } from "../chunk-Y5V7UAZZ.mjs";
@@ -14,6 +14,9 @@ import {
14
14
  import {
15
15
  snakeCase
16
16
  } from "../chunk-F3WCQQET.mjs";
17
+ import {
18
+ startCase
19
+ } from "../chunk-MJA7DAOJ.mjs";
17
20
  import "../chunk-WVQ7YVRK.mjs";
18
21
  import "../chunk-2MM5EJJX.mjs";
19
22
  export {
@@ -21,6 +24,7 @@ export {
21
24
  capitalize,
22
25
  kebabCase,
23
26
  lowerCase,
24
- snakeCase
27
+ snakeCase,
28
+ startCase
25
29
  };
26
30
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
3
+ *
4
+ * Start case is the naming convention in which each word is written with an initial capital letter.
5
+ * @param {string} str - The string to convert.
6
+ * @returns {string} The converted string.
7
+ *
8
+ * @example
9
+ * const result1 = startCase('hello world'); // result will be 'Hello World'
10
+ * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'
11
+ * const result3 = startCase('hello-world'); // result will be 'Hello World'
12
+ * const result4 = startCase('hello_world'); // result will be 'Hello World'
13
+ */
14
+ declare function startCase(str: string): string;
15
+
16
+ export { startCase };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.
3
+ *
4
+ * Start case is the naming convention in which each word is written with an initial capital letter.
5
+ * @param {string} str - The string to convert.
6
+ * @returns {string} The converted string.
7
+ *
8
+ * @example
9
+ * const result1 = startCase('hello world'); // result will be 'Hello World'
10
+ * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'
11
+ * const result3 = startCase('hello-world'); // result will be 'Hello World'
12
+ * const result4 = startCase('hello_world'); // result will be 'Hello World'
13
+ */
14
+ declare function startCase(str: string): string;
15
+
16
+ export { startCase };
@@ -0,0 +1,54 @@
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/string/startCase.ts
21
+ var startCase_exports = {};
22
+ __export(startCase_exports, {
23
+ startCase: () => startCase
24
+ });
25
+ module.exports = __toCommonJS(startCase_exports);
26
+
27
+ // src/string/_internal/getWords.ts
28
+ var CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;
29
+ function getWords(str) {
30
+ var _a;
31
+ return Array.from((_a = str.match(CASE_SPLIT_PATTERN)) != null ? _a : []);
32
+ }
33
+
34
+ // src/string/startCase.ts
35
+ function startCase(str) {
36
+ const words = getWords(str.trim());
37
+ let result = "";
38
+ for (const word of words) {
39
+ if (result) {
40
+ result += " ";
41
+ }
42
+ if (word === word.toUpperCase()) {
43
+ result += word;
44
+ } else {
45
+ result += word[0].toUpperCase() + word.slice(1).toLowerCase();
46
+ }
47
+ }
48
+ return result;
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ startCase
53
+ });
54
+ //# sourceMappingURL=startCase.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,9 @@
1
+ import {
2
+ startCase
3
+ } from "../chunk-MJA7DAOJ.mjs";
4
+ import "../chunk-WVQ7YVRK.mjs";
5
+ import "../chunk-2MM5EJJX.mjs";
6
+ export {
7
+ startCase
8
+ };
9
+ //# sourceMappingURL=startCase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","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.229+1ea74b70",
4
+ "version": "1.10.1-dev.230+7ee48c0e",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-QKYYOLJ6.mjs.map