ut2 1.5.6 → 1.7.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 +11 -0
- package/dist/ut2.js +239 -101
- package/dist/ut2.js.map +1 -1
- package/dist/ut2.min.js +1 -1
- package/dist/ut2.min.js.map +1 -1
- package/es/countBy.js +11 -13
- package/es/difference.js +2 -0
- package/es/every.js +16 -0
- package/es/filter.js +15 -0
- package/es/find.js +16 -0
- package/es/forEach.js +6 -0
- package/es/forEachRight.js +6 -0
- package/es/groupBy.js +13 -13
- package/es/index.js +11 -0
- package/es/internals/createExtremum.js +8 -18
- package/es/internals/createForEach.js +23 -0
- package/es/internals/createReduce.js +29 -0
- package/es/internals/helpers.js +1 -1
- package/es/intersection.js +2 -0
- package/es/isEmpty.js +1 -1
- package/es/keyBy.js +8 -8
- package/es/keys.js +11 -0
- package/es/map.js +13 -0
- package/es/merge.js +32 -22
- package/es/orderBy.js +9 -9
- package/es/partition.js +7 -7
- package/es/range.js +28 -0
- package/es/reduce.js +6 -0
- package/es/reduceRight.js +6 -0
- package/es/some.js +16 -0
- package/es/toString.js +1 -1
- package/es/uniq.js +5 -13
- package/es/xor.js +2 -0
- package/lib/countBy.js +11 -13
- package/lib/difference.js +2 -0
- package/lib/every.js +18 -0
- package/lib/filter.js +17 -0
- package/lib/find.js +18 -0
- package/lib/forEach.js +8 -0
- package/lib/forEachRight.js +8 -0
- package/lib/groupBy.js +13 -13
- package/lib/index.js +22 -0
- package/lib/internals/createExtremum.js +8 -18
- package/lib/internals/createForEach.js +25 -0
- package/lib/internals/createReduce.js +31 -0
- package/lib/internals/helpers.js +1 -1
- package/lib/intersection.js +2 -0
- package/lib/isEmpty.js +2 -2
- package/lib/keyBy.js +8 -8
- package/lib/keys.js +13 -0
- package/lib/map.js +15 -0
- package/lib/merge.js +32 -22
- package/lib/orderBy.js +9 -9
- package/lib/partition.js +7 -7
- package/lib/range.js +30 -0
- package/lib/reduce.js +8 -0
- package/lib/reduceRight.js +8 -0
- package/lib/some.js +18 -0
- package/lib/toString.js +1 -1
- package/lib/uniq.js +5 -13
- package/lib/xor.js +2 -0
- package/package.json +1 -1
- package/types/allKeys.d.ts +1 -1
- package/types/allKeysIn.d.ts +1 -1
- package/types/conformsTo.d.ts +2 -1
- package/types/countBy.d.ts +3 -24
- package/types/difference.d.ts +3 -2
- package/types/every.d.ts +6 -0
- package/types/filter.d.ts +6 -0
- package/types/find.d.ts +6 -0
- package/types/forEach.d.ts +36 -0
- package/types/forEachRight.d.ts +36 -0
- package/types/groupBy.d.ts +3 -24
- package/types/index.d.ts +11 -0
- package/types/internals/compare.d.ts +2 -1
- package/types/internals/createExtremum.d.ts +2 -1
- package/types/internals/createForEach.d.ts +15 -0
- package/types/internals/createIteratee.d.ts +2 -2
- package/types/internals/createReduce.d.ts +19 -0
- package/types/intersection.d.ts +3 -2
- package/types/isArrayBuffer.d.ts +1 -1
- package/types/isArrayLike.d.ts +1 -1
- package/types/isError.d.ts +1 -1
- package/types/isWeakMap.d.ts +1 -1
- package/types/isWeakSet.d.ts +1 -1
- package/types/keyBy.d.ts +3 -24
- package/types/keys.d.ts +24 -0
- package/types/keysIn.d.ts +1 -1
- package/types/map.d.ts +6 -0
- package/types/max.d.ts +3 -2
- package/types/merge.d.ts +6 -2
- package/types/min.d.ts +3 -2
- package/types/orderBy.d.ts +3 -39
- package/types/partition.d.ts +3 -34
- package/types/range.d.ts +4 -0
- package/types/reduce.d.ts +38 -0
- package/types/reduceRight.d.ts +38 -0
- package/types/some.d.ts +6 -0
- package/types/union.d.ts +2 -1
- package/types/uniq.d.ts +2 -1
- package/types/xor.d.ts +3 -2
- /package/es/internals/{keys.js → specialKeys.js} +0 -0
- /package/lib/internals/{keys.js → specialKeys.js} +0 -0
- /package/types/internals/{keys.d.ts → specialKeys.d.ts} +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对每个元素调用 `iteratee` 函数,每一次运行 `iteratee` 会将元素的计算结果作为参数传入,最后将其结果汇总为单个返回值。
|
|
3
|
+
*
|
|
4
|
+
* 如果没有提供第三个参数值,则集合中的第一个元素将用作初始值。
|
|
5
|
+
*
|
|
6
|
+
* `iteratee` 调用时会传入四个参数 `accumulator`、`value`、`index|key`、`collection` 。
|
|
7
|
+
*
|
|
8
|
+
* @function
|
|
9
|
+
* @alias module:Collection.reduce
|
|
10
|
+
* @since 1.7.0
|
|
11
|
+
* @param {ArrayLike<any> | Object} collection 要迭代的集合。
|
|
12
|
+
* @param {Function} [iteratee=identity] 每次迭代调用的函数。
|
|
13
|
+
* @param {*} [initialValue] 初始值。
|
|
14
|
+
* @returns {*} 累计值。
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* reduce([1,2,3], function(accumulator, current, index){
|
|
18
|
+
* return accumulator + current;
|
|
19
|
+
* }, 0);
|
|
20
|
+
* // 6
|
|
21
|
+
*
|
|
22
|
+
* reduce({a: 1, b: 2, c: 3}, function(accumulator, current, key){
|
|
23
|
+
* return accumulator + current;
|
|
24
|
+
* }, 0);
|
|
25
|
+
* // 6
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
declare const reduce: {
|
|
29
|
+
<T, R>(collection: import("./internals/types").WithNullable<T[]>, iteratee: import("./internals/types").ReduceArrayIterator<T, R>, initialValue: R): R;
|
|
30
|
+
<R_1>(collection: import("./internals/types").WithNullable<string>, iteratee: import("./internals/types").ReduceStringIterator<R_1>, initialValue: R_1): R_1;
|
|
31
|
+
<T_1, R_2>(collection: import("./internals/types").WithNullable<ArrayLike<T_1>>, iteratee: import("./internals/types").ReduceArrayLikeIterator<T_1, R_2>, initialValue: R_2): R_2;
|
|
32
|
+
<T_2 extends object, R_3>(collection: import("./internals/types").WithNullable<T_2>, iteratee: import("./internals/types").ReduceObjectIterator<T_2, R_3>, initialValue: R_3): R_3;
|
|
33
|
+
<T_3>(collection: import("./internals/types").WithNullable<T_3[]>, iteratee?: import("./internals/types").ReduceArrayIterator<T_3, T_3> | undefined): T_3 | undefined;
|
|
34
|
+
(collection: import("./internals/types").WithNullable<string>, iteratee?: import("./internals/types").ReduceStringIterator<string> | undefined): string | undefined;
|
|
35
|
+
<T_4>(collection: import("./internals/types").WithNullable<ArrayLike<T_4>>, iteratee?: import("./internals/types").ReduceArrayLikeIterator<T_4, T_4> | undefined): T_4 | undefined;
|
|
36
|
+
<T_5 extends object>(collection: import("./internals/types").WithNullable<T_5>, iteratee?: import("./internals/types").ReduceObjectIterator<T_5, T_5[keyof T_5]> | undefined): T_5[keyof T_5] | undefined;
|
|
37
|
+
};
|
|
38
|
+
export default reduce;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 对每个元素(从右往左的顺序)调用 `iteratee` 函数,每一次运行 `iteratee` 会将元素的计算结果作为参数传入,最后将其结果汇总为单个返回值。
|
|
3
|
+
*
|
|
4
|
+
* 如果没有提供第三个参数值,则集合中的第一个元素将用作初始值。
|
|
5
|
+
*
|
|
6
|
+
* `iteratee` 调用时会传入四个参数 `accumulator`、`value`、`index|key`、`collection` 。
|
|
7
|
+
*
|
|
8
|
+
* @function
|
|
9
|
+
* @alias module:Collection.reduceRight
|
|
10
|
+
* @since 1.7.0
|
|
11
|
+
* @param {ArrayLike<any> | Object} collection 要迭代的集合。
|
|
12
|
+
* @param {Function} [iteratee=identity] 每次迭代调用的函数。
|
|
13
|
+
* @param {*} [initialValue] 初始值。
|
|
14
|
+
* @returns {*} 累计值。
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* reduceRight([1,2,3], function(accumulator, current, index){
|
|
18
|
+
* return accumulator + current;
|
|
19
|
+
* }, 0);
|
|
20
|
+
* // 6
|
|
21
|
+
*
|
|
22
|
+
* reduceRight({a: 1, b: 2, c: 3}, function(accumulator, current, key){
|
|
23
|
+
* return accumulator + current;
|
|
24
|
+
* }, 0);
|
|
25
|
+
* // 6
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
declare const reduceRight: {
|
|
29
|
+
<T, R>(collection: import("./internals/types").WithNullable<T[]>, iteratee: import("./internals/types").ReduceArrayIterator<T, R>, initialValue: R): R;
|
|
30
|
+
<R_1>(collection: import("./internals/types").WithNullable<string>, iteratee: import("./internals/types").ReduceStringIterator<R_1>, initialValue: R_1): R_1;
|
|
31
|
+
<T_1, R_2>(collection: import("./internals/types").WithNullable<ArrayLike<T_1>>, iteratee: import("./internals/types").ReduceArrayLikeIterator<T_1, R_2>, initialValue: R_2): R_2;
|
|
32
|
+
<T_2 extends object, R_3>(collection: import("./internals/types").WithNullable<T_2>, iteratee: import("./internals/types").ReduceObjectIterator<T_2, R_3>, initialValue: R_3): R_3;
|
|
33
|
+
<T_3>(collection: import("./internals/types").WithNullable<T_3[]>, iteratee?: import("./internals/types").ReduceArrayIterator<T_3, T_3> | undefined): T_3 | undefined;
|
|
34
|
+
(collection: import("./internals/types").WithNullable<string>, iteratee?: import("./internals/types").ReduceStringIterator<string> | undefined): string | undefined;
|
|
35
|
+
<T_4>(collection: import("./internals/types").WithNullable<ArrayLike<T_4>>, iteratee?: import("./internals/types").ReduceArrayLikeIterator<T_4, T_4> | undefined): T_4 | undefined;
|
|
36
|
+
<T_5 extends object>(collection: import("./internals/types").WithNullable<T_5>, iteratee?: import("./internals/types").ReduceObjectIterator<T_5, T_5[keyof T_5]> | undefined): T_5[keyof T_5] | undefined;
|
|
37
|
+
};
|
|
38
|
+
export default reduceRight;
|
package/types/some.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ArrayIterator, ArrayLikeIterator, ObjectIterator, StringIterator, WithNullable } from './internals/types';
|
|
2
|
+
declare function some<T>(collection: WithNullable<T[]>, predicate?: ArrayIterator<T, any>): boolean;
|
|
3
|
+
declare function some(collection: WithNullable<string>, predicate?: StringIterator<any>): boolean;
|
|
4
|
+
declare function some<T>(collection: WithNullable<ArrayLike<T>>, predicate?: ArrayLikeIterator<T, any>): boolean;
|
|
5
|
+
declare function some<T extends object>(collection: WithNullable<T>, predicate?: ObjectIterator<T, any>): boolean;
|
|
6
|
+
export default some;
|
package/types/union.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IterateeParam } from './internals/types';
|
|
1
2
|
/**
|
|
2
3
|
* 创建一个按顺序排列的唯一值的数组(并集)。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。与 [`uniq`](#.uniq) 相似。
|
|
3
4
|
*
|
|
@@ -29,5 +30,5 @@
|
|
|
29
30
|
* union([-0, 0], [-0], undefined, true); // [-0, 0]
|
|
30
31
|
*
|
|
31
32
|
*/
|
|
32
|
-
declare function union<T
|
|
33
|
+
declare function union<T>(array: T[], other?: T[], iteratee?: IterateeParam<T>, strickCheck?: boolean): T[];
|
|
33
34
|
export default union;
|
package/types/uniq.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IterateeParam } from './internals/types';
|
|
1
2
|
/**
|
|
2
3
|
* 创建一个去重后的数组副本。只有第一次出现的元素才会被保留。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
3
4
|
*
|
|
@@ -28,5 +29,5 @@
|
|
|
28
29
|
* uniq([-0, 0], undefined, true); // [-0, 0]
|
|
29
30
|
*
|
|
30
31
|
*/
|
|
31
|
-
declare function uniq<T
|
|
32
|
+
declare function uniq<T>(array: T[], iteratee?: IterateeParam<T>, strickCheck?: boolean): T[];
|
|
32
33
|
export default uniq;
|
package/types/xor.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IterateeParam } from './internals/types';
|
|
1
2
|
/**
|
|
2
3
|
* 创建一个唯一值的数组(并集-交集),该数组包含 2 个数组参数中不相同的元素。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
3
4
|
*
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
* @since 1.0.0
|
|
11
12
|
* @param {Array} array 要检查的数组。
|
|
12
13
|
* @param {Array} [other=[]] 另一个要检查的数组。
|
|
13
|
-
* @param {Function | string} [iteratee] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {Function | string} [iteratee={@link https://caijf.github.io/ut2/module-Util.html#.identity | identity}] 迭代函数,调用每个元素。
|
|
14
15
|
* @param {boolean} [strictCheck=false] 严格比较,区分 `0` `-0`,默认 `false` 。
|
|
15
16
|
* @returns {Array} 过滤值后的新数组。
|
|
16
17
|
* @example
|
|
@@ -29,5 +30,5 @@
|
|
|
29
30
|
* xor([-0, 0],[0], undefined, true); // [-0]
|
|
30
31
|
*
|
|
31
32
|
*/
|
|
32
|
-
declare function xor<T
|
|
33
|
+
declare function xor<T>(array: T[], other?: T[], iteratee?: IterateeParam<T>, strickCheck?: boolean): T[];
|
|
33
34
|
export default xor;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|