@specialblend/fiterable

0.0.6 • Public • Published

fiterable: fluent/functional iterables

fluent, composable iterators for Javascript with map, filter, concat

Key Features

  • ✓ Pure Javascript
  • ✓ Fluent interface
  • ✓ Includes functional-style exports

Installation

npm i @specialblend/fiterable

Quick Start

import * as R from 'ramda';
import { fiterable, Fiterable } from '@specialblend/fiterable';

const isEven = x => x % 2 === 0;

/**
 * Functional style
 * @type {Fiterable}
 */
const myFunctionalFit = fiterable(R.range(0, 10));
console.log(
    R.compose(
        R.map(R.multiply(3)),
        R.filter(isEven),
    )(myFunctionalFit),
);

/**
 * Fluent class style
 * @type {Fiterable}
 */
const myClassFit = new Fiterable(R.range(0, 10));
console.log(
    myClassFit
        .filter(isEven)
        .map(x => x * 3)
);

/**
 * Imperative for .. of style
 * @type {Fiterable}
 */
const myImperativeFit = new Fiterable(R.range(0, 10));
for (const x of myImperativeFit) {
    if (isEven(x)) {
        console.log(x * 3);
    }
}

Package Sidebar

Install

npm i @specialblend/fiterable

Weekly Downloads

0

Version

0.0.6

License

ISC

Unpacked Size

6.68 kB

Total Files

4

Last publish

Collaborators

  • __specialblend__