changeset 33:8af8e840dd49

added return fn
author nickolay
date Wed, 05 Jun 2019 17:44:17 +0300
parents aee8ea860e9b
children 27e8e9e38e07
files src/implab/safe.js
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/implab/safe.js	Mon Dec 11 16:48:19 2017 +0300
+++ b/src/implab/safe.js	Wed Jun 05 17:44:17 2019 +0300
@@ -164,10 +164,10 @@
                         if (x && x.then)
                             return x;
                         return {
-                            then : function(cb) {
+                            then: function (cb) {
                                 try {
                                     return cb ? wrapresult(cb(x)) : this;
-                                } catch(e2) {
+                                } catch (e2) {
                                     return wrapresult(e2);
                                 }
                             }
@@ -175,10 +175,12 @@
                     }
                 }
 
-                try {
-                    return wrapresult(fn.apply(thisArg, arguments));
-                } catch (e) {
-                    return wrapresult(null, e);
+                return function () {
+                    try {
+                        return wrapresult(fn.apply(thisArg, arguments));
+                    } catch (e) {
+                        return wrapresult(null, e);
+                    }
                 };
             },