GithubHelp home page GithubHelp logo

iterablex's Introduction

iterablex

Lazy method chaining iterables

About

This library exports a function to create a lazy iterable from any iterable. The return value's type will depend on what operations the original iterable supports:

  • A ContiguousRange for any TypedArray
  • A RandomAccessRange for any iterable not above implementing a constant-time .at(index) method
  • A ForwardRange for any iterable not above that can be iterated without consuming the input
  • An InputRange for any other iterable not above

A BidirectionalRange may be returned by some of the lazy methods for ContiguousRange, RandomAccessRange, and itself, to indicate the returned iterable supports lazy .toReversed() without buffering.

Lazy methods:

  • .drop(count: number)
  • .entries()
  • .filter(predicate: (value, index) => boolean)
  • .flatMap(callback: (value, index) => iterable)
  • .map(callback: (value, index) => any)
  • .scan(callback: (previous, value, index) => next, initial?)
  • .slice(begin?, end?)
  • .take(count: number)
  • .toReversed()
  • .toSorted(compare?: (a, b) => number)

Eager methods:

  • .at(index: number): value?
  • .every(predicate: (value, index) => boolean): boolean
  • .find(predicate: (value, index) => boolean): value?
  • .findIndex(predicate: (value, index) => boolean): number
  • .findLast(predicate: (value, index) => boolean): value?
  • .findLastIndex(predicate: (value, index) => boolean): number
  • .first(predicate?: (value, index) => boolean): value?
  • .forEach(callback: (value, index) => void): void
  • .includes(value, fromIndex?: number): boolean
  • .indexOf(value, fromIndex?: number): number
  • .last(predicate?: (value, index) => boolean): value?
  • .lastIndexOf(value, fromIndex?: number): number
  • .reduce(callback: (previous, value, index) => next, initial?)
  • .some(predicate: (value, index) => boolean): boolean
  • .toArray(): array

...and more to come!

TODO

  • Tests (and bugfixes)
  • More documentation
  • More methods

iterablex's People

Contributors

patrickroberts avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.