ut2 1.5.1 → 1.5.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 (98) hide show
  1. package/README.md +1 -1
  2. package/dist/ut2.js +103 -125
  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/gt.js +3 -4
  7. package/es/gte.js +3 -4
  8. package/es/internals/createExtremum.js +19 -12
  9. package/es/internals/createIteratee.js +2 -1
  10. package/es/internals/getTag.js +2 -23
  11. package/es/internals/getTagWithBugfix.js +6 -6
  12. package/es/internals/helpers.js +6 -4
  13. package/es/internals/native.js +4 -3
  14. package/es/internals/root.js +6 -4
  15. package/es/isArguments.js +3 -2
  16. package/es/isArrayBuffer.js +3 -2
  17. package/es/isBlob.js +3 -2
  18. package/es/isBoolean.js +3 -2
  19. package/es/isDate.js +3 -2
  20. package/es/isEmpty.js +4 -3
  21. package/es/isEqual.js +1 -1
  22. package/es/isError.js +3 -2
  23. package/es/isFunction.js +3 -2
  24. package/es/isMatch.js +3 -2
  25. package/es/isNumber.js +3 -2
  26. package/es/isObject.js +1 -1
  27. package/es/isObjectLike.js +1 -1
  28. package/es/isRegExp.js +3 -2
  29. package/es/isString.js +3 -2
  30. package/es/isSymbol.js +3 -2
  31. package/es/isTypedArray.js +3 -2
  32. package/es/isWeakSet.js +3 -2
  33. package/es/lowerFirst.js +3 -4
  34. package/es/lt.js +3 -4
  35. package/es/lte.js +3 -4
  36. package/es/max.js +2 -4
  37. package/es/min.js +2 -4
  38. package/es/nth.js +2 -6
  39. package/es/omit.js +1 -1
  40. package/es/omitBy.js +2 -1
  41. package/es/pickBy.js +2 -1
  42. package/es/toString.js +1 -1
  43. package/es/uniq.js +13 -5
  44. package/es/upperFirst.js +3 -4
  45. package/lib/gt.js +3 -4
  46. package/lib/gte.js +3 -4
  47. package/lib/internals/createExtremum.js +19 -12
  48. package/lib/internals/createIteratee.js +2 -1
  49. package/lib/internals/getTag.js +1 -22
  50. package/lib/internals/getTagWithBugfix.js +5 -5
  51. package/lib/internals/helpers.js +4 -2
  52. package/lib/internals/native.js +3 -2
  53. package/lib/internals/root.js +6 -4
  54. package/lib/isArguments.js +2 -1
  55. package/lib/isArrayBuffer.js +2 -1
  56. package/lib/isBlob.js +2 -1
  57. package/lib/isBoolean.js +2 -1
  58. package/lib/isDate.js +2 -1
  59. package/lib/isEmpty.js +4 -3
  60. package/lib/isEqual.js +1 -1
  61. package/lib/isError.js +2 -1
  62. package/lib/isFunction.js +2 -1
  63. package/lib/isMatch.js +2 -1
  64. package/lib/isNumber.js +2 -1
  65. package/lib/isObject.js +1 -1
  66. package/lib/isObjectLike.js +1 -1
  67. package/lib/isRegExp.js +2 -1
  68. package/lib/isString.js +2 -1
  69. package/lib/isSymbol.js +2 -1
  70. package/lib/isTypedArray.js +2 -1
  71. package/lib/isWeakSet.js +2 -1
  72. package/lib/lowerFirst.js +3 -4
  73. package/lib/lt.js +3 -4
  74. package/lib/lte.js +3 -4
  75. package/lib/max.js +2 -4
  76. package/lib/min.js +2 -4
  77. package/lib/nth.js +2 -6
  78. package/lib/omit.js +1 -1
  79. package/lib/omitBy.js +2 -1
  80. package/lib/pickBy.js +2 -1
  81. package/lib/toString.js +1 -1
  82. package/lib/uniq.js +13 -5
  83. package/lib/upperFirst.js +3 -4
  84. package/package.json +7 -2
  85. package/types/gt.d.ts +2 -2
  86. package/types/gte.d.ts +2 -2
  87. package/types/identity.d.ts +1 -1
  88. package/types/internals/createExtremum.d.ts +1 -1
  89. package/types/internals/createIteratee.d.ts +2 -1
  90. package/types/internals/decimalAdjust.d.ts +1 -1
  91. package/types/internals/getTag.d.ts +1 -1
  92. package/types/internals/helpers.d.ts +1 -0
  93. package/types/internals/native.d.ts +3 -2
  94. package/types/internals/root.d.ts +1 -1
  95. package/types/lowerFirst.d.ts +2 -2
  96. package/types/lt.d.ts +2 -2
  97. package/types/lte.d.ts +2 -2
  98. package/types/upperFirst.d.ts +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ut2",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "author": "caijf",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -12,6 +12,7 @@
