0.0.2 • Published 11 years ago

mabbe v0.0.2

Weekly downloads
36
License
-
Repository
github
Last release
11 years ago

mabbe is (yet another) Haskell:Maybe and Scala:Option for JS

... works in node.js and on the browser.

Build Status

Download

Example

  var option = require('mabbe')

  var parsedQuery = option(req.param.id)
    .map(function(q) { return { _id: new ObjectId(q) }})
    .orElse(option(req.query.query).map(JSON.parse))
    .getOrElse({})

API

Construct

  var option = require('mabbe')

  option('pow')         // Some('pow')
  option.some('pow')    // Some('pow')
  option(0)             // Some(0)

  option(undefined)     // None
  option(null)          // None
  option.none           // None

Use

For more usage, see tests

Enjoy,

0.0.2

11 years ago

0.0.1

11 years ago