Packages@accelint/predicates
doesNotStartWith
Curried predicate for testing if strings do not start with a specific prefix
Creates a predicate function that determines if a string does not start with a specific prefix.
Usage
import { doesNotStartWith } from '@accelint/predicates';
const isNotHidden = doesNotStartWith('.');
const files = ['.git', '.env', 'README.md', '.gitignore', 'src'];
const visible = files.filter(isNotHidden);
// ['README.md', 'src']Reference
function doesNotStartWith(prefix: string): (input: string) => booleanParameters
| Parameter | Type | Description |
|---|---|---|
prefix | string | The substring to use as the prefix |
Returns
Curried function that accepts a string and returns true if it does not start with the prefix.
Examples
Example: Excluding system files
import { doesNotStartWith } from '@accelint/predicates';
const isNotHidden = doesNotStartWith('.');
const files = ['.git', '.env', 'README.md', '.gitignore', 'src'];
const visible = files.filter(isNotHidden);
// ['README.md', 'src']Good to know: Comparisons are case-sensitive. Use native String methods like
.toLowerCase()before applying this predicate if case-insensitive matching is needed.
Related
- doesStartWith - Positive version of this function
- doesEndWith - Check if string ends with suffix
- doesNotEndWith - Check if string does not end with suffix
- isLike - Pattern matching with RegExp
- isNotLike - Negated pattern matching
- isString - Type guard for strings