12
12
  "test": "jest",
13
13
  "test:coverage": "jest --coverage",
14
14
  "test:coverage:local": "cross-env COVERAGE_LOCAL=1 jest --coverage --detectOpenHandles && open ./coverage/lcov-report/index.html",
15
+ "benchmark": "node benchmark/node.js",
15
16
  "build": "npm run build:module && npm run build:umd && npm run build:types",
16
17
  "build:module": "rm -rf es && rm -rf lib && rollup -c rollup.module.config.mjs",
17
18
  "build:umd": "rm -rf dist && rollup -c rollup.umd.config.mjs",
@@ -71,20 +72,24 @@
71
72
  "@types/node": "^20.6.2",
72
73
  "@typescript-eslint/eslint-plugin": "^5.62.0",
73
74
  "@typescript-eslint/parser": "^5.62.0",
75
+ "benchmark": "^2.1.4",
74
76
  "cross-env": "^7.0.3",
75
77
  "cz-conventional-changelog": "^3.3.0",
78
+ "dayjs": "^1.11.10",
76
79
  "docdash": "^2.0.2",
77
80
  "eslint": "^8.48.0",
81
+ "husky": "^8.0.0",
78
82
  "jest": "^29.6.4",
79
83
  "jest-environment-jsdom": "^29.6.4",
80
84
  "jsdoc": "^4.0.2",
81
85
  "lint-staged": "^13.3.0",
86
+ "lodash": "^4.17.21",
82
87
  "prettier": "^2.8.8",
83
88
  "rollup": "^3.28.1",
84
89
  "ts-jest": "^29.1.1",
85
90
  "tslib": "^2.6.2",
86
91
  "typescript": "^5.2.2",
87
- "husky": "^8.0.0"
92
+ "underscore": "^1.13.6"
88
93
  },
