@anjianshi/utils 2.3.1 → 2.3.2

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.
@@ -8,5 +8,6 @@ export declare function getRandomInt(min: number, max: number): number;
8
8
  export declare function getRandomString(length?: number, seed?: string): string;
9
9
  /**
10
10
  * 从给定的选择中随机选中一项
11
+ * 如果数组为空,会返回 undefined
11
12
  */
12
- export declare function choiceRandom<T>(choices: T[]): NonNullable<T>;
13
+ export declare function choiceRandom<T>(choices: T[]): T | undefined;
@@ -21,6 +21,7 @@ export function getRandomString(length = 6, seed = '0123456789abcdefghijklmnopqr
21
21
  }
22
22
  /**
23
23
  * 从给定的选择中随机选中一项
24
+ * 如果数组为空,会返回 undefined
24
25
  */
25
26
  export function choiceRandom(choices) {
26
27
  return choices[getRandomInt(0, choices.length - 1)];
package/lang/random.d.ts CHANGED
@@ -8,5 +8,6 @@ export declare function getRandomInt(min: number, max: number): number;
8
8
  export declare function getRandomString(length?: number, seed?: string): string;
9
9
  /**
10
10
  * 从给定的选择中随机选中一项
11
+ * 如果数组为空,会返回 undefined
11
12
  */
12
- export declare function choiceRandom<T>(choices: T[]): NonNullable<T>;
13
+ export declare function choiceRandom<T>(choices: T[]): T | undefined;
package/lang/random.js CHANGED
@@ -17,6 +17,7 @@ export function getRandomString(length = 6, seed = '0123456789abcdefghijklmnopqr
17
17
  }
18
18
  /**
19
19
  * 从给定的选择中随机选中一项
20
+ * 如果数组为空,会返回 undefined
20
21
  */
21
22
  export function choiceRandom(choices) {
22
23
  return choices[getRandomInt(0, choices.length - 1)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anjianshi/utils",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Common JavaScript Utils",
5
5
  "homepage": "https://github.com/anjianshi/js-packages/utils",
6
6
  "bugs": {
@@ -29,9 +29,9 @@
29
29
  "vconsole": "^3.15.1",
30
30
  "@anjianshi/presets-eslint-node": "4.0.8",
31
31
  "@anjianshi/presets-eslint-typescript": "5.0.5",
32
+ "@anjianshi/presets-eslint-react": "4.0.7",
32
33
  "@anjianshi/presets-prettier": "3.0.1",
33
- "@anjianshi/presets-typescript": "3.2.2",
34
- "@anjianshi/presets-eslint-react": "4.0.7"
34
+ "@anjianshi/presets-typescript": "3.2.2"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@emotion/react": "^11.13.3",