Add a helper application to manage attributes on characters
This commit is contained in:
parent
91ccd93814
commit
6b81d8d83b
10 changed files with 298 additions and 12 deletions
13
module/utils/toID.mjs
Normal file
13
module/utils/toID.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* 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, ``);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue