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

x/iter/lib/reducers.ts>includes

A bunch of utilities for working with iterables, many inspired by the native array methods.
Latest
function includes
import { includes } from "https://deno.land/x/iter@v3.2.3/lib/reducers.ts";
Determines whether an iterable includes a certain element, returning true or false as appropriate.

warning: When ran on an endless iterable which does not contain value, this function never returns.

Examples

Example 1

import * as iter from "https://deno.land/x/iter";

const naturals = iter.create.increments(1);
const has100 = iter.includes(naturals, 100);

console.log(has100); // -> true

// Will never return.
// const has0 = iter.includes(naturals, 0);

Parameters

it: Iterable<T>
  • The iterable to be tested.
value: T
  • The item to search for.

Returns

boolean

Whether value is in it.