0.4.0 • Published 1 month ago
iterpal v0.4.0
Iterpal
Iterable tools for JavaScript.
Installation
Iterpal is available from the npm registry:
npm install iterpal
With Deno:
import { filter, map } from "https://evanhahn.com/tape/iterpal/0.3.0/mod.ts";
Documentation
Use cases
Get helpful utilities not in the standard library.
last
is a simple one, but there are many others:import { last } from "iterpal"; last("iterpal!"); // => "!"
Use collection utilities like
map
andfilter
with any iterable.That includes arrays, strings, sets, maps, typed arrays, buffers, streams, (async) generators, or anything implementing the interface.
import { filter } from "iterpal"; const letterOs = filter("foo", (c) => c === "o");
Take advantage of lazy iteration.
Many of Iterpal's functions return lazily, which can help you maintain a functional style while still enjoying performance benefits.
import { map, take } from "iterpal"; // The second operation is faster because // it iterates over fewer values. lotsOfNumbers.map(square).slice(10); lotsOfNumbers.slice(10).map(square); // These two operations are basically equivalent. take(map(lotsOfNumbers, square), 10); map(take(lotsOfNumbers, 10), square);