Converts a string to kebab-case.
This function converts a string to kebab-case, which is a naming convention where multiple words are joined together with hyphens, and all letters are lowercase.
Converting a string with spaces to camelCase:
toKebabCase('hello world')// => { ok: true, value: 'hello-world' } Copy
toKebabCase('hello world')// => { ok: true, value: 'hello-world' }
Converting a string with hyphens to camelCase:
toKebabCase('fooBarBaz')// => { ok: true, value: 'foo-bar-baz' } Copy
toKebabCase('fooBarBaz')// => { ok: true, value: 'foo-bar-baz' }
Handling non-string input:
toKebabCase(42)// => { ok: false, error: Error('[strings.toKebabCase] Expected string value as input') } Copy
toKebabCase(42)// => { ok: false, error: Error('[strings.toKebabCase] Expected string value as input') }
The input string to convert.
A Result containing the converted string on success, or an Error object if the provided input is not a string.
Result
Error
Generated using TypeDoc v0.24.7
Converts a string to kebab-case.
Remarks
This function converts a string to kebab-case, which is a naming convention where multiple words are joined together with hyphens, and all letters are lowercase.
Example
Converting a string with spaces to camelCase:
Example
Converting a string with hyphens to camelCase:
Example
Handling non-string input: