Skip to main content
Module

x/iterators/mod.ts

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

Functions

Yield accumulated values (similar to Array.reduce, but with intermediate values).

Return true if every item in iterable is truthy.

Return true if any item in iterable is truthy.

cacheIterator creates a wrapper around an iterator and caches its values when next() is called. The cache can be traversed with prev().

Chain together items from each of the iterables as a single iterator.

Create a chain from an iterable of iterables.

Generator items of iterable where the corresponding item from selectors is truthy.

Generator numbers starting from 0, counting by 1.

Indefinitely cycle items of an iterable.

The sum of multiplying each item from two vectors (iterables).

Don't yield items until the predicate has returned false once.

Yield a tuple of the index and the item.

Generator items of iterable for where fn of that item is truthy.

Generator items of iterable where fn returns false.

Check if an iterator result is an IteratorReturnResult.

Check if an iterator result is an IteratorYieldResult.

Get the iterator of a given iterable.

Apply fn to each item of an iterable.

Get the cartesian product of the given iterables.

Generator numbers from start to stop, non-inclusive. Increment by step.

Generator the same object a given number of times.

Take a slice of an iterable, starting from 0.

Get the sum of all numbers in an iterable.

Yield items of iterable until the predicate has returned false once.

Yield items from the same index in each iterable as a tuple. Once an iterable is exhausted, the generator closes.

Yield items from the same index in each iterable, as a tuple. The fill value is used in place of a value from an exhausted iterable.

Yield items from the same index in each iterable, as a tuple. Will throw if at least one iterable is done before all of them are done.

Interfaces

CachedIterator is an iterator that stores previous generated values.