Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/ahh/src/iterator.ts>successors

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

Creates an Iterator where each successive item is computed from the previous one.

Examples

Example 1

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

const iter = I.successors<number>(0, (i) => i + 1);

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

Type Parameters

T extends Some<unknown>

Parameters

init: Option<T>
fn: (item: T) => Option<T>