Function: startsWith()
startsWith(
prefix):Predicate<string>
Defined in: predicate/comparison/index.ts:205
Creates a predicate that tests if a string starts with a prefix.
Case-sensitive.
Parameters
prefix
string
The prefix to test for
Returns
Predicate<string>
A predicate that returns true if value starts with prefix
Example
import * as R from 'remeda'
const names = ['Alice', 'Bob', 'Alex', 'Barbara']
R.filter(names, startsWith('A')) // => ['Alice', 'Alex']
// Real-world: Filter files by extension
const files = ['app.ts', 'test.spec.ts', 'config.json']
R.filter(files, (f) => !startsWith('test.')(f)) // => non-test files
See
- endsWith - for suffix testing
- includes - for substring testing