1.0.3 • Published 7 years ago

node-either-monad v1.0.3

Weekly downloads
15
License
SEE LICENSE IN LI...
Repository
github
Last release
7 years ago

node-either-monad

Build Status

Either monad, good pattern to use when you have a function that may returns totally two different types

install

npm install --save node-either-monad

usage

const either = require('node-either-monad')

let left = either.left(1) // left
let right = either.right('data') //right

left.isLeft() // true
right.isRight() // true

let dataFolded = left.fold(x => x + 1, y => y + '-k'); // 2
let dataFolded = right.fold(x => x + 1, y => y + '-k'); // data-k

let left.swap() /// returns right with the same data
let right.swap() /// returns left with the same data

left.a // data of the left side
right.b // data of the right side
1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago