# HG changeset patch # User nickolay # Date 1559745857 -10800 # Node ID 8af8e840dd49f31085a8af1fd9cc3b1f1caecb5d # Parent aee8ea860e9b6955aa84f56310c6420bfa666f80 added return fn diff -r aee8ea860e9b -r 8af8e840dd49 src/implab/safe.js --- 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); + } }; },