toKebabCase

toKebabCase

Converts any casing to kebab-case

Import

import { toKebabCase } from '@fullstacksjs/toolbox';

Signature

function toKebabCase(str: string): string {}

Examples

toKebabCase('')             // ''
toKebabCase(' ')            // ''
toKebabCase('foo')          // 'foo'
toKebabCase('foo bar')      // 'foo-bar'
toKebabCase('foo-bar')      // 'foo-bar'
toKebabCase('fooBar')       // 'foo-bar'
toKebabCase('foo_bar')      // 'foo-bar'
toKebabCase('foo bar code') // 'foo-bar-code'
toKebabCase('foo-bar-code') // 'foo-bar-code'
toKebabCase('fooBarCode')   // 'foo-bar-code'
toKebabCase('foo_bar_code') // 'foo-bar-code'
toKebabCase('FOO_BAR_CODE') // 'foo-bar-code'
toKebabCase('ThisIs-fullstacksjs radio__and--I-loveCoding') // 'this-is-fullstacksjs-radio-and-i-love-coding',