maybe2

0.2.0 • Public • Published

(Just to get this https://gist.github.com/andyhd/1618403 as a module, with a little bit of sugar). So the following constructions are now possible:

var greaterThan = function (num) { return function (x) { return x > num ? x:null; }; };
var lessThan = function (num) { return function (x) { return x < num ? x:null; }; };
var definitelyUndefined;
log('All together: ', maybe(definitelyUndefined)
                        .is(Number)
                        .map(greaterThan(0))
                        .map(lessThan(42))
                        .getOrElse(9000));

Take a look at the example.js or test.js for more info. (All glory goes to @andyhd)

Readme

Keywords

Package Sidebar

Install

npm i maybe2

Weekly Downloads

2

Version

0.2.0

License

MIT

Last publish

Collaborators

  • mynameisdaniil