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

x/iter/mod.ts>until

A bunch of utilities for working with iterables, many inspired by the native array methods.
Latest
function until
import { until } from "https://deno.land/x/iter@v3.2.3/mod.ts";

Returns a new iterable which yields until f returns true.

Examples

Example 1

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

const naturals = iter.create.increments(1);
const numbers = iter.until(naturals, (n) => n ** 2 > 54);

for (const num of numbers) {
  console.log(num);
}

// -> 1
// -> 2
// -> 3
// -> 4
// -> 5
// -> 6
// -> 7
// -> 8

Parameters

it: Iterable<T>
  • The iterable being cut.
  • A function that accepts up to three arguments. The until function calls f one time for each item in the iterable.
optional
includeLast = [UNSUPPORTED]
  • Whether the item for which f returns true should be included.

Returns

A new iterables of it which terminates