Converts a string to a slug format, replacing spaces with hyphens and removing special characters.
toSlug("Bread And Butter")// => { ok: true, value: 'bread-and-butter' } Copy
toSlug("Bread And Butter")// => { ok: true, value: 'bread-and-butter' }
Handling non-string input:
toSlug(42)// => { ok: false, error: Error('[strings.toSlug] Expected string value as input') } Copy
toSlug(42)// => { ok: false, error: Error('[strings.toSlug] Expected string value as input') }
The string to convert to a slug format.
A Result object with either the slug 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 a slug format, replacing spaces with hyphens and removing special characters.
Example
Example
Handling non-string input: