some
some() function
Returns true if any of the values in Iterable/AsyncIterable pass f
truth test
declare function some<A extends readonly []>(f: Arrow, iterable: A): false;
declare function some<A, B = unknown>(f: (a: A) => B, iterable: Iterable<A>): boolean;
declare function some<A, B = unknown>(f: (a: A) => B, iterable: AsyncIterable<A>): Promise<boolean>;
declare function some<A extends Iterable<unknown> | AsyncIterable<unknown>, B = unknown>(f: (a: IterableInfer<A>) => B): (a: A) => ReturnValueType<A, boolean>;
Example
some(a=> a, [null, 0, 1, false]); // true
// with pipe
pipe(
[{id:1, age: 27}, {id:2, age: 36}, {id:3, age: 42}],
map(user => user.age),
some(age => age > 40),
); // true
await pipe(
Promise.resolve([{id:1, age: 27}, {id:2, age: 36}, {id:3, age: 42}]),
map(user => user.age),
some(age => age > 40),
); // true
// with toAsync
await pipe(
[Promise.resolve({id:1, age: 27}), Promise.resolve({id:2, age: 36}), Promise.resolve({id:3, age: 42})],
toAsync,
map(user => user.age),
some(age => age > 40),
); // true