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

x/iter/mod.ts>some

A bunch of utilities for working with iterables, many inspired by the native array methods.
Latest
function some
import { some } from "https://deno.land/x/iter@v3.2.3/mod.ts";
Determines whether the specified callback function returns true for any item in an iterable.

warning: When ran on an endless iterable for which predicate never returns true, this functions will never return.

Examples

Example 1

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

const naturals = iter.create.increments(1);
const hasEvens = iter.some(naturals, (n) => n % 2 === 0);

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

// Will never return.
// const hasNeg = iter.some(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.