xdash / separateWords
Function: separateWords()
separateWords(
str
):string
[]
Separates words in a string based on the detected case.
Parameters
• str: string
The string to separate.
Returns
string
[]
An array of separated words.
Example
separateWords('fooBar') // returns ['foo', 'Bar']
separateWords('foo-bar') // returns ['foo', 'bar']
separateWords('FOO_BAR') // returns ['FOO', 'BAR']
separateWords('foo bar') // returns ['foo', 'bar']
separateWords('') // returns []
separateWords('fooBar-baz') // returns ['foo', 'Bar', 'baz']