Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/iter/mod.ts>every

A bunch of utilities for working with iterables, many inspired by the native array methods.
Latest
function every
import { every } from "https://deno.land/x/iter@v3.2.3/mod.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

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.

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

Returns

boolean

Whether any of the items in it predicate true.