Iter Version Build Status

A bunch of utilities for working with iterables, many inspired by the native array methods.

Iterables are great for doing things you would normally do with arrays, lazily, meaning you only compute what you need. The aim of this module is to provide lazy iterable alternatives to javascript's native array methods, as well as a few quality-of-life iterable utilities.

Installation

The module is currently hosted on deno.land/x/.

import * as iter from "https://deno.land/x/iter/mod.ts";
// or with a version
import * as iter from "https://deno.land/x/iter@v1.0.0/mod.ts";

Conventions

API

API documentation can be found here

Return types

All functions which return iterables (generators, transformers, and combinators) return the IterableIterator type, meaning they return an iterator which itself is iterable. This means both of these work.

import * as iter from "https://deno.land/x/iter/mod.ts";

const randomNumbers = iter.create.randomNumbers();
// As iterator
console.log(randomNumbers.next().value);
// Or as iterable
console.log(randomNumbers[Symbol.iterator]().next().value);
// Note these will still generate two different values.

Array.prototype parity completeness

  • concat
  • entries (as indexedPairs)
  • every
  • filter
  • find
  • findIndex
  • includes
  • map
  • reduce
  • some

Currently not being considered

  • copyWithin
  • fill
  • flat
  • flatMap
  • forEach
  • indexOf
  • join
  • lastIndexOf
  • pop
  • push
  • reduceRight
  • reverse
  • shift
  • slice
  • sort
  • splice
  • toLocaleString
  • toString
  • unshift