es-toolkit 1.20.0-dev.646 → 1.20.0-dev.648

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.
@@ -82,6 +82,7 @@ export { withTimeout } from '../promise/withTimeout.mjs';
82
82
  export { timeout } from '../promise/timeout.mjs';
83
83
  export { capitalize } from '../string/capitalize.mjs';
84
84
  export { pascalCase } from '../string/pascalCase.mjs';
85
+ export { constantCase } from '../string/constantCase.mjs';
85
86
  export { upperFirst } from '../string/upperFirst.mjs';
86
87
  export { lowerFirst } from '../string/lowerFirst.mjs';
87
88
  export { deburr } from '../string/deburr.mjs';
@@ -82,6 +82,7 @@ export { withTimeout } from '../promise/withTimeout.js';
82
82
  export { timeout } from '../promise/timeout.js';
83
83
  export { capitalize } from '../string/capitalize.js';
84
84
  export { pascalCase } from '../string/pascalCase.js';
85
+ export { constantCase } from '../string/constantCase.js';
85
86
  export { upperFirst } from '../string/upperFirst.js';
86
87
  export { lowerFirst } from '../string/lowerFirst.js';
87
88
  export { deburr } from '../string/deburr.js';
@@ -1674,6 +1674,7 @@ exports.isNotNil = isWeakSet$1.isNotNil;
1674
1674
  exports.isNull = isWeakSet$1.isNull;
1675
1675
  exports.isUndefined = isWeakSet$1.isUndefined;
1676
1676
  exports.capitalize = string_index.capitalize;
1677
+ exports.constantCase = string_index.constantCase;
1677
1678
  exports.deburr = string_index.deburr;
1678
1679
  exports.escape = string_index.escape;
1679
1680
  exports.escapeRegExp = string_index.escapeRegExp;
@@ -83,6 +83,7 @@ export { withTimeout } from '../promise/withTimeout.mjs';
83
83
  export { timeout } from '../promise/timeout.mjs';
84
84
  export { capitalize } from '../string/capitalize.mjs';
85
85
  export { pascalCase } from '../string/pascalCase.mjs';
86
+ export { constantCase } from '../string/constantCase.mjs';
86
87
  export { upperFirst } from '../string/upperFirst.mjs';
87
88
  export { lowerFirst } from '../string/lowerFirst.mjs';
88
89
  export { deburr } from '../string/deburr.mjs';
package/dist/index.d.mts CHANGED
@@ -123,6 +123,7 @@ export { lowerCase } from './string/lowerCase.mjs';
123
123
  export { startCase } from './string/startCase.mjs';
124
124
  export { capitalize } from './string/capitalize.mjs';
125
125
  export { pascalCase } from './string/pascalCase.mjs';
126
+ export { constantCase } from './string/constantCase.mjs';
126
127
  export { trim } from './string/trim.mjs';
127
128
  export { trimStart } from './string/trimStart.mjs';
128
129
  export { trimEnd } from './string/trimEnd.mjs';
package/dist/index.d.ts CHANGED
@@ -123,6 +123,7 @@ export { lowerCase } from './string/lowerCase.js';
123
123
  export { startCase } from './string/startCase.js';
124
124
  export { capitalize } from './string/capitalize.js';
125
125
  export { pascalCase } from './string/pascalCase.js';
126
+ export { constantCase } from './string/constantCase.js';
126
127
  export { trim } from './string/trim.js';
127
128
  export { trimStart } from './string/trimStart.js';
128
129
  export { trimEnd } from './string/trimEnd.js';
package/dist/index.js CHANGED
@@ -138,6 +138,7 @@ exports.isPrimitive = isPlainObject.isPrimitive;
138
138
  exports.isTypedArray = isPlainObject.isTypedArray;
139
139
  exports.camelCase = string_index.camelCase;
140
140
  exports.capitalize = string_index.capitalize;
141
+ exports.constantCase = string_index.constantCase;
141
142
  exports.deburr = string_index.deburr;
142
143
  exports.escape = string_index.escape;
143
144
  exports.escapeRegExp = string_index.escapeRegExp;
package/dist/index.mjs CHANGED
@@ -123,6 +123,7 @@ export { lowerCase } from './string/lowerCase.mjs';
123
123
  export { startCase } from './string/startCase.mjs';
