diff options
Diffstat (limited to 'lib/results.js')
| -rw-r--r-- | lib/results.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/results.js b/lib/results.js index fe9f632..bd66430 100644 --- a/lib/results.js +++ b/lib/results.js @@ -14,6 +14,11 @@ Result.prototype.map = function(func) { return new Result(func(this.value), this.messages); }; +Result.prototype.flatMap = function(func) { + var funcResult = func(this.value); + return new Result(funcResult.value, combineMessages([this, funcResult])); +}; + Result.prototype.flatMapThen = function(func) { var that = this; return func(this.value).then(function(otherResult) { |
