Added test suite
All checks were successful
Build / Build NPM Project (push) Successful in 1m16s
Build / Tag Version (push) Successful in 14s
Build / Publish Documentation (push) Successful in 53s

This commit is contained in:
2025-05-14 16:30:42 -04:00
parent cf122ef9e8
commit fec373ca4c
32 changed files with 1719 additions and 310 deletions

View File

@ -23,7 +23,7 @@ export const CHAR_LIST = LETTER_LIST + LETTER_LIST.toLowerCase() + NUMBER_LIST +
*/
export function camelCase(str?: string) {
const text = pascalCase(str);
return text[0].toLowerCase() + text.slice(1);
return !text ? '' : text[0].toLowerCase() + text.slice(1);
}
/**
@ -110,13 +110,14 @@ export function pad(text: any, length: number, char: string = ' ', start = true)
* @param {string} str
* @return {string}
*/
export function pascalCase(str?: string) {
export function pascalCase(str?: string): string {
if(!str) return '';
const text = str.replaceAll(/(^[^a-zA-Z]+|[^a-zA-Z0-9-_])/g, '')
.replaceAll(/[^a-zA-Z0-9]+(\w?)/g, (...args) => args[1]?.toUpperCase() || '');
return text[0].toUpperCase() + text.slice(1);
return str.match(/[a-zA-Z0-9]+/g)
?.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
.join('') ?? '';
}
/**
* Generate a random hexadecimal value
*