ut2 1.9.1 → 1.9.3

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 (125) hide show
  1. package/README.md +2 -2
  2. package/dist/ut2.js +13 -21
  3. package/dist/ut2.js.map +1 -1
  4. package/dist/ut2.min.js +1 -1
  5. package/dist/ut2.min.js.map +1 -1
  6. package/es/clamp.js +1 -2
  7. package/es/conforms.js +1 -2
  8. package/es/conformsTo.js +1 -2
  9. package/es/countBy.js +1 -2
  10. package/es/curry.js +1 -2
  11. package/es/defaultTo.js +1 -2
  12. package/es/escapeRegExp.js +1 -3
  13. package/es/every.js +1 -2
  14. package/es/filter.js +1 -2
  15. package/es/find.js +1 -2
  16. package/es/forEach.js +1 -2
  17. package/es/forEachRight.js +1 -2
  18. package/es/fromPairs.js +1 -2
  19. package/es/groupBy.js +1 -2
  20. package/es/gt.js +1 -2
  21. package/es/gte.js +1 -2
  22. package/es/internals/helpers.js +1 -1
  23. package/es/internals/native.js +1 -2
  24. package/es/internals/root.js +1 -2
  25. package/es/isObject.js +3 -2
  26. package/es/isPlainObject.js +1 -1
  27. package/es/isTypedArray.js +2 -3
  28. package/es/keyBy.js +1 -2
  29. package/es/lowerFirst.js +1 -2
  30. package/es/lt.js +1 -2
  31. package/es/lte.js +1 -2
  32. package/es/map.js +1 -2
  33. package/es/max.js +1 -2
  34. package/es/min.js +1 -2
  35. package/es/omit.js +1 -2
  36. package/es/orderBy.js +1 -2
  37. package/es/partial.js +1 -2
  38. package/es/partition.js +1 -2
  39. package/es/pick.js +1 -2
  40. package/es/random.js +1 -1
  41. package/es/randomInt.js +1 -1
  42. package/es/range.js +1 -2
  43. package/es/reduce.js +1 -2
  44. package/es/reduceRight.js +1 -2
  45. package/es/some.js +1 -2
  46. package/es/times.js +1 -2
  47. package/es/toNumber.js +1 -5
  48. package/es/uniqueId.js +4 -4
  49. package/es/upperFirst.js +1 -2
  50. package/lib/clamp.js +1 -2
  51. package/lib/conforms.js +1 -2
  52. package/lib/conformsTo.js +1 -2
  53. package/lib/countBy.js +1 -2
  54. package/lib/curry.js +1 -2
  55. package/lib/defaultTo.js +1 -2
  56. package/lib/escapeRegExp.js +1 -3
  57. package/lib/every.js +1 -2
  58. package/lib/filter.js +1 -2
  59. package/lib/find.js +1 -2
  60. package/lib/forEach.js +1 -2
  61. package/lib/forEachRight.js +1 -2
  62. package/lib/fromPairs.js +1 -2
  63. package/lib/groupBy.js +1 -2
  64. package/lib/gt.js +1 -2
  65. package/lib/gte.js +1 -2
  66. package/lib/index.js +4 -16
  67. package/lib/internals/comparator.js +8 -4
  68. package/lib/internals/helpers.js +10 -5
  69. package/lib/internals/native.js +104 -53
  70. package/lib/internals/nodeUtil.js +13 -6
  71. package/lib/internals/root.js +1 -2
  72. package/lib/isObject.js +3 -2
  73. package/lib/isTypedArray.js +2 -3
  74. package/lib/keyBy.js +1 -2
  75. package/lib/lowerFirst.js +1 -2
  76. package/lib/lt.js +1 -2
  77. package/lib/lte.js +1 -2
  78. package/lib/map.js +1 -2
  79. package/lib/max.js +1 -2
  80. package/lib/min.js +1 -2
  81. package/lib/omit.js +1 -2
  82. package/lib/orderBy.js +1 -2
  83. package/lib/partial.js +1 -2
  84. package/lib/partition.js +1 -2
  85. package/lib/pick.js +1 -2
  86. package/lib/range.js +1 -2
  87. package/lib/reduce.js +1 -2
  88. package/lib/reduceRight.js +1 -2
  89. package/lib/some.js +1 -2
  90. package/lib/times.js +1 -2
  91. package/lib/toNumber.js +1 -5
  92. package/lib/uniqueId.js +4 -4
  93. package/lib/upperFirst.js +1 -2
  94. package/package.json +19 -19
  95. package/types/camelCase.d.ts +1 -1
  96. package/types/ceil.d.ts +1 -1
  97. package/types/compact.d.ts +1 -1
  98. package/types/delay.d.ts +0 -1
  99. package/types/eq.d.ts +1 -1
  100. package/types/escape.d.ts +1 -1
  101. package/types/escapeRegExp.d.ts +1 -1
  102. package/types/floor.d.ts +1 -1
  103. package/types/internals/native.d.ts +4 -5
  104. package/types/isArrayLikeObject.d.ts +1 -1
  105. package/types/isBlob.d.ts +2 -2
  106. package/types/isBuffer.d.ts +0 -1
  107. package/types/isElement.d.ts +1 -1
  108. package/types/isLength.d.ts +1 -1
  109. package/types/isObject.d.ts +3 -2
  110. package/types/isObjectLike.d.ts +1 -1
  111. package/types/isPlainObject.d.ts +1 -1
  112. package/types/isPromiseLike.d.ts +6 -1
  113. package/types/isTypedArray.d.ts +1 -1
  114. package/types/kebabCase.d.ts +1 -1
  115. package/types/merge.d.ts +1 -1
  116. package/types/orderBy.d.ts +1 -1
  117. package/types/pascalCase.d.ts +1 -1
  118. package/types/random.d.ts +10 -6
  119. package/types/randomInt.d.ts +9 -5
  120. package/types/round.d.ts +1 -1
  121. package/types/snakeCase.d.ts +1 -1
  122. package/types/toLength.d.ts +1 -1
  123. package/types/uniqueId.d.ts +3 -3
  124. package/types/words.d.ts +1 -1
  125. package/types/xor.d.ts +1 -1
