0.0.2 • Published 11 years ago
mabbe v0.0.2
mabbe
is (yet another) Haskell:Maybe and Scala:Option for JS
... works in node.js and on the browser.
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,