@anjianshi/utils 2.3.0 → 2.3.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.
@@ -6,7 +6,9 @@ import crypto from 'node:crypto';
6
6
  * 返回随机数,包含 min 和 max
7
7
  */
8
8
  export function getRandomInt(min, max) {
9
- return crypto.randomInt(min, max + 1);
9
+ // 如果传入的 max 小于 min,把它拉到和 min 一样。不然 crypto.randomInt 无法处理
10
+ const fixedMax = Math.max(min, max);
11
+ return crypto.randomInt(min, fixedMax + 1);
10
12
  }
11
13
  /**
12
14
  * 返回随机字符串
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anjianshi/utils",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Common JavaScript Utils",
5
5
  "homepage": "https://github.com/anjianshi/js-packages/utils",
6
6
  "bugs": {
@@ -28,9 +28,9 @@
28
28
  "typescript": "^5.5.4",
29
29
  "vconsole": "^3.15.1",
30
30
  "@anjianshi/presets-eslint-node": "4.0.8",
31
- "@anjianshi/presets-typescript": "3.2.2",
32
31
  "@anjianshi/presets-eslint-typescript": "5.0.5",
33
32
  "@anjianshi/presets-prettier": "3.0.1",
33
+ "@anjianshi/presets-typescript": "3.2.2",
34
34
  "@anjianshi/presets-eslint-react": "4.0.7"
35
35
  },
36
36
  "peerDependencies": {