@antv/g2plot
Version:
An interactive and responsive charting library
13 lines (12 loc) • 300 B
text/typescript
/**
* @desc simple kebabCase like lodash
*
* kebabCase('fooBar'); => 'foo-bar'
*/
export function kebabCase(word: string) {
if (!word) {
return word;
}
const result = word.match(/(([A-Z]{0,1}[a-z]*[^A-Z])|([A-Z]{1}))/g);
return result.map((s: string) => s.toLowerCase()).join('-');
}