S (String)
Single-argument
Section titled “Single-argument”trim(s: string): stringtrimStart(s: string): stringtrimEnd(s: string): stringtoLowerCase(s: string): stringtoUpperCase(s: string): stringisEmpty(s: string): booleanlength(s: string): numberCurried
Section titled “Curried”startsWith(search: string): (s: string) => booleanendsWith(search: string): (s: string) => booleanincludes(search: string): (s: string) => booleansplit(sep: string): (s: string) => string[]repeat(n: number): (s: string) => stringslice(start: number, end?: number): (s: string) => stringreplaceAll(search: string, replacement: string): (s: string) => stringExamples
Section titled “Examples”import { pipe } from '@stopcock/fp'import * as S from '@stopcock/fp/string'
// slug from titlepipe(' Hello World! ', S.trim, S.toLowerCase, S.replaceAll(' ', '-'), S.replaceAll('!', ''))// 'hello-world'
// parse CSV headerpipe('name,email,role', S.split(','))// ['name', 'email', 'role']
// check file extensionpipe('report.pdf', S.endsWith('.pdf')) // true
// templatepipe('Hello, NAME!', S.replaceAll('NAME', user.name))
// truncateconst preview = pipe(description, S.slice(0, 100))