computation
Advanced tools
Comparing version 0.0.2 to 0.0.3
"use strict"; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -11,3 +11,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var Computation = (function () { | ||
var Computation = function () { | ||
function Computation(fn) { | ||
@@ -24,13 +24,15 @@ _classCallCheck(this, Computation); | ||
return new Computation(function () { | ||
try { | ||
if (reject === undefined) { | ||
return new Computation(function () { | ||
return resolve(_this.fn()); | ||
} catch (e) { | ||
if (reject) { | ||
}); | ||
} else { | ||
return new Computation(function () { | ||
try { | ||
return resolve(_this.fn()); | ||
} catch (e) { | ||
return reject(e); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -93,15 +95,11 @@ }, { | ||
value: function liftA2(a, b, f) { | ||
try { | ||
return new Computation(function () { | ||
var av = a.fn(), | ||
bv = b.fn(); | ||
if (av !== Computation.Pending && bv !== Computation.Pending) { | ||
return new Computation(function () { | ||
return f(av, bv); | ||
}); | ||
return f(av, bv); | ||
} else { | ||
return Computation.pending; | ||
return Computation.Pending; | ||
} | ||
} catch (e) { | ||
return Computation.fail(e); | ||
} | ||
}); | ||
} | ||
@@ -111,3 +109,3 @@ }]); | ||
return Computation; | ||
})(); | ||
}(); | ||
@@ -114,0 +112,0 @@ exports.default = Computation; |
{ | ||
"name": "computation", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A small JavaScript library to express computations", | ||
@@ -5,0 +5,0 @@ "main": "computation.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10884
117