Converts a string to comma-separated format by replacing all non-word characters and underscores with commas.
toCommaSepareted("one two")// => { ok: true, value: 'one,two' }toCommaSepareted("one;two")// => { ok: true, value: 'one,two' }toCommaSepareted("one-two")// => { ok: true, value: 'one,two' }toCommaSepareted("one_two")// => { ok: true, value: 'one,two' } Copy
toCommaSepareted("one two")// => { ok: true, value: 'one,two' }toCommaSepareted("one;two")// => { ok: true, value: 'one,two' }toCommaSepareted("one-two")// => { ok: true, value: 'one,two' }toCommaSepareted("one_two")// => { ok: true, value: 'one,two' }
Handle an invalid input string:
toCommaSeparated(42) // => { ok: false, error: Error('[strings.toCommaSeparated] Expected string value as input') } Copy
toCommaSeparated(42) // => { ok: false, error: Error('[strings.toCommaSeparated] Expected string value as input') }
The string to convert to comma-separated format.
A Result object with either 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 comma-separated format by replacing all non-word characters and underscores with commas.
Example
Example
Handle an invalid input string: