From afb7168343d31e75f6ca1ada35e4d28bc75a8ddf Mon Sep 17 00:00:00 2001 From: Kevin Li Date: Sat, 31 Dec 2016 16:10:18 -0800 Subject: [PATCH] v0.7.0 --- dist/monapt.d.ts | 4 ++-- dist/monapt.js | 12 ++++++++++-- dist/monapt.min.js | 2 +- package.json | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dist/monapt.d.ts b/dist/monapt.d.ts index 5636bce..bcf138b 100644 --- a/dist/monapt.d.ts +++ b/dist/monapt.d.ts @@ -144,11 +144,11 @@ declare module 'monapt' { onComplete(callback: ICompleteFunction): void; onSuccess(callback: (value: T) => void): void; onFailure(callback: (error: Error) => void): void; - map(f: (value: T, promise: IFuturePromiseLike) => void): Future; + map(f: (value: T) => U): Future; flatMap(f: (value: T) => Future): Future; filter(predicate: (value: T) => boolean): Future; reject(predicate: (value: T) => boolean): Future; - recover(fn: (e: Error, promise: IFuturePromiseLike) => void): Future; + recover(fn: (e: Error) => T): Future; recoverWith(fn: (e: Error) => Future): Future; } class Promise extends Future { diff --git a/dist/monapt.js b/dist/monapt.js index 8e808fa..abed5d9 100644 --- a/dist/monapt.js +++ b/dist/monapt.js @@ -370,7 +370,15 @@ var monapt; this.onComplete(function (r) { r.match({ Failure: function (e) { return promise.failure(e); }, - Success: function (v) { return f(v, F(promise)); } + Success: function (v) { + try { + var result = f(v); + promise.success(result); + } + catch (e) { + promise.failure(e); + } + } }); }); return promise.future(); @@ -423,7 +431,7 @@ var monapt; r.match({ Failure: function (error) { try { - fn(error, F(promise)); + promise.success(fn(error)); } catch (e) { promise.failure(e); diff --git a/dist/monapt.min.js b/dist/monapt.min.js index 53367d4..73c3ef0 100644 --- a/dist/monapt.min.js +++ b/dist/monapt.min.js @@ -1 +1 @@ -!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.monapt=b()}(this,function(){var a,b=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){a.Tuple1=function(a){return{_1:a}},a.Tuple2=function(a,b){return{_1:a,_2:b}}}(a||(a={}));var a;!function(a){var c=function(a){function c(){a.call(this,"No such element."),this.name="NoSuchElementError",this.message="No such element.",this.stack=(new Error).stack}return b(c,a),c}(Error);a.NoSuchElementError=c,a.Option=function(b){return"undefined"!=typeof b&&null!==b?new d(b):a.None};var d=function(){function b(a){this.value=a,this.isDefined=!0,this.isEmpty=!1}return b.prototype.get=function(){return this.value},b.prototype.getOrElse=function(a){return this.value},b.prototype.orElse=function(a){return this},b.prototype.match=function(a){return a.Some(this.value)},b.prototype.map=function(a){return new b(a(this.get()))},b.prototype.flatMap=function(a){return a(this.get())},b.prototype.filter=function(b){return b(this.value)?this:a.None},b.prototype.reject=function(a){return this.filter(function(b){return!a(b)})},b.prototype.foreach=function(a){a(this.value)},b.prototype.equals=function(a){var b=this;return a.match({None:function(){return!1},Some:function(a){return b.value===a}})},b}();a.Some=d;var e=function(){function b(){this.isDefined=!1,this.isEmpty=!0}return b.prototype.get=function(){throw new c},b.prototype.getOrElse=function(a){return a()},b.prototype.orElse=function(a){return a()},b.prototype.match=function(a){return a.None()},b.prototype.map=function(b){return a.None},b.prototype.flatMap=function(b){return a.None},b.prototype.filter=function(a){return this},b.prototype.reject=function(a){return this},b.prototype.foreach=function(a){},b.prototype.equals=function(a){return a.isEmpty},b}();a.None=new e,a.flatten=function(a){for(var b=[],c=0,d=a.length;c0?new a.Some(this.real[0]):a.None},c}();a.Map=c}(a||(a={})),a}); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define([],function(){return a.returnExportsGlobal=b()}):"object"==typeof exports?module.exports=b():a.monapt=b()}(this,function(){var a,b=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};!function(a){a.Tuple1=function(a){return{_1:a}},a.Tuple2=function(a,b){return{_1:a,_2:b}}}(a||(a={}));var a;!function(a){var c=function(a){function c(){a.call(this,"No such element."),this.name="NoSuchElementError",this.message="No such element.",this.stack=(new Error).stack}return b(c,a),c}(Error);a.NoSuchElementError=c,a.Option=function(b){return"undefined"!=typeof b&&null!==b?new d(b):a.None};var d=function(){function b(a){this.value=a,this.isDefined=!0,this.isEmpty=!1}return b.prototype.get=function(){return this.value},b.prototype.getOrElse=function(a){return this.value},b.prototype.orElse=function(a){return this},b.prototype.match=function(a){return a.Some(this.value)},b.prototype.map=function(a){return new b(a(this.get()))},b.prototype.flatMap=function(a){return a(this.get())},b.prototype.filter=function(b){return b(this.value)?this:a.None},b.prototype.reject=function(a){return this.filter(function(b){return!a(b)})},b.prototype.foreach=function(a){a(this.value)},b.prototype.equals=function(a){var b=this;return a.match({None:function(){return!1},Some:function(a){return b.value===a}})},b}();a.Some=d;var e=function(){function b(){this.isDefined=!1,this.isEmpty=!0}return b.prototype.get=function(){throw new c},b.prototype.getOrElse=function(a){return a()},b.prototype.orElse=function(a){return a()},b.prototype.match=function(a){return a.None()},b.prototype.map=function(b){return a.None},b.prototype.flatMap=function(b){return a.None},b.prototype.filter=function(a){return this},b.prototype.reject=function(a){return this},b.prototype.foreach=function(a){},b.prototype.equals=function(a){return a.isEmpty},b}();a.None=new e,a.flatten=function(a){for(var b=[],c=0,d=a.length;c0?new a.Some(this.real[0]):a.None},c}();a.Map=c}(a||(a={})),a}); \ No newline at end of file diff --git a/package.json b/package.json index c2f3198..a41b623 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monapt", - "version": "0.6.0", + "version": "0.7.0", "description": "Scala Monads for TypeScript and JavaScript", "homepage": "https://github.com/jiaweihli/monapt", "repository": {