overSome()
overSome<
T>(predicates): (value) =>boolean
Creates a function that checks if any of the predicates return truthy when invoked with the arguments it receives.
DEPRECATED
Use predicates.some(fn => fn(value)) directly instead.
Type Parametersโ
T: Tโ
The type of the value to check.
Parametersโ
predicates: (value) => boolean[]โ
The predicates to check.
Returnsโ
A function that returns true if any predicate passes.
See Alsoโ
Sinceโ
2.0.0
Also known asโ
anyPass (Ramda) ยท overSome (Lodash, es-toolkit) ยท โ (Remeda, Radashi, Effect, Modern Dash, Antfu)
Exampleโ
// โ Deprecated approach
const isPositiveOrEven = overSome([n => n > 0, n => n % 2 === 0]);
isPositiveOrEven(-2); // => true (even)
isPositiveOrEven(-3); // => false
// โ
Recommended approach
const predicates = [(n: number) => n > 0, (n: number) => n % 2 === 0];
const isPositiveOrEven = (n: number) => predicates.some(fn => fn(n));
isPositiveOrEven(-2); // => true (even)
isPositiveOrEven(-3); // => false
How it works?โ
Creates a function that checks if any predicate returns truthy.
Deprecated: Use Array.some() with predicates.
Native Equivalentโ
// โ overSome([fn1, fn2])(value)
// โ
[fn1, fn2].some(fn => fn(value))
Use Casesโ
Combine predicates with OR ๐โ
Check if any predicate passes.
const predicates = [
(n: number) => n > 0,
(n: number) => n % 2 === 0
];
const isPositiveOrEven = (n: number) => predicates.some(fn => fn(n));
isPositiveOrEven(-2); // true (even)
isPositiveOrEven(-3); // false
Match any conditionโ
Filter items matching any condition.
const matchers = [
(s: string) => s.startsWith('error'),
(s: string) => s.includes('fail')
];
const isError = (s: string) => matchers.some(m => m(s));
logs.filter(isError);