Skip to main content
Module

x/iterators/mod.ts>CachedIterator

Iterators and related functions for Deno. Similar to Python's itertools module. Unlicensed, do what you want.
Latest
interface CachedIterator
import { type CachedIterator } from "https://deno.land/x/iterators@v0.2.0/mod.ts";

CachedIterator is an iterator that stores previous generated values.

Type Parameters

T
optional
TReturn = any
optional
TNext = undefined

Methods

[[Symbol.iterator]](): this
next(...args: [] | [TNext]): Readonly<IteratorResult<T, TReturn>>

next() moves the iterator forwards one step and calculates the value if it is not cached.

prev(): Readonly<IndexedIteratorResult<T, TReturn>>

prev() moves the iterator back one step.

If there is nothing in the cache (ie. next() hasn't been called), prev() will throw.