@zoodogood/utils 2.0.0-change.1496 → 2.0.2-change.1508

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.
@@ -14,7 +14,7 @@ export function getRandomElementFromArray(array, { needPop, associatedWeights }
14
14
  }
15
15
  const index = associatedWeights
16
16
  ? getRandomElementIndexInWeights(associatedWeights)
17
- : getRandomNumberInRange({ max: array.length });
17
+ : getRandomNumberInRange({ max: array.length - 1 });
18
18
  const input = array[index];
19
19
  if (needPop) {
20
20
  array.splice(index, 1);
@@ -3,5 +3,5 @@ interface IGetRandomValueOptions {
3
3
  max: number;
4
4
  needRound?: boolean;
5
5
  }
6
- declare function getRandomNumberInRange({ min, max, needRound }: IGetRandomValueOptions): number;
6
+ declare function getRandomNumberInRange({ min, max, needRound, }: IGetRandomValueOptions): number;
7
7
  export { getRandomNumberInRange };
@@ -1,4 +1,4 @@
1
- function getRandomNumberInRange({ min = 0, max, needRound = true }) {
1
+ function getRandomNumberInRange({ min = 0, max, needRound = true, }) {
2
2
  let value = Math.random() * (max - min + Number(needRound)) + min;
3
3
  if (needRound) {
4
4
  value = Math.floor(value);
@@ -55,7 +55,7 @@ export class FlagsManager {
55
55
  captureFlags(flags, context) {
56
56
  for (const { name, capture, expectValue } of flags) {
57
57
  for (const flag of capture) {
58
- const regex = `(?<=^|\\s)${flag}${expectValue ? "(?:(?:\\s+(?!-)|=)(?<value>[^\\s]+))" : ""}`;
58
+ const regex = `(?<=^|\\s)${flag}${expectValue ? "(?:(?:\\s+(?!-)|=)(?<value>[^\\s]+))?" : ""}`;
59
59
  const { parser } = context;
60
60
  const captureName = name || flag;
61
61
  const match = parser.replaceByMatch(RegExp(regex, "i"));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zoodogood/utils",
3
3
  "type": "module",
4
- "version": "2.0.0-change.1496",
4
+ "version": "2.0.2-change.1508",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",