maybe-fantasy

0.0.1 • Public • Published

maybe-fantasy

A fantasyland compliant implementation of the maybe monad.

 
var maybe = require('../')
var log = console.log.bind(console, '=>')
 
 
var something = maybe.of('Hello ').map(function(v) { return v + 'world!' })
 
log(something.isSomething())
// => true
 
log(something.value)
// => 'Hello world!'
 
 
var nothing = maybe.nothing('Hello ').map(function(v) { return v + 'world!' })
 
log(nothing.isSomething())
// => false
 
log(nothing.value)
// => null  (never use this, it not a value!)
 
 

Unlike many other "maybe" implementations this is not a currying function that checks for null inputs, but a value representation that can be Nothing.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i maybe-fantasy

      Weekly Downloads

      143

      Version

      0.0.1

      License

      MIT

      Last publish

      Collaborators

      • pirfalt