apphouse
Version:
Component library for React that uses observable state management and theme-able components.
12 lines (11 loc) • 490 B
text/typescript
/**
* Converts a string into an ID format by removing non-alphanumeric characters and converting the first letter to lowercase.
* @param {string} input - The input string to convert.
* @returns {string} The converted ID string.
*/
export function makeId(input: string): string {
const cleanedString = input.replace(/[^a-zA-Z0-9]/g, '');
const firstLetter = cleanedString.charAt(0).toLowerCase();
const restOfString = cleanedString.slice(1);
return firstLetter + restOfString;
}