UNPKG
@samlevy/string-helpers
Version:
latest (1.2.0)
1.2.0
1.1.0
1.0.1
1.0.0
Basic string helper functions
github.com/samlev/string-helpers
samlev/string-helpers
@samlevy/string-helpers
/
src
/
snake.ts
13 lines
(11 loc)
•
265 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
import studly
from
"./studly"
;
/** * Converts a string to Headline Case * *
@param
str */
export
default
(str:
string
):
string
=>
studly
(str) .
replaceAll
(/(?<=[a-z])([A-Z0-
9
])/g,
"_
$1
"
) .
replaceAll
(/(?<=[
0
-
9
])([A-Za-z])/g,
"_
$1
"
) .
toLowerCase
();