ut2 1.11.0 → 1.11.1
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 +1 -0
- package/dist/ut2.js +5 -4
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/internals/helpers.js +1 -1
- package/es/move.js +4 -3
- package/lib/internals/helpers.js +1 -1
- package/lib/move.js +4 -3
- package/package.json +1 -1
- package/types/move.d.ts +4 -5
- package/types/nth.d.ts +6 -4
package/es/internals/helpers.js
CHANGED
|
@@ -2,7 +2,7 @@ import isObjectLike from '../isObjectLike.js';
|
|
|
2
2
|
import getTag from './getTag.js';
|
|
3
3
|
import { argumentsTag, stringUndefined, functionProtoToString } from './native.js';
|
|
4
4
|
|
|
5
|
-
var VERSION = "1.11.
|
|
5
|
+
var VERSION = "1.11.1";
|
|
6
6
|
var isBrowser = typeof window !== stringUndefined && isObjectLike(window) && typeof document !== stringUndefined && isObjectLike(document) && window.document === document;
|
|
7
7
|
var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
|
|
8
8
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
package/es/move.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
function move(
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
function move(array, from, to) {
|
|
2
|
+
var copyArray = array.slice();
|
|
3
|
+
copyArray.splice(to, 0, copyArray.splice(from, 1)[0]);
|
|
4
|
+
return copyArray;
|
|
4
5
|
}
|
|
5
6
|
|
|
6
7
|
export { move as default };
|
package/lib/internals/helpers.js
CHANGED
|
@@ -4,7 +4,7 @@ var isObjectLike = require('../isObjectLike.js');
|
|
|
4
4
|
var getTag = require('./getTag.js');
|
|
5
5
|
var native = require('./native.js');
|
|
6
6
|
|
|
7
|
-
var VERSION = "1.11.
|
|
7
|
+
var VERSION = "1.11.1";
|
|
8
8
|
var isBrowser = typeof window !== native.stringUndefined && isObjectLike(window) && typeof document !== native.stringUndefined && isObjectLike(document) && window.document === document;
|
|
9
9
|
var supportedArgumentsType = getTag((function () { return arguments; })()) === native.argumentsTag;
|
|
10
10
|
var FUNC_ERROR_TEXT = 'Expected a function';
|
package/lib/move.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function move(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
function move(array, from, to) {
|
|
4
|
+
var copyArray = array.slice();
|
|
5
|
+
copyArray.splice(to, 0, copyArray.splice(from, 1)[0]);
|
|
6
|
+
return copyArray;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
module.exports = move;
|
package/package.json
CHANGED
package/types/move.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 将数组 `from` 位置的元素移至 `to`
|
|
2
|
+
* 将数组 `from` 位置的元素移至 `to` 位置,返回处理后的新数组。
|
|
3
3
|
*
|
|
4
4
|
* @static
|
|
5
5
|
* @alias module:Array.move
|
|
@@ -8,16 +8,15 @@
|
|
|
8
8
|
* @param {Array} array 要处理的数组。
|
|
9
9
|
* @param {number} from 要移动的元素索引。
|
|
10
10
|
* @param {number} to 要移动目标位置的元素索引。
|
|
11
|
-
* @returns {*}
|
|
11
|
+
* @returns {*} 处理后的新数组。
|
|
12
12
|
* @example
|
|
13
13
|
*
|
|
14
14
|
* const arr = ['a', 'b', 'c', 'd'];
|
|
15
15
|
*
|
|
16
16
|
* move(arr, 0, 1); // ['b', 'a', 'c', 'd']
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
* move(arr, -2, 0); // ['c', 'b', 'a', 'd']
|
|
18
|
+
* move(arr, -2, 0); // ['c', 'a', 'b', 'd']
|
|
20
19
|
*
|
|
21
20
|
*/
|
|
22
|
-
declare function move<T>(
|
|
21
|
+
declare function move<T>(array: T[], from: number, to: number): T[];
|
|
23
22
|
export default move;
|
package/types/nth.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
interface Nth {
|
|
2
2
|
(array: [], n?: number): undefined;
|
|
3
|
-
<T>(array: T
|
|
3
|
+
<T>(array: ArrayLike<T>, n?: number): T;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* 获取类数组的第 `n` 个元素。如果 `n` 为负数,则返回从数组结尾开始的第 `n` 个元素。
|
|
7
7
|
*
|
|
8
8
|
* 同 `Array.prototype.at` 方法。
|
|
9
9
|
*
|
|
10
10
|
* @static
|
|
11
11
|
* @alias module:Array.nth
|
|
12
12
|
* @since 1.0.0
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {ArrayLike} array 要查询的类数组。
|
|
14
14
|
* @param {number} [n=0] 要返回元素的索引值。默认 `0`。
|
|
15
|
-
* @returns {*}
|
|
15
|
+
* @returns {*} 类数组的第 `n` 个元素。
|
|
16
16
|
* @example
|
|
17
17
|
*
|
|
18
18
|
* const arr = ['a', 'b', 'c', 'd'];
|
|
@@ -21,6 +21,8 @@ interface Nth {
|
|
|
21
21
|
*
|
|
22
22
|
* nth(arr, -2); // 'c'
|
|
23
23
|
*
|
|
24
|
+
* nth('abcd', 1); // 'b'
|
|
25
|
+
*
|
|
24
26
|
*/
|
|
25
27
|
declare const nth: Nth;
|
|
26
28
|
export default nth;
|