some
description
Returns a Boolean
indicating if at least one item in the input collection
satisfies the provided predicate
function. It works exactly like Array.prototype.some
, except it also accepts Sets
, Maps
& Objects
as inputs, and asynchronous predicates.
Like all functions in conductor, this function is automatically is curried. If the predicate is asynchronous, it will return a Promise
, allowing you to use Promise.prototype.then
or the await
keyword to retrieve the result.
examples
basic example
Here, we simply check if at least one item in our numbers array is an even number. Luckily, that's the case.
using other data structures
some
also works on Objects
, Sets
, and Maps
.
using an asynchronous predicate
Here, our predicate is asynchronous (notice the async
keyword before the function definition), which makes some return a Promise
. We then (no pun intended) simply use the await
keyword to retrieve the result.
Last updated