Skip to main content
Module

x/fun/iterable.ts

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
import * as fun from "https://deno.land/x/fun@v2.0.0/iterable.ts";

This file contains the Iterable algebraic data type. Iterable is a lazy, synchronous, and native structure defined by ecmascript. Generally, one interacts with the Iterator structure directly, but the Iterable type, being more generic, is a better target for functional. Any data structure that implements Iterable (ie. Array, Map, Set, etc) can use the iterable methods contained here if neeeded.

Something to keep in mind here is that Iterables can have nasty edge cases that don't exist for non-lazy data structures. Specifically, an iterable can generate a theoretically infinite number of values, making the draining of an iterable potentially impossible (trying it will cause the runtime to hang). Additionally, many iterables are constructed using generators, which cannot be easily cloned. This makes the process of chaining iterables a resource intensive operation. As always, use these combinators with care.

Functions

Collect all values of an iterable into an array. WARNING: If the iterable is infinite then this will cause the program to hang indefinitely.