little-monad-that-could

Little null-safe monad for handling either single values or arrays.

Usage no npm install needed!

<script type="module">
  import littleMonadThatCould from 'https://cdn.skypack.dev/little-monad-that-could';
</script>

README

Little Monad That Could

NPM

Simple null-safe monad for handling singular values as well as arrays.

Installation

Module can be easily installed with NPM:

npm install --save little-monad-that-could

Usage

Simply require it in your code:

const { when, pipe, get, filter } = require('little-monad-that-could');

const life = { life: 42 }
const universe = value => value + 12
const everything = value => value === 6 * 9

when(life)
    .get('life')
    .map(universe)
    .filter(everything)
    .otherwise(0)

const compute = pipe(
    get('life'),
    universe,
    filter(everything))

compute(life).otherwise(0)