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

x/itertools/builtins.ts>all

🦕 A TypeScript port of Python's itertools and more-itertools for Deno
Latest
function all
import { all } from "https://deno.land/x/itertools@v1.1.2/builtins.ts";

Returns true when all of the items in iterable are truthy. An optional key function can be used to define what truthiness means for this specific collection.

Examples:

all([])                           // => true
all([0])                          // => false
all([0, 1, 2])                    // => false
all([1, 2, 3])                    // => true

Examples with using a key function:

all([2, 4, 6], n => n % 2 === 0)  // => true
all([2, 4, 5], n => n % 2 === 0)  // => false

Parameters

iterable: Iterable<T>
optional
keyFn: Predicate<T> = [UNSUPPORTED]

Returns

boolean