@sohanemon/utils 4.0.31 → 4.0.32
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/functions/index.d.ts +7 -0
- package/dist/functions/index.js +13 -0
- package/package.json +1 -1
|
@@ -53,3 +53,10 @@ export declare const scrollTo: (containerSelector: string | React.RefObject<HTML
|
|
|
53
53
|
* @param [onSuccess=() => {}] - Optional callback executed after successful copy.
|
|
54
54
|
*/
|
|
55
55
|
export declare const copyToClipboard: (value: string, onSuccess?: () => void) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Converts camelCase, PascalCase, kebab-case, snake_case into normal case.
|
|
58
|
+
*
|
|
59
|
+
* @param inputString - The string need to be converted into normal case
|
|
60
|
+
* @returns - Normal Case
|
|
61
|
+
*/
|
|
62
|
+
export declare function convertToNormalCase(inputString: string): string;
|
package/dist/functions/index.js
CHANGED
|
@@ -96,3 +96,16 @@ export const copyToClipboard = (value, onSuccess = () => { }) => {
|
|
|
96
96
|
}
|
|
97
97
|
navigator.clipboard.writeText(value).then(onSuccess);
|
|
98
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* Converts camelCase, PascalCase, kebab-case, snake_case into normal case.
|
|
101
|
+
*
|
|
102
|
+
* @param inputString - The string need to be converted into normal case
|
|
103
|
+
* @returns - Normal Case
|
|
104
|
+
*/
|
|
105
|
+
export function convertToNormalCase(inputString) {
|
|
106
|
+
const splittedString = inputString.split('.').pop();
|
|
107
|
+
const string = splittedString || inputString;
|
|
108
|
+
const words = string.replace(/([a-z])([A-Z])/g, '$1 $2').split(/[-_|\s]+/);
|
|
109
|
+
const capitalizedWords = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1));
|
|
110
|
+
return capitalizedWords.join(' ');
|
|
111
|
+
}
|