import { some } from "https://deno.land/x/iter@v3.2.3/mod.ts";
- Determines whether the specified callback function returns true for any item in an iterable.
-
warning: When ran on an endless iterable for which
predicate
never returns true, this functions will never return.
Examples
Example 1
Example 1
import * as iter from "https://deno.land/x/iter";
const naturals = iter.create.increments(1);
const hasEvens = iter.some(naturals, (n) => n % 2 === 0);
console.log(hasEvens); // -> true
// Will never return.
// const hasNeg = iter.some(naturals, (n) => n < 0);
Parameters
it: Iterable<T>
- The iterable to be tested.
predicate: IterablePredicateCallback<T>
A function that accepts up to three arguments. The some function calls the predicate function for each element in the array until the predicate returns a value