ut2 1.9.5 → 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 +9 -0
- package/dist/ut2.js +16 -1
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/index.js +4 -1
- package/es/internals/helpers.js +5 -3
- package/es/internals/native.js +2 -1
- package/es/isWindow.js +9 -0
- package/es/move.js +6 -0
- package/lib/index.js +7 -0
- package/lib/internals/helpers.js +4 -1
- package/lib/internals/native.js +2 -0
- package/lib/isWindow.js +11 -0
- package/lib/move.js +8 -0
- package/package.json +1 -1
- package/types/index.d.ts +4 -1
- package/types/internals/helpers.d.ts +7 -0
- package/types/internals/native.d.ts +1 -0
- package/types/internals/root.d.ts +12 -0
- package/types/isWindow.d.ts +21 -0
- package/types/move.d.ts +23 -0
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;
|
|
@@ -599,7 +605,8 @@
|
|
|
599
605
|
return value == null || value !== value ? defaultValue : value;
|
|
600
606
|
};
|
|
601
607
|
|
|
602
|
-
var VERSION = "1.
|
|
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) {
|
|
@@ -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];
|
|
@@ -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;
|