@futdevpro/fsm-dynamo 1.10.37 → 1.10.39

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 (290) hide show
  1. package/.github/workflows/main.yml +11 -51
  2. package/build/_collections/constants/error-defaults.const.d.ts +8 -0
  3. package/build/_collections/constants/error-defaults.const.d.ts.map +1 -1
  4. package/build/_collections/constants/error-defaults.const.js +8 -0
  5. package/build/_collections/constants/error-defaults.const.js.map +1 -1
  6. package/build/_collections/constants/global-settings.const.d.ts +8 -0
  7. package/build/_collections/constants/global-settings.const.d.ts.map +1 -1
  8. package/build/_collections/constants/global-settings.const.js +9 -0
  9. package/build/_collections/constants/global-settings.const.js.map +1 -1
  10. package/build/_collections/constants/numbers.const.d.ts +32 -0
  11. package/build/_collections/constants/numbers.const.d.ts.map +1 -1
  12. package/build/_collections/constants/numbers.const.js +32 -0
  13. package/build/_collections/constants/numbers.const.js.map +1 -1
  14. package/build/_collections/constants/times.const.d.ts +31 -0
  15. package/build/_collections/constants/times.const.d.ts.map +1 -1
  16. package/build/_collections/constants/times.const.js +31 -0
  17. package/build/_collections/constants/times.const.js.map +1 -1
  18. package/build/_collections/utils/array.util.d.ts +136 -7
  19. package/build/_collections/utils/array.util.d.ts.map +1 -1
  20. package/build/_collections/utils/array.util.js +132 -2
  21. package/build/_collections/utils/array.util.js.map +1 -1
  22. package/build/_collections/utils/array.util.spec.js.map +1 -1
  23. package/build/_collections/utils/log.util.d.ts +123 -0
  24. package/build/_collections/utils/log.util.d.ts.map +1 -1
  25. package/build/_collections/utils/log.util.js +123 -0
  26. package/build/_collections/utils/log.util.js.map +1 -1
  27. package/build/_collections/utils/math/box-bounds.spec.js +2 -5
  28. package/build/_collections/utils/math/box-bounds.spec.js.map +1 -1
  29. package/build/_collections/utils/math/box-bounds.util.d.ts +52 -6
  30. package/build/_collections/utils/math/box-bounds.util.d.ts.map +1 -1
  31. package/build/_collections/utils/math/box-bounds.util.js +57 -5
  32. package/build/_collections/utils/math/box-bounds.util.js.map +1 -1
  33. package/build/_collections/utils/math/box-bounds.util.spec.js +1 -1
  34. package/build/_collections/utils/math/box-bounds.util.spec.js.map +1 -1
  35. package/build/_collections/utils/math/math.util.d.ts +30 -0
  36. package/build/_collections/utils/math/math.util.d.ts.map +1 -1
  37. package/build/_collections/utils/math/math.util.js +30 -0
  38. package/build/_collections/utils/math/math.util.js.map +1 -1
  39. package/build/_collections/utils/math/random.util.d.ts +19 -2
  40. package/build/_collections/utils/math/random.util.d.ts.map +1 -1
  41. package/build/_collections/utils/math/random.util.js +22 -0
  42. package/build/_collections/utils/math/random.util.js.map +1 -1
  43. package/build/_collections/utils/math/random.util.spec.js.map +1 -1
  44. package/build/_collections/utils/math/vector2.util.d.ts +142 -20
  45. package/build/_collections/utils/math/vector2.util.d.ts.map +1 -1
  46. package/build/_collections/utils/math/vector2.util.js +126 -0
  47. package/build/_collections/utils/math/vector2.util.js.map +1 -1
  48. package/build/_collections/utils/round-list.util.d.ts +36 -1
  49. package/build/_collections/utils/round-list.util.d.ts.map +1 -1
  50. package/build/_collections/utils/round-list.util.js +35 -0
  51. package/build/_collections/utils/round-list.util.js.map +1 -1
  52. package/build/_collections/utils/shared.util.js.map +1 -1
  53. package/build/_collections/utils/stack.util.js +3 -3
  54. package/build/_collections/utils/stack.util.js.map +1 -1
  55. package/build/_collections/utils/string.util.d.ts +8 -1
  56. package/build/_collections/utils/string.util.d.ts.map +1 -1
  57. package/build/_collections/utils/string.util.js +8 -1
  58. package/build/_collections/utils/string.util.js.map +1 -1
  59. package/build/_collections/utils/time.util.d.ts +29 -0
  60. package/build/_collections/utils/time.util.d.ts.map +1 -1
  61. package/build/_collections/utils/time.util.js +29 -0
  62. package/build/_collections/utils/time.util.js.map +1 -1
  63. package/build/_collections/utils/type-cloning-facility.util.d.ts +29 -3
  64. package/build/_collections/utils/type-cloning-facility.util.d.ts.map +1 -1
  65. package/build/_collections/utils/type-cloning-facility.util.js +53 -3
  66. package/build/_collections/utils/type-cloning-facility.util.js.map +1 -1
  67. package/build/_collections/utils/utilities.util.d.ts +49 -2
  68. package/build/_collections/utils/utilities.util.d.ts.map +1 -1
  69. package/build/_collections/utils/utilities.util.js +53 -1
  70. package/build/_collections/utils/utilities.util.js.map +1 -1
  71. package/build/_collections/utils/utilities.util.spec.js.map +1 -1
  72. package/build/_collections/utils/uuid.util.d.ts +5 -0
  73. package/build/_collections/utils/uuid.util.d.ts.map +1 -1
  74. package/build/_collections/utils/uuid.util.js +5 -0
  75. package/build/_collections/utils/uuid.util.js.map +1 -1
  76. package/build/_enums/basic-property-type.enum.d.ts +8 -0
  77. package/build/_enums/basic-property-type.enum.d.ts.map +1 -1
  78. package/build/_enums/basic-property-type.enum.js +8 -0
  79. package/build/_enums/basic-property-type.enum.js.map +1 -1
  80. package/build/_enums/data-model-type.enum.d.ts +8 -4
  81. package/build/_enums/data-model-type.enum.d.ts.map +1 -1
  82. package/build/_enums/data-model-type.enum.js +8 -4
  83. package/build/_enums/data-model-type.enum.js.map +1 -1
  84. package/build/_enums/environment-flag.enum.d.ts +18 -0
  85. package/build/_enums/environment-flag.enum.d.ts.map +1 -1
  86. package/build/_enums/environment-flag.enum.js +18 -0
  87. package/build/_enums/environment-flag.enum.js.map +1 -1
  88. package/build/_enums/error-level.enum.d.ts +10 -0
  89. package/build/_enums/error-level.enum.d.ts.map +1 -1
  90. package/build/_enums/error-level.enum.js +10 -0
  91. package/build/_enums/error-level.enum.js.map +1 -1
  92. package/build/_enums/http-call-type.enum.d.ts +6 -2
  93. package/build/_enums/http-call-type.enum.d.ts.map +1 -1
  94. package/build/_enums/http-call-type.enum.js +6 -2
  95. package/build/_enums/http-call-type.enum.js.map +1 -1
  96. package/build/_enums/http-response-type.enum.d.ts +8 -0
  97. package/build/_enums/http-response-type.enum.d.ts.map +1 -1
  98. package/build/_enums/http-response-type.enum.js +8 -0
  99. package/build/_enums/http-response-type.enum.js.map +1 -1
  100. package/build/_enums/log-style.enum.d.ts +8 -0
  101. package/build/_enums/log-style.enum.d.ts.map +1 -1
  102. package/build/_enums/log-style.enum.js +8 -0
  103. package/build/_enums/log-style.enum.js.map +1 -1
  104. package/build/_enums/time/day-of-week.enum.d.ts +13 -1
  105. package/build/_enums/time/day-of-week.enum.d.ts.map +1 -1
  106. package/build/_enums/time/day-of-week.enum.js +13 -1
  107. package/build/_enums/time/day-of-week.enum.js.map +1 -1
  108. package/build/_enums/time/month.enum.d.ts +8 -0
  109. package/build/_enums/time/month.enum.d.ts.map +1 -1
  110. package/build/_enums/time/month.enum.js +8 -0
  111. package/build/_enums/time/month.enum.js.map +1 -1
  112. package/build/_enums/time/relative-date.enum.d.ts +10 -0
  113. package/build/_enums/time/relative-date.enum.d.ts.map +1 -1
  114. package/build/_enums/time/relative-date.enum.js +10 -0
  115. package/build/_enums/time/relative-date.enum.js.map +1 -1
  116. package/build/_models/control-models/data-model-params.control-model.d.ts +4 -4
  117. package/build/_models/control-models/data-model-params.control-model.d.ts.map +1 -1
  118. package/build/_models/control-models/data-model-params.control-model.js.map +1 -1
  119. package/build/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
  120. package/build/_models/control-models/data-property-params.control-model.js.map +1 -1
  121. package/build/_models/control-models/error.control-model.spec.js.map +1 -1
  122. package/build/_models/interfaces/box-bounds.interface.d.ts +8 -0
  123. package/build/_models/interfaces/box-bounds.interface.d.ts.map +1 -0
  124. package/build/_models/interfaces/box-bounds.interface.js +3 -0
  125. package/build/_models/interfaces/box-bounds.interface.js.map +1 -0
  126. package/build/_models/interfaces/environment/global-settings.interface.d.ts +1 -0
  127. package/build/_models/interfaces/environment/global-settings.interface.d.ts.map +1 -1
  128. package/build/_models/interfaces/route-settings.interface.d.ts +6 -1
  129. package/build/_models/interfaces/route-settings.interface.d.ts.map +1 -1
  130. package/build/_modules/crypto/_collections/crypto.util.d.ts +11 -17
  131. package/build/_modules/crypto/_collections/crypto.util.d.ts.map +1 -1
  132. package/build/_modules/crypto/_collections/crypto.util.js +74 -58
  133. package/build/_modules/crypto/_collections/crypto.util.js.map +1 -1
  134. package/build/_modules/crypto/_collections/crypto.util.spec.js +390 -0
  135. package/build/_modules/crypto/_collections/crypto.util.spec.js.map +1 -1
  136. package/build/_modules/custom-data/_collections/cud-module-settings.const.d.ts +6 -0
  137. package/build/_modules/custom-data/_collections/cud-module-settings.const.d.ts.map +1 -1
  138. package/build/_modules/custom-data/_collections/cud-module-settings.const.js +6 -0
  139. package/build/_modules/custom-data/_collections/cud-module-settings.const.js.map +1 -1
  140. package/build/_modules/custom-data/_models/cud.data-model.d.ts +3 -0
  141. package/build/_modules/custom-data/_models/cud.data-model.d.ts.map +1 -1
  142. package/build/_modules/custom-data/_models/cud.data-model.js +3 -0
  143. package/build/_modules/custom-data/_models/cud.data-model.js.map +1 -1
  144. package/build/_modules/location/_collections/loc-country-divisions.const.d.ts +1 -0
  145. package/build/_modules/location/_collections/loc-country-divisions.const.d.ts.map +1 -1
  146. package/build/_modules/location/_collections/loc-country-divisions.const.js +1 -0
  147. package/build/_modules/location/_collections/loc-country-divisions.const.js.map +1 -1
  148. package/build/_modules/location/_collections/loc-regions.util.d.ts +4 -0
  149. package/build/_modules/location/_collections/loc-regions.util.d.ts.map +1 -1
  150. package/build/_modules/location/_collections/loc-regions.util.js +4 -0
  151. package/build/_modules/location/_collections/loc-regions.util.js.map +1 -1
  152. package/build/_modules/location/_collections/loc.util.d.ts +9 -0
  153. package/build/_modules/location/_collections/loc.util.d.ts.map +1 -1
  154. package/build/_modules/location/_collections/loc.util.js +9 -0
  155. package/build/_modules/location/_collections/loc.util.js.map +1 -1
  156. package/build/_modules/location/_enums/loc-region.enum.d.ts +3 -0
  157. package/build/_modules/location/_enums/loc-region.enum.d.ts.map +1 -1
  158. package/build/_modules/location/_enums/loc-region.enum.js +3 -0
  159. package/build/_modules/location/_enums/loc-region.enum.js.map +1 -1
  160. package/build/_modules/location/_enums/loc-sub-region.enum.d.ts +3 -0
  161. package/build/_modules/location/_enums/loc-sub-region.enum.d.ts.map +1 -1
  162. package/build/_modules/location/_enums/loc-sub-region.enum.js +3 -0
  163. package/build/_modules/location/_enums/loc-sub-region.enum.js.map +1 -1
  164. package/build/_modules/location/_enums/loc-subdivision-region-type.enum.d.ts +37 -34
  165. package/build/_modules/location/_enums/loc-subdivision-region-type.enum.d.ts.map +1 -1
  166. package/build/_modules/location/_enums/loc-subdivision-region-type.enum.js +3 -0
  167. package/build/_modules/location/_enums/loc-subdivision-region-type.enum.js.map +1 -1
  168. package/build/_modules/location/_models/loc-coordinates.interface.d.ts +1 -0
  169. package/build/_modules/location/_models/loc-coordinates.interface.d.ts.map +1 -1
  170. package/build/_modules/open-ai/_enums/open-ai-model.enum.d.ts +10 -7
  171. package/build/_modules/open-ai/_enums/open-ai-model.enum.d.ts.map +1 -1
  172. package/build/_modules/open-ai/_enums/open-ai-model.enum.js +3 -0
  173. package/build/_modules/open-ai/_enums/open-ai-model.enum.js.map +1 -1
  174. package/build/_modules/pipe/_enums/pip-range-pipe-setting.enum.d.ts +3 -0
  175. package/build/_modules/pipe/_enums/pip-range-pipe-setting.enum.d.ts.map +1 -1
  176. package/build/_modules/pipe/_enums/pip-range-pipe-setting.enum.js +3 -0
  177. package/build/_modules/pipe/_enums/pip-range-pipe-setting.enum.js.map +1 -1
  178. package/build/_modules/pipe/_enums/pip.enum.d.ts +14 -0
  179. package/build/_modules/pipe/_enums/pip.enum.d.ts.map +1 -1
  180. package/build/_modules/pipe/_enums/pip.enum.js +11 -0
  181. package/build/_modules/pipe/_enums/pip.enum.js.map +1 -1
  182. package/build/_modules/socket/_enums/sck-event-key.enum.d.ts +3 -0
  183. package/build/_modules/socket/_enums/sck-event-key.enum.d.ts.map +1 -1
  184. package/build/_modules/socket/_enums/sck-event-key.enum.js +3 -0
  185. package/build/_modules/socket/_enums/sck-event-key.enum.js.map +1 -1
  186. package/build/_modules/socket/_models/sck-client-params.control-model.d.ts +12 -0
  187. package/build/_modules/socket/_models/sck-client-params.control-model.d.ts.map +1 -1
  188. package/build/_modules/socket/_models/sck-client-params.control-model.js +12 -0
  189. package/build/_modules/socket/_models/sck-client-params.control-model.js.map +1 -1
  190. package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts +12 -1
  191. package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts.map +1 -1
  192. package/build/_modules/socket/_models/sck-socket-event.control-model.js +12 -1
  193. package/build/_modules/socket/_models/sck-socket-event.control-model.js.map +1 -1
  194. package/build/_modules/socket/_services/sck-client.service-base.d.ts +4 -0
  195. package/build/_modules/socket/_services/sck-client.service-base.d.ts.map +1 -1
  196. package/build/_modules/socket/_services/sck-client.service-base.js +4 -0
  197. package/build/_modules/socket/_services/sck-client.service-base.js.map +1 -1
  198. package/build/_modules/test/_collections/tst-module-settings.const.d.ts +9 -0
  199. package/build/_modules/test/_collections/tst-module-settings.const.d.ts.map +1 -1
  200. package/build/_modules/test/_collections/tst-module-settings.const.js +9 -0
  201. package/build/_modules/test/_collections/tst-module-settings.const.js.map +1 -1
  202. package/build/_modules/usage/_models/usg-action.control-model.d.ts +13 -0
  203. package/build/_modules/usage/_models/usg-action.control-model.d.ts.map +1 -1
  204. package/build/_modules/usage/_models/usg-action.control-model.js +13 -0
  205. package/build/_modules/usage/_models/usg-action.control-model.js.map +1 -1
  206. package/build/_modules/usage/_models/usg-daily-usage-data.control-model.d.ts +14 -0
  207. package/build/_modules/usage/_models/usg-daily-usage-data.control-model.d.ts.map +1 -1
  208. package/build/_modules/usage/_models/usg-daily-usage-data.control-model.js +14 -0
  209. package/build/_modules/usage/_models/usg-daily-usage-data.control-model.js.map +1 -1
  210. package/build/_modules/usage/_models/usg-data.control-model.d.ts +16 -0
  211. package/build/_modules/usage/_models/usg-data.control-model.d.ts.map +1 -1
  212. package/build/_modules/usage/_models/usg-data.control-model.js +16 -0
  213. package/build/_modules/usage/_models/usg-data.control-model.js.map +1 -1
  214. package/build/_modules/usage/_models/usg-session.data-model.d.ts +17 -0
  215. package/build/_modules/usage/_models/usg-session.data-model.d.ts.map +1 -1
  216. package/build/_modules/usage/_models/usg-session.data-model.js +17 -0
  217. package/build/_modules/usage/_models/usg-session.data-model.js.map +1 -1
  218. package/build/_modules/usage/_models/usg-session.data-model.spec.js.map +1 -1
  219. package/build/index.d.ts +1 -0
  220. package/build/index.d.ts.map +1 -1
  221. package/build/index.js +1 -0
  222. package/build/index.js.map +1 -1
  223. package/futdevpro-fsm-dynamo-01.10.39.tgz +0 -0
  224. package/package.json +9 -5
  225. package/src/_collections/constants/error-defaults.const.ts +8 -0
  226. package/src/_collections/constants/global-settings.const.ts +12 -2
  227. package/src/_collections/constants/numbers.const.ts +32 -0
  228. package/src/_collections/constants/times.const.ts +37 -0
  229. package/src/_collections/utils/array.util.spec.ts +36 -38
  230. package/src/_collections/utils/array.util.ts +146 -12
  231. package/src/_collections/utils/log.util.ts +126 -2
  232. package/src/_collections/utils/math/box-bounds.spec.ts +8 -13
  233. package/src/_collections/utils/math/box-bounds.util.spec.ts +3 -3
  234. package/src/_collections/utils/math/box-bounds.util.ts +65 -12
  235. package/src/_collections/utils/math/math.util.ts +30 -6
  236. package/src/_collections/utils/math/random.util.spec.ts +7 -7
  237. package/src/_collections/utils/math/random.util.ts +27 -4
  238. package/src/_collections/utils/math/vector2.util.ts +148 -21
  239. package/src/_collections/utils/round-list.util.ts +36 -3
  240. package/src/_collections/utils/shared.util.ts +17 -17
  241. package/src/_collections/utils/stack.util.ts +6 -6
  242. package/src/_collections/utils/string.util.ts +8 -1
  243. package/src/_collections/utils/time.util.ts +37 -2
  244. package/src/_collections/utils/type-cloning-facility.util.ts +57 -8
  245. package/src/_collections/utils/utilities.util.spec.ts +2 -2
  246. package/src/_collections/utils/utilities.util.ts +61 -8
  247. package/src/_collections/utils/uuid.util.ts +5 -0
  248. package/src/_enums/basic-property-type.enum.ts +8 -0
  249. package/src/_enums/data-model-type.enum.ts +11 -6
  250. package/src/_enums/environment-flag.enum.ts +18 -0
  251. package/src/_enums/error-level.enum.ts +10 -0
  252. package/src/_enums/http-call-type.enum.ts +6 -2
  253. package/src/_enums/http-response-type.enum.ts +8 -0
  254. package/src/_enums/log-style.enum.ts +8 -0
  255. package/src/_enums/time/day-of-week.enum.ts +13 -1
  256. package/src/_enums/time/month.enum.ts +8 -0
  257. package/src/_enums/time/relative-date.enum.ts +10 -0
  258. package/src/_models/control-models/data-model-params.control-model.ts +6 -6
  259. package/src/_models/control-models/data-property-params.control-model.ts +1 -1
  260. package/src/_models/control-models/error.control-model.spec.ts +2 -2
  261. package/src/_models/interfaces/box-bounds.interface.ts +8 -0
  262. package/src/_models/interfaces/environment/global-settings.interface.ts +2 -0
  263. package/src/_models/interfaces/route-settings.interface.ts +6 -1
  264. package/src/_modules/crypto/_collections/crypto.util.spec.ts +428 -0
  265. package/src/_modules/crypto/_collections/crypto.util.ts +88 -52
  266. package/src/_modules/custom-data/_collections/cud-module-settings.const.ts +6 -0
  267. package/src/_modules/custom-data/_models/cud.data-model.ts +3 -0
  268. package/src/_modules/location/_collections/loc-country-divisions.const.ts +2 -1
  269. package/src/_modules/location/_collections/loc-regions.util.ts +4 -0
  270. package/src/_modules/location/_collections/loc.util.ts +13 -5
  271. package/src/_modules/location/_enums/loc-region.enum.ts +3 -0
  272. package/src/_modules/location/_enums/loc-sub-region.enum.ts +3 -0
  273. package/src/_modules/location/_enums/loc-subdivision-region-type.enum.ts +37 -34
  274. package/src/_modules/location/_models/loc-coordinates.interface.ts +1 -0
  275. package/src/_modules/open-ai/_enums/open-ai-model.enum.ts +11 -8
  276. package/src/_modules/pipe/_enums/pip-range-pipe-setting.enum.ts +3 -0
  277. package/src/_modules/pipe/_enums/pip.enum.ts +17 -3
  278. package/src/_modules/socket/_enums/sck-event-key.enum.ts +3 -0
  279. package/src/_modules/socket/_models/sck-client-params.control-model.ts +12 -0
  280. package/src/_modules/socket/_models/sck-socket-event.control-model.ts +12 -1
  281. package/src/_modules/socket/_services/sck-client.service-base.ts +4 -0
  282. package/src/_modules/test/_collections/tst-module-settings.const.ts +9 -0
  283. package/src/_modules/usage/_models/usg-action.control-model.ts +13 -0
  284. package/src/_modules/usage/_models/usg-daily-usage-data.control-model.ts +14 -0
  285. package/src/_modules/usage/_models/usg-data.control-model.ts +16 -0
  286. package/src/_modules/usage/_models/usg-session.data-model.spec.ts +2 -1
  287. package/src/_modules/usage/_models/usg-session.data-model.ts +17 -0
  288. package/src/index.ts +1 -0
  289. package/tsconfig.json +1 -0
  290. package/futdevpro-fsm-dynamo-01.10.37.tgz +0 -0
