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);