yummies 7.11.0 → 7.12.0

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 (146) hide show
  1. package/async.cjs +162 -48
  2. package/async.cjs.map +1 -1
  3. package/async.d.ts +108 -7
  4. package/async.js +163 -54
  5. package/async.js.map +1 -1
  6. package/chunk-CVq3Gv4J.cjs +50 -0
  7. package/chunk-YKewjYmz.js +37 -0
  8. package/common.cjs +48 -8
  9. package/common.cjs.map +1 -1
  10. package/common.d.ts +35 -2
  11. package/common.js +49 -11
  12. package/common.js.map +1 -1
  13. package/complex.cjs +275 -128
  14. package/complex.cjs.map +1 -1
  15. package/complex.js +275 -133
  16. package/complex.js.map +1 -1
  17. package/cookie.cjs +17 -7
  18. package/cookie.cjs.map +1 -1
  19. package/cookie.d.ts +8 -0
  20. package/cookie.js +18 -9
  21. package/cookie.js.map +1 -1
  22. package/css.cjs +147 -39
  23. package/css.cjs.map +1 -1
  24. package/css.d.ts +98 -6
  25. package/css.js +143 -41
  26. package/css.js.map +1 -1
  27. package/data.cjs +90 -55
  28. package/data.cjs.map +1 -1
  29. package/data.d.ts +32 -0
  30. package/data.js +91 -61
  31. package/data.js.map +1 -1
  32. package/date-time.cjs +578 -412
  33. package/date-time.cjs.map +1 -1
  34. package/date-time.d.ts +88 -0
  35. package/date-time.js +575 -421
  36. package/date-time.js.map +1 -1
  37. package/device.cjs +48 -23
  38. package/device.cjs.map +1 -1
  39. package/device.d.ts +32 -0
  40. package/device.js +49 -31
  41. package/device.js.map +1 -1
  42. package/encodings.cjs +275 -266
  43. package/encodings.cjs.map +1 -1
  44. package/encodings.d.ts +8 -0
  45. package/encodings.js +276 -268
  46. package/encodings.js.map +1 -1
  47. package/errors.cjs +20 -18
  48. package/errors.cjs.map +1 -1
  49. package/errors.js +19 -19
  50. package/errors.js.map +1 -1
  51. package/file.cjs +42 -24
  52. package/file.cjs.map +1 -1
  53. package/file.d.ts +16 -0
  54. package/file.js +43 -27
  55. package/file.js.map +1 -1
  56. package/format.cjs +125 -83
  57. package/format.cjs.map +1 -1
  58. package/format.js +118 -82
  59. package/format.js.map +1 -1
  60. package/html.cjs +226 -137
  61. package/html.cjs.map +1 -1
  62. package/html.d.ts +64 -0
  63. package/html.js +223 -150
  64. package/html.js.map +1 -1
  65. package/id.cjs +74 -17
  66. package/id.cjs.map +1 -1
  67. package/id.js +73 -24
  68. package/id.js.map +1 -1
  69. package/imports.cjs +41 -29
  70. package/imports.cjs.map +1 -1
  71. package/imports.d.ts +8 -0
  72. package/imports.js +40 -31
  73. package/imports.js.map +1 -1
  74. package/math.cjs +32 -6
  75. package/math.cjs.map +1 -1
  76. package/math.d.ts +16 -0
  77. package/math.js +33 -10
  78. package/math.js.map +1 -1
  79. package/media.cjs +275 -84
  80. package/media.cjs.map +1 -1
  81. package/media.d.ts +188 -2
  82. package/media.js +274 -93
  83. package/media.js.map +1 -1
  84. package/mobx.cjs +353 -193
  85. package/mobx.cjs.map +1 -1
  86. package/mobx.d.ts +7 -0
  87. package/mobx.js +351 -200
  88. package/mobx.js.map +1 -1
  89. package/ms.cjs +21 -10
  90. package/ms.cjs.map +1 -1
  91. package/ms.js +22 -13
  92. package/ms.js.map +1 -1
  93. package/number.cjs +13 -7
  94. package/number.cjs.map +1 -1
  95. package/number.js +14 -9
  96. package/number.js.map +1 -1
  97. package/package.json +10 -2
  98. package/parser.cjs +117 -64
  99. package/parser.cjs.map +1 -1
  100. package/parser.js +111 -64
  101. package/parser.js.map +1 -1
  102. package/price.cjs +24 -18
  103. package/price.cjs.map +1 -1
  104. package/price.d.ts +8 -0
  105. package/price.js +25 -20
  106. package/price.js.map +1 -1
  107. package/random.cjs +79 -13
  108. package/random.cjs.map +1 -1
  109. package/random.d.ts +64 -0
  110. package/random.js +80 -22
  111. package/random.js.map +1 -1
  112. package/react.cjs +673 -214
  113. package/react.cjs.map +1 -1
  114. package/react.d.ts +21 -0
  115. package/react.js +674 -239
  116. package/react.js.map +1 -1
  117. package/sound.cjs +14 -9
  118. package/sound.cjs.map +1 -1
  119. package/sound.js +15 -11
  120. package/sound.js.map +1 -1
  121. package/storage.cjs +49 -50
  122. package/storage.cjs.map +1 -1
  123. package/storage.d.ts +8 -0
  124. package/storage.js +50 -53
  125. package/storage.js.map +1 -1
  126. package/text.cjs +51 -34
  127. package/text.cjs.map +1 -1
  128. package/text.js +52 -37
  129. package/text.js.map +1 -1
  130. package/type-guard.cjs +292 -72
  131. package/type-guard.cjs.map +1 -1
  132. package/type-guard.js +288 -73
  133. package/type-guard.js.map +1 -1
  134. package/types.cjs +0 -2
  135. package/types.global.cjs +0 -2
  136. package/types.global.js +0 -2
  137. package/types.js +0 -2
  138. package/vibrate.cjs +31 -6
  139. package/vibrate.cjs.map +1 -1
  140. package/vibrate.d.ts +23 -1
  141. package/vibrate.js +32 -8
  142. package/vibrate.js.map +1 -1
  143. package/types.cjs.map +0 -1
  144. package/types.global.cjs.map +0 -1
  145. package/types.global.js.map +0 -1
  146. package/types.js.map +0 -1
