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