@@ -15,7 +15,7 @@ export declare const functionProto: Function;
15
15
  export declare const functionProtoToString: () => string;
16
16
  export declare const symbolProto: Symbol | undefined;
17
17
  export declare const arrayProto: any[];
18
- export declare const arrayProtoSlice: (start?: number | undefined, end?: number | undefined) => any[];
18
+ export declare const arrayProtoSlice: (start?: number, end?: number) => any[];
19
19
  export declare const mathMin: (...values: number[]) => number;
20
20
  export declare const mathMax: (...values: number[]) => number;
21
21
  export declare const mathRandom: () => number;
@@ -33,7 +33,7 @@ export declare const selfExisted: false | (Window & typeof globalThis);
33
33
  *
34
34
  * @static
35
35
  * @since 1.0.0
36
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER | MAX_SAFE_INTEGER}
36
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER MAX_SAFE_INTEGER}
37
37
  */
38
38
  export declare const MAX_SAFE_INTEGER: number;
39
39
  /**
@@ -41,7 +41,7 @@ export declare const MAX_SAFE_INTEGER: number;
41
41
  *
42
42
  * @static
43
43
  * @since 1.0.0
44
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER | MIN_SAFE_INTEGER}
44
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER MIN_SAFE_INTEGER}
45
45
  */
46
46
  export declare const MIN_SAFE_INTEGER: number;
47
47
  /**
@@ -49,7 +49,7 @@ export declare const MIN_SAFE_INTEGER: number;
49
49
  *
50
50
  * @static
51
51
  * @since 1.0.0
52
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/length | length}
52
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/length length}
53
53
  */