89
94
  "engines": {
90
95
  "node": ">=10"
package/types/gt.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 检查 `value` 是否大于 `other` 。
3
3
  *
4
- * @static
4
+ * @function
5
5
  * @alias module:Util.gt
6
6
  * @since 1.0.0
7
7
  * @param {*} value 要比较的值。
@@ -16,5 +16,5 @@
16
16
  * gt(3, 1); // true
17
17
  *
18
18
  */
19
- declare function gt(value: any, other: any): boolean;
19
+ declare const gt: (value: any, other: any) => boolean;
20
20
  export default gt;
package/types/gte.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 检查 `value` 是否大于或等于 `other` 。
3
3
  *
4
- * @static
4
+ * @function
5
5
  * @alias module:Util.gte
6
6
  * @since 1.0.0
7
7
  * @param {*} value 要比较的值。
@@ -16,5 +16,5 @@
16
16
  * gte(3, 1); // true
17
17
  *
18
18
  */
19
- declare function gte(value: any, other: any): boolean;
19
+ declare const gte: (value: any, other: any) => boolean;
20
20
  export default gte;
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * const obj = { a: 1, b: 2 };
12
12
  *
13
- * console.log(identity(obj, 1) === obj); // true
13
+ * console.log(identity(obj) === obj); // true
14
14
  *
15
15
  */
16
16
  declare function identity<T>(value?: T): T;
@@ -1,2 +1,2 @@
1
- declare function createExtremum<T, F extends (item: T) => any, K extends keyof T>(array: T[], iteratee: F | K, comparator: (value: any, other: any) => boolean): T | undefined;
1
+ declare function createExtremum<T, F extends (item: T) => any, K extends keyof T>(array: T[], comparator: (value: any, other: any) => boolean, iteratee?: F | K): T | undefined;
2
2
  export default createExtremum;
@@ -1,3 +1,4 @@
1
+ import identity from '../identity';
1
2
  /**
2
3
  * 创建迭代函数。
3
4
  *
@@ -5,5 +6,5 @@
5
6
  * @param {Function} iteratee 迭代函数或对象属性。
6
7
  * @returns {Function} 如果参数为函数,返回该函数,否则包装一个返回对象属性的函数。
7
8
  */
8
- declare function createIteratee<T, F extends (value: T) => any, K extends keyof T>(iteratee?: F | K): F | ((value: any) => any);
9
+ declare function createIteratee<T, F extends (value: T) => any, K extends keyof T>(iteratee?: F | K): typeof identity | F;
9
10
  export default createIteratee;
@@ -4,7 +4,7 @@
4
4
  * @private
5
5
  * @param {'floor' | 'ceil' | 'round'} type 调整的类型。
6
6
  * @param {number} value 要调整的数字。
7
- * @param {number} precision 指数(调整基数的10个对数)。
7
+ * @param {number} [precision=0] 指数(调整基数的10个对数)。
8
8
  * @returns {number} 调整后的数字。
9
9
  */
10
10
  declare function decimalAdjust(type: 'floor' | 'ceil' | 'round', value: number, precision?: number): number;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 获取值的 `Object.prototype.toString` ,忽略 `Symbol.toStringTag` 影响。
2
+ * 获取值的 `Object.prototype.toString`
3
3
  *
4
4
  * @private
5
5
  * @param value 要查询的值
@@ -8,3 +8,4 @@ export declare const VERSION: string;
8
8
  export declare const supportedArgumentsType: boolean;
9
9
  export declare const FUNC_ERROR_TEXT = "Expected a function";
10
10
  export declare function toSource(func: any): string;
11
+ export declare const stubFlase: () => boolean;
@@ -11,10 +11,8 @@ export declare const objectKeys: {
11
11
  export declare const functionProto: Function;
12
12
  export declare const functionProtoToString: () => string;
13
13
  export declare const symbolProto: Symbol | undefined;
14
- export declare const symbolToStringTag: typeof Symbol.toStringTag | undefined;
15
14
  export declare const arrayProto: any[];
16
15
  export declare const arrayProtoSlice: (start?: number | undefined, end?: number | undefined) => any[];
17
- export declare const arrayProtoAt: (index: number) => any;
18
16
  export declare const mathMin: (...values: number[]) => number;
19
17
  export declare const mathMax: (...values: number[]) => number;
20
18
  export declare const mathRandom: () => number;
@@ -24,6 +22,9 @@ export declare const mathAbs: (x: number) => number;
24
22
  export declare const numberIsFinite: (number: unknown) => boolean;
25
23
  export declare const numberIsInteger: (number: unknown) => boolean;
26
24
  export declare const numberIsSafeInteger: (number: unknown) => boolean;
25
+ export declare const globalThisExisted: false | typeof globalThis;
26
+ export declare const globalExisted: false | typeof globalThis;
27
+ export declare const selfExisted: false | (Window & typeof globalThis);
27
28
  /**
28
29
  * 最大安全整数。
29
30
  *
@@ -1,2 +1,2 @@
1
- declare const root: any;
1
+ declare const root: typeof globalThis;
2
2
  export default root;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 转换字符串第一个字符为小写。
3
3
  *
4
- * @static
4
+ * @function
5
5
  * @alias module:String.lowerFirst
6
6
  * @since 1.0.0
7
7
  * @param {string} string 要转换的字符串。
@@ -13,5 +13,5 @@
13
13
  * lowerFirst('BAR'); // 'bAR'
14
14
  *
15
15
  */
16
- declare function lowerFirst(string: string): string;
16
+ declare const lowerFirst: (string: string) => string;
17
17
  export default lowerFirst;
package/types/lt.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 检查 `value` 是否小于 `other` 。
3
3
  *
4
- * @static
4
+ * @function
5
5
  * @alias module:Util.lt
6
6
  * @since 1.0.0
7
7
  * @param {*} value 要比较的值。
@@ -16,5 +16,5 @@
16
16
  * lt(3, 1); // false
17
17
  *
18
18
  */
19
- declare function lt(value: any, other: any): boolean;
19
+ declare const lt: (value: any, other: any) => boolean;
20
20
  export default lt;
package/types/lte.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 检查 `value` 是否小于或等于 `other` 。
3
3
  *
4
- * @static
4
+ * @function
5
5
  * @alias module:Util.lte
6
6
  * @since 1.0.0
7
7
  * @param {*} value 要比较的值。
@@ -16,5 +16,5 @@
16
16
  * lte(3, 1); // false
17
17
  *
18
18
  */
19
- declare function lte(value: any, other: any): boolean;
19
+ declare const lte: (value: any, other: any) => boolean;
20
20
  export default lte;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 转换字符串第一个字符为大写。
3
3
  *
4
- * @static
4
+ * @function
5
5
  * @alias module:String.upperFirst
6
6
  * @since 1.0.0
7
7
  * @param {string} string 要转换的字符串。
@@ -13,5 +13,5 @@
13
13
  * upperFirst('BAR'); // 'BAR'
14
14
  *
15
15
  */
16
- declare function upperFirst(string: string): string;
16
+ declare const upperFirst: (string: string) => string;
17
17
  export default upperFirst;