forofa

1.1.0 • Public • Published

forofa

Build Status codecov dependencies Status

Maintainability Test Coverage

A lazy iteration library that contains many of the Array.prototype methods that support any objects that implement the iterator protocol. It also contains the Iterable and AsyncIterable types that can be easily extended and allow a fluent API. Since this library is all about iterators, it can support infinite iteratables, such as a Fibonacci sequence or any other infinite sequence.

Functions

Click here to check all the currently supported functions.

Example

Most collection types in JavaScript implement the iterator protocol (Array, String, Set, Map), this library wraps any iterable into an object that has several fluent-api functions, allowing the types to be abstracted but still share the same methods. The wrapper also implements the iterator protocol, allowing the resulting iterables to be used with for..of loops, hence, the name.

const { Iterable } = require("forofa");
 
// This is lazy, nothing has been iterated yet.
const iterable = new Iterable(["2", "1", "4", "3", "7", "2", "3", "99"])
  .map(t => parseInt(t))
  .filter(t => t >= 3)
  .skip(1)
  .take(4);
 
// Does the iteration itself.
for (const curr of iterable) {
  console.log(curr);
}

This will print 3, 7, 3 and 99.

Package Sidebar

Install

npm i forofa

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

37.2 kB

Total Files

49

Last publish

Collaborators

  • sj-freitas