54
54
  export declare const MAX_ARRAY_LENGTH = 4294967295;
55
55
  export declare const bigIntTag = "[object BigInt]";
@@ -63,7 +63,6 @@ export declare const errorTag = "[object Error]";
63
63
  export declare const arrayBufferTag = "[object ArrayBuffer]";
64
64
  export declare const argumentsTag = "[object Arguments]";
65
65
  export declare const arrayTag = "[object Array]";
66
- export declare const typedArrayTags: string[];
67
66
  export declare const functionTags: string[];
68
67
  export declare const weakSetTag = "[object WeakSet]";
69
68
  export declare const blobTag = "[object Blob]";
@@ -17,5 +17,5 @@
17
17
  * isArrayLikeObject(()=>{}); // false
18
18
  *
19
19
  */
20
- declare function isArrayLikeObject(value: any): boolean;
20
+ declare function isArrayLikeObject(value: any): value is ArrayLike<any>;
21
21
  export default isArrayLikeObject;
package/types/isBlob.d.ts CHANGED
@@ -6,8 +6,8 @@
6
6
  * @static
7
7
  * @alias module:Language.isBlob
8
8
  * @since 1.0.0
9
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/Blob | Blob}
10
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/File | File}
9
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/Blob Blob}
10
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/File File}
11
11
  * @param {*} value 要检查的值。
12
12
  * @returns {boolean} 如果值为 `Blob` 对象,返回 `true` ,否则返回 `false` 。
13
13
  * @example
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * 检查值是否为 `buffer` 。
4
3
  *
@@ -13,5 +13,5 @@
13
13
  * isElement('<body>'); // false
14
14
  *
15
15
  */
16
- declare function isElement(value: any): boolean;
16
+ declare function isElement(value: any): value is Element;
17
17
  export default isElement;
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Language.isLength
6
6
  * @since 1.0.0
7
- * @see {@link https://tc39.es/ecma262/#sec-tolength | ToLength}
7
+ * @see {@link https://tc39.es/ecma262/#sec-tolength ToLength}
8
8
  * @param {*} value 要检查的值。
9
9
  * @returns {boolean} 如果值为有效的类数组长度,返回 `true` ,否则返回 `false` 。
10
10
  * @example
@@ -1,10 +1,11 @@
1
+ import { FunctionAny } from './internals/types';
1
2
  /**
2
3
  * 检查值是否为对象。(例如,数组、函数、对象、正则表达式、new Number(0) 和 new String(''))。
3
4
  *
4
5
  * @static
5
6
  * @alias module:Language.isObject
6
7
  * @since 1.0.0
7
- * @see {@link https://tc39.es/ecma262/#sec-ecmascript-language-types | language type}
8
+ * @see {@link https://tc39.es/ecma262/#sec-ecmascript-language-types language type}
8
9
  * @param {*} value 要检查的值。
9
10
  * @returns {boolean} 如果值为对象,返回 `true` ,否则返回 `false` 。
10
11
  * @example
@@ -18,5 +19,5 @@
18
19
  * isObject(null); // false
19
20
  *
20
21
  */
21
- declare function isObject(value: any): boolean;
22
+ declare function isObject(value: any): value is object | FunctionAny;
22
23
  export default isObject;
@@ -19,5 +19,5 @@
19
19
  * isObjectLike(null); // false
20
20
  *
21
21
  */
22
- declare function isObjectLike(value: any): boolean;
22
+ declare function isObjectLike(value: any): value is object;
23
23
  export default isObjectLike;
@@ -21,5 +21,5 @@
21
21
  * isPlainObject(Object.create(null)); // true
22
22
  *
23
23
  */
24
- declare function isPlainObject(value: any): boolean;
24
+ declare function isPlainObject(value: any): value is object;
25
25
  export default isPlainObject;
@@ -1,3 +1,8 @@
1
+ import { FunctionAny } from './internals/types';
2
+ type PromiseLikeObject = {
3
+ then: FunctionAny;
4
+ [x: string]: any;
5
+ };
1
6
  /**
2
7
  * 检测值是否类似 `Promise` 对象。
3
8
  *
@@ -17,5 +22,5 @@
17
22
  * isPromiseLike([]); // false
18
23
  *
19
24
  */
20
- declare function isPromiseLike(value: any): boolean;
25
+ declare function isPromiseLike(value: any): value is Promise<any> | PromiseLikeObject;
21
26
  export default isPromiseLike;
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Language.isTypedArray
6
6
  * @since 1.0.0
7
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Typed_arrays | Typed_arrays}
7
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Typed_arrays Typed_arrays}
8
8
  * @param {*} value 要检查的值。
