+11
-5
@@ -8,7 +8,13 @@ "use strict"; | ||
| function _ifElse(pred, then, otherwise) { | ||
| if (pred() === true) { | ||
| return then(); | ||
| } else { | ||
| return otherwise(); | ||
| } | ||
| return function () { | ||
| for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
| args[_key] = arguments[_key]; | ||
| } | ||
| if (pred.apply(null, args) === true) { | ||
| return then.apply(null, args); | ||
| } else { | ||
| return otherwise.apply(null, args); | ||
| } | ||
| }; | ||
| } | ||
@@ -15,0 +21,0 @@ |
+1
-1
| { | ||
| "name": "fj-ifelse", | ||
| "version": "1.0.1", | ||
| "version": "1.1.0", | ||
| "description": "Functional ifElse", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+11
-11
@@ -12,17 +12,17 @@ "use strict"; | ||
| ifElse(function () { | ||
| return true; | ||
| ifElse(function (x, y) { | ||
| return x === y; | ||
| }, function (x, y) { | ||
| return t.equals(x, y); | ||
| }, function () { | ||
| return t.ok(true); | ||
| }, function () { | ||
| return t.fail(); | ||
| }); | ||
| })(true, true); | ||
| ifElse(function () { | ||
| return false; | ||
| ifElse(function (x) { | ||
| return x === true; | ||
| }, function () { | ||
| return t.fail(); | ||
| }, function () { | ||
| return t.ok(true); | ||
| }); | ||
| }, function (x) { | ||
| return t.ok(x === false); | ||
| })(false); | ||
@@ -37,3 +37,3 @@ var ifTrue = ifElse(function () { | ||
| return t.fail(); | ||
| }); | ||
| })(); | ||
| }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8031
5.41%69
7.81%