import { every } from "https://deno.land/x/iter@v3.2.3/lib/reducers.ts";
- Determines whether the specified callback function returns true for all items in an iterable.
-
warning: When ran on an endless iterable for which
predicate
never returns false, this function will never return.
Examples
Example 1
Example 1
import * as iter from "https://deno.land/x/iter";
const naturals = iter.create.increments(1);
const allOdd = iter.every(naturals, (n) => n % 2 === 1);
console.log(allOdd); // -> false
// Will never return.
// const allPositive = iter.every(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