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.
Files changed (67) hide show
  1. package/dist/ut2.js +63 -93
  2. package/dist/ut2.js.map +1 -1
  3. package/dist/ut2.min.js +1 -1
  4. package/dist/ut2.min.js.map +1 -1
  5. package/es/countBy.js +2 -2
  6. package/es/groupBy.js +2 -2
  7. package/es/internals/compare.js +19 -26
  8. package/es/internals/createExtremum.js +2 -2
  9. package/es/internals/createForEach.js +2 -2
  10. package/es/internals/createReduce.js +2 -2
  11. package/es/internals/helpers.js +1 -1
  12. package/es/invert.js +2 -2
  13. package/es/isEmpty.js +2 -2
  14. package/es/keyBy.js +2 -2
  15. package/es/max.js +4 -3
  16. package/es/merge.js +2 -2
  17. package/es/min.js +4 -3
  18. package/es/orderBy.js +2 -2
  19. package/es/partition.js +2 -2
  20. package/es/pick.js +4 -0
  21. package/es/pickBy.js +0 -4
  22. package/lib/countBy.js +2 -2
  23. package/lib/groupBy.js +2 -2
  24. package/lib/internals/compare.js +18 -27
  25. package/lib/internals/createExtremum.js +2 -2
  26. package/lib/internals/createForEach.js +2 -2
  27. package/lib/internals/createReduce.js +2 -2
  28. package/lib/internals/helpers.js +1 -1
  29. package/lib/invert.js +2 -2
  30. package/lib/isEmpty.js +2 -2
  31. package/lib/keyBy.js +2 -2
  32. package/lib/max.js +4 -3
  33. package/lib/merge.js +2 -2
  34. package/lib/min.js +4 -3
  35. package/lib/orderBy.js +2 -2
  36. package/lib/partition.js +2 -2
  37. package/lib/pick.js +4 -0
  38. package/lib/pickBy.js +0 -4
  39. package/package.json +1 -1
  40. package/types/countBy.d.ts +7 -5
  41. package/types/difference.d.ts +2 -2
  42. package/types/groupBy.d.ts +7 -5
  43. package/types/internals/compare.d.ts +0 -2
  44. package/types/internals/createExtremum.d.ts +2 -2
  45. package/types/internals/types.d.ts +9 -2
  46. package/types/intersection.d.ts +3 -3
  47. package/types/invert.d.ts +1 -1
  48. package/types/keyBy.d.ts +7 -5
  49. package/types/max.d.ts +5 -5
  50. package/types/merge.d.ts +3 -3
  51. package/types/min.d.ts +4 -4
  52. package/types/omitBy.d.ts +1 -1
  53. package/types/orderBy.d.ts +7 -5
  54. package/types/partition.d.ts +7 -5
  55. package/types/pickBy.d.ts +1 -1
  56. package/types/reduce.d.ts +1 -1
  57. package/types/reduceRight.d.ts +1 -1
  58. package/types/times.d.ts +1 -1
  59. package/types/union.d.ts +2 -2
  60. package/types/uniq.d.ts +2 -2
  61. package/types/xor.d.ts +3 -3
  62. package/es/internals/isPrototype.js +0 -12
  63. package/es/internals/specialKeys.js +0 -17
  64. package/lib/internals/isPrototype.js +0 -14
  65. package/lib/internals/specialKeys.js +0 -19
  66. package/types/internals/isPrototype.d.ts +0 -9
  67. package/types/internals/specialKeys.d.ts +0 -9