124
124
  export { capitalize } from './string/capitalize.mjs';
125
125
  export { pascalCase } from './string/pascalCase.mjs';
126
+ export { constantCase } from './string/constantCase.mjs';
126
127
  export { trim } from './string/trim.mjs';
127
128
  export { trimStart } from './string/trimStart.mjs';
128
129
  export { trimEnd } from './string/trimEnd.mjs';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to constant case.
3
+ *
4
+ * Constant case is a naming convention where each word is written in uppercase letters and separated by an underscore (`_`). For example, `CONSTANT_CASE`.
5
+ *
6
+ * @param {string} str - The string that is to be changed to constant case.
7
+ * @returns {string} - The converted string to constant case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE'
11
+ * const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE'
12
+ * const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT'
13
+ * const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST'
14
+ */
15
+ declare function constantCase(str: string): string;
16
+
17
+ export { constantCase };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to constant case.
3
+ *
4
+ * Constant case is a naming convention where each word is written in uppercase letters and separated by an underscore (`_`). For example, `CONSTANT_CASE`.
5
+ *
6
+ * @param {string} str - The string that is to be changed to constant case.
7
+ * @returns {string} - The converted string to constant case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE'
11
+ * const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE'
12
+ * const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT'
13
+ * const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST'
14
+ */
15
+ declare function constantCase(str: string): string;
16
+
17
+ export { constantCase };
@@ -0,0 +1,8 @@
1
+ import { getWords } from './_internal/getWords.mjs';
2
+
3
+ function constantCase(str) {
4
+ const words = getWords(str);
5
+ return words.map(word => word.toUpperCase()).join('_');
6
+ }
7
+
8
+ export { constantCase };
@@ -6,6 +6,7 @@ export { lowerCase } from './lowerCase.mjs';
6
6
  export { startCase } from './startCase.mjs';
7
7
  export { capitalize } from './capitalize.mjs';
8
8
  export { pascalCase } from './pascalCase.mjs';
9
+ export { constantCase } from './constantCase.mjs';
9
10
  export { trim } from './trim.mjs';
10
11
  export { trimStart } from './trimStart.mjs';
11
12
  export { trimEnd } from './trimEnd.mjs';
@@ -6,6 +6,7 @@ export { lowerCase } from './lowerCase.js';
6
6
  export { startCase } from './startCase.js';
7
7
  export { capitalize } from './capitalize.js';
8
8
  export { pascalCase } from './pascalCase.js';
9
+ export { constantCase } from './constantCase.js';
9
10
  export { trim } from './trim.js';
10
11
  export { trimStart } from './trimStart.js';
11
12
  export { trimEnd } from './trimEnd.js';
@@ -69,6 +69,11 @@ function pascalCase(str) {
69
69
  return words.map(word => capitalize(word)).join('');
70
70
  }
71
71
 
72
+ function constantCase(str) {
73
+ const words = getWords(str);
74
+ return words.map(word => word.toUpperCase()).join('_');
75
+ }
76
+
72
77
  function trimStart(str, chars) {
73
78
  if (chars === undefined) {
74
79
  return str.trimStart();
@@ -202,6 +207,7 @@ function pad(str, length, chars = ' ') {
202
207
 
203
208
  exports.camelCase = camelCase;
204
209
  exports.capitalize = capitalize;
210
+ exports.constantCase = constantCase;
205
211
  exports.deburr = deburr;
206
212
  exports.escape = escape;
207
213
  exports.escapeRegExp = escapeRegExp;
@@ -6,6 +6,7 @@ export { lowerCase } from './lowerCase.mjs';
6
6
  export { startCase } from './startCase.mjs';
7
7
  export { capitalize } from './capitalize.mjs';
8
8
  export { pascalCase } from './pascalCase.mjs';
9
+ export { constantCase } from './constantCase.mjs';
9
10
  export { trim } from './trim.mjs';
10
11
  export { trimStart } from './trimStart.mjs';
11
12
  export { trimEnd } from './trimEnd.mjs';
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.20.0-dev.646+53703f4a",
4
+ "version": "1.20.0-dev.648+60e4ba38",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {