Skip to main content

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โ€‹

Array.some() - MDN


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