Mercurial > pub > ImplabJs
comparison src/implab/safe.js @ 33:8af8e840dd49
added return fn
author | nickolay |
---|---|
date | Wed, 05 Jun 2019 17:44:17 +0300 |
parents | 8332e287d552 |
children |
comparison
equal
deleted
inserted
replaced
27:aee8ea860e9b | 33:8af8e840dd49 |
---|---|
162 }; | 162 }; |
163 } else { | 163 } else { |
164 if (x && x.then) | 164 if (x && x.then) |
165 return x; | 165 return x; |
166 return { | 166 return { |
167 then : function(cb) { | 167 then: function (cb) { |
168 try { | 168 try { |
169 return cb ? wrapresult(cb(x)) : this; | 169 return cb ? wrapresult(cb(x)) : this; |
170 } catch(e2) { | 170 } catch (e2) { |
171 return wrapresult(e2); | 171 return wrapresult(e2); |
172 } | 172 } |
173 } | 173 } |
174 }; | 174 }; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 try { | 178 return function () { |
179 return wrapresult(fn.apply(thisArg, arguments)); | 179 try { |
180 } catch (e) { | 180 return wrapresult(fn.apply(thisArg, arguments)); |
181 return wrapresult(null, e); | 181 } catch (e) { |
182 return wrapresult(null, e); | |
183 } | |
182 }; | 184 }; |
183 }, | 185 }, |
184 | 186 |
185 create: function () { | 187 create: function () { |
186 if (console && console.warn) | 188 if (console && console.warn) |