The iiris/text
module includes functions for working with text. It is
designed to be imported with a wildcard, e.g.
import * as T from 'iiris/text'
(string: string) => string
Convert the first code point of string
to uppercase and the rest to lowercase.
T.capitalize('aBc')
// => 'Abc'
See also: toLowerCase, toUpperCase
(separator: RegExp | string) => (string: string) => string
Split the string
into an array of substrings between each separator
.
T.split(', ', 'a, b, c')
// => ['a', 'b', 'c']
See also: join
(regexp: RegExp) => (string: string) => boolean
Check if string
matches the regexp
.
T.test(/abc/, 'abc')
// => true
(string: string) => string
Convert string
to lowercase.
T.toLowerCase('ABC')
// => 'abc'
See also: toUpperCase, capitalize
(string: string) => string
Convert string
to uppercase.
T.toUpperCase('abc')
// => 'ABC'
See also: toLowerCase, capitalize
(string: string) => string
Remove whitespace from both ends of a string
.
T.trim(' abc ')
// => 'abc'
(string: string) => string
Remove whitespace from the end of a string
.
T.trimEnd(' abc ')
// => ' abc'
(string: string) => string
Remove whitespace from the beginning of a string
.
T.trimStart(' abc ')
// => 'abc '