@drew887121/iteratorfuncs

IteratorFuncs a simple single file package to make working with JS iterators easier.

The documentation lives online here.

If you've ever had a generator, or a Set, or a Map that you've needed to map/filter/reduce over in JS, you've been hit by the pain of having to either convert to an Array with Array.from and then use the method you need, or write a for...of loop and do your logic in there.

While the for...of loop is almost certainly the "proper" or "js way" of doing things, and is what you normally get as an answer when searching for this, it can be a little disappointing or jarring for those of us wanting a more fp like approach that js normally lets you take.

So this package is simply to help facilitate these patterns for IterableIterators.

tldr:

const set = new Set([1, 2, 3, 4, 5]);

const mappedAndFiltered =
mapIterator(set, (item) => item * 2)
.filter((item) => item > 5);

console.log(Array.from(mappedAndFiltered)); // logs out [6, 8, 10]

Index

Classes

Interfaces

Type Aliases

Functions

Generated using TypeDoc