Comparing version 0.1.1 to 0.2.0
@@ -19,16 +19,14 @@ // data Maybe a = Just a | Nothing | ||
const Maybe = require('./maybe'); | ||
const Just = require('./just'); | ||
const Nothing = require('./nothing'); | ||
var Maybe = require('./maybe'); | ||
var Just = require('./just'); | ||
var Nothing = require('./nothing'); | ||
Maybe.of = function(val) { | ||
if (val == null || val == undefined) return Nothing; | ||
if (val === null || val === undefined) return Nothing; | ||
return new Just(val); | ||
}; | ||
module.exports = { | ||
Just, | ||
Nothing, | ||
Maybe, | ||
of: Maybe.of | ||
}; | ||
module.exports.Just = Just; | ||
module.exports.Nothing = Nothing; | ||
module.exports.Maybe = Maybe; | ||
module.exports.of = Maybe.of; |
@@ -1,5 +0,5 @@ | ||
const Maybe = require('./maybe'); | ||
const Nothing = require('./nothing'); | ||
var Maybe = require('./maybe'); | ||
var Nothing = require('./nothing'); | ||
const Just = function(val) { | ||
var Just = function(val) { | ||
this._val = val; | ||
@@ -13,3 +13,3 @@ return this; | ||
Just.of = function(val) { | ||
if (val == null) return Nothing; | ||
if (val === null || val === undefined) return Nothing; | ||
return new Just(val); | ||
@@ -20,3 +20,3 @@ }; | ||
if (typeof f !== 'function') throw 'Function not provided to Just.map'; | ||
let newVal; | ||
var newVal; | ||
@@ -23,0 +23,0 @@ try { |
// Exists purely for prototypical inheritance | ||
// So both Just and Nothing are instances of Maybe | ||
const Maybe = function() {}; | ||
var Maybe = function() {}; | ||
module.exports = Maybe; |
@@ -1,4 +0,4 @@ | ||
const Maybe = require('./maybe'); | ||
var Maybe = require('./maybe'); | ||
const Nothing = (function () { | ||
var Nothing = (function () { | ||
function Nothing() {} | ||
@@ -5,0 +5,0 @@ |
{ | ||
"name": "jsmaybe", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "A simple, useful, but somewhat incorrect implementation of the Maybe monad in Javascript.", | ||
@@ -16,2 +16,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"babel-cli": "6.23.0", | ||
"chai": "3.5.0", | ||
@@ -18,0 +19,0 @@ "mocha": "3.2.0" |
4649
3
77