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

x/itertools/builtins.ts>contains

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

Returns true when any of the items in the iterable are equal to the target object.

Examples:

contains([], 'whatever')         // => false
contains([3], 42)                // => false
contains([3], 3)                 // => true
contains([0, 1, 2], 2)           // => true

Parameters

haystack: Iterable<T>
needle: T

Returns

boolean