Added camelCase function
All checks were successful
Build / Build NPM Project (push) Successful in 1m12s
Build / Tag Version (push) Successful in 12s
Build / Publish Documentation (push) Successful in 50s

This commit is contained in:
Zakary Timson 2025-03-10 09:50:16 -04:00
parent cd5741d6ab
commit 1c2c18b65d
2 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/utils",
"version": "0.23.14",
"version": "0.23.15",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -18,6 +18,16 @@ export const 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
*