ut2 1.8.1 → 1.9.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/dist/ut2.js +63 -93
- 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 +2 -2
- package/es/groupBy.js +2 -2
- package/es/internals/compare.js +19 -26
- package/es/internals/createExtremum.js +2 -2
- package/es/internals/createForEach.js +2 -2
- package/es/internals/createReduce.js +2 -2
- package/es/internals/helpers.js +1 -1
- package/es/invert.js +2 -2
- package/es/isEmpty.js +2 -2
- package/es/keyBy.js +2 -2
- package/es/max.js +4 -3
- package/es/merge.js +2 -2
- package/es/min.js +4 -3
- package/es/orderBy.js +2 -2
- package/es/partition.js +2 -2
- package/es/pick.js +4 -0
- package/es/pickBy.js +0 -4
- package/lib/countBy.js +2 -2
- package/lib/groupBy.js +2 -2
- package/lib/internals/compare.js +18 -27
- package/lib/internals/createExtremum.js +2 -2
- package/lib/internals/createForEach.js +2 -2
- package/lib/internals/createReduce.js +2 -2
- package/lib/internals/helpers.js +1 -1
- package/lib/invert.js +2 -2
- package/lib/isEmpty.js +2 -2
- package/lib/keyBy.js +2 -2
- package/lib/max.js +4 -3
- package/lib/merge.js +2 -2
- package/lib/min.js +4 -3
- package/lib/orderBy.js +2 -2
- package/lib/partition.js +2 -2
- package/lib/pick.js +4 -0
- package/lib/pickBy.js +0 -4
- package/package.json +1 -1
- package/types/countBy.d.ts +7 -5
- package/types/difference.d.ts +2 -2
- package/types/groupBy.d.ts +7 -5
- package/types/internals/compare.d.ts +0 -2
- package/types/internals/createExtremum.d.ts +2 -2
- package/types/internals/types.d.ts +9 -2
- package/types/intersection.d.ts +3 -3
- package/types/invert.d.ts +1 -1
- package/types/keyBy.d.ts +7 -5
- package/types/max.d.ts +5 -5
- package/types/merge.d.ts +3 -3
- package/types/min.d.ts +4 -4
- package/types/omitBy.d.ts +1 -1
- package/types/orderBy.d.ts +7 -5
- package/types/partition.d.ts +7 -5
- package/types/pickBy.d.ts +1 -1
- package/types/reduce.d.ts +1 -1
- package/types/reduceRight.d.ts +1 -1
- package/types/times.d.ts +1 -1
- package/types/union.d.ts +2 -2
- package/types/uniq.d.ts +2 -2
- package/types/xor.d.ts +3 -3
- package/es/internals/isPrototype.js +0 -12
- package/es/internals/specialKeys.js +0 -17
- package/lib/internals/isPrototype.js +0 -14
- package/lib/internals/specialKeys.js +0 -19
- package/types/internals/isPrototype.d.ts +0 -9
- package/types/internals/specialKeys.d.ts +0 -9
package/types/difference.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IterateeParam } from './internals/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建一个 `array` 排除 `values` 值的新数组。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
4
4
|
*
|
|
5
|
-
* `iteratee`
|
|
5
|
+
* `iteratee` 调用时会传入一个参数 `value` 。
|
|
6
6
|
*
|
|
7
7
|
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
8
8
|
*
|
|
@@ -11,7 +11,7 @@ import { IterateeParam } from './internals/types';
|
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
* @param {Array} array 要检查的数组。
|
|
13
13
|
* @param {Array} values 排除的值。
|
|
14
|
-
* @param {Function | string} [iteratee=identity] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {Function | string | number | Symbol} [iteratee=identity] 迭代函数,调用每个元素。
|
|
15
15
|
* @param {boolean} [strictCheck=false] 严格比较,区分 `0` `-0`,默认 `false` 。
|
|
16
16
|
* @returns {Array} 过滤值后的新数组。
|
|
17
17
|
* @example
|
package/types/groupBy.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { CollectionList, CollectionObject,
|
|
1
|
+
import { ArrayLikeIterator, CollectionList, CollectionObject, PropertyName, ObjectIterator } from './internals/types';
|
|
2
2
|
interface GroupBy {
|
|
3
|
-
<T>(collection: CollectionList<T>, iteratee?:
|
|
4
|
-
<T
|
|
3
|
+
<T extends object>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, PropertyName> | keyof T): Record<PropertyName, T[]>;
|
|
4
|
+
<T>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, PropertyName> | PropertyName): Record<PropertyName, T[]>;
|
|
5
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: ObjectIterator<T, PropertyName> | keyof T): Record<PropertyName, V[]>;
|
|
6
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: PropertyName): Record<PropertyName, V[]>;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* 创建一个组成聚合对象, `key` 是经过 `iteratee` 执行处理 `collection` 中每个元素后返回的结果。分组值的顺序是由他们出现在 `collection` 的顺序确定的。每个键对应的值负责生成 `key` 的元素组成的数组。
|
|
8
10
|
*
|
|
9
|
-
* `iteratee`
|
|
11
|
+
* `iteratee` 调用时会传入三个参数 `value` `index|key` `collection` 。
|
|
10
12
|
*
|
|
11
13
|
* @static
|
|
12
14
|
* @alias module:Collection.groupBy
|
|
13
15
|
* @since 1.0.0
|
|
14
16
|
* @param {ArrayLike<any> | Object} collection 一个用来迭代的集合。
|
|
15
|
-
* @param {Function | string} [iteratee=identity] 迭代函数,用来转换键。
|
|
17
|
+
* @param {Function | string | number | Symbol} [iteratee=identity] 迭代函数,用来转换键。
|
|
16
18
|
* @returns {Object} 组成聚合对象。
|
|
17
19
|
* @example
|
|
18
20
|
*
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IterateeParam } from './types';
|
|
2
|
-
declare function createExtremum<T>(array: T[]
|
|
1
|
+
import { IterateeParam, WithNullable } from './types';
|
|
2
|
+
declare function createExtremum<T>(array: WithNullable<T[]>, comparator: (value: any, other: any) => boolean, iteratee?: IterateeParam<T>): T | undefined;
|
|
3
3
|
export default createExtremum;
|
|
@@ -9,14 +9,14 @@ export type ObjectPredicate<T extends object, K extends keyof T = keyof T> = (va
|
|
|
9
9
|
/**
|
|
10
10
|
* 迭代参数
|
|
11
11
|
*/
|
|
12
|
-
export type IterateeParam<T> = ((value: T, ...args: any[]) => any) |
|
|
12
|
+
export type IterateeParam<T> = ((value: T, ...args: any[]) => any) | PropertyName;
|
|
13
13
|
/**
|
|
14
14
|
* 迭代方法
|
|
15
15
|
*/
|
|
16
16
|
export type StringIterator<R> = (char: string, index: number, string: string) => R;
|
|
17
17
|
export type ArrayIterator<T, R> = (item: T, index: number, list: T[]) => R;
|
|
18
18
|
export type ArrayLikeIterator<T, R> = (item: T, index: number, list: ArrayLike<T>) => R;
|
|
19
|
-
export type ObjectIterator<T, R> = (value: T[keyof T], key:
|
|
19
|
+
export type ObjectIterator<T, R> = (value: T[keyof T], key: keyof T, object: T) => R;
|
|
20
20
|
export type ReduceStringIterator<R> = (accumulator: R, currentValue: string, currentIndex: number, string: string) => R;
|
|
21
21
|
export type ReduceArrayIterator<T, R> = (accumulator: R, currentValue: T, currentIndex: number, list: T[]) => R;
|
|
22
22
|
export type ReduceArrayLikeIterator<T, R> = (accumulator: R, currentValue: T, currentIndex: number, list: ArrayLike<T>) => R;
|
|
@@ -29,3 +29,10 @@ export type CollectionList<T> = WithNullable<ArrayLike<T>>;
|
|
|
29
29
|
* 集合对象
|
|
30
30
|
*/
|
|
31
31
|
export type CollectionObject<T extends object> = WithNullable<T>;
|
|
32
|
+
/**
|
|
33
|
+
* max、min方法
|
|
34
|
+
*/
|
|
35
|
+
export interface ExtremumFunction {
|
|
36
|
+
<T extends object>(array: WithNullable<T[]>, iteratee?: ArrayIterator<T, any> | keyof T): T | undefined;
|
|
37
|
+
<T>(array: WithNullable<T[]>, iteratee?: ArrayIterator<T, any> | PropertyName): T | undefined;
|
|
38
|
+
}
|
package/types/intersection.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IterateeParam } from './internals/types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 创建唯一值的数组,该数组包含两个数组参数都包含的元素(交集)。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
4
4
|
*
|
|
5
|
-
* `iteratee`
|
|
5
|
+
* `iteratee` 调用时会传入一个参数 `value` 。
|
|
6
6
|
*
|
|
7
7
|
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
8
8
|
*
|
|
@@ -11,7 +11,7 @@ import { IterateeParam } from './internals/types';
|
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
* @param {Array} array 要检查的数组。
|
|
13
13
|
* @param {Array} other 另一个要检查的数组。
|
|
14
|
-
* @param {Function | string} [iteratee=identity] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {Function | string | number | Symbol} [iteratee=identity] 迭代函数,调用每个元素。
|
|
15
15
|
* @param {boolean} [strictCheck=false] 严格比较,区分 `0` `-0`,默认 `false` 。
|
|
16
16
|
* @returns {Array} 包含所有传入数组交集元素的新数组。
|
|
17
17
|
* @example
|
package/types/invert.d.ts
CHANGED
package/types/keyBy.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { CollectionList, CollectionObject,
|
|
1
|
+
import { ArrayLikeIterator, CollectionList, CollectionObject, ObjectIterator, PropertyName } from './internals/types';
|
|
2
2
|
interface KeyBy {
|
|
3
|
-
<T>(collection: CollectionList<T>, iteratee?:
|
|
4
|
-
<T
|
|
3
|
+
<T extends object>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, PropertyName> | keyof T): Record<PropertyName, T>;
|
|
4
|
+
<T>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, PropertyName> | PropertyName): Record<PropertyName, T>;
|
|
5
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: ObjectIterator<T, PropertyName> | keyof T): Record<PropertyName, V>;
|
|
6
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: PropertyName): Record<PropertyName, V>;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* 创建一个组成聚合对象, `key` 是经过 `iteratee` 执行处理 `collection` 中每个元素后返回的结果。每个 `key` 对应的值是生成 `key` 的最后一个元素。
|
|
8
10
|
*
|
|
9
|
-
* `iteratee`
|
|
11
|
+
* `iteratee` 调用时会传入三个参数 `value` `index|key` `collection` 。
|
|
10
12
|
*
|
|
11
13
|
* @function
|
|
12
14
|
* @alias module:Collection.keyBy
|
|
13
15
|
* @since 1.0.0
|
|
14
16
|
* @param {ArrayLike<any> | Object} collection 一个用来迭代的集合。
|
|
15
|
-
* @param {Function | string} [iteratee=identity] 迭代函数,用来转换键。
|
|
17
|
+
* @param {Function | string | number | Symbol} [iteratee=identity] 迭代函数,用来转换键。
|
|
16
18
|
* @returns {Object} 组成聚合对象。
|
|
17
19
|
* @example
|
|
18
20
|
*
|
package/types/max.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtremumFunction } from './internals/types';
|
|
2
2
|
/**
|
|
3
3
|
* 调用 `array` 中的每一个元素,来生成其值排序的标准,返回最大的值。
|
|
4
4
|
*
|
|
5
|
-
* `iteratee`
|
|
5
|
+
* `iteratee` 调用时会传入三个参数 `value` `index` `array` 。
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
7
|
+
* @function
|
|
8
8
|
* @alias module:Math.max
|
|
9
9
|
* @since 1.0.0
|
|
10
10
|
* @param {Array} array 要迭代的数组。
|
|
11
|
-
* @param {Function | string} [iteratee] 调用每个元素的迭代函数。
|
|
11
|
+
* @param {Function | string | number | Symbol} [iteratee] 调用每个元素的迭代函数。
|
|
12
12
|
* @returns {*} 最大的值。
|
|
13
13
|
* @example
|
|
14
14
|
*
|
|
@@ -24,5 +24,5 @@ import { IterateeParam } from './internals/types';
|
|
|
24
24
|
* max(objects, 'n'); // {n: 2};
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
|
-
declare
|
|
27
|
+
declare const max: ExtremumFunction;
|
|
28
28
|
export default max;
|
package/types/merge.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
type GetKeysMethod = <T extends object>(object: T) => (symbol | string)[];
|
|
2
2
|
type Customizer = (objValue: any, srcValue: any, key: string | symbol, object: any, source: any) => any;
|
|
3
3
|
/**
|
|
4
|
-
* 递归合并 `source`
|
|
4
|
+
* 递归合并 `source` 来源对象自身的可枚举属性(包含 `Symbol` 属性)到 `object` 目标对象。
|
|
5
5
|
*
|
|
6
6
|
* 如果目标值存在,被解析为 `undefined` 的 `source` 来源对象属性将被跳过。数组和普通对象会递归合并,其他对象和值会被直接分配覆盖。
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* 如果你需要合并继承的属性,第四个参数传入 {@link https://caijf.github.io/ut2/module-Object.html#.allKeysIn | allKeysIn} 方法, `merge(object, source, undefined, allKeysIn)` 。
|
|
9
9
|
*
|
|
10
10
|
* @static
|
|
11
11
|
* @alias module:Object.merge
|
|
@@ -13,7 +13,7 @@ type Customizer = (objValue: any, srcValue: any, key: string | symbol, object: a
|
|
|
13
13
|
* @param {Object | Array} object 目标对象。
|
|
14
14
|
* @param {Object | Array} source 来源对象。
|
|
15
15
|
* @param {Function} [customizer] 自定义赋值函数。
|
|
16
|
-
* @param {Function} [getKeys=
|
|
16
|
+
* @param {Function} [getKeys=allKeys] 自定义获取对象键方法。
|
|
17
17
|
* @returns {Object} 目标对象。
|
|
18
18
|
* @example
|
|
19
19
|
*
|
package/types/min.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtremumFunction } from './internals/types';
|
|
2
2
|
/**
|
|
3
3
|
* 调用 `array` 中的每一个元素,来生成其值排序的标准,返回最小的值。
|
|
4
4
|
*
|
|
5
|
-
* `iteratee`
|
|
5
|
+
* `iteratee` 调用时会传入三个参数 `value` `index` `array` 。
|
|
6
6
|
*
|
|
7
7
|
* @static
|
|
8
8
|
* @alias module:Math.min
|
|
9
9
|
* @since 1.0.0
|
|
10
10
|
* @param {Array} array 要迭代的数组。
|
|
11
|
-
* @param {Function | string} [iteratee] 调用每个元素的迭代函数。
|
|
11
|
+
* @param {Function | string | number | Symbol} [iteratee] 调用每个元素的迭代函数。
|
|
12
12
|
* @returns {*} 最小的值。
|
|
13
13
|
* @example
|
|
14
14
|
*
|
|
@@ -23,5 +23,5 @@ import { IterateeParam } from './internals/types';
|
|
|
23
23
|
* // 迭代函数可以直接写入属性。
|
|
24
24
|
* min(objects, 'n'); // {n: 1};
|
|
25
25
|
*/
|
|
26
|
-
declare
|
|
26
|
+
declare const min: ExtremumFunction;
|
|
27
27
|
export default min;
|
package/types/omitBy.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ObjectPredicate, WithNullable } from './internals/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建一个对象,该对象忽略 `predicate` (断言函数)判断不是真值的属性后,`object` 自身和继承的可枚举属性组成。与 [`pickBy`](#.pickBy) 相反。
|
|
4
4
|
*
|
|
5
|
-
* `predicate`
|
|
5
|
+
* `predicate` 调用时会传入两个参数 `value` `key` 。
|
|
6
6
|
*
|
|
7
7
|
* @static
|
|
8
8
|
* @alias module:Object.omitBy
|
package/types/orderBy.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { CompareOrder } from './internals/compare';
|
|
2
|
-
import { CollectionList, CollectionObject,
|
|
2
|
+
import { ArrayLikeIterator, CollectionList, CollectionObject, Many, ObjectIterator, PropertyName } from './internals/types';
|
|
3
3
|
interface OrderBy {
|
|
4
|
-
<T>(collection: CollectionList<T>, iteratee?: Many<
|
|
5
|
-
<T
|
|
4
|
+
<T extends object>(collection: CollectionList<T>, iteratee?: Many<ArrayLikeIterator<T, any> | keyof T>, orders?: Many<CompareOrder>): T[];
|
|
5
|
+
<T>(collection: CollectionList<T>, iteratee?: Many<ArrayLikeIterator<T, any> | PropertyName>, orders?: Many<CompareOrder>): T[];
|
|
6
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: Many<ObjectIterator<T, any> | keyof T>, orders?: Many<CompareOrder>): V[];
|
|
7
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: Many<PropertyName>, orders?: Many<CompareOrder>): V[];
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* 创建一个元素数组,以迭代函数处理的结果排序。如果没有指定排序,默认为升序排序。
|
|
9
11
|
*
|
|
10
12
|
* `asc` 升序, `desc` 降序,默认执行稳定排序,也就是说相同元素会保持原始排序。
|
|
11
13
|
*
|
|
12
|
-
* `iteratee`
|
|
14
|
+
* `iteratee` 调用时会传入三个参数 `value` `index|key` `collection` 。
|
|
13
15
|
*
|
|
14
16
|
* @function
|
|
15
17
|
* @alias module:Collection.orderBy
|
|
16
18
|
* @since 1.0.0
|
|
17
19
|
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | sort}
|
|
18
20
|
* @param {ArrayLike<any> | Object} collection 一个用来迭代的集合。
|
|
19
|
-
* @param {Function | string | Array} [iteratees] 排序的迭代函数。
|
|
21
|
+
* @param {Function | string | number | Symbol | Array} [iteratees] 排序的迭代函数。
|
|
20
22
|
* @param {'asc' | 'desc' | Array} [orders] 迭代函数的排序顺序。
|
|
21
23
|
* @returns {Array} 排序后的新数组。
|
|
22
24
|
* @example
|
package/types/partition.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { CollectionList, CollectionObject,
|
|
1
|
+
import { ArrayLikeIterator, CollectionList, CollectionObject, ObjectIterator, PropertyName } from './internals/types';
|
|
2
2
|
interface Partition {
|
|
3
|
-
<T>(collection: CollectionList<T>, iteratee?:
|
|
4
|
-
<T
|
|
3
|
+
<T extends object>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, any> | keyof T): [T[], T[]];
|
|
4
|
+
<T>(collection: CollectionList<T>, iteratee?: ArrayLikeIterator<T, any> | PropertyName): [T[], T[]];
|
|
5
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: ObjectIterator<T, any> | keyof T): [V[], V[]];
|
|
6
|
+
<T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: PropertyName): [V[], V[]];
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* 创建一个分成两组的元素数组,第一组包含 `predicate`(断言函数)返回为 [`truthy`](https://developer.mozilla.org/zh-CN/docs/Glossary/Truthy)(真值)的元素,第二组包含 `predicate`(断言函数)返回为 [`falsy`](https://developer.mozilla.org/zh-CN/docs/Glossary/Falsy)(假值)的元素。
|
|
8
10
|
*
|
|
9
|
-
* `predicate`
|
|
11
|
+
* `predicate` 调用时会传入三个参数 `value` `index|key` `collection` 。
|
|
10
12
|
*
|
|
11
13
|
* @static
|
|
12
14
|
* @alias module:Collection.partition
|
|
13
15
|
* @since 1.0.0
|
|
14
16
|
* @param {ArrayLike<any> | Object} collection 一个用来迭代的集合。
|
|
15
|
-
* @param {Function | string} [predicate=identity] 每次迭代调用的断言函数。
|
|
17
|
+
* @param {Function | string | number | Symbol | Array} [predicate=identity] 每次迭代调用的断言函数。
|
|
16
18
|
* @returns {Array} 分组后的数组。
|
|
17
19
|
* @example
|
|
18
20
|
*
|
package/types/pickBy.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ObjectPredicate, WithNullable } from './internals/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建一个对象,该对象的属性从 `object` 中经 `predicate` (断言函数)判断为真值的属性。
|
|
4
4
|
*
|
|
5
|
-
* `predicate`
|
|
5
|
+
* `predicate` 调用时会传入两个参数 `value` `key` 。
|
|
6
6
|
*
|
|
7
7
|
* @static
|
|
8
8
|
* @alias module:Object.pickBy
|
package/types/reduce.d.ts
CHANGED
package/types/reduceRight.d.ts
CHANGED
package/types/times.d.ts
CHANGED
package/types/union.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IterateeParam } from './internals/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建一个按顺序排列的唯一值的数组(并集)。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。与 [`uniq`](#.uniq) 相似。
|
|
4
4
|
*
|
|
5
|
-
* `iteratee`
|
|
5
|
+
* `iteratee` 调用时会传入一个参数 `value` 。
|
|
6
6
|
*
|
|
7
7
|
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
8
8
|
*
|
|
@@ -11,7 +11,7 @@ import { IterateeParam } from './internals/types';
|
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
* @param {Array} array 要检查的数组。
|
|
13
13
|
* @param {Array} [other=[]] 另一个要检查的数组。
|
|
14
|
-
* @param {Function | string} [iteratee] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {Function | string | number | Symbol} [iteratee] 迭代函数,调用每个元素。
|
|
15
15
|
* @param {boolean} [strictCheck=false] 严格比较,区分 `0` `-0`,默认 `false` 。
|
|
16
16
|
* @returns {Array} 新的联合数组。
|
|
17
17
|
* @example
|
package/types/uniq.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IterateeParam } from './internals/types';
|
|
|
2
2
|
/**
|
|
3
3
|
* 创建一个去重后的数组副本。只有第一次出现的元素才会被保留。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
4
4
|
*
|
|
5
|
-
* `iteratee`
|
|
5
|
+
* `iteratee` 调用时会传入一个参数 `value` 。
|
|
6
6
|
*
|
|
7
7
|
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
8
8
|
*
|
|
@@ -10,7 +10,7 @@ import { IterateeParam } from './internals/types';
|
|
|
10
10
|
* @alias module:Array.uniq
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
* @param {Array} array 要检查的数组。
|
|
13
|
-
* @param {Function | string} [iteratee] 迭代函数,调用每个元素。
|
|
13
|
+
* @param {Function | string | number | Symbol} [iteratee] 迭代函数,调用每个元素。
|
|
14
14
|
* @param {boolean} [strictCheck=false] 严格比较,区分 `0` `-0`,默认 `false` 。
|
|
15
15
|
* @returns {Array} 去重后的新数组。
|
|
16
16
|
* @example
|
package/types/xor.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IterateeParam } from './internals/types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 创建一个唯一值的数组(并集-交集),该数组包含两个数组参数中不相同的元素。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
|
|
4
4
|
*
|
|
5
|
-
* `iteratee`
|
|
5
|
+
* `iteratee` 调用时会传入一个参数 `value` 。
|
|
6
6
|
*
|
|
7
7
|
* 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
|
|
8
8
|
*
|
|
@@ -11,7 +11,7 @@ import { IterateeParam } from './internals/types';
|
|
|
11
11
|
* @since 1.0.0
|
|
12
12
|
* @param {Array} array 要检查的数组。
|
|
13
13
|
* @param {Array} [other=[]] 另一个要检查的数组。
|
|
14
|
-
* @param {Function | string} [iteratee={@link https://caijf.github.io/ut2/module-Util.html#.identity | identity}] 迭代函数,调用每个元素。
|
|
14
|
+
* @param {Function | string | number | Symbol} [iteratee={@link https://caijf.github.io/ut2/module-Util.html#.identity | identity}] 迭代函数,调用每个元素。
|
|
15
15
|
* @param {boolean} [strictCheck=false] 严格比较,区分 `0` `-0`,默认 `false` 。
|
|
16
16
|
* @returns {Array} 过滤值后的新数组。
|
|
17
17
|
* @example
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { objectProto } from './native.js';
|
|
2
|
-
|
|
3
|
-
function isPrototype(value) {
|
|
4
|
-
if (typeof value !== 'object') {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
var Ctor = value.constructor;
|
|
8
|
-
var proto = typeof Ctor === 'function' ? Ctor.prototype : objectProto;
|
|
9
|
-
return value === proto;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { isPrototype as default };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import isPrototype from './isPrototype.js';
|
|
2
|
-
import { objectKeys, objectProtoHasOwnProperty } from './native.js';
|
|
3
|
-
|
|
4
|
-
function keys(value) {
|
|
5
|
-
if (!isPrototype(value)) {
|
|
6
|
-
return objectKeys(value);
|
|
7
|
-
}
|
|
8
|
-
var result = [];
|
|
9
|
-
for (var key in Object(value)) {
|
|
10
|
-
if (objectProtoHasOwnProperty.call(value, key) && key !== 'constructor') {
|
|
11
|
-
result.push(key);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { keys as default };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var native = require('./native.js');
|
|
4
|
-
|
|
5
|
-
function isPrototype(value) {
|
|
6
|
-
if (typeof value !== 'object') {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
var Ctor = value.constructor;
|
|
10
|
-
var proto = typeof Ctor === 'function' ? Ctor.prototype : native.objectProto;
|
|
11
|
-
return value === proto;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
module.exports = isPrototype;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var isPrototype = require('./isPrototype.js');
|
|
4
|
-
var native = require('./native.js');
|
|
5
|
-
|
|
6
|
-
function keys(value) {
|
|
7
|
-
if (!isPrototype(value)) {
|
|
8
|
-
return native.objectKeys(value);
|
|
9
|
-
}
|
|
10
|
-
var result = [];
|
|
11
|
-
for (var key in Object(value)) {
|
|
12
|
-
if (native.objectProtoHasOwnProperty.call(value, key) && key !== 'constructor') {
|
|
13
|
-
result.push(key);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = keys;
|