Adds utility to convert string to snake case

This commit is contained in:
Aaron Louie 2020-01-13 22:18:31 -05:00
parent 04f44155ab
commit 915a5a45e7
1 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,6 @@
export const toSnakeCase = (str: string) => {
return !str ? '' : String(str)
.replace(/^\W+|\W+$/gi, '')
.replace(/\W+/gi, '_')
.toLowerCase();
};