9
9
  * @returns {boolean} 如果值为类型化数组,返回 `true` ,否则返回 `false` 。
10
10
  * @example
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:String.kebabCase
6
6
  * @since 1.0.0
7
- * @see {@link https://en.wikipedia.org/wiki/Letter_case#Special_case_styles | kebab case}
7
+ * @see {@link https://en.wikipedia.org/wiki/Letter_case#Special_case_styles kebab case}
8
8
  * @param {string} string 要转换的字符串。
9
9
  * @param {RegExp | string} [pattern] 拆分词组的匹配模式。
10
10
  * @returns {string} 转换后的字符串。
package/types/merge.d.ts CHANGED
@@ -5,7 +5,7 @@ type Customizer = (objValue: any, srcValue: any, key: string | symbol, object: a
5
5
  *
6
6
  * 如果目标值存在,被解析为 `undefined` 的 `source` 来源对象属性将被跳过。数组和普通对象会递归合并,其他对象和值会被直接分配覆盖。
7
7
  *
8
- * 如果你需要合并继承的属性,第四个参数传入 {@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
@@ -16,7 +16,7 @@ interface OrderBy {
16
16
  * @function
17
17
  * @alias module:Collection.orderBy
18
18
  * @since 1.0.0
19
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/sort | sort}
19
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/sort sort}
20
20
  * @param {ArrayLike<any> | Object} collection 一个用来迭代的集合。
21
21
  * @param {Function | string | number | Symbol | Array} [iteratees] 排序的迭代函数。
22
22
  * @param {'asc' | 'desc' | Array} [orders] 迭代函数的排序顺序。
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:String.pascalCase
6
6
  * @since 1.8.0
7
- * @see {@link https://en.wikipedia.org/wiki/Camel_case | Camel_case}
7
+ * @see {@link https://en.wikipedia.org/wiki/Camel_case Camel_case}
8
8
  * @param {string} string 要转换的字符串。
9
9
  * @param {RegExp | string} [pattern] 拆分词组的匹配模式。
10
10
  * @returns {string} 帕斯卡写法的字符串。
package/types/random.d.ts CHANGED
@@ -6,18 +6,22 @@
6
6
  * @static
7
7
  * @alias module:Number.random
8
8
  * @since 1.0.0
9
- * @param {number} [lower=0] 下限。
10
- * @param {number} [upper=1] 上限。
9
+ * @param {number} [lower=0] 下限,默认 0 。
10
+ * @param {number} [upper=1] 上限,默认 1 。
11
11
  * @returns {number} 随机浮点数。
12
12
  * @example
13
13
  *
14
- * random(); // 0 到 1 之间的浮点数
14
+ * // 0 到 1 之间的浮点数
15
+ * random(); // 0.40340470210512236
15
16
  *
16
- * random(2, 4); // 2 到 4 之间的浮点数
17
+ * // 2 到 4 之间的浮点数
18
+ * random(2, 4); // 3.0039717466399787
17
19
  *
18
- * random(4, 2); // 2 到 4 之间的浮点数
20
+ * // 2 到 4 之间的浮点数
21
+ * random(4, 2); // 2.388398370184757
19
22
  *
20
- * random(1.2, 2.4); // 1.2 到 2.4 之间的浮点数
23
+ * // 1.2 到 2.4 之间的浮点数
24
+ * random(1.2, 2.4); // 1.6319041677720918
21
25
  *
22
26
  */
23
27
  declare function random(lower?: number, upper?: number): number;
@@ -6,17 +6,21 @@
6
6
  * @static
7
7
  * @alias module:Number.randomInt
8
8
  * @since 1.0.0
9
- * @param {number} [lower=0] 下限。
10
- * @param {number} [upper=1] 上限。
9
+ * @param {number} [lower=0] 下限,默认 0 。
10
+ * @param {number} [upper=1] 上限,默认 1 。
11
11
  * @returns {number} 随机整数。
12
12
  * @example
13
13
  *
14
- * randomInt(); // 0 到 1 之间的整数
14
+ * // 0 到 1 之间的整数
15
+ * randomInt(); // 1
15
16
  *
16
- * randomInt(2, 4); // 2 到 4 之间的整数
17
+ * // 2 到 4 之间的整数
18
+ * randomInt(2, 4); // 4
17
19
  *
18
- * randomInt(4, 2); // 2 到 4 之间的整数
20
+ * // 2 到 4 之间的整数
21
+ * randomInt(4, 2); // 3
19
22
  *
23
+ * // 区间只有一个整数
20
24
  * randomInt(1.2, 2.4); // 2
21
25
  *
22
26
  */
package/types/round.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * @static
7
7
  * @alias module:Math.round
8
8
  * @since 1.0.0
9
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Math/round#小数舍入 | 小数舍入}
9
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Math/round#小数舍入 小数舍入}
10
10
  * @param {number} number 要四舍五入的值。
11
11
  * @param {number} [precision=0] 四舍五入的精度。
12
12
  * @returns {number} 四舍五入的值。
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:String.snakeCase
6
6
  * @since 1.0.0
7
- * @see {@link https://en.wikipedia.org/wiki/Snake_case | snake case}
7
+ * @see {@link https://en.wikipedia.org/wiki/Snake_case snake case}
8
8
  * @param {string} string 要转换的字符串。
9
9
  * @param {RegExp | string} [pattern] 拆分词组的匹配模式。
10
10
  * @returns {string} 转换后的字符串。
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Util.toLength
6
6
  * @since 1.0.0
7
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/length | length}
7
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/length length}
8
8
  * @param {*} value 要转换的值。
9
9
  * @returns {number} 转换后的整数。
10
10
  * @example
@@ -4,13 +4,13 @@
4
4
  * @static
5
5
  * @alias module:Util.uniqueId
6
6
  * @since 1.0.0
7
- * @param {string} [prefix] 要添加到ID前缀的值。
7
+ * @param {string} [prefix] 要添加到ID前缀的值,默认 `"_" + 2个随机生成的字符`。
8
8
  * @returns {string} 唯一ID。
9
9
  * @example
10
10
  *
11
- * uniqueId(); // '1'
11
+ * uniqueId(); // '_vn1'
12
12
  *
13
- * uniqueId(); // '2'
13
+ * uniqueId(); // '_vn2'
14
14
  *
15
15
  * uniqueId('abc_'); // 'abc_3'
16
16
  *
package/types/words.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:String.words
6
6
  * @since 1.0.0
7
- * @see {@link https://zh.wikipedia.org/wiki/ASCII | ASCII}
7
+ * @see {@link https://zh.wikipedia.org/wiki/ASCII ASCII}
8
8
  * @param {string} string 要拆分的字符串。
9
9
  * @param {RegExp | string} [pattern=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g] 匹配模式。
10
10
  * @returns {string[]} 拆分后的数组。
package/types/xor.d.ts CHANGED
@@ -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 | number | Symbol} [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