nhb-toolbox 2.3.3 → 2.3.4
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/string/convert.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* * Converts a string to `camelCase`, `snake_case`,
|
|
2
|
+
* * Converts a string to `camelCase`, `snake_case`, `kebab-case`, `PascalCase`, `Title Case`.
|
|
3
3
|
*
|
|
4
4
|
* @param string - The input string to be converted. Words should be separated by **non-alphanumeric characters** (e.g., spaces, hyphens, underscores, dots, slashes, etc.).
|
|
5
|
-
* @param format - The format to convert the string to (`'camelCase'`, `'snake_case'`,
|
|
5
|
+
* @param format - The format to convert the string to (`'camelCase'`, `'snake_case'`, `'kebab-case'`, `PascalCase`, or `Title Case`).
|
|
6
6
|
* @returns The formatted string in the specified case format.
|
|
7
7
|
*/
|
|
8
|
-
export declare function convertStringCase(string: string, format: 'camelCase' | 'snake_case' | 'kebab-case'): string;
|
|
8
|
+
export declare function convertStringCase(string: string, format: 'camelCase' | 'snake_case' | 'kebab-case' | 'PascalCase' | 'Title Case'): string;
|
|
9
9
|
/**
|
|
10
10
|
* Replaces all occurrences of a string or pattern in the given input string.
|
|
11
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/string/convert.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,MAAM,EACd,MAAM,
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/string/convert.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,MAAM,EACd,MAAM,EACH,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,YAAY,GACb,MAAM,CAyCR;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,UACvB,MAAM,QACP,MAAM,GAAG,MAAM,WACZ,MAAM,KACb,MAgBF,CAAC"}
|
package/dist/string/convert.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* * Converts a string to `camelCase`, `snake_case`,
|
|
3
|
+
* * Converts a string to `camelCase`, `snake_case`, `kebab-case`, `PascalCase`, `Title Case`.
|
|
4
4
|
*
|
|
5
5
|
* @param string - The input string to be converted. Words should be separated by **non-alphanumeric characters** (e.g., spaces, hyphens, underscores, dots, slashes, etc.).
|
|
6
|
-
* @param format - The format to convert the string to (`'camelCase'`, `'snake_case'`,
|
|
6
|
+
* @param format - The format to convert the string to (`'camelCase'`, `'snake_case'`, `'kebab-case'`, `PascalCase`, or `Title Case`).
|
|
7
7
|
* @returns The formatted string in the specified case format.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -23,6 +23,11 @@ function convertStringCase(string, format) {
|
|
|
23
23
|
return formattedString.replace(/[A-Z]/g, (letter, index) => index === 0 ? letter.toLowerCase() : `_${letter.toLowerCase()}`);
|
|
24
24
|
case 'kebab-case':
|
|
25
25
|
return formattedString.replace(/[A-Z]/g, (letter, index) => index === 0 ? letter.toLowerCase() : `-${letter.toLowerCase()}`);
|
|
26
|
+
case 'PascalCase':
|
|
27
|
+
return (formattedString.charAt(0).toUpperCase() +
|
|
28
|
+
formattedString.slice(1));
|
|
29
|
+
case 'Title Case':
|
|
30
|
+
return formattedString.replace(/[A-Z]/g, (letter, index) => index === 0 ? letter.toUpperCase() : ` ${letter.toUpperCase()}`);
|
|
26
31
|
default:
|
|
27
32
|
return formattedString;
|
|
28
33
|
}
|
package/package.json
CHANGED