Added camelCase function
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
| 	"name": "@ztimson/utils", | 	"name": "@ztimson/utils", | ||||||
| 	"version": "0.23.14", | 	"version": "0.23.15", | ||||||
| 	"description": "Utility library", | 	"description": "Utility library", | ||||||
| 	"author": "Zak Timson", | 	"author": "Zak Timson", | ||||||
| 	"license": "MIT", | 	"license": "MIT", | ||||||
|   | |||||||
| @@ -18,6 +18,16 @@ export const SYMBOL_LIST = '~`!@#$%^&*()_-+={[}]|\\:;"\'<,>.?/'; | |||||||
|  */ |  */ | ||||||
| export const CHAR_LIST = LETTER_LIST + LETTER_LIST.toLowerCase() + NUMBER_LIST + SYMBOL_LIST; | export const CHAR_LIST = LETTER_LIST + LETTER_LIST.toLowerCase() + NUMBER_LIST + SYMBOL_LIST; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Converts text to camel case | ||||||
|  |  */ | ||||||
|  | export function camelCase(text?: string) { | ||||||
|  | 	if(!text) return ''; | ||||||
|  | 	text = text.replaceAll(/^[0-9]+/g, '') | ||||||
|  | 		.replaceAll(/[^a-zA-Z0-9]+(\w?)/g, (...args) => args[1]?.toUpperCase() || ''); | ||||||
|  | 	return text[0].toLowerCase() + text.slice(1); | ||||||
|  | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Convert number of bytes into a human-readable size |  * Convert number of bytes into a human-readable size | ||||||
|  * |  * | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user