package/price.cjs CHANGED
@@ -1,21 +1,27 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const formatPrice = (price, locale, currency, { withoutSymbol, customSymbol, ...options } = {}) => {
4
- const priceFormatter = new Intl.NumberFormat(locale, {
5
- style: "currency",
6
- currency,
7
- minimumFractionDigits: 0,
8
- currencyDisplay: "narrowSymbol",
9
- ...options
10
- });
11
- const zeroPrice = priceFormatter.format(0);
12
- const currencySymbol = zeroPrice.replace("0", "");
13
- const rawPrice = priceFormatter.format(price);
14
- const priceWithoutCurrency = rawPrice.replace(currencySymbol, "");
15
- if (withoutSymbol) {
16
- return priceWithoutCurrency;
17
- }
18
- return `${priceWithoutCurrency} ${customSymbol ?? (currency === "RUB" ? "р" : currencySymbol)}`.replace(/\s{2,}/, " ");
2
+ //#region src/price.ts
3
+ /**
4
+ * Formats a numeric price using locale and currency options.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * formatPrice(1990, 'ru-RU', 'RUB');
9
+ * ```
10
+ */
11
+ var formatPrice = (price, locale, currency, { withoutSymbol, customSymbol, ...options } = {}) => {
12
+ const priceFormatter = new Intl.NumberFormat(locale, {
13
+ style: "currency",
14
+ currency,
15
+ minimumFractionDigits: 0,
16
+ currencyDisplay: "narrowSymbol",
17
+ ...options
18
+ });
19
+ const currencySymbol = priceFormatter.format(0).replace("0", "");
20
+ const priceWithoutCurrency = priceFormatter.format(price).replace(currencySymbol, "");
21
+ if (withoutSymbol) return priceWithoutCurrency;
22
+ return `${priceWithoutCurrency} ${customSymbol ?? (currency === "RUB" ? "р" : currencySymbol)}`.replace(/\s{2,}/, " ");
19
23
  };
24
+ //#endregion
20
25
  exports.formatPrice = formatPrice;
21
- //# sourceMappingURL=price.cjs.map
26
+
27
+ //# sourceMappingURL=price.cjs.map
package/price.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"price.cjs","sources":["../src/price.ts"],"sourcesContent":["export interface PriceFormatOptions\n extends Partial<Omit<Intl.NumberFormatOptions, 'currency'>> {\n withoutSymbol?: boolean;\n customSymbol?: string;\n}\n\nexport const formatPrice = (\n price: number,\n locale: string,\n currency?: string,\n { withoutSymbol, customSymbol, ...options }: PriceFormatOptions = {},\n) => {\n const priceFormatter = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n currencyDisplay: 'narrowSymbol',\n ...options,\n });\n\n const zeroPrice = priceFormatter.format(0);\n const currencySymbol = zeroPrice.replace('0', '');\n const rawPrice = priceFormatter.format(price);\n const priceWithoutCurrency = rawPrice.replace(currencySymbol, '');\n\n if (withoutSymbol) {\n return priceWithoutCurrency;\n }\n\n return `${priceWithoutCurrency} ${\n customSymbol ?? (currency === 'RUB' ? 'р' : currencySymbol)\n }`.replace(/\\s{2,}/, ' ');\n};\n"],"names":[],"mappings":";;AAMO,MAAM,cAAc,CACzB,OACA,QACA,UACA,EAAE,eAAe,cAAc,GAAG,QAAA,IAAgC,OAC/D;AACH,QAAM,iBAAiB,IAAI,KAAK,aAAa,QAAQ;AAAA,IACnD,OAAO;AAAA,IACP;AAAA,IACA,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,IACjB,GAAG;AAAA,EAAA,CACJ;AAED,QAAM,YAAY,eAAe,OAAO,CAAC;AACzC,QAAM,iBAAiB,UAAU,QAAQ,KAAK,EAAE;AAChD,QAAM,WAAW,eAAe,OAAO,KAAK;AAC5C,QAAM,uBAAuB,SAAS,QAAQ,gBAAgB,EAAE;AAEhE,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,SAAO,GAAG,oBAAoB,IAC5B,iBAAiB,aAAa,QAAQ,MAAM,eAC9C,GAAG,QAAQ,UAAU,GAAG;AAC1B;;"}
1
+ {"version":3,"file":"price.cjs","names":[],"sources":["../src/price.ts"],"sourcesContent":["export interface PriceFormatOptions\n extends Partial<Omit<Intl.NumberFormatOptions, 'currency'>> {\n withoutSymbol?: boolean;\n customSymbol?: string;\n}\n\n/**\n * Formats a numeric price using locale and currency options.\n *\n * @example\n * ```ts\n * formatPrice(1990, 'ru-RU', 'RUB');\n * ```\n */\nexport const formatPrice = (\n price: number,\n locale: string,\n currency?: string,\n { withoutSymbol, customSymbol, ...options }: PriceFormatOptions = {},\n) => {\n const priceFormatter = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n currencyDisplay: 'narrowSymbol',\n ...options,\n });\n\n const zeroPrice = priceFormatter.format(0);\n const currencySymbol = zeroPrice.replace('0', '');\n const rawPrice = priceFormatter.format(price);\n const priceWithoutCurrency = rawPrice.replace(currencySymbol, '');\n\n if (withoutSymbol) {\n return priceWithoutCurrency;\n }\n\n return `${priceWithoutCurrency} ${\n customSymbol ?? (currency === 'RUB' ? 'р' : currencySymbol)\n }`.replace(/\\s{2,}/, ' ');\n};\n"],"mappings":";;;;;;;;;;AAcA,IAAa,eACX,OACA,QACA,UACA,EAAE,eAAe,cAAc,GAAG,YAAgC,EAAE,KACjE;CACH,MAAM,iBAAiB,IAAI,KAAK,aAAa,QAAQ;EACnD,OAAO;EACP;EACA,uBAAuB;EACvB,iBAAiB;EACjB,GAAG;EACJ,CAAC;CAGF,MAAM,iBADY,eAAe,OAAO,EAAE,CACT,QAAQ,KAAK,GAAG;CAEjD,MAAM,uBADW,eAAe,OAAO,MAAM,CACP,QAAQ,gBAAgB,GAAG;AAEjE,KAAI,cACF,QAAO;AAGT,QAAO,GAAG,qBAAqB,GAC7B,iBAAiB,aAAa,QAAQ,MAAM,kBAC3C,QAAQ,UAAU,IAAI"}
package/price.d.ts CHANGED
@@ -2,6 +2,14 @@ interface PriceFormatOptions extends Partial<Omit<Intl.NumberFormatOptions, 'cur
2
2
  withoutSymbol?: boolean;
