isNotLike()
isNotLike(
pattern
): (...args
) =>boolean
Creates a predicate function that determines if a string does not match a given pattern or regular expression.
Parameters
pattern
The string pattern or RegExp to use for testing
string
| RegExp
Returns
A function that takes a string and returns true if it does not match the pattern
(...
args
):boolean
Parameters
args
...[string
]
Returns
boolean
Remarks
- Pure function with no side effects
- Negation of
isLike
using functional composition - Accepts both string patterns and RegExp objects
- String patterns are automatically converted to RegExp using
new RegExp(pattern)
Example
const isNotJsFile = isNotLike(/\.(js|ts)$/);
isNotJsFile('style.css'); // true
isNotJsFile('app.js'); // false
const hasNoNumbers = isNotLike('[0-9]');
hasNoNumbers('abcdef'); // true
hasNoNumbers('abc123'); // false
const isNotEmail = isNotLike(/^[^\s@]+@[^\s@]+\.[^\s@]+$/);
isNotEmail('invalid-email'); // true
isNotEmail('user@example.com'); // false
// Useful with arrays
const files = ['app.js', 'style.css', 'main.ts', 'README.md'];
const nonScriptFiles = files.filter(isNotLike(/\.(js|ts)$/)); // ['style.css', 'README.md']