@@ -11,6 +11,10 @@ export type DyFM_L = DyFM_Log;
11
11
  */
12
12
  export class DyFM_Log {
13
13
 
14
+ /**
15
+ * Sets the style of the console log.
16
+ * @param styles - The styles to set.
17
+ */
14
18
  static setStyle(styles: DyFM_LogStyle[]): void {
15
19
  let styleSets = '';
16
20
 
@@ -20,10 +24,21 @@ export class DyFM_Log {
20
24
 
21
25
  console.log(styleSets);
22
26
  }
27
+
28
+ /**
29
+ * Resets the style of the console log.
30
+ */
23
31
  static resetStyle(): void {
24
32
  console.log(DyFM_LogStyle.reset);
25
33
  }
26
34
 
35
+ /**
36
+ * Adds a style to the console log.
37
+ * @param input - The input to add the style to.
38
+ * @param styles - The styles to add.
39
+ * @param dontReset - Whether to not reset the style.
40
+ * @returns The input with the style added.
41
+ */
27
42
  static addStyle(input: string, styles: DyFM_LogStyle[], dontReset?: boolean): string {
28
43
  let result = '';
29
44
 
@@ -40,6 +55,15 @@ export class DyFM_Log {
40
55
  return result;
41
56
  }
42
57
 
58
+ /**
59
+ * Logs a success message.
60
+ * @param message - The message to log.
61
+ * @param optionalParams - The optional parameters to log.
62
+ *//**
63
+ * Logs a success message.
64
+ * @param message - The message to log.
65
+ * @param optionalParams - The optional parameters to log.
66
+ */
43
67
  static success(message: string, ...optionalParams: any[]): void {
44
68
  if (0 < optionalParams.length) {
45
69
  console.log(
@@ -55,6 +79,11 @@ export class DyFM_Log {
55
79
  */
56
80
  static readonly logSuccess = this.success;
57
81
 
82
+ /**
83
+ * Logs an error message.
84
+ * @param message - The message to log.
85
+ * @param optionalParams - The optional parameters to log.
86
+ */
58
87
  static error(message: string, ...optionalParams: any[]): void {
59
88
  if (0 < optionalParams.length) {
60
89
  console.error(
@@ -70,6 +99,11 @@ export class DyFM_Log {
70
99
  */
71
100
  static readonly logError = this.error;
72
101
 
102
+ /**
103
+ * Logs a warning message.
104
+ * @param message - The message to log.
105
+ * @param optionalParams - The optional parameters to log.
106
+ */
73
107
  static warn(message: string, ...optionalParams: any[]): void {
74
108
  if (0 < optionalParams.length) {
75
109
  console.warn(
@@ -91,20 +125,41 @@ export class DyFM_Log {
91
125
 
92
126
  // ez azért nem egy sima "static readonly info = console.info;",
93
127
  // mert azon nincs rajta az első input típusa, ami csak string lehet
128
+ /**
129
+ * Logs an info message.
130
+ * @param message - The message to log.
131
+ * @param optionalParams - The optional parameters to log.
132
+ */
94
133
  static info(message: string, ...optionalParams: any[]): void {
95
134
  console.info(message, ...optionalParams);
96
135
  }
97
136
 
98
137
  // ez azért nem egy sima "static readonly log = console.log;",
99
138
  // mert azon nincs rajta az első input típusa, ami csak string lehet
139
+ /**
140
+ * Logs a log message.
141
+ * @param message - The message to log.
142
+ * @param optionalParams - The optional parameters to log.
143
+ */
100
144
  static log(message: string, ...optionalParams: any[]): void {
101
145
  console.log(message, ...optionalParams);
102
146
  }
103
147
 
148
+ /**
149
+ * Gets a highlighted message.
150
+ * @param message - The message to highlight.
151
+ * @param optionalParams - The optional parameters to highlight.
152
+ * @returns The highlighted message.
153
+ */
104
154
  static getHighlighted(message: string, ...optionalParams: any[]): string {
105
155
  return `${DyFM_LogStyle.white}${DyFM_LogStyle.bright}${message}${DyFM_LogStyle.reset}`;
106
156
  }
107
157
 
158
+ /**
159
+ * Logs a highlighted message.
160
+ * @param message - The message to highlight.
161
+ * @param optionalParams - The optional parameters to highlight.
162
+ */
108
163
  static highlighted(message: string, ...optionalParams: any[]): void {
109
164
  if (0 < optionalParams.length) {
110
165
  console.log(
@@ -117,6 +172,11 @@ export class DyFM_Log {
117
172
  );
118
173
  }
119
174
  }
175
+ /**
176
+ * Tests a log message.
177
+ * @param message - The message to test.
178
+ * @param optionalParams - The optional parameters to test.
179
+ */
120
180
  static testLog(message: string, ...optionalParams: any[]): void {
121
181
  this.log('\n\n' + this.h_solid + '\n');
122
182
  this.log(message, ...optionalParams);
@@ -124,6 +184,11 @@ export class DyFM_Log {
124
184
  }
125
185
  static readonly test = DyFM_Log.testLog;
126
186
 
187
+ /**
188
+ * Logs a highlighted log message.
189
+ * @param message - The message to highlight.
190
+ * @param optionalParams - The optional parameters to highlight.
191
+ */
127
192
  static highlightedLog(message: string, ...optionalParams: any[]): void {
128
193
  this.log('\n\n' + this.h_before);
129
194
  this.log(' ' + this.h_before);
@@ -135,12 +200,22 @@ export class DyFM_Log {
135
200
  }
136
201
  static readonly H_log = DyFM_Log.highlightedLog;
137
202
 
203
+ /**
204
+ * Tests an info message.
205
+ * @param message - The message to test.
206
+ * @param optionalParams - The optional parameters to test.
207
+ */
138
208
  static testInfo(message: string, ...optionalParams: any[]): void {
139
209
  this.info('\n\n' + this.h_solid + '\n');
140
210
  this.info(message, ...optionalParams);
141
211
  this.info('\n' + this.h_solid + '\n\n');
142
212
  }
143
213
 
214
+ /**
215
+ * Logs a highlighted info message.
216
+ * @param message - The message to highlight.
217
+ * @param optionalParams - The optional parameters to highlight.
218
+ */
144
219
  static highlightedInfo(message: string, ...optionalParams: any[]): void {
145
220
  this.info('\n\n' + this.h_before);
146
221
  this.info(' ' + this.h_before);
@@ -152,12 +227,22 @@ export class DyFM_Log {
152
227
  }
153
228
  static readonly H_info = DyFM_Log.highlightedInfo;
154
229
 
230
+ /**
231
+ * Tests an error message.
232
+ * @param message - The message to test.
233
+ * @param optionalParams - The optional parameters to test.
234
+ */
155
235
  static testError(message: string, ...optionalParams: any[]): void {
156
236
  this.error('\n\n' + this.h_solid + '\n');
157
237
  this.error(message, ...optionalParams);
158
238
  this.error('\n' + this.h_solid + '\n\n');
159
239
  }
160
240
 
241
+ /**
242
+ * Logs a highlighted error message.
243
+ * @param message - The message to highlight.
244
+ * @param optionalParams - The optional parameters to highlight.
245
+ */
161
246
  static highlightedError(message: string, ...optionalParams: any[]): void {
162
247
  this.error('\n\n' + this.h_before);
163
248
  this.error(' ' + this.h_before);
@@ -169,12 +254,22 @@ export class DyFM_Log {
169
254
  }
170
255
  static readonly H_error = DyFM_Log.highlightedError;
171
256
 
257
+ /**
258
+ * Tests a warning message.
259
+ * @param message - The message to test.
260
+ * @param optionalParams - The optional parameters to test.
261
+ */
172
262
  static testWarn(message: string, ...optionalParams: any[]): void {
173
263
  this.warn('\n\n' + this.h_solid + '\n');
174
264
  this.warn(message, ...optionalParams);
175
265
  this.warn('\n' + this.h_solid + '\n\n');
176
266
  }
177
267
 
268
+ /**
269
+ * Logs a highlighted warning message.
270
+ * @param message - The message to highlight.
271
+ * @param optionalParams - The optional parameters to highlight.
272
+ */
178
273
  static highlightedWarn(message: string, ...optionalParams: any[]): void {
179
274
  this.warn('\n\n' + this.h_before);
180
275
  this.warn(' ' + this.h_before);
@@ -186,12 +281,22 @@ export class DyFM_Log {
186
281
  }
187
282
  static readonly H_warn = DyFM_Log.highlightedWarn;
188
283
 
284
+ /**
285
+ * Tests a success message.
286
+ * @param message - The message to test.
287
+ * @param optionalParams - The optional parameters to test.
288
+ */
189
289
  static testSuccess(message: string, ...optionalParams: any[]): void {
190
290
  this.success('\n\n' + this.h_solid + '\n');
191
291
  this.success(message, ...optionalParams);
192
292
  this.success('\n' + this.h_solid + '\n\n');
193
293
  }
194
294
 
295
+ /**
296
+ * Logs a highlighted success message.
297
+ * @param message - The message to highlight.
298
+ * @param optionalParams - The optional parameters to highlight.
299
+ */
195
300
  static highlightedSuccess(message: string, ...optionalParams: any[]): void {
196
301
  this.success('\n\n' + this.h_before);
197
302
  this.success(' ' + this.h_before);
@@ -210,24 +315,38 @@ export class DyFM_Log {
210
315
  // eslint-disable-next-line max-len
211
316
  private static readonly h_after: string = '/////////////////////////////////////////////////////////////////////////////';
212
317
 
318
+ /**
319
+ * Removes the log styles from a message.
320
+ * @param message - The message to remove the styles from.
321
+ * @returns The message without the styles.
322
+ */
213
323
  static removeLogStyles(message: string): string {
214
324
  for (const styleKey of Object(DyFM_LogStyle)) {
215
- message = message.replace(new RegExp(DyFM_LogStyle[styleKey], 'g'), '');
325
+ message = message.replace(new RegExp(DyFM_LogStyle[styleKey as keyof typeof DyFM_LogStyle], 'g'), '');
216
326
  }
217
327
 
218
328
  return message;
219
329
  }
220
330
 
331
+ /**
332
+ * Silences all logs.
333
+ */
221
334
  static silenceLogs(): void {
222
335
  console.log = (): void => {};
223
336
  }
224
337
 
338
+ /**
339
+ * Silences non-error logs.
340
+ */
225
341
  static silenceNonErrorLogs(): void {
226
342
  console.log = (): void => {};
227
343
  console.info = (): void => {};
228
344
  console.warn = (): void => {};
229
345
  }
230
-
346
+
347
+ /**
348
+ * Silences all logs.
349
+ */
231
350
  static silenceConsole(): void {
232
351
  console.log = (): void => {};
233
352
  console.info = (): void => {};
@@ -235,6 +354,11 @@ export class DyFM_Log {
235
354
  console.error = (): void => {};
236
355
  }
237
356
 
357
+ /**
358
+ * Adds breaks and tabs to the string parameters.
359
+ * @param params - The parameters to add the breaks and tabs to.
360
+ * @returns The parameters with the breaks and tabs added.
361
+ */
238
362
  static addBreaksAndTabsToStringParams(params: any[]): any[] {
239
363
  return params.map((param: any): string => {
240
364
  if (typeof param === 'string') {
@@ -1,14 +1,13 @@
1
-
2
- import { DyFM_BoxBounds } from './box-bounds.util';
1
+ import { DyFM_BoxBounds_Util } from './box-bounds.util';
3
2
  import { DyFM_Vector2_Util } from './vector2.util';
4
3
 
5
4
  xdescribe('| DyFM_BoxBounds', () => {
6
- let boxBounds: DyFM_BoxBounds;
5
+ let boxBounds: DyFM_BoxBounds_Util;
7
6
  const mockPosition = new DyFM_Vector2_Util({ x: 0, y: 0 });
8
7
  const mockSize = new DyFM_Vector2_Util({ x: 10, y: 10 });
9
8
 
10
9
  beforeEach(() => {
11
- boxBounds = new DyFM_BoxBounds(mockPosition, mockSize);
10
+ boxBounds = new DyFM_BoxBounds_Util(mockPosition, mockSize);
12
11
  });
13
12
 
14
13
  it('| should set position correctly ()', () => {
@@ -39,15 +38,11 @@ xdescribe('| DyFM_BoxBounds', () => {
39
38
 
40
39
  it('| should calculate center correctly', () => {
41
40
  const expectedCenter = new DyFM_Vector2_Util({ x: 10, y: 10 });
42
-
43
- boxBounds['calcCenter']();
44
41
  expect(boxBounds.center).toEqual(expectedCenter);
45
42
  });
46
43
 
47
44
  it('| should calculate center margin correctly', () => {
48
45
  const expectedCenterMargin = new DyFM_Vector2_Util({ x: -5, y: -5 });
49
-
50
- boxBounds['calcCenter']();
51
46
  expect(boxBounds.centerMargin).toEqual(expectedCenterMargin);
52
47
  });
53
48
 
@@ -57,23 +52,23 @@ xdescribe('| DyFM_BoxBounds', () => {
57
52
 
58
53
  it('| should throw error when newValues has undefined position', () => {
59
54
  expect(() => {
60
- boxBounds.newValues(undefined, { x: 10, y: 10 });
55
+ boxBounds.newValues(undefined as any, { x: 10, y: 10 });
61
56
  }).toThrow(Error);
62
57
  });
63
58
 
64
59
  it('| should throw error when newValues has undefined size', () => {
65
60
  expect(() => {
66
- boxBounds.newValues({ x: 0, y: 0 }, undefined);
61
+ boxBounds.newValues({ x: 0, y: 0 }, undefined as any);
67
62
  }).toThrow(Error);
68
63
  });
69
64
 
70
65
  it('| should clone and return a new instance', () => {
71
66
  const clonedBoxBounds = boxBounds.clone();
72
67
 
73
- expect(clonedBoxBounds).toBeInstanceOf(DyFM_BoxBounds);
68
+ expect(clonedBoxBounds).toBeInstanceOf(DyFM_BoxBounds_Util);
74
69
  expect(clonedBoxBounds).toEqual(boxBounds);
75
70
  });
76
-
77
- // Add more test cases as needed
71
+
72
+
78
73
 
79
74
  });
@@ -1,15 +1,15 @@
1
1
 
2
- import { DyFM_BoxBounds } from './box-bounds.util';
2
+ import { DyFM_BoxBounds_Util } from './box-bounds.util';
3
3
  import { DyFM_Vector2_Util } from './vector2.util';
4
4
  import { DyFM_Vector2 } from '../../../_models/interfaces/vector2.interface';
5
5
 
6
6
  describe('| DyFM_BoxBounds', () => {
7
- let boxBounds: DyFM_BoxBounds;
7
+ let boxBounds: DyFM_BoxBounds_Util;
8
8
  const position: DyFM_Vector2 = { x: 10, y: 20 };
9
9
  const size: DyFM_Vector2 = { x: 30, y: 40 };
10
10
 
11
11
  beforeEach(() => {
12
- boxBounds = new DyFM_BoxBounds(position, size);
12
+ boxBounds = new DyFM_BoxBounds_Util(position, size);
13
13
  });
14
14
 
15
15
  it('| should initialize with given position and size', () => {
@@ -1,5 +1,6 @@
1
1
 
2
2
 
3
+ import { DyFM_BoxBounds } from '../../../_models/interfaces/box-bounds.interface';
3
4
  import { DyFM_Vector2 } from '../../../_models/interfaces/vector2.interface';
4
5
  import { DyFM_Vector2_Util } from './vector2.util';
5
6
 
@@ -9,33 +10,53 @@ import { DyFM_Vector2_Util } from './vector2.util';
9
10
  * while instance functions change the current BoxBounds and returns itself.
10
11
  * (if this is not true, report it as a bug)
11
12
  */
12
- export class DyFM_BoxBounds {
13
+ export class DyFM_BoxBounds_Util {
13
14
  private readonly _pos: DyFM_Vector2_Util;
15
+ /**
16
+ * setting the position will also recalculate the center and centerMargin
17
+ */
14
18
  set pos(value: DyFM_Vector2) {
15
19
  this._pos.newValues(value);
16
20
 
17
21
  this.calcCenter();
18
22
  }
23
+ /**
24
+ * getting the position will return the position as a DyFM_Vector2_Util
25
+ */
19
26
  get pos(): DyFM_Vector2_Util {
20
27
  return this._pos;
21
28
  }
22
29
 
23
30
  private readonly _size: DyFM_Vector2_Util;
31
+ /**
32
+ * setting the size will also recalculate the center and centerMargin
33
+ */
24
34
  set size(value: DyFM_Vector2) {
25
35
  this._size.newValues(value);
26
36
 
27
37
  this.calcCenter();
28
38
  }
39
+ /**
40
+ * getting the size will return the size as a DyFM_Vector2_Util
41
+ */
29
42
  get size(): DyFM_Vector2_Util {
30
43
  return this._size;
31
44
  }
32
45
 
33
- private _center: DyFM_Vector2_Util;
46
+ private _center!: DyFM_Vector2_Util;
47
+ /**
48
+ * getting the center will return the center as a DyFM_Vector2_Util
49
+ * (this is calculated from the position and size every time they are set)
50
+ */
34
51
  get center(): DyFM_Vector2_Util {
35
52
  return this._center;
36
53
  }
37
54
 
38
- private _centerMargin: DyFM_Vector2_Util;
55
+ private _centerMargin!: DyFM_Vector2_Util;
56
+ /**
57
+ * getting the centerMargin will return the centerMargin as a DyFM_Vector2_Util
58
+ * (this is calculated from the size every time it is set)
59
+ */
39
60
  get centerMargin(): DyFM_Vector2_Util {
40
61
  return this._centerMargin;
41
62
  }
@@ -52,11 +73,18 @@ export class DyFM_BoxBounds {
52
73
  this.calcCenter();
53
74
  }
54
75
 
55
- constructed?(): boolean {
76
+ /**
77
+ * returns true if the box bounds has been constructed
78
+ */
79
+ constructed(): boolean {
56
80
  return true;
57
81
  }
58
82
 
59
- newValues?(position: DyFM_Vector2, size: DyFM_Vector2): void {
83
+ /**
84
+ * sets the position and size of the box bounds
85
+ * (this will also recalculate the center and centerMargin)
86
+ */
87
+ newValues(position: DyFM_Vector2, size: DyFM_Vector2): void {
60
88
  if (position === undefined) {
61
89
  throw new Error('new position is undefined!');
62
90
  }
@@ -71,24 +99,49 @@ export class DyFM_BoxBounds {
71
99
  this.calcCenter();
72
100
  }
73
101
 
74
- static bounds(box: DyFM_BoxBounds, position: DyFM_Vector2): boolean {
102
+ /**
103
+ * returns true if the position is within the box bounds
104
+ */
105
+ static bounds(box: DyFM_BoxBounds_Util, position: DyFM_Vector2): boolean {
75
106
  return box.pos.x <= position.x && position.x <= box.pos.x + box.size.x &&
76
107
  box.pos.y <= position.y && position.y <= box.pos.y + box.size.y;
77
108
  }
78
- bounds?(position: DyFM_Vector2): boolean {
79
- return DyFM_BoxBounds.bounds(this, position);
109
+ /**
110
+ * returns true if the position is within the box bounds
111
+ */
112
+ bounds(position: DyFM_Vector2): boolean {
113
+ return DyFM_BoxBounds_Util.bounds(this, position);
80
114
  }
81
115
 
82
- private calcCenter?(): void {
116
+ /**
117
+ * calculates the center and centerMargin of the box bounds
118
+ */
119
+ private calcCenter(): void {
83
120
  const halfSize = DyFM_Vector2_Util.divide(this.size, 2);
84
121
 
85
122
  this._center = DyFM_Vector2_Util.plus(this.pos, halfSize);
86
123
  this._centerMargin = DyFM_Vector2_Util.negative(halfSize);
87
124
  }
88
125
 
89
- clone?(): DyFM_BoxBounds {
90
- return new DyFM_BoxBounds(this._pos.clone(), this._size.clone());
126
+ /**
127
+ * returns the box bounds as a DyFM_BoxBounds
128
+ */
129
+ get(): DyFM_BoxBounds {
130
+ return {
131
+ pos: this._pos.get(),
132
+ size: this._size.get(),
133
+ center: this._center.get(),
134
+ centerMargin: this._centerMargin.get()
135
+ };
136
+ }
137
+ getBoxBounds = this.get;
138
+ toBoxBounds = this.get;
139
+
140
+ /**
141
+ * returns a new DyFM_BoxBounds_Util with the same position and size
142
+ */
143
+ clone(): DyFM_BoxBounds_Util {
144
+ return new DyFM_BoxBounds_Util(this._pos.clone(), this._size.clone());
91
145
  }
92
146
  }
93
147
 
94
-
@@ -1,27 +1,36 @@
1
1
 
2
2
 
3
3
 
4
-
5
-
6
-
7
-
8
-
9
-
4
+ /**
5
+ * this class is a collection of static methods for mathematical operations
6
+ */
10
7
  export class DyFM_Math {
11
8
 
9
+ /**
10
+ * returns true if the value is between the min and max
11
+ */
12
12
  static between(value: number, minExclusive: number, maxExclusive: number): boolean {
13
13
  return minExclusive < value && value < maxExclusive;
14
14
  }
15
15
 
16
+ /**
17
+ * returns true if the value is between the target and the range
18
+ */
16
19
  static around(value: number, target: number, range: number): boolean {
17
20
  return this.between(value, target - range, target + range);
18
21
  }
19
22
 
23
+ /**
24
+ * returns a random integer between the min and max
25
+ */
20
26
  static getRandomInt(min: number, max: number): number {
21
27
  return min + Math.round((max - min) * Math.random());
22
28
  }
23
29
 
24
30
  static readonly toFixed = this.round;
31
+ /**
32
+ * returns a number rounded to the specified number of decimals
33
+ */
25
34
  static round(value: number, decimals: number = 2): number {
26
35
  if (0 <= decimals) {
27
36
  return Number(value.toFixed(decimals));
@@ -32,10 +41,16 @@ export class DyFM_Math {
32
41
  }
33
42
  }
34
43
 
44
+ /**
45
+ * returns a number with spaces between the thousands
46
+ */
35
47
  static numberWithSpaces(x: number): string {
36
48
  return x?.toString()?.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
37
49
  }
38
50
 
51
+ /**
52
+ * returns a number with shorter units
53
+ */
39
54
  static numberWithShorters(x: number): string {
40
55
  if (x < 1000) {
41
56
  return x?.toString();
@@ -48,10 +63,16 @@ export class DyFM_Math {
48
63
  }
49
64
  }
50
65
 
66
+ /**
67
+ * returns a number with shorter units and spaces between the thousands
68
+ */
51
69
  static numberWithShortersAndSpaces(x: number): string {
52
70
  return this.numberWithShorters(x)?.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
53
71
  }
54
72
 
73
+ /**
74
+ * returns a number with spaces between the thousands
75
+ */
55
76
  static floatingNumberWithSpaces(x: number): string {
56
77
  const parts: string[] = x?.toString()?.split('.');
57
78
 
@@ -60,6 +81,9 @@ export class DyFM_Math {
60
81
  return parts?.join('.');
61
82
  }
62
83
 
84
+ /**
85
+ * returns a number with spaces between the thousands
86
+ */
63
87
  static decimals(x: number, useSpacer: string = ','): string {
64
88
  const parts: string[] = x?.toString()?.split('.');
65
89
 
@@ -50,14 +50,14 @@ describe('| DyFM_Random', () => {
50
50
 
51
51
  describe('| getRandomListElement', () => {
52
52
  it('| should return a random element from the list', () => {
53
- const list = [1, 2, 3, 4, 5];
54
- const result = DyFM_Random.getRandomListElement(list);
55
- expect(list).toContain(result);
53
+ const list: number[] = [1, 2, 3, 4, 5];
54
+ const result: number | null = DyFM_Random.getRandomListElement(list);
55
+ expect(list).toContain(result as number);
56
56
  });
57
57
 
58
58
  it('| should return null if the list is empty', () => {
59
59
  const list: number[] = [];
60
- const result = DyFM_Random.getRandomListElement(list);
60
+ const result: number | null = DyFM_Random.getRandomListElement(list);
61
61
  expect(result).toBeNull();
62
62
  });
63
63
  });
@@ -69,13 +69,13 @@ describe('| DyFM_Random', () => {
69
69
  { chance: 0.5, result: 'b' },
70
70
  { chance: 0.3, result: 'c' }
71
71
  ];
72
- const result = DyFM_Random.getRandomWeighted(weights);
73
- expect(['a', 'b', 'c']).toContain(result);
72
+ const result: string | null = DyFM_Random.getRandomWeighted(weights);
73
+ expect(['a', 'b', 'c']).toContain(result as string);
74
74
  });
75
75
 
76
76
  it('| should return null if weights array is empty', () => {
77
77
  const weights: DyFM_RandomWeight<string>[] = [];
78
- const result = DyFM_Random.getRandomWeighted(weights);
78
+ const result: string | null = DyFM_Random.getRandomWeighted(weights);
79
79
  expect(result).toBeNull();
80
80
  });
81
81
  });
@@ -1,8 +1,15 @@
1
1
 
2
2
 
3
3
  import { DyFM_RandomWeight } from '../../../_models/interfaces/random-weight.interface';
4
+ import { DyFM_Log } from '../log.util';
4
5
 
6
+ /**
7
+ * this class is a collection of static methods for random operations
8
+ */
5
9
  export class DyFM_Random {
10
+ /**
11
+ * returns a random weighted integer between the min and max
12
+ */
6
13
  static getRandomWeightedInt(
7
14
  min: number,
8
15
  max: number,
@@ -18,7 +25,7 @@ export class DyFM_Random {
18
25
  }
19
26
 
20
27
  const randomChance: number = Math.random();
21
- let result: number;
28
+ let result: number | undefined;
22
29
  let chancer = 0;
23
30
 
24
31
  for (let i = 0; i < weights.length && result === undefined; i++) {
@@ -40,7 +47,12 @@ export class DyFM_Random {
40
47
  return min + Math.round((max - min) * Math.random());
41
48
  }
42
49
 
43
- static getRandomListElement<T>(list: T[]): T {
50
+ /**
51
+ * returns null if list is empty
52
+ * @param list
53
+ * @returns
54
+ */
55
+ static getRandomListElement<T>(list: T[]): T | null {
44
56
  if (0 < list.length) {
45
57
  return list[this.getRandomInt(0, list.length - 1)];
46
58
  } else {
@@ -48,7 +60,13 @@ export class DyFM_Random {
48
60
  }
49
61
  }
50
62
 
51
- static getRandomWeighted<T>(weights: DyFM_RandomWeight<T>[]): T {
63
+ /**
64
+ * returns a random weighted element from the list
65
+ * (returns null if list is empty)
66
+ * @param weights
67
+ * @returns
68
+ */
69
+ static getRandomWeighted<T>(weights: DyFM_RandomWeight<T>[]): T | null {
52
70
  if (!weights?.length) {
53
71
  return null;
54
72
  }
@@ -64,7 +82,7 @@ export class DyFM_Random {
64
82
  });
65
83
 
66
84
  const randomChance: number = Math.random();
67
- let result: T;
85
+ let result: T | undefined;
68
86
  let chancer = 0;
69
87
 
70
88
  for (let i = 0; i < weights.length && result === undefined; i++) {
@@ -74,6 +92,11 @@ export class DyFM_Random {
74
92
  result = weights[i].result;
75
93
  }
76
94
  }
95
+
96
+ if (result === undefined) {
97
+ DyFM_Log.error('DyFM_Random failed to get a random weighted element from the list');
98
+ return null;
99
+ }
77
100
 
78
101
  return result;
79
102
  }