ut2 1.11.6 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -154,6 +154,7 @@ const debounced = debounce(() => {
154
154
  - [Object](https://caijf.github.io/ut2/module-Object.html) 对象
155
155
  - [allKeys](https://caijf.github.io/ut2/module-Object.html#.allKeys) - 对象自身的可枚举属性(包含 `Symbol` 属性)。
156
156
  - [allKeysIn](https://caijf.github.io/ut2/module-Object.html#.allKeysIn) - 对象自身及继承的可枚举属性(包含 `Symbol` 属性)。
157
+ - [findKey](https://caijf.github.io/ut2/module-Object.html#.findKey) - 查找对象的键。
157
158
  - [invert](https://caijf.github.io/ut2/module-Object.html#.invert) - 对象自身的可枚举属性(包含 `Symbol` 属性)和值反转。
158
159
  - [keys](https://caijf.github.io/ut2/module-Object.html#.keys) - 对象自身的可枚举属性(不包含 `Symbol` 属性)。
159
160
  - [keysIn](https://caijf.github.io/ut2/module-Object.html#.keysIn) - 对象自身及继承的可枚举属性(不包含 `Symbol` 属性)。
@@ -186,19 +187,20 @@ const debounced = debounce(() => {
186
187
  - [gt](https://caijf.github.io/ut2/module-Util.html#.gt) - 大于。
187
188
  - [gte](https://caijf.github.io/ut2/module-Util.html#.gte) - 大于等于
188
189
  - [identity](https://caijf.github.io/ut2/module-Util.html#.identity) - 返回第一个参数的函数。
190
+ - [list](https://caijf.github.io/ut2/module-Util.html#.list) - 迭代执行次数。
189
191
  - [lt](https://caijf.github.io/ut2/module-Util.html#.lt) - 小于。
190
192
  - [lte](https://caijf.github.io/ut2/module-Util.html#.lte) - 小于等于。
191
193
  - [noop](https://caijf.github.io/ut2/module-Util.html#.noop) - 空函数。
192
194
  - [nthArg](https://caijf.github.io/ut2/module-Util.html#.nthArg) - 返回指定位置参数的函数。
193
195
  - [range](https://caijf.github.io/ut2/module-Util.html#.range) - 创建升序或降序的数字数组。
194
196
  - [sleep](https://caijf.github.io/ut2/module-Util.html#.sleep) - 返回 `promise` 延迟。
195
- - [times](https://caijf.github.io/ut2/module-Util.html#.times) - 迭代执行次数。
196
197
  - [toFinite](https://caijf.github.io/ut2/module-Util.html#.toFinite) - 转为有限数字。
197
198
  - [toInteger](https://caijf.github.io/ut2/module-Util.html#.toInteger) - 转为整数。
198
199
  - [toLength](https://caijf.github.io/ut2/module-Util.html#.toLength) - 转为数组长度整数。
199
200
  - [toNumber](https://caijf.github.io/ut2/module-Util.html#.toNumber) - 转为数字。
200
201
  - [toSafeInteger](https://caijf.github.io/ut2/module-Util.html#.toSafeInteger) - 转为安全整数。
201
202
  - [toString](https://caijf.github.io/ut2/module-Util.html#.toString) - 转为字符串。
203
+ - [tryit](https://caijf.github.io/ut2/module-Util.html#.tryit) - 包装函数为错误优先函数。
202
204
  - [uniqueId](https://caijf.github.io/ut2/module-Util.html#.uniqueId) - 唯一 ID。
203
205
  - [GLOBAL](https://caijf.github.io/ut2/global.html) 其他导出的成员
204
206
  - [MAX_ARRAY_LENGTH](https://caijf.github.io/ut2/global.html#MAX_ARRAY_LENGTH) - 最大数组长度。
package/dist/ut2.js CHANGED
@@ -606,7 +606,7 @@
606
606
  return value == null || value !== value ? defaultValue : value;
607
607
  };
608
608
 
609
- var VERSION = "1.11.6";
609
+ var VERSION = "1.13.0";
610
610
  var isBrowser = typeof window !== stringUndefined && isObjectLike(window) && typeof document !== stringUndefined && isObjectLike(document) && window.document === document;
611
611
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
612
612
  var FUNC_ERROR_TEXT = 'Expected a function';
@@ -1430,6 +1430,100 @@
1430
1430
  return getKeysIn(object).concat(getSymbolsIn(object));
1431
1431
  }
1432
1432
 
1433
+ /******************************************************************************
1434
+ Copyright (c) Microsoft Corporation.
1435
+
1436
+ Permission to use, copy, modify, and/or distribute this software for any
1437
+ purpose with or without fee is hereby granted.
1438
+
1439
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1440
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1441
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1442
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1443
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1444
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1445
+ PERFORMANCE OF THIS SOFTWARE.
1446
+ ***************************************************************************** */
1447
+ /* global Reflect, Promise, SuppressedError, Symbol */
1448
+
1449
+
1450
+ function __values(o) {
1451
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
1452
+ if (m) return m.call(o);
1453
+ if (o && typeof o.length === "number") return {
1454
+ next: function () {
1455
+ if (o && i >= o.length) o = void 0;
1456
+ return { value: o && o[i++], done: !o };
1457
+ }
1458
+ };
1459
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1460
+ }
1461
+
1462
+ function __read(o, n) {
1463
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
1464
+ if (!m) return o;
1465
+ var i = m.call(o), r, ar = [], e;
1466
+ try {
1467
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1468
+ }
1469
+ catch (error) { e = { error: error }; }
1470
+ finally {
1471
+ try {
1472
+ if (r && !r.done && (m = i["return"])) m.call(i);
1473
+ }
1474
+ finally { if (e) throw e.error; }
1475
+ }
1476
+ return ar;
1477
+ }
1478
+
1479
+ function __spreadArray(to, from, pack) {
1480
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1481
+ if (ar || !(i in from)) {
1482
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1483
+ ar[i] = from[i];
1484
+ }
1485
+ }
1486
+ return to.concat(ar || Array.prototype.slice.call(from));
1487
+ }
1488
+
1489
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1490
+ var e = new Error(message);
1491
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1492
+ };
1493
+
1494
+ var findKey = function (obj, predicate) {
1495
+ var e_1, _a;
1496
+ if (predicate === void 0) { predicate = stubFlase; }
1497
+ var key;
1498
+ if (isMap(obj)) {
1499
+ try {
1500
+ for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) {
1501
+ var _b = __read(obj_1_1.value, 2), k = _b[0], v = _b[1];
1502
+ if (predicate(v, k)) {
1503
+ key = k;
1504
+ break;
1505
+ }
1506
+ }
1507
+ }
1508
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1509
+ finally {
1510
+ try {
1511
+ if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1);
1512
+ }
1513
+ finally { if (e_1) throw e_1.error; }
1514
+ }
1515
+ }
1516
+ else if (isObject(obj)) {
1517
+ forEach(obj, function (v, k) {
1518
+ if (predicate(v, k)) {
1519
+ key = k;
1520
+ return false;
1521
+ }
1522
+ });
1523
+ }
1524
+ return key;
1525
+ };
1526
+
1433
1527
  function invert(object, predicate) {
1434
1528
  if (predicate === void 0) { predicate = stubTrue; }
1435
1529
  var _keys = allKeys(object);
@@ -1744,7 +1838,7 @@
1744
1838
  });
1745
1839
  }
1746
1840
 
1747
- var times = function (n, iteratee) {
1841
+ var list = function (n, iteratee) {
1748
1842
  if (iteratee === void 0) { iteratee = identity; }
1749
1843
  if (n < 1 || n > MAX_SAFE_INTEGER) {
1750
1844
  return [];
@@ -1760,6 +1854,8 @@
1760
1854
  return result;
1761
1855
  };
1762
1856
 
1857
+ var times = list;
1858
+
1763
1859
  function toSafeInteger(value) {
1764
1860
  if (!value) {
1765
1861
  return value === 0 ? value : 0;
@@ -1774,6 +1870,31 @@
1774
1870
  return value;
1775
1871
  }
1776
1872
 
1873
+ var tryit = function (fn) {
1874
+ return function () {
1875
+ var args = [];
1876
+ for (var _i = 0; _i < arguments.length; _i++) {
1877
+ args[_i] = arguments[_i];
1878
+ }
1879
+ try {
1880
+ var result = fn.apply(void 0, __spreadArray([], __read(args), false));
1881
+ if (isPromiseLike(result)) {
1882
+ return result
1883
+ .then(function (res) {
1884
+ return [null, res];
1885
+ })
1886
+ .catch(function (err) {
1887
+ return [err, nativeUndefined];
1888
+ });
1889
+ }
1890
+ return [null, result];
1891
+ }
1892
+ catch (err) {
1893
+ return [err, nativeUndefined];
1894
+ }
1895
+ };
1896
+ };
1897
+
1777
1898
  var idCounter = 0;
1778
1899
  var defaultPrefix = '_' + mathRandom().toString(36).substring(2, 4);
1779
1900
  function uniqueId(prefix) {
@@ -1811,6 +1932,7 @@
1811
1932
  exports.every = every;
1812
1933
  exports.filter = filter;
1813
1934
  exports.find = find;
1935
+ exports.findKey = findKey;
1814
1936
  exports.floor = floor;
1815
1937
  exports.forEach = forEach;
1816
1938
  exports.forEachRight = forEachRight;
@@ -1867,6 +1989,7 @@
1867
1989
  exports.keyBy = keyBy;
1868
1990
  exports.keys = keys;
1869
1991
  exports.keysIn = keysIn;
1992
+ exports.list = list;
1870
1993
  exports.lowerCase = lowerCase;
1871
1994
  exports.lowerFirst = lowerFirst;
1872
1995
  exports.lt = lt;
@@ -1908,6 +2031,7 @@
1908
2031
  exports.toNumber = toNumber;
1909
2032
  exports.toSafeInteger = toSafeInteger;
1910
2033
  exports.toString = toString;
2034
+ exports.tryit = tryit;
1911
2035
  exports.unescape = unescape;
1912
2036
  exports.union = union;
1913
2037
  exports.uniq = uniq;