3
3
  customSymbol?: string;
4
4
  }
5
+ /**
6
+ * Formats a numeric price using locale and currency options.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * formatPrice(1990, 'ru-RU', 'RUB');
11
+ * ```
12
+ */
5
13
  declare const formatPrice: (price: number, locale: string, currency?: string, { withoutSymbol, customSymbol, ...options }?: PriceFormatOptions) => string;
6
14
 
7
15
  export { formatPrice };
package/price.js CHANGED
@@ -1,21 +1,26 @@
1
- const formatPrice = (price, locale, currency, { withoutSymbol, customSymbol, ...options } = {}) => {
2
- const priceFormatter = new Intl.NumberFormat(locale, {
3
- style: "currency",
4
- currency,
5
- minimumFractionDigits: 0,
6
- currencyDisplay: "narrowSymbol",
7
- ...options
8
- });
9
- const zeroPrice = priceFormatter.format(0);
10
- const currencySymbol = zeroPrice.replace("0", "");
11
- const rawPrice = priceFormatter.format(price);
12
- const priceWithoutCurrency = rawPrice.replace(currencySymbol, "");
13
- if (withoutSymbol) {
14
- return priceWithoutCurrency;
15
- }
16
- return `${priceWithoutCurrency} ${customSymbol ?? (currency === "RUB" ? "р" : currencySymbol)}`.replace(/\s{2,}/, " ");
1
+ //#region src/price.ts
2
+ /**
3
+ * Formats a numeric price using locale and currency options.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * formatPrice(1990, 'ru-RU', 'RUB');
8
+ * ```
9
+ */
10
+ var formatPrice = (price, locale, currency, { withoutSymbol, customSymbol, ...options } = {}) => {
11
+ const priceFormatter = new Intl.NumberFormat(locale, {
12
+ style: "currency",
13
+ currency,
14
+ minimumFractionDigits: 0,
15
+ currencyDisplay: "narrowSymbol",
16
+ ...options
17
+ });
18
+ const currencySymbol = priceFormatter.format(0).replace("0", "");
19
+ const priceWithoutCurrency = priceFormatter.format(price).replace(currencySymbol, "");
20
+ if (withoutSymbol) return priceWithoutCurrency;
21
+ return `${priceWithoutCurrency} ${customSymbol ?? (currency === "RUB" ? "р" : currencySymbol)}`.replace(/\s{2,}/, " ");
17
22
  };
18
- export {
19
- formatPrice
20
- };
21
- //# sourceMappingURL=price.js.map
23
+ //#endregion
24
+ export { formatPrice };
25
+
26
+ //# sourceMappingURL=price.js.map
package/price.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"price.js","sources":["../src/price.ts"],"sourcesContent":["export interface PriceFormatOptions\n extends Partial<Omit<Intl.NumberFormatOptions, 'currency'>> {\n withoutSymbol?: boolean;\n customSymbol?: string;\n}\n\nexport const formatPrice = (\n price: number,\n locale: string,\n currency?: string,\n { withoutSymbol, customSymbol, ...options }: PriceFormatOptions = {},\n) => {\n const priceFormatter = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n currencyDisplay: 'narrowSymbol',\n ...options,\n });\n\n const zeroPrice = priceFormatter.format(0);\n const currencySymbol = zeroPrice.replace('0', '');\n const rawPrice = priceFormatter.format(price);\n const priceWithoutCurrency = rawPrice.replace(currencySymbol, '');\n\n if (withoutSymbol) {\n return priceWithoutCurrency;\n }\n\n return `${priceWithoutCurrency} ${\n customSymbol ?? (currency === 'RUB' ? 'р' : currencySymbol)\n }`.replace(/\\s{2,}/, ' ');\n};\n"],"names":[],"mappings":"AAMO,MAAM,cAAc,CACzB,OACA,QACA,UACA,EAAE,eAAe,cAAc,GAAG,QAAA,IAAgC,OAC/D;AACH,QAAM,iBAAiB,IAAI,KAAK,aAAa,QAAQ;AAAA,IACnD,OAAO;AAAA,IACP;AAAA,IACA,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,IACjB,GAAG;AAAA,EAAA,CACJ;AAED,QAAM,YAAY,eAAe,OAAO,CAAC;AACzC,QAAM,iBAAiB,UAAU,QAAQ,KAAK,EAAE;AAChD,QAAM,WAAW,eAAe,OAAO,KAAK;AAC5C,QAAM,uBAAuB,SAAS,QAAQ,gBAAgB,EAAE;AAEhE,MAAI,eAAe;AACjB,WAAO;AAAA,EACT;AAEA,SAAO,GAAG,oBAAoB,IAC5B,iBAAiB,aAAa,QAAQ,MAAM,eAC9C,GAAG,QAAQ,UAAU,GAAG;AAC1B;"}
1
+ {"version":3,"file":"price.js","names":[],"sources":["../src/price.ts"],"sourcesContent":["export interface PriceFormatOptions\n extends Partial<Omit<Intl.NumberFormatOptions, 'currency'>> {\n withoutSymbol?: boolean;\n customSymbol?: string;\n}\n\n/**\n * Formats a numeric price using locale and currency options.\n *\n * @example\n * ```ts\n * formatPrice(1990, 'ru-RU', 'RUB');\n * ```\n */\nexport const formatPrice = (\n price: number,\n locale: string,\n currency?: string,\n { withoutSymbol, customSymbol, ...options }: PriceFormatOptions = {},\n) => {\n const priceFormatter = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n currencyDisplay: 'narrowSymbol',\n ...options,\n });\n\n const zeroPrice = priceFormatter.format(0);\n const currencySymbol = zeroPrice.replace('0', '');\n const rawPrice = priceFormatter.format(price);\n const priceWithoutCurrency = rawPrice.replace(currencySymbol, '');\n\n if (withoutSymbol) {\n return priceWithoutCurrency;\n }\n\n return `${priceWithoutCurrency} ${\n customSymbol ?? (currency === 'RUB' ? 'р' : currencySymbol)\n }`.replace(/\\s{2,}/, ' ');\n};\n"],"mappings":";;;;;;;;;AAcA,IAAa,eACX,OACA,QACA,UACA,EAAE,eAAe,cAAc,GAAG,YAAgC,EAAE,KACjE;CACH,MAAM,iBAAiB,IAAI,KAAK,aAAa,QAAQ;EACnD,OAAO;EACP;EACA,uBAAuB;EACvB,iBAAiB;EACjB,GAAG;EACJ,CAAC;CAGF,MAAM,iBADY,eAAe,OAAO,EAAE,CACT,QAAQ,KAAK,GAAG;CAEjD,MAAM,uBADW,eAAe,OAAO,MAAM,CACP,QAAQ,gBAAgB,GAAG;AAEjE,KAAI,cACF,QAAO;AAGT,QAAO,GAAG,qBAAqB,GAC7B,iBAAiB,aAAa,QAAQ,MAAM,kBAC3C,QAAQ,UAAU,IAAI"}
package/random.cjs CHANGED
@@ -1,19 +1,84 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const getRandomFloat = (min = 0, max = 1) => Math.random() * (max - min) + min;
4
- const getRandomInt = (min = 0, max = 1) => min === max ? min : Math.round(getRandomFloat(min, max));
5
- const getRandomChoice = (arr) => arr[getRandomInt(0, arr.length - 1)];
6
- const getRandomSizeArray = (min = 0, max = 10) => Array.from({ length: getRandomInt(min, max) }).fill(null);
7
- const getRandomBool = () => getRandomInt(0, 1) === 1;
8
- const getMajorRandomBool = () => {
9
- return getRandomInt(0, 10) <= 6;
2
+ //#region src/random.ts
3
+ /**
4
+ * Returns a random floating-point number between `min` and `max`.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const value = getRandomFloat(1, 10);
9
+ * ```
10
+ */
11
+ var getRandomFloat = (min = 0, max = 1) => Math.random() * (max - min) + min;
12
+ /**
13
+ * Returns a random integer between `min` and `max`.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const value = getRandomInt(1, 10);
18
+ * ```
19
+ */
20
+ var getRandomInt = (min = 0, max = 1) => min === max ? min : Math.round(getRandomFloat(min, max));
21
+ /**
22
+ * Picks a random element from the provided array.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const fruit = getRandomChoice(['apple', 'banana', 'orange']);
27
+ * ```
28
+ */
29
+ var getRandomChoice = (arr) => arr[getRandomInt(0, arr.length - 1)];
30
+ /**
31
+ * Creates an array filled with `null` values using a random length.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const items = getRandomSizeArray(2, 5);
36
+ * ```
37
+ */
38
+ var getRandomSizeArray = (min = 0, max = 10) => Array.from({ length: getRandomInt(min, max) }).fill(null);
39
+ /**
40
+ * Returns a uniformly random boolean.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const value = getRandomBool();
45
+ * ```
46
+ */
47
+ var getRandomBool = () => getRandomInt(0, 1) === 1;
48
+ /**
49
+ * Returns `true` more often than `false`.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const value = getMajorRandomBool();
54
+ * ```
55
+ */
56
+ var getMajorRandomBool = () => {
57
+ return getRandomInt(0, 10) <= 6;
10
58
  };
11
- const getMinorRandomBool = () => {
12
- return !getMajorRandomBool();
59
+ /**
60
+ * Returns `true` less often than `false`.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const value = getMinorRandomBool();
65
+ * ```
66
+ */
67
+ var getMinorRandomBool = () => {
68
+ return !getMajorRandomBool();
13
69
  };
14
- const getFrequencyValue = (frequency) => {
15
- return Math.random() < frequency;
70
+ /**
71
+ * Returns `true` with the provided probability from `0` to `1`.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const shouldRun = getFrequencyValue(0.25);
76
+ * ```
77
+ */
78
+ var getFrequencyValue = (frequency) => {
79
+ return Math.random() < frequency;
16
80
  };
81
+ //#endregion
17
82
  exports.getFrequencyValue = getFrequencyValue;
18
83
  exports.getMajorRandomBool = getMajorRandomBool;
19
84
  exports.getMinorRandomBool = getMinorRandomBool;
@@ -22,4 +87,5 @@ exports.getRandomChoice = getRandomChoice;
22
87
  exports.getRandomFloat = getRandomFloat;
23
88
  exports.getRandomInt = getRandomInt;
24
89
  exports.getRandomSizeArray = getRandomSizeArray;
25
- //# sourceMappingURL=random.cjs.map
90
+
91
+ //# sourceMappingURL=random.cjs.map
package/random.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"random.cjs","sources":["../src/random.ts"],"sourcesContent":["export const getRandomFloat = <T extends number = number>(\n min = 0,\n max = 1,\n): T => (Math.random() * (max - min) + min) as T;\n\nexport const getRandomInt = <T extends number = number>(min = 0, max = 1): T =>\n min === max ? (min as T) : (Math.round(getRandomFloat(min, max)) as T);\n\nexport const getRandomChoice = <T>(arr: T[]): T =>\n arr[getRandomInt(0, arr.length - 1)];\n\nexport const getRandomSizeArray = (min = 0, max = 10) =>\n Array.from({ length: getRandomInt(min, max) }).fill(null);\n\nexport const getRandomBool = () => getRandomInt(0, 1) === 1;\n\nexport const getMajorRandomBool = () => {\n return getRandomInt(0, 10) <= 6;\n};\n\nexport const getMinorRandomBool = () => {\n return !getMajorRandomBool();\n};\n\nexport const getFrequencyValue = (frequency: number) => {\n return Math.random() < frequency;\n};\n"],"names":[],"mappings":";;AAAO,MAAM,iBAAiB,CAC5B,MAAM,GACN,MAAM,MACC,KAAK,OAAA,KAAY,MAAM,OAAO;AAEhC,MAAM,eAAe,CAA4B,MAAM,GAAG,MAAM,MACrE,QAAQ,MAAO,MAAa,KAAK,MAAM,eAAe,KAAK,GAAG,CAAC;AAE1D,MAAM,kBAAkB,CAAI,QACjC,IAAI,aAAa,GAAG,IAAI,SAAS,CAAC,CAAC;AAE9B,MAAM,qBAAqB,CAAC,MAAM,GAAG,MAAM,OAChD,MAAM,KAAK,EAAE,QAAQ,aAAa,KAAK,GAAG,GAAG,EAAE,KAAK,IAAI;AAEnD,MAAM,gBAAgB,MAAM,aAAa,GAAG,CAAC,MAAM;AAEnD,MAAM,qBAAqB,MAAM;AACtC,SAAO,aAAa,GAAG,EAAE,KAAK;AAChC;AAEO,MAAM,qBAAqB,MAAM;AACtC,SAAO,CAAC,mBAAA;AACV;AAEO,MAAM,oBAAoB,CAAC,cAAsB;AACtD,SAAO,KAAK,WAAW;AACzB;;;;;;;;;"}
1
+ {"version":3,"file":"random.cjs","names":[],"sources":["../src/random.ts"],"sourcesContent":["/**\n * Returns a random floating-point number between `min` and `max`.\n *\n * @example\n * ```ts\n * const value = getRandomFloat(1, 10);\n * ```\n */\nexport const getRandomFloat = <T extends number = number>(\n min = 0,\n max = 1,\n): T => (Math.random() * (max - min) + min) as T;\n\n/**\n * Returns a random integer between `min` and `max`.\n *\n * @example\n * ```ts\n * const value = getRandomInt(1, 10);\n * ```\n */\nexport const getRandomInt = <T extends number = number>(min = 0, max = 1): T =>\n min === max ? (min as T) : (Math.round(getRandomFloat(min, max)) as T);\n\n/**\n * Picks a random element from the provided array.\n *\n * @example\n * ```ts\n * const fruit = getRandomChoice(['apple', 'banana', 'orange']);\n * ```\n */\nexport const getRandomChoice = <T>(arr: T[]): T =>\n arr[getRandomInt(0, arr.length - 1)];\n\n/**\n * Creates an array filled with `null` values using a random length.\n *\n * @example\n * ```ts\n * const items = getRandomSizeArray(2, 5);\n * ```\n */\nexport const getRandomSizeArray = (min = 0, max = 10) =>\n Array.from({ length: getRandomInt(min, max) }).fill(null);\n\n/**\n * Returns a uniformly random boolean.\n *\n * @example\n * ```ts\n * const value = getRandomBool();\n * ```\n */\nexport const getRandomBool = () => getRandomInt(0, 1) === 1;\n\n/**\n * Returns `true` more often than `false`.\n *\n * @example\n * ```ts\n * const value = getMajorRandomBool();\n * ```\n */\nexport const getMajorRandomBool = () => {\n return getRandomInt(0, 10) <= 6;\n};\n\n/**\n * Returns `true` less often than `false`.\n *\n * @example\n * ```ts\n * const value = getMinorRandomBool();\n * ```\n */\nexport const getMinorRandomBool = () => {\n return !getMajorRandomBool();\n};\n\n/**\n * Returns `true` with the provided probability from `0` to `1`.\n *\n * @example\n * ```ts\n * const shouldRun = getFrequencyValue(0.25);\n * ```\n */\nexport const getFrequencyValue = (frequency: number) => {\n return Math.random() < frequency;\n};\n"],"mappings":";;;;;;;;;;AAQA,IAAa,kBACX,MAAM,GACN,MAAM,MACC,KAAK,QAAQ,IAAI,MAAM,OAAO;;;;;;;;;AAUvC,IAAa,gBAA2C,MAAM,GAAG,MAAM,MACrE,QAAQ,MAAO,MAAa,KAAK,MAAM,eAAe,KAAK,IAAI,CAAC;;;;;;;;;AAUlE,IAAa,mBAAsB,QACjC,IAAI,aAAa,GAAG,IAAI,SAAS,EAAE;;;;;;;;;AAUrC,IAAa,sBAAsB,MAAM,GAAG,MAAM,OAChD,MAAM,KAAK,EAAE,QAAQ,aAAa,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,KAAK;;;;;;;;;AAU3D,IAAa,sBAAsB,aAAa,GAAG,EAAE,KAAK;;;;;;;;;AAU1D,IAAa,2BAA2B;AACtC,QAAO,aAAa,GAAG,GAAG,IAAI;;;;;;;;;;AAWhC,IAAa,2BAA2B;AACtC,QAAO,CAAC,oBAAoB;;;;;;;;;;AAW9B,IAAa,qBAAqB,cAAsB;AACtD,QAAO,KAAK,QAAQ,GAAG"}
package/random.d.ts CHANGED
@@ -1,10 +1,74 @@
1
+ /**
2
+ * Returns a random floating-point number between `min` and `max`.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const value = getRandomFloat(1, 10);
7
+ * ```
8
+ */
1
9
  declare const getRandomFloat: <T extends number = number>(min?: number, max?: number) => T;
10
+ /**
11
+ * Returns a random integer between `min` and `max`.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const value = getRandomInt(1, 10);
16
+ * ```
17
+ */
2
18
  declare const getRandomInt: <T extends number = number>(min?: number, max?: number) => T;
19
+ /**
20
+ * Picks a random element from the provided array.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const fruit = getRandomChoice(['apple', 'banana', 'orange']);
25
+ * ```
26
+ */
3
27
  declare const getRandomChoice: <T>(arr: T[]) => T;
28
+ /**
29
+ * Creates an array filled with `null` values using a random length.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const items = getRandomSizeArray(2, 5);
34
+ * ```
35
+ */
4
36
  declare const getRandomSizeArray: (min?: number, max?: number) => unknown[];
37
+ /**
38
+ * Returns a uniformly random boolean.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const value = getRandomBool();
43
+ * ```
44
+ */
5
45
  declare const getRandomBool: () => boolean;
46
+ /**
47
+ * Returns `true` more often than `false`.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const value = getMajorRandomBool();
52
+ * ```
53
+ */
6
54
  declare const getMajorRandomBool: () => boolean;
55
+ /**
56
+ * Returns `true` less often than `false`.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const value = getMinorRandomBool();
61
+ * ```
62
+ */
7
63
  declare const getMinorRandomBool: () => boolean;
64
+ /**
65
+ * Returns `true` with the provided probability from `0` to `1`.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const shouldRun = getFrequencyValue(0.25);
70
+ * ```
71
+ */
8
72
  declare const getFrequencyValue: (frequency: number) => boolean;
9
73
 
10
74
  export { getFrequencyValue, getMajorRandomBool, getMinorRandomBool, getRandomBool, getRandomChoice, getRandomFloat, getRandomInt, getRandomSizeArray };
package/random.js CHANGED
@@ -1,25 +1,83 @@
1
- const getRandomFloat = (min = 0, max = 1) => Math.random() * (max - min) + min;
2
- const getRandomInt = (min = 0, max = 1) => min === max ? min : Math.round(getRandomFloat(min, max));
3
- const getRandomChoice = (arr) => arr[getRandomInt(0, arr.length - 1)];
4
- const getRandomSizeArray = (min = 0, max = 10) => Array.from({ length: getRandomInt(min, max) }).fill(null);
5
- const getRandomBool = () => getRandomInt(0, 1) === 1;
6
- const getMajorRandomBool = () => {
7
- return getRandomInt(0, 10) <= 6;
1
+ //#region src/random.ts
2
+ /**
3
+ * Returns a random floating-point number between `min` and `max`.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const value = getRandomFloat(1, 10);
8
+ * ```
9
+ */
10
+ var getRandomFloat = (min = 0, max = 1) => Math.random() * (max - min) + min;
11
+ /**
12
+ * Returns a random integer between `min` and `max`.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const value = getRandomInt(1, 10);
17
+ * ```
18
+ */
19
+ var getRandomInt = (min = 0, max = 1) => min === max ? min : Math.round(getRandomFloat(min, max));
20
+ /**
21
+ * Picks a random element from the provided array.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const fruit = getRandomChoice(['apple', 'banana', 'orange']);
26
+ * ```
27
+ */
28
+ var getRandomChoice = (arr) => arr[getRandomInt(0, arr.length - 1)];
29
+ /**
30
+ * Creates an array filled with `null` values using a random length.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const items = getRandomSizeArray(2, 5);
35
+ * ```
36
+ */
37
+ var getRandomSizeArray = (min = 0, max = 10) => Array.from({ length: getRandomInt(min, max) }).fill(null);
38
+ /**
39
+ * Returns a uniformly random boolean.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const value = getRandomBool();
44
+ * ```
45
+ */
46
+ var getRandomBool = () => getRandomInt(0, 1) === 1;
47
+ /**
48
+ * Returns `true` more often than `false`.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const value = getMajorRandomBool();
53
+ * ```
54
+ */
55
+ var getMajorRandomBool = () => {
56
+ return getRandomInt(0, 10) <= 6;
8
57
  };
9
- const getMinorRandomBool = () => {
10
- return !getMajorRandomBool();
58
+ /**
59
+ * Returns `true` less often than `false`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const value = getMinorRandomBool();
64
+ * ```
65
+ */
66
+ var getMinorRandomBool = () => {
67
+ return !getMajorRandomBool();
11
68
  };
12
- const getFrequencyValue = (frequency) => {
13
- return Math.random() < frequency;
69
+ /**
70
+ * Returns `true` with the provided probability from `0` to `1`.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const shouldRun = getFrequencyValue(0.25);
75
+ * ```
76
+ */
77
+ var getFrequencyValue = (frequency) => {
78
+ return Math.random() < frequency;
14
79
  };
15
- export {
16
- getFrequencyValue,
17
- getMajorRandomBool,
18
- getMinorRandomBool,
19
- getRandomBool,
20
- getRandomChoice,
21
- getRandomFloat,
22
- getRandomInt,
23
- getRandomSizeArray
24
- };
25
- //# sourceMappingURL=random.js.map
80
+ //#endregion
81
+ export { getFrequencyValue, getMajorRandomBool, getMinorRandomBool, getRandomBool, getRandomChoice, getRandomFloat, getRandomInt, getRandomSizeArray };
82
+
83
+ //# sourceMappingURL=random.js.map
package/random.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"random.js","sources":["../src/random.ts"],"sourcesContent":["export const getRandomFloat = <T extends number = number>(\n min = 0,\n max = 1,\n): T => (Math.random() * (max - min) + min) as T;\n\nexport const getRandomInt = <T extends number = number>(min = 0, max = 1): T =>\n min === max ? (min as T) : (Math.round(getRandomFloat(min, max)) as T);\n\nexport const getRandomChoice = <T>(arr: T[]): T =>\n arr[getRandomInt(0, arr.length - 1)];\n\nexport const getRandomSizeArray = (min = 0, max = 10) =>\n Array.from({ length: getRandomInt(min, max) }).fill(null);\n\nexport const getRandomBool = () => getRandomInt(0, 1) === 1;\n\nexport const getMajorRandomBool = () => {\n return getRandomInt(0, 10) <= 6;\n};\n\nexport const getMinorRandomBool = () => {\n return !getMajorRandomBool();\n};\n\nexport const getFrequencyValue = (frequency: number) => {\n return Math.random() < frequency;\n};\n"],"names":[],"mappings":"AAAO,MAAM,iBAAiB,CAC5B,MAAM,GACN,MAAM,MACC,KAAK,OAAA,KAAY,MAAM,OAAO;AAEhC,MAAM,eAAe,CAA4B,MAAM,GAAG,MAAM,MACrE,QAAQ,MAAO,MAAa,KAAK,MAAM,eAAe,KAAK,GAAG,CAAC;AAE1D,MAAM,kBAAkB,CAAI,QACjC,IAAI,aAAa,GAAG,IAAI,SAAS,CAAC,CAAC;AAE9B,MAAM,qBAAqB,CAAC,MAAM,GAAG,MAAM,OAChD,MAAM,KAAK,EAAE,QAAQ,aAAa,KAAK,GAAG,GAAG,EAAE,KAAK,IAAI;AAEnD,MAAM,gBAAgB,MAAM,aAAa,GAAG,CAAC,MAAM;AAEnD,MAAM,qBAAqB,MAAM;AACtC,SAAO,aAAa,GAAG,EAAE,KAAK;AAChC;AAEO,MAAM,qBAAqB,MAAM;AACtC,SAAO,CAAC,mBAAA;AACV;AAEO,MAAM,oBAAoB,CAAC,cAAsB;AACtD,SAAO,KAAK,WAAW;AACzB;"}
1
+ {"version":3,"file":"random.js","names":[],"sources":["../src/random.ts"],"sourcesContent":["/**\n * Returns a random floating-point number between `min` and `max`.\n *\n * @example\n * ```ts\n * const value = getRandomFloat(1, 10);\n * ```\n */\nexport const getRandomFloat = <T extends number = number>(\n min = 0,\n max = 1,\n): T => (Math.random() * (max - min) + min) as T;\n\n/**\n * Returns a random integer between `min` and `max`.\n *\n * @example\n * ```ts\n * const value = getRandomInt(1, 10);\n * ```\n */\nexport const getRandomInt = <T extends number = number>(min = 0, max = 1): T =>\n min === max ? (min as T) : (Math.round(getRandomFloat(min, max)) as T);\n\n/**\n * Picks a random element from the provided array.\n *\n * @example\n * ```ts\n * const fruit = getRandomChoice(['apple', 'banana', 'orange']);\n * ```\n */\nexport const getRandomChoice = <T>(arr: T[]): T =>\n arr[getRandomInt(0, arr.length - 1)];\n\n/**\n * Creates an array filled with `null` values using a random length.\n *\n * @example\n * ```ts\n * const items = getRandomSizeArray(2, 5);\n * ```\n */\nexport const getRandomSizeArray = (min = 0, max = 10) =>\n Array.from({ length: getRandomInt(min, max) }).fill(null);\n\n/**\n * Returns a uniformly random boolean.\n *\n * @example\n * ```ts\n * const value = getRandomBool();\n * ```\n */\nexport const getRandomBool = () => getRandomInt(0, 1) === 1;\n\n/**\n * Returns `true` more often than `false`.\n *\n * @example\n * ```ts\n * const value = getMajorRandomBool();\n * ```\n */\nexport const getMajorRandomBool = () => {\n return getRandomInt(0, 10) <= 6;\n};\n\n/**\n * Returns `true` less often than `false`.\n *\n * @example\n * ```ts\n * const value = getMinorRandomBool();\n * ```\n */\nexport const getMinorRandomBool = () => {\n return !getMajorRandomBool();\n};\n\n/**\n * Returns `true` with the provided probability from `0` to `1`.\n *\n * @example\n * ```ts\n * const shouldRun = getFrequencyValue(0.25);\n * ```\n */\nexport const getFrequencyValue = (frequency: number) => {\n return Math.random() < frequency;\n};\n"],"mappings":";;;;;;;;;AAQA,IAAa,kBACX,MAAM,GACN,MAAM,MACC,KAAK,QAAQ,IAAI,MAAM,OAAO;;;;;;;;;AAUvC,IAAa,gBAA2C,MAAM,GAAG,MAAM,MACrE,QAAQ,MAAO,MAAa,KAAK,MAAM,eAAe,KAAK,IAAI,CAAC;;;;;;;;;AAUlE,IAAa,mBAAsB,QACjC,IAAI,aAAa,GAAG,IAAI,SAAS,EAAE;;;;;;;;;AAUrC,IAAa,sBAAsB,MAAM,GAAG,MAAM,OAChD,MAAM,KAAK,EAAE,QAAQ,aAAa,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,KAAK;;;;;;;;;AAU3D,IAAa,sBAAsB,aAAa,GAAG,EAAE,KAAK;;;;;;;;;AAU1D,IAAa,2BAA2B;AACtC,QAAO,aAAa,GAAG,GAAG,IAAI;;;;;;;;;;AAWhC,IAAa,2BAA2B;AACtC,QAAO,CAAC,oBAAoB;;;;;;;;;;AAW9B,IAAa,qBAAqB,cAAsB;AACtD,QAAO,KAAK,QAAQ,GAAG"}