import { until } from "https://deno.land/x/iter@v3.2.3/lib/transformers.ts";
Returns a new iterable which yields until f
returns true.
Examples
Example 1
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 callsf
one time for each item in the iterable.
Returns
A new iterables of it
which terminates