0.0.9 • Published 7 years ago

spirals v0.0.9

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

NSP Status Build Status

spirals

Simple functional utilities for javascript.

For the moment: Maybe and Either.

Intall it with yarn:

yarn add spirals

or npm:

npm install spirals

Examples:

import { Maybe, Either } from 'spirals';

const double = n => n + n;

Maybe(1).map(double).value;
// returns 2

Maybe(null).map(double).value;
// returns null

Maybe({a: 10}).get('a').value;
// returns 10

Maybe({b: 10}).get('a').value;
// returns null

Maybe({n: 20}).get('n').map(double);
// returns Maybe(40)

Either({
    value: null,
    left: () => 'nothing here',
    right: value => value * 10
  });
// returns 'nothing here'

Either({
    value: 1.5,
    left: () => 'nothing here',
    right: value => value * 10
  });
// returns 15
0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.1

7 years ago

0.0.00

7 years ago