UNPKG

719 BJavaScriptView Raw
1"use strict";
2/**
3 * Try 对象
4 */
5var Try = {
6 /**
7 * 接收任意数目的函数作为参数,返回第一个执行成功的函数(未抛出异常的函数)的结果
8 *
9 * @return 任意函数参数执行结果
10 */
11 these: function () {
12 var result;
13 for (var i = 0; i < arguments.length; i++) {
14 var lambda = arguments[i];
15 if (Object.isFunction(lambda)) {
16 try {
17 result = lambda();
18 break;
19 }
20 catch (e) {
21 console.error(e);
22 }
23 }
24 }
25 return result;
26 }
27};
28window.Try = Try;
29//# sourceMappingURL=try.js.map
\No newline at end of file