ut2 1.1.3 → 1.2.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 +2 -0
- package/dist/ut2.js +55 -37
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/difference.js +3 -2
- package/es/eq.js +7 -1
- package/es/index.js +2 -0
- package/es/internals/helpers.js +3 -2
- package/es/internals/sameValue.js +10 -0
- package/es/intersection.js +3 -3
- package/es/isDataView.js +7 -0
- package/es/isPlainObject.js +1 -3
- package/es/merge.js +1 -3
- package/es/once.js +7 -0
- package/es/orderBy.js +2 -6
- package/es/union.js +3 -2
- package/es/uniq.js +3 -2
- package/es/xor.js +6 -5
- package/lib/difference.js +3 -2
- package/lib/eq.js +7 -1
- package/lib/index.js +4 -0
- package/lib/internals/helpers.js +2 -1
- package/lib/internals/sameValue.js +12 -0
- package/lib/intersection.js +3 -3
- package/lib/isDataView.js +9 -0
- package/lib/isPlainObject.js +1 -3
- package/lib/merge.js +1 -3
- package/lib/once.js +9 -0
- package/lib/orderBy.js +2 -6
- package/lib/union.js +3 -2
- package/lib/uniq.js +3 -2
- package/lib/xor.js +6 -5
- package/package.json +1 -1
- package/types/before.d.ts +0 -7
- package/types/countBy.d.ts +1 -1
- package/types/difference.d.ts +9 -2
- package/types/eq.d.ts +8 -2
- package/types/groupBy.d.ts +1 -1
- package/types/index.d.ts +2 -0
- package/types/internals/decimalAdjust.d.ts +3 -3
- package/types/internals/helpers.d.ts +1 -0
- package/types/internals/isType.d.ts +1 -1
- package/types/internals/sameValue.d.ts +12 -0
- package/types/internals/splitCaseWords.d.ts +1 -1
- package/types/intersection.d.ts +9 -2
- package/types/isArrayLikeObject.d.ts +4 -4
- package/types/isBuffer.d.ts +1 -1
- package/types/isDataView.d.ts +15 -0
- package/types/isPlainObject.d.ts +3 -3
- package/types/isTypedArray.d.ts +2 -2
- package/types/kebabCase.d.ts +1 -1
- package/types/keyBy.d.ts +1 -1
- package/types/lowerCase.d.ts +1 -1
- package/types/merge.d.ts +2 -2
- package/types/omit.d.ts +1 -1
- package/types/once.d.ts +24 -0
- package/types/orderBy.d.ts +2 -2
- package/types/partition.d.ts +1 -1
- package/types/pick.d.ts +1 -1
- package/types/snakeCase.d.ts +1 -1
- package/types/toFinite.d.ts +8 -8
- package/types/union.d.ts +11 -4
- package/types/uniq.d.ts +10 -3
- package/types/upperCase.d.ts +1 -1
- package/types/words.d.ts +1 -1
- package/types/xor.d.ts +13 -6
package/types/intersection.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 创建唯一值的数组,该数组包含 2
|
|
2
|
+
* 创建唯一值的数组,该数组包含 2 个数组参数都包含的元素(交集)。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
3
3
|
*
|
|
4
4
|
* `iteratee` 调用时会传入 1 个参数 `value` 。
|
|
5
5
|
*
|
|
6
|
+
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
7
|
+
*
|
|
6
8
|
* @static
|
|
7
9
|
* @alias module:Array.intersection
|
|
8
10
|
* @since 1.0.0
|
|
9
11
|
* @param {Array} array 要检查的数组。
|
|
10
12
|
* @param {Array} other 另一个要检查的数组。
|
|
11
13
|
* @param {Function | string} [iteratee] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {boolean} [strictCheck=false] 严格比较,区分 `+0` `-0`。
|
|
12
15
|
* @returns {Array} 包含所有传入数组交集元素的新数组。
|
|
13
16
|
* @example
|
|
14
17
|
*
|
|
@@ -21,6 +24,10 @@
|
|
|
21
24
|
* // 迭代函数可以直接写入属性。
|
|
22
25
|
* intersection([{x: 1}, {x: 1}, {x: 2}, {x: 2}], [{x: 1}], 'x'); // [{x: 1}]
|
|
23
26
|
*
|
|
27
|
+
* intersection([-0, 0], [0]); // [-0]
|
|
28
|
+
*
|
|
29
|
+
* intersection([-0, 0], [0], undefined, true); // [0]
|
|
30
|
+
*
|
|
24
31
|
*/
|
|
25
|
-
declare function intersection<T, F extends (value: T) => any, K extends keyof T>(array: T[], other: T[], iteratee?: F | K): T[];
|
|
32
|
+
declare function intersection<T, F extends (value: T) => any, K extends keyof T>(array: T[], other: T[], iteratee?: F | K, strictCheck?: boolean): T[];
|
|
26
33
|
export default intersection;
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* @returns {boolean} 如果值为类数组对象,返回 `true` ,否则返回 `false` 。
|
|
9
9
|
* @example
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* isArrayLikeObject([1, 2, 3]); // true
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* isArrayLikeObject(document.body.children); // true
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* isArrayLikeObject('abc'); // false
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* isArrayLikeObject(()=>{}); // false
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
declare function isArrayLikeObject(value: any): boolean;
|
package/types/isBuffer.d.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 检查值是否为 `DataView` 对象。
|
|
3
|
+
*
|
|
4
|
+
* @static
|
|
5
|
+
* @alias module:Type.isDataView
|
|
6
|
+
* @since 1.2.0
|
|
7
|
+
* @param {*} value 要检查的值。
|
|
8
|
+
* @returns {boolean} 如果值为 `DataView` 对象,返回 `true` ,否则返回 `false` 。
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* isDataView(new DataView(new ArrayBuffer(8))); // true
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
declare function isDataView(value: any): boolean;
|
|
15
|
+
export default isDataView;
|
package/types/isPlainObject.d.ts
CHANGED
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
*
|
|
15
15
|
* isPlainObject(new Foo); // false
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* isPlainObject([1,2,3]); // false
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* isPlainObject({ a: 1, b: 2 }); // true
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* isPlainObject(Object.create(null)); // true
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
24
|
declare function isPlainObject(value: any): boolean;
|
package/types/isTypedArray.d.ts
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* @returns {boolean} 如果值为类型化数组,返回 `true` ,否则返回 `false` 。
|
|
10
10
|
* @example
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* isTypedArray(new Uint8Array); // true
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* isTypedArray([]); // false
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
declare function isTypedArray(value: any): boolean;
|
package/types/kebabCase.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @since 1.0.0
|
|
7
7
|
* @see {@link https://en.wikipedia.org/wiki/Letter_case#Special_case_styles | kebab case}
|
|
8
8
|
* @param {string} string 要转换的字符串。
|
|
9
|
-
* @param {RegExp|string} [pattern] 拆分词组的匹配模式。
|
|
9
|
+
* @param {RegExp | string} [pattern] 拆分词组的匹配模式。
|
|
10
10
|
* @returns {string} 转换后的字符串。
|
|
11
11
|
* @example
|
|
12
12
|
*
|
package/types/keyBy.d.ts
CHANGED
package/types/lowerCase.d.ts
CHANGED
package/types/merge.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ type Customizer = (objValue: any, srcValue: any, key: string | symbol, object: a
|
|
|
7
7
|
* @static
|
|
8
8
|
* @alias module:Object.merge
|
|
9
9
|
* @since 1.0.0
|
|
10
|
-
* @param {Object|Array} object 目标对象。
|
|
11
|
-
* @param {Object|Array} source 来源对象。
|
|
10
|
+
* @param {Object | Array} object 目标对象。
|
|
11
|
+
* @param {Object | Array} source 来源对象。
|
|
12
12
|
* @param {Function} [customizer] 自定义赋值函数。
|
|
13
13
|
* @returns {Object} 目标对象。
|
|
14
14
|
* @example
|
package/types/omit.d.ts
CHANGED
package/types/once.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 创建一个只能调用 `func` 一次的函数。重复调用将返回第一次调用 `func` 的结果。
|
|
3
|
+
*
|
|
4
|
+
* @static
|
|
5
|
+
* @alias module:Function.once
|
|
6
|
+
* @since 1.2.0
|
|
7
|
+
* @requires module:Function.before
|
|
8
|
+
* @param {Function} func 限制执行的函数。
|
|
9
|
+
* @returns {Function} 新的限定函数。
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* let count = 0;
|
|
13
|
+
*
|
|
14
|
+
* const increment = _.once(()=>{
|
|
15
|
+
* return ++count;
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* increment(); // 1
|
|
19
|
+
* increment(); // 1
|
|
20
|
+
* increment(); // 1
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
declare function once<T extends (...args: any[]) => any>(func: T): T;
|
|
24
|
+
export default once;
|
package/types/orderBy.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { Order } from './internals/compare';
|
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | sort}
|
|
13
13
|
* @param {Array} collection 一个用来迭代的集合。
|
|
14
|
-
* @param {Function|string|Array} [iteratees] 排序的迭代函数。
|
|
15
|
-
* @param {'asc'|'desc'|Array} [orders] 迭代函数的排序顺序。
|
|
14
|
+
* @param {Function | string | Array} [iteratees] 排序的迭代函数。
|
|
15
|
+
* @param {'asc' | 'desc' | Array} [orders] 迭代函数的排序顺序。
|
|
16
16
|
* @returns {Array} 排序后的新数组。
|
|
17
17
|
* @example
|
|
18
18
|
*
|
package/types/partition.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @alias module:Collection.partition
|
|
8
8
|
* @since 1.0.0
|
|
9
9
|
* @param {Array} collection 一个用来迭代的集合。
|
|
10
|
-
* @param {Function|string} [predicate=identity] 每次迭代调用的断言函数。
|
|
10
|
+
* @param {Function | string} [predicate=identity] 每次迭代调用的断言函数。
|
|
11
11
|
* @returns {Array} 分组后的数组。
|
|
12
12
|
* @example
|
|
13
13
|
*
|
package/types/pick.d.ts
CHANGED
package/types/snakeCase.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @since 1.0.0
|
|
7
7
|
* @see {@link https://en.wikipedia.org/wiki/Snake_case | snake case}
|
|
8
8
|
* @param {string} string 要转换的字符串。
|
|
9
|
-
* @param {RegExp|string} [pattern] 拆分词组的匹配模式。
|
|
9
|
+
* @param {RegExp | string} [pattern] 拆分词组的匹配模式。
|
|
10
10
|
* @returns {string} 转换后的字符串。
|
|
11
11
|
* @example
|
|
12
12
|
*
|
package/types/toFinite.d.ts
CHANGED
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
* @returns {number} 转换后的数字。
|
|
9
9
|
* @example
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* toFinite(3.2); // 3.2
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* toFinite('3.2'); // 3.2
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* toFinite(-0); // -0
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* toFinite('-0'); // -0
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* toFinite('0'); // 0
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* toFinite(NaN); // 0
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* toFinite(Infinity); // 1.7976931348623157e+308
|
|
24
24
|
*
|
|
25
|
-
*
|
|
25
|
+
* toFinite(-Infinity); // -1.7976931348623157e+308
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
28
|
declare function toFinite(value: any): number;
|
package/types/union.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 创建一个按顺序排列的唯一值的数组(并集)。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。与 [`uniq`](#.uniq) 相似。
|
|
3
3
|
*
|
|
4
4
|
* `iteratee` 调用时会传入 1 个参数 `value` 。
|
|
5
5
|
*
|
|
6
|
+
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
7
|
+
*
|
|
6
8
|
* @static
|
|
7
9
|
* @alias module:Array.union
|
|
8
10
|
* @since 1.0.0
|
|
9
11
|
* @param {Array} array 要检查的数组。
|
|
10
12
|
* @param {Array} [other=[]] 另一个要检查的数组。
|
|
11
13
|
* @param {Function | string} [iteratee] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {boolean} [strictCheck=false] 严格比较,区分 `+0` `-0`。
|
|
12
15
|
* @returns {Array} 新的联合数组。
|
|
13
16
|
* @example
|
|
14
17
|
*
|
|
@@ -16,11 +19,15 @@
|
|
|
16
19
|
*
|
|
17
20
|
* union([2.1], [1.2, 2.3], Math.floor); // [2.1, 1.2]
|
|
18
21
|
*
|
|
19
|
-
*
|
|
22
|
+
* union([{x: 1}, {x: 1}, {x: 2}, {x: 2}], [{x: 1}], item=>item.x); // [{x: 1}, {x: 2}]
|
|
20
23
|
*
|
|
21
24
|
* // 迭代函数可以直接写入属性。
|
|
22
|
-
*
|
|
25
|
+
* union([{x: 1}, {x: 1}, {x: 2}, {x: 2}], [{x: 1}], 'x'); // [{x: 1}, {x: 2}]
|
|
26
|
+
*
|
|
27
|
+
* union([-0, 0], [-0]); // [-0]
|
|
28
|
+
*
|
|
29
|
+
* union([-0, 0], [-0], undefined, true); // [-0, 0]
|
|
23
30
|
*
|
|
24
31
|
*/
|
|
25
|
-
declare function union<T, F extends (value: T) => any, K extends keyof T>(array: T[], other?: T[], iteratee?: F | K): T[];
|
|
32
|
+
declare function union<T, F extends (value: T) => any, K extends keyof T>(array: T[], other?: T[], iteratee?: F | K, strickCheck?: boolean): T[];
|
|
26
33
|
export default union;
|
package/types/uniq.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 创建一个去重后的数组副本。只有第一次出现的元素才会被保留。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
3
3
|
*
|
|
4
4
|
* `iteratee` 调用时会传入 1 个参数 `value` 。
|
|
5
5
|
*
|
|
6
|
+
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
7
|
+
*
|
|
6
8
|
* @static
|
|
7
9
|
* @alias module:Array.uniq
|
|
8
10
|
* @since 1.0.0
|
|
9
|
-
* @param {Array}
|
|
11
|
+
* @param {Array} array 要检查的数组。
|
|
10
12
|
* @param {Function | string} [iteratee] 迭代函数,调用每个元素。
|
|
13
|
+
* @param {boolean} [strictCheck=false] 严格比较,区分 `+0` `-0`。
|
|
11
14
|
* @returns {Array} 去重后的新数组。
|
|
12
15
|
* @example
|
|
13
16
|
*
|
|
@@ -20,6 +23,10 @@
|
|
|
20
23
|
* // 迭代函数可以直接写入属性。
|
|
21
24
|
* uniq([{x: 1}, {x: 2}, {x: 1}], 'x'); // [{x: 1}, {x: 2}]
|
|
22
25
|
*
|
|
26
|
+
* uniq([-0, 0]); // [-0]
|
|
27
|
+
*
|
|
28
|
+
* uniq([-0, 0], undefined, true); // [-0, 0]
|
|
29
|
+
*
|
|
23
30
|
*/
|
|
24
|
-
declare function uniq<T, F extends (value: T) => any, K extends keyof T>(array: T[], iteratee?: F | K): T[];
|
|
31
|
+
declare function uniq<T, F extends (value: T) => any, K extends keyof T>(array: T[], iteratee?: F | K, strickCheck?: boolean): T[];
|
|
25
32
|
export default uniq;
|
package/types/upperCase.d.ts
CHANGED
package/types/words.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @since 1.0.0
|
|
7
7
|
* @see {@link https://zh.wikipedia.org/wiki/ASCII | ASCII}
|
|
8
8
|
* @param {string} string 要拆分的字符串。
|
|
9
|
-
* @param {RegExp|string} [pattern=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g] 匹配模式。
|
|
9
|
+
* @param {RegExp | string} [pattern=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g] 匹配模式。
|
|
10
10
|
* @returns {string[]} 拆分后的数组。
|
|
11
11
|
* @example
|
|
12
12
|
*
|
package/types/xor.d.ts
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 创建一个唯一值的数组(并集-交集),该数组包含 2
|
|
2
|
+
* 创建一个唯一值的数组(并集-交集),该数组包含 2 个数组参数中不相同的元素。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
3
3
|
*
|
|
4
4
|
* `iteratee` 调用时会传入 1 个参数 `value` 。
|
|
5
5
|
*
|
|
6
|
+
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
7
|
+
*
|
|
6
8
|
* @static
|
|
7
9
|
* @alias module:Array.xor
|
|
8
10
|
* @since 1.0.0
|
|
9
11
|
* @param {Array} array 要检查的数组。
|
|
10
12
|
* @param {Array} [other=[]] 另一个要检查的数组。
|
|
11
13
|
* @param {Function | string} [iteratee] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {boolean} [strictCheck=false] 严格比较,区分 `+0` `-0`。
|
|
12
15
|
* @returns {Array} 过滤值后的新数组。
|
|
13
16
|
* @example
|
|
14
17
|
*
|
|
15
|
-
*
|
|
18
|
+
* xor([2, 1, 1], [4, 2]); // [1, 4]
|
|
16
19
|
*
|
|
17
|
-
*
|
|
20
|
+
* xor([2.1, 1.2], [4.3, 2.4], Math.floor); // [1.2, 4.3]
|
|
18
21
|
*
|
|
19
|
-
*
|
|
22
|
+
* xor([{x: 1}, {x: 1}, {x: 2}, {x: 2}], [{x: 1}], item=>item.x); // [{x: 2}]
|
|
20
23
|
*
|
|
21
24
|
* // 迭代函数可以直接写入属性。
|
|
22
|
-
*
|
|
25
|
+
* xor([{x: 1}, {x: 1}, {x: 2}, {x: 2}], [{x: 1}], 'x'); // [{x: 2}]
|
|
26
|
+
*
|
|
27
|
+
* xor([-0, 0],[0]); // []
|
|
28
|
+
*
|
|
29
|
+
* xor([-0, 0],[0], undefined, true); // [-0]
|
|
23
30
|
*
|
|
24
31
|
*/
|
|
25
|
-
declare function xor<T, F extends (value: T) => any, K extends keyof T>(array: T[], other?: T[], iteratee?: F | K): T[];
|
|
32
|
+
declare function xor<T, F extends (value: T) => any, K extends keyof T>(array: T[], other?: T[], iteratee?: F | K, strickCheck?: boolean): T[];
|
|
26
33
|
export default xor;
|