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

x/ahh/src/iterator.ts>fromFn

Opinionated idiomatic features for TypeScript.
Latest
function fromFn
import { fromFn } from "https://deno.land/x/ahh@v0.14.0/src/iterator.ts";

Creates an Iterator that yields the result of fn each iteration.

Examples

Example 1

import { assert } from "../test_deps.ts";
import I from "./iterator.ts";

let i = 0;
const iter = I.fromFn(() => i++);

assert(iter.next() === 0);
assert(iter.next() === 1);
assert(iter.next() === 2);

Type Parameters

T extends Some<unknown>

Parameters

fn: () => Option<T>