13 lines
305 B
JavaScript
13 lines
305 B
JavaScript
/**
|
|
* A helper method that converts an arbitrary string into a format that can be
|
|
* used as an object key easily.
|
|
*
|
|
* @param {string} text The text to convert
|
|
* @returns The converted ID
|
|
*/
|
|
export function toID(text) {
|
|
return text
|
|
.toLowerCase()
|
|
.replace(/\s+/g, `_`)
|
|
.replace(/\W/g, ``);
|
|
};
|