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