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

x/itertools/mod.ts>any

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

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

Examples:

any([])                           // => false
any([0])                          // => false
any([0, 1, null, undefined])      // => true

Examples with using a key function:

any([1, 4, 5], n => n % 2 === 0)  // => true
any([{name: 'Bob'}, {name: 'Alice'}], person => person.name.startsWith('C'))  // => false

Parameters

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

Returns

boolean