@@ -2,7 +2,7 @@ import { IterateeParam } from './internals/types';
2
2
  /**
3
3
  * 创建一个 `array` 排除 `values` 值的新数组。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
4
4
  *
5
- * `iteratee` 调用时会传入 1 个参数 `value` 。
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
@@ -1,18 +1,20 @@
1
- import { CollectionList, CollectionObject, IterateeParam } from './internals/types';
1
+ import { ArrayLikeIterator, CollectionList, CollectionObject, PropertyName, ObjectIterator } from './internals/types';
2
2
  interface GroupBy {
3
- <T>(collection: CollectionList<T>, iteratee?: IterateeParam<T>): Record<string, T[]>;
4
- <T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: IterateeParam<V>): Record<string, V[]>;
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` 调用时会传入 1 个参数 `value` 。
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,5 +1,3 @@
1
- export declare function compareAsc(value: any, other: any): 0 | 1 | -1;
2
- export declare function compareDesc(value: any, other: any): 0 | 1 | -1;
3
1
  export type CompareOrderData<T> = {
4
2
  criteria: any[];
5
3
  index: number;
@@ -1,3 +1,3 @@
1
- import { IterateeParam } from './types';
2
- declare function createExtremum<T>(array: T[], comparator: (value: any, other: any) => boolean, iteratee?: IterateeParam<T>): T | undefined;
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) | keyof T;
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: string, object: T) => R;
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
+ }
@@ -1,8 +1,8 @@
1
1
  import { IterateeParam } from './internals/types';
2
2
  /**
3
- * 创建唯一值的数组,该数组包含 2 个数组参数都包含的元素(交集)。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
3
+ * 创建唯一值的数组,该数组包含两个数组参数都包含的元素(交集)。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
4
4
  *
5
- * `iteratee` 调用时会传入 1 个参数 `value` 。
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
@@ -1,6 +1,6 @@
1
1
  import { ObjectPredicate, PropertyName, WithNullable } from './internals/types';
2
2
  /**
3
- * 创建一个对象,该对象由 `object` 自身可枚举属性(不包含 `Symbol` 属性)和值反转组成。
3
+ * 创建一个对象,该对象由 `object` 自身可枚举属性(包含 `Symbol` 属性)和值反转组成。
4
4
  *
5
5
  * @static
6
6
  * @alias module:Object.invert
package/types/keyBy.d.ts CHANGED
@@ -1,18 +1,20 @@
1
- import { CollectionList, CollectionObject, IterateeParam } from './internals/types';
1
+ import { ArrayLikeIterator, CollectionList, CollectionObject, ObjectIterator, PropertyName } from './internals/types';
2
2
  interface KeyBy {
3
- <T>(collection: CollectionList<T>, iteratee?: IterateeParam<T>): Record<string, T>;
4
- <T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: IterateeParam<V>): Record<string, V>;
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` 调用时会传入 1 个参数 `value` 。
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 { IterateeParam } from './internals/types';
1
+ import { ExtremumFunction } from './internals/types';
2
2
  /**
3
3
  * 调用 `array` 中的每一个元素,来生成其值排序的标准,返回最大的值。
4
4
  *
5
- * `iteratee` 调用时会传入 1 个参数 `value`。
5
+ * `iteratee` 调用时会传入三个参数 `value` `index` `array` 。
6
6
  *
7
- * @static
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 function max<T>(array: T[], iteratee?: IterateeParam<T>): T | undefined;
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` 来源对象自身和继承的可枚举属性(不包含 `Symbol` 属性)到 `object` 目标对象。
4
+ * 递归合并 `source` 来源对象自身的可枚举属性(包含 `Symbol` 属性)到 `object` 目标对象。
5
5
  *
6
6
  * 如果目标值存在,被解析为 `undefined` 的 `source` 来源对象属性将被跳过。数组和普通对象会递归合并,其他对象和值会被直接分配覆盖。
7
7
  *
8
- * 如果你需要合并 `Symbol` 属性,第四个参数传入 {@link https://caijf.github.io/ut2/module-Object.html#.allKeysIn | allKeysIn} 方法, `merge(object, source, undefined, allKeysIn)` 。
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=keysIn] 自定义获取对象键方法。
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 { IterateeParam } from './internals/types';
1
+ import { ExtremumFunction } from './internals/types';
2
2
  /**
3
3
  * 调用 `array` 中的每一个元素,来生成其值排序的标准,返回最小的值。
4
4
  *
5
- * `iteratee` 调用时会传入 1 个参数 `value`。
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 function min<T>(array: T[], iteratee?: IterateeParam<T>): T | undefined;
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` 调用时会传入 2 个参数 `value` `key` 。
5
+ * `predicate` 调用时会传入两个参数 `value` `key` 。
6
6
  *
7
7
  * @static
8
8
  * @alias module:Object.omitBy
@@ -1,22 +1,24 @@
1
1
  import { CompareOrder } from './internals/compare';
2
- import { CollectionList, CollectionObject, IterateeParam, Many } from './internals/types';
2
+ import { ArrayLikeIterator, CollectionList, CollectionObject, Many, ObjectIterator, PropertyName } from './internals/types';
3
3
  interface OrderBy {
4
- <T>(collection: CollectionList<T>, iteratee?: Many<IterateeParam<T>>, orders?: Many<CompareOrder>): T[];
5
- <T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: Many<IterateeParam<V>>, orders?: Many<CompareOrder>): V[];
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` 调用时会传入 1 个参数 `value` 。
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
@@ -1,18 +1,20 @@
1
- import { CollectionList, CollectionObject, IterateeParam } from './internals/types';
1
+ import { ArrayLikeIterator, CollectionList, CollectionObject, ObjectIterator, PropertyName } from './internals/types';
2
2
  interface Partition {
3
- <T>(collection: CollectionList<T>, iteratee?: IterateeParam<T>): [T[], T[]];
4
- <T extends object, V extends T[keyof T]>(collection: CollectionObject<T>, iteratee?: IterateeParam<V>): [V[], V[]];
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` 调用时会传入 1 个参数 `value`。
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` 调用时会传入 2 个参数 `value` `key` 。
5
+ * `predicate` 调用时会传入两个参数 `value` `key` 。
6
6
  *
7
7
  * @static
8
8
  * @alias module:Object.pickBy
package/types/reduce.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * 如果没有提供第三个参数值,则集合中的第一个元素将用作初始值。
5
5
  *
6
- * `iteratee` 调用时会传入四个参数 `accumulator`、`value`、`index|key`、`collection` 。
6
+ * `iteratee` 调用时会传入四个参数 `accumulator` `value` `index|key` `collection` 。
7
7
  *
8
8
  * @function
9
9
  * @alias module:Collection.reduce
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * 如果没有提供第三个参数值,则集合中的第一个元素将用作初始值。
5
5
  *
6
- * `iteratee` 调用时会传入四个参数 `accumulator`、`value`、`index|key`、`collection` 。
6
+ * `iteratee` 调用时会传入四个参数 `accumulator` `value` `index|key` `collection` 。
7
7
  *
8
8
  * @function
9
9
  * @alias module:Collection.reduceRight
package/types/times.d.ts CHANGED
@@ -5,7 +5,7 @@ interface Times {
5
5
  /**
6
6
  * 调用 `iteratee` `n` 次,每次调用返回的结果存入到数组中。
7
7
  *
8
- * `iteratee` 调用传入 1 个参数 `index` 。
8
+ * `iteratee` 调用传入一个参数 `index` 。
9
9
  *
10
10
  * @function
11
11
  * @alias module:Util.times
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` 调用时会传入 1 个参数 `value` 。
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` 调用时会传入 1 个参数 `value` 。
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
- * 创建一个唯一值的数组(并集-交集),该数组包含 2 个数组参数中不相同的元素。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
3
+ * 创建一个唯一值的数组(并集-交集),该数组包含两个数组参数中不相同的元素。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
4
4
  *
5
- * `iteratee` 调用时会传入 1 个参数 `value` 。
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;
@@ -1,9 +0,0 @@
1
- /**
2
- * 检测值是否为原型对象。
3
- *
4
- * @private
5
- * @param {*} value 要检查的值。
6
- * @returns {boolean} 是否为原型对象。
7
- */
8
- declare function isPrototype(value: any): boolean;
9
- export default isPrototype;
@@ -1,9 +0,0 @@
1
- /**
2
- * 获取对象的键,忽略 `constructor` 。
3
- *
4
- * @private
5
- * @param value 对象
6
- * @returns 可枚举的键
7
- */
8
- declare function keys(value: object): string[];
9
- export default keys;