ut2 1.9.4 → 1.10.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
@@ -66,6 +66,7 @@ const debounced = debounce(() => {
66
66
  - [difference](https://caijf.github.io/ut2/module-Array.html#.difference) - 排除部分值。
67
67
  - [formPairs](https://caijf.github.io/ut2/module-Array.html#.fromPairs) - 将键值对转为对象。
68
68
  - [intersection](https://caijf.github.io/ut2/module-Array.html#.intersection) - 交集去重。
69
+ - [move](https://caijf.github.io/ut2/module-Array.html#.move) - 数组元素移动。
69
70
  - [nth](https://caijf.github.io/ut2/module-Array.html#.nth) - 获取第 `n` 个元素。
70
71
  - [shuffle](https://caijf.github.io/ut2/module-Array.html#.shuffle) - 打乱数组。
71
72
  - [union](https://caijf.github.io/ut2/module-Array.html#.union) - 并集去重。
@@ -137,6 +138,7 @@ const debounced = debounce(() => {
137
138
  - [isUndefined](https://caijf.github.io/ut2/module-Language.html#.isUndefined) - `undefined` 。
138
139
  - [isWeakMap](https://caijf.github.io/ut2/module-Language.html#.isWeakMap) - `WeakMap` 对象。
139
140
  - [isWeakSet](https://caijf.github.io/ut2/module-Language.html#.isWeakSet) - `WeakSet` 对象。
141
+ - [isWindow](https://caijf.github.io/ut2/module-Language.html#.isWindow) - `Window` 对象。
140
142
  - [Math](https://caijf.github.io/ut2/module-Math.html) 数学
141
143
  - [ceil](https://caijf.github.io/ut2/module-Math.html#.ceil) - 向上舍入。
142
144
  - [floor](https://caijf.github.io/ut2/module-Math.html#.floor) - 向下舍入。
@@ -197,6 +199,13 @@ const debounced = debounce(() => {
197
199
  - [toSafeInteger](https://caijf.github.io/ut2/module-Util.html#.toSafeInteger) - 转为安全整数。
198
200
  - [toString](https://caijf.github.io/ut2/module-Util.html#.toString) - 转为字符串。
199
201
  - [uniqueId](https://caijf.github.io/ut2/module-Util.html#.uniqueId) - 唯一 ID。
202
+ - [GLOBAL](https://caijf.github.io/ut2/global.html) 其他导出的成员
203
+ - [MAX_ARRAY_LENGTH](https://caijf.github.io/ut2/global.html#MAX_ARRAY_LENGTH) - 最大数组长度。
204
+ - [MAX_SAFE_INTEGER](https://caijf.github.io/ut2/global.html#MAX_SAFE_INTEGER) - 最大安全整数。
205
+ - [MIN_SAFE_INTEGER](https://caijf.github.io/ut2/global.html#MIN_SAFE_INTEGER) - 最小安全整数。
206
+ - [VERSION](https://caijf.github.io/ut2/global.html#VERSION) - 当前版本号。
207
+ - [isBrowser](https://caijf.github.io/ut2/global.html#isBrowser) - 当前运行环境是否为浏览器。
208
+ - [root](https://caijf.github.io/ut2/global.html#root) - 全局对象。
200
209
 
201
210
  [npm]: https://img.shields.io/npm/v/ut2.svg
202
211
  [npm-url]: https://npmjs.com/package/ut2
package/dist/ut2.js CHANGED
@@ -56,6 +56,7 @@
56
56
  var promiseTag = '[object Promise]';
57
57
  var setTag = '[object Set]';
58
58
  var weakMapTag = '[object WeakMap]';
59
+ var windowTag = '[object Window]';
59
60
 
60
61
  function isArray(value) {
61
62
  return Array.isArray(value);
@@ -207,6 +208,11 @@
207
208
  });
208
209
  }
209
210
 
211
+ function move(arr, from, to) {
212
+ arr.splice(to, 0, arr.splice(from, 1)[0]);
213
+ return arr;
214
+ }
215
+
210
216
  function isFunction(value) {
211
217
  if (typeof value === 'function') {
212
218
  return true;
@@ -223,14 +229,14 @@
223
229
  return value != null && isLength(value.length) && !isFunction(value);
224
230
  }
225
231
 
226
- function nth(array, n) {
232
+ var nth = function (array, n) {
227
233
  if (n === void 0) { n = 0; }
228
234
  if (!isArrayLike(array)) {
229
235
  return nativeUndefined;
230
236
  }
231
237
  n += n < 0 ? array.length : 0;
232
238
  return array[n];
233
- }
239
+ };
234
240
 
235
241
  var MAX_VALUE = 1.7976931348623157e308;
236
242
  function toFinite(value) {
@@ -599,7 +605,8 @@
599
605
  return value == null || value !== value ? defaultValue : value;
600
606
  };
601
607
 
602
- var VERSION = "1.9.4";
608
+ var VERSION = "1.10.0";
609
+ var isBrowser = typeof window !== stringUndefined && isObjectLike(window) && typeof document !== stringUndefined && isObjectLike(document) && window.document === document;
603
610
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
604
611
  var FUNC_ERROR_TEXT = 'Expected a function';
605
612
  function toSource(func) {
@@ -954,7 +961,7 @@
954
961
  if (nodeIsTypedArray) {
955
962
  return nodeIsTypedArray(value);
956
963
  }
957
- if (isObjectLike(value) && isLength(value.length)) {
964
+ if (isArrayLikeObject(value)) {
958
965
  return typedArrayPattern.test(getTag(value));
959
966
  }
960
967
  return false;
@@ -1268,6 +1275,10 @@
1268
1275
  return getTag(value) === weakSetTag;
1269
1276
  }
1270
1277
 
1278
+ function isWindow(value) {
1279
+ return isObjectLike(value) && getTag(value) === windowTag;
1280
+ }
1281
+
1271
1282
  function decimalAdjust(type, value, precision) {
1272
1283
  if (precision === void 0) { precision = 0; }
1273
1284
  var func = Math[type];
@@ -1417,8 +1428,8 @@
1417
1428
  _keys.forEach(function (key) {
1418
1429
  var value = object[key];
1419
1430
  if (predicate(value, key)) {
1420
- var valueStr = value != null && typeof value.toString != 'function' ? objectProtoToString.call(value) : value;
1421
- result[valueStr] = key;
1431
+ var valueProp = value != null && typeof value.toString != 'function' ? objectProtoToString.call(value) : value;
1432
+ result[valueProp] = key;
1422
1433
  }
1423
1434
  else {
1424
1435
  result[key] = value;
@@ -1809,6 +1820,7 @@
1809
1820
  exports.isBigInt = isBigInt;
1810
1821
  exports.isBlob = isBlob;
1811
1822
  exports.isBoolean = isBoolean;
1823
+ exports.isBrowser = isBrowser;
1812
1824
  exports.isBuffer = isBuffer;
1813
1825
  exports.isDataView = isDataView;
1814
1826
  exports.isDate = isDate;
@@ -1839,6 +1851,7 @@
1839
1851
  exports.isUndefined = isUndefined;
1840
1852
  exports.isWeakMap = isWeakMap;
1841
1853
  exports.isWeakSet = isWeakSet;
1854
+ exports.isWindow = isWindow;
1842
1855
  exports.kebabCase = kebabCase;
1843
1856
  exports.keyBy = keyBy;
1844
1857
  exports.keys = keys;
@@ -1851,6 +1864,7 @@
1851
1864
  exports.max = max;
1852
1865
  exports.merge = merge;
1853
1866
  exports.min = min;
1867
+ exports.move = move;
1854
1868
  exports.negate = negate;
1855
1869
  exports.noop = noop;
1856
1870
  exports.nth = nth;
@@ -1869,6 +1883,7 @@
1869
1883
  exports.range = range;
1870
1884
  exports.reduce = reduce;
1871
1885
  exports.reduceRight = reduceRight;
1886
+ exports.root = root;
1872
1887
  exports.round = round;
1873
1888
  exports.shuffle = shuffle;
1874
1889
  exports.sleep = sleep;