Skip to content

some() function

Returns true if any of the values in Iterable/AsyncIterable pass f truth test

Signature:

typescript
declare function some<A extends readonly []>(f: Arrow, iterable: A): false;

Example

ts
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

Try It

see pipe, toAsync, map

Open Source Code

Released under the Apache-2.0 License.