import { I } from "https://deno.land/x/ahh@v0.10.3/src/iter/mod.ts";
Consume the next value of an Iterator
and return it if f
returns true
.
Examples
Example 1
Example 1
import { I } from "./mod.ts";
const iter = I.peekable(I.iter([1, 2, 3]));
console.log(I.nextIf(iter, (i) => i < 2)); // 1
console.log(I.nextIf(iter, (i) => i < 2)); // undefined
console.log(iter.next()); // 2