@futdevpro/fsm-dynamo 1.14.10 → 1.14.11
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.
- package/build/_collections/constants/data-sizes.const.d.ts +3 -3
- package/build/_collections/constants/data-sizes.const.d.ts.map +1 -1
- package/build/_collections/constants/data-sizes.const.js +4 -3
- package/build/_collections/constants/data-sizes.const.js.map +1 -1
- package/build/_collections/utils/array.util.d.ts +189 -0
- package/build/_collections/utils/array.util.d.ts.map +1 -1
- package/build/_collections/utils/array.util.js +189 -0
- package/build/_collections/utils/array.util.js.map +1 -1
- package/build/_collections/utils/async.util.d.ts +29 -0
- package/build/_collections/utils/async.util.d.ts.map +1 -1
- package/build/_collections/utils/async.util.js +40 -0
- package/build/_collections/utils/async.util.js.map +1 -1
- package/build/_collections/utils/json-error-helper.util.d.ts +38 -0
- package/build/_collections/utils/json-error-helper.util.d.ts.map +1 -1
- package/build/_collections/utils/json-error-helper.util.js +38 -0
- package/build/_collections/utils/json-error-helper.util.js.map +1 -1
- package/build/_collections/utils/log.util.d.ts +195 -5
- package/build/_collections/utils/log.util.d.ts.map +1 -1
- package/build/_collections/utils/log.util.js +195 -5
- package/build/_collections/utils/log.util.js.map +1 -1
- package/build/_collections/utils/math/box-bounds.util.d.ts +36 -0
- package/build/_collections/utils/math/box-bounds.util.d.ts.map +1 -1
- package/build/_collections/utils/math/box-bounds.util.js +36 -0
- package/build/_collections/utils/math/box-bounds.util.js.map +1 -1
- package/build/_collections/utils/math/math.util.d.ts +48 -12
- package/build/_collections/utils/math/math.util.d.ts.map +1 -1
- package/build/_collections/utils/math/math.util.js +48 -14
- package/build/_collections/utils/math/math.util.js.map +1 -1
- package/build/_collections/utils/math/math.util.spec.js +0 -9
- package/build/_collections/utils/math/math.util.spec.js.map +1 -1
- package/build/_collections/utils/math/random.util.d.ts +30 -0
- package/build/_collections/utils/math/random.util.d.ts.map +1 -1
- package/build/_collections/utils/math/random.util.js +30 -0
- package/build/_collections/utils/math/random.util.js.map +1 -1
- package/build/_collections/utils/math/trigonometry.util.d.ts +30 -0
- package/build/_collections/utils/math/trigonometry.util.d.ts.map +1 -1
- package/build/_collections/utils/math/trigonometry.util.js +30 -0
- package/build/_collections/utils/math/trigonometry.util.js.map +1 -1
- package/build/_collections/utils/math/vector2.util.d.ts +247 -17
- package/build/_collections/utils/math/vector2.util.d.ts.map +1 -1
- package/build/_collections/utils/math/vector2.util.js +247 -19
- package/build/_collections/utils/math/vector2.util.js.map +1 -1
- package/build/_collections/utils/regex/password-regex.util.d.ts +12 -0
- package/build/_collections/utils/regex/password-regex.util.d.ts.map +1 -1
- package/build/_collections/utils/regex/password-regex.util.js +12 -0
- package/build/_collections/utils/regex/password-regex.util.js.map +1 -1
- package/build/_collections/utils/round-list.util.d.ts +39 -0
- package/build/_collections/utils/round-list.util.d.ts.map +1 -1
- package/build/_collections/utils/round-list.util.js +39 -0
- package/build/_collections/utils/round-list.util.js.map +1 -1
- package/build/_collections/utils/stack.util.d.ts +19 -0
- package/build/_collections/utils/stack.util.d.ts.map +1 -1
- package/build/_collections/utils/stack.util.js +19 -0
- package/build/_collections/utils/stack.util.js.map +1 -1
- package/build/_collections/utils/string.util.d.ts +17 -0
- package/build/_collections/utils/string.util.d.ts.map +1 -1
- package/build/_collections/utils/string.util.js +17 -0
- package/build/_collections/utils/string.util.js.map +1 -1
- package/build/_collections/utils/time.util.d.ts +136 -0
- package/build/_collections/utils/time.util.d.ts.map +1 -1
- package/build/_collections/utils/time.util.js +136 -0
- package/build/_collections/utils/time.util.js.map +1 -1
- package/build/_collections/utils/utilities.util.d.ts +17 -1
- package/build/_collections/utils/utilities.util.d.ts.map +1 -1
- package/build/_collections/utils/utilities.util.js +17 -1
- package/build/_collections/utils/utilities.util.js.map +1 -1
- package/build/_collections/utils/uuid.util.d.ts +6 -0
- package/build/_collections/utils/uuid.util.d.ts.map +1 -1
- package/build/_collections/utils/uuid.util.js +6 -0
- package/build/_collections/utils/uuid.util.js.map +1 -1
- package/build/_enums/data-model-type.enum.d.ts +6 -0
- package/build/_enums/data-model-type.enum.d.ts.map +1 -1
- package/build/_enums/data-model-type.enum.js +6 -0
- package/build/_enums/data-model-type.enum.js.map +1 -1
- package/build/_enums/http/http-call-type.enum.d.ts +8 -0
- package/build/_enums/http/http-call-type.enum.d.ts.map +1 -1
- package/build/_enums/http/http-call-type.enum.js +8 -0
- package/build/_enums/http/http-call-type.enum.js.map +1 -1
- package/build/_enums/http/http-event-type.enum.d.ts +5 -0
- package/build/_enums/http/http-event-type.enum.d.ts.map +1 -1
- package/build/_enums/http/http-event-type.enum.js +5 -0
- package/build/_enums/http/http-event-type.enum.js.map +1 -1
- package/build/_enums/time/day-of-week.enum.d.ts +14 -1
- package/build/_enums/time/day-of-week.enum.d.ts.map +1 -1
- package/build/_enums/time/day-of-week.enum.js +14 -1
- package/build/_enums/time/day-of-week.enum.js.map +1 -1
- package/build/_models/control-models/data-model-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/data-model-params.control-model.js +11 -1
- package/build/_models/control-models/data-model-params.control-model.js.map +1 -1
- package/build/_models/control-models/data-property-params.control-model.d.ts +8 -0
- package/build/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
- package/build/_models/control-models/data-property-params.control-model.js +8 -0
- package/build/_models/control-models/data-property-params.control-model.js.map +1 -1
- package/build/_models/control-models/http/http-error-response.control-model.d.ts +25 -0
- package/build/_models/control-models/http/http-error-response.control-model.d.ts.map +1 -1
- package/build/_models/control-models/http/http-error-response.control-model.js +25 -0
- package/build/_models/control-models/http/http-error-response.control-model.js.map +1 -1
- package/build/_models/control-models/http/http-headers.control-model.d.ts +8 -0
- package/build/_models/control-models/http/http-headers.control-model.d.ts.map +1 -1
- package/build/_models/control-models/http/http-headers.control-model.js +8 -0
- package/build/_models/control-models/http/http-headers.control-model.js.map +1 -1
- package/build/_models/control-models/http/http-response.model-base.d.ts +9 -0
- package/build/_models/control-models/http/http-response.model-base.d.ts.map +1 -1
- package/build/_models/control-models/http/http-response.model-base.js +9 -0
- package/build/_models/control-models/http/http-response.model-base.js.map +1 -1
- package/build/_models/control-models/poll.control-model.d.ts +18 -0
- package/build/_models/control-models/poll.control-model.d.ts.map +1 -1
- package/build/_models/control-models/poll.control-model.js +18 -0
- package/build/_models/control-models/poll.control-model.js.map +1 -1
- package/build/_models/control-models/range-value.control-model.d.ts +141 -0
- package/build/_models/control-models/range-value.control-model.d.ts.map +1 -1
- package/build/_models/control-models/range-value.control-model.js +141 -0
- package/build/_models/control-models/range-value.control-model.js.map +1 -1
- package/build/_models/control-models/server-status.control-model.d.ts +10 -0
- package/build/_models/control-models/server-status.control-model.d.ts.map +1 -1
- package/build/_models/control-models/server-status.control-model.js +10 -0
- package/build/_models/control-models/server-status.control-model.js.map +1 -1
- package/build/_models/control-models/service-endpoint-settings-base.control-model.d.ts +12 -0
- package/build/_models/control-models/service-endpoint-settings-base.control-model.d.ts.map +1 -1
- package/build/_models/control-models/service-endpoint-settings-base.control-model.js +12 -0
- package/build/_models/control-models/service-endpoint-settings-base.control-model.js.map +1 -1
- package/build/_models/data-models/errors.data-model.d.ts +10 -0
- package/build/_models/data-models/errors.data-model.d.ts.map +1 -1
- package/build/_models/data-models/errors.data-model.js +10 -0
- package/build/_models/data-models/errors.data-model.js.map +1 -1
- package/build/_models/data-models/metadata.data-model.d.ts +26 -0
- package/build/_models/data-models/metadata.data-model.d.ts.map +1 -1
- package/build/_models/data-models/metadata.data-model.js +26 -0
- package/build/_models/data-models/metadata.data-model.js.map +1 -1
- package/build/_modules/ci-tools/_models/cit-ci-result-info.data-models.d.ts +23 -0
- package/build/_modules/ci-tools/_models/cit-ci-result-info.data-models.d.ts.map +1 -1
- package/build/_modules/ci-tools/_models/cit-ci-result-info.data-models.js +23 -0
- package/build/_modules/ci-tools/_models/cit-ci-result-info.data-models.js.map +1 -1
- package/build/_modules/custom-data/_models/cud.data-model.d.ts +7 -0
- package/build/_modules/custom-data/_models/cud.data-model.d.ts.map +1 -1
- package/build/_modules/custom-data/_models/cud.data-model.js +7 -0
- package/build/_modules/custom-data/_models/cud.data-model.js.map +1 -1
- package/build/_modules/location/_collections/loc-regions.util.d.ts +33 -0
- package/build/_modules/location/_collections/loc-regions.util.d.ts.map +1 -1
- package/build/_modules/location/_collections/loc-regions.util.js +33 -0
- package/build/_modules/location/_collections/loc-regions.util.js.map +1 -1
- package/build/_modules/location/_collections/loc.util.d.ts +10 -0
- package/build/_modules/location/_collections/loc.util.d.ts.map +1 -1
- package/build/_modules/location/_collections/loc.util.js +10 -0
- package/build/_modules/location/_collections/loc.util.js.map +1 -1
- package/futdevpro-fsm-dynamo-01.14.11.tgz +0 -0
- package/package.json +1 -1
- package/src/_collections/constants/data-sizes.const.ts +4 -4
- package/src/_collections/utils/array.util.ts +189 -0
- package/src/_collections/utils/async.util.ts +40 -0
- package/src/_collections/utils/json-error-helper.util.ts +38 -0
- package/src/_collections/utils/log.util.ts +194 -4
- package/src/_collections/utils/math/box-bounds.util.ts +36 -0
- package/src/_collections/utils/math/math.util.spec.ts +0 -10
- package/src/_collections/utils/math/math.util.ts +48 -16
- package/src/_collections/utils/math/random.util.ts +30 -0
- package/src/_collections/utils/math/trigonometry.util.ts +30 -0
- package/src/_collections/utils/math/vector2.util.ts +254 -24
- package/src/_collections/utils/regex/password-regex.util.ts +12 -0
- package/src/_collections/utils/round-list.util.ts +39 -0
- package/src/_collections/utils/stack.util.ts +19 -0
- package/src/_collections/utils/string.util.ts +17 -0
- package/src/_collections/utils/time.util.ts +136 -0
- package/src/_collections/utils/utilities.util.ts +17 -1
- package/src/_collections/utils/uuid.util.ts +6 -0
- package/src/_enums/data-model-type.enum.ts +6 -0
- package/src/_enums/http/http-call-type.enum.ts +8 -0
- package/src/_enums/http/http-event-type.enum.ts +5 -0
- package/src/_enums/time/day-of-week.enum.ts +14 -1
- package/src/_models/control-models/data-model-params.control-model.ts +11 -1
- package/src/_models/control-models/data-property-params.control-model.ts +8 -0
- package/src/_models/control-models/http/http-error-response.control-model.ts +25 -0
- package/src/_models/control-models/http/http-headers.control-model.ts +8 -0
- package/src/_models/control-models/http/http-response.model-base.ts +9 -0
- package/src/_models/control-models/poll.control-model.ts +18 -0
- package/src/_models/control-models/range-value.control-model.ts +141 -0
- package/src/_models/control-models/server-status.control-model.ts +10 -0
- package/src/_models/control-models/service-endpoint-settings-base.control-model.ts +12 -0
- package/src/_models/data-models/errors.data-model.ts +10 -0
- package/src/_models/data-models/metadata.data-model.ts +27 -0
- package/src/_modules/ci-tools/_models/cit-ci-result-info.data-models.ts +23 -0
- package/src/_modules/custom-data/_models/cud.data-model.ts +7 -0
- package/src/_modules/location/_collections/loc-regions.util.ts +34 -1
- package/src/_modules/location/_collections/loc.util.ts +10 -0
- package/futdevpro-fsm-dynamo-01.14.10.tgz +0 -0
|
@@ -30,6 +30,11 @@ export class DyFM_Log {
|
|
|
30
30
|
/**
|
|
31
31
|
* Sets the style of the console log.
|
|
32
32
|
* @param styles - The styles to set.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* DyFM_Log.setStyle([ DyFM_LogStyle.bold, DyFM_LogStyle.underline ]);
|
|
37
|
+
* ```
|
|
33
38
|
*/
|
|
34
39
|
static setStyle(styles: DyFM_LogStyle[]): void {
|
|
35
40
|
let styleSets = '';
|
|
@@ -43,6 +48,11 @@ export class DyFM_Log {
|
|
|
43
48
|
|
|
44
49
|
/**
|
|
45
50
|
* Resets the style of the console log.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* DyFM_Log.resetStyle();
|
|
55
|
+
* ```
|
|
46
56
|
*/
|
|
47
57
|
static resetStyle(): void {
|
|
48
58
|
console.log(DyFM_LogStyle.reset);
|
|
@@ -54,6 +64,11 @@ export class DyFM_Log {
|
|
|
54
64
|
* @param styles - The styles to add.
|
|
55
65
|
* @param dontReset - Whether to not reset the style.
|
|
56
66
|
* @returns The input with the style added.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const result = DyFM_Log.addStyle('Hello, world!', [ DyFM_LogStyle.bold, DyFM_LogStyle.underline ]);
|
|
71
|
+
* ```
|
|
57
72
|
*/
|
|
58
73
|
static addStyle(input: string, styles: DyFM_LogStyle[], dontReset?: boolean): string {
|
|
59
74
|
let result = '';
|
|
@@ -75,10 +90,11 @@ export class DyFM_Log {
|
|
|
75
90
|
* Logs a success message.
|
|
76
91
|
* @param message - The message to log.
|
|
77
92
|
* @param optionalParams - The optional parameters to log.
|
|
78
|
-
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* DyFM_Log.success('Hello, world!');
|
|
97
|
+
* ```
|
|
82
98
|
*/
|
|
83
99
|
static success(message: string, ...optionalParams: any[]): void {
|
|
84
100
|
if (0 < optionalParams.length) {
|
|
@@ -99,6 +115,11 @@ export class DyFM_Log {
|
|
|
99
115
|
* Logs an error message.
|
|
100
116
|
* @param message - The message to log.
|
|
101
117
|
* @param optionalParams - The optional parameters to log.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* DyFM_Log.error('An error occurred: {errorMessage}', errorMessage);
|
|
122
|
+
* ```
|
|
102
123
|
*/
|
|
103
124
|
static error(message: string, ...optionalParams: any[]): void {
|
|
104
125
|
if (0 < optionalParams.length) {
|
|
@@ -119,6 +140,11 @@ export class DyFM_Log {
|
|
|
119
140
|
* Logs a warning message.
|
|
120
141
|
* @param message - The message to log.
|
|
121
142
|
* @param optionalParams - The optional parameters to log.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* DyFM_Log.warn('A warning occurred: {warningMessage}', warningMessage);
|
|
147
|
+
* ```
|
|
122
148
|
*/
|
|
123
149
|
static warn(message: string, ...optionalParams: any[]): void {
|
|
124
150
|
if (0 < optionalParams.length) {
|
|
@@ -145,6 +171,11 @@ export class DyFM_Log {
|
|
|
145
171
|
* Logs an info message.
|
|
146
172
|
* @param message - The message to log.
|
|
147
173
|
* @param optionalParams - The optional parameters to log.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* DyFM_Log.info('An info message: {infoMessage}', infoMessage);
|
|
178
|
+
* ```
|
|
148
179
|
*/
|
|
149
180
|
static info(message: string, ...optionalParams: any[]): void {
|
|
150
181
|
if (0 < optionalParams.length) {
|
|
@@ -163,6 +194,11 @@ export class DyFM_Log {
|
|
|
163
194
|
* Logs a log message.
|
|
164
195
|
* @param message - The message to log.
|
|
165
196
|
* @param optionalParams - The optional parameters to log.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* DyFM_Log.log('A log message: {logMessage}', logMessage);
|
|
201
|
+
* ```
|
|
166
202
|
*/
|
|
167
203
|
static log(message: string, ...optionalParams: any[]): void {
|
|
168
204
|
console.log(message, ...optionalParams);
|
|
@@ -173,6 +209,12 @@ export class DyFM_Log {
|
|
|
173
209
|
* @param message - The message to highlight.
|
|
174
210
|
* @param optionalParams - The optional parameters to highlight.
|
|
175
211
|
* @returns The highlighted message.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* const highlightedMessage = DyFM_Log.getHighlighted('A highlighted message: {highlightedMessage}', highlightedMessage);
|
|
216
|
+
* console.log(highlightedMessage); // A highlighted message: {highlightedMessage}
|
|
217
|
+
* ```
|
|
176
218
|
*/
|
|
177
219
|
static getHighlighted(message: string, ...optionalParams: any[]): string {
|
|
178
220
|
return `${this.highlightedStyle}${message}${DyFM_LogStyle.reset}`;
|
|
@@ -182,6 +224,11 @@ export class DyFM_Log {
|
|
|
182
224
|
* Logs a highlighted message.
|
|
183
225
|
* @param message - The message to highlight.
|
|
184
226
|
* @param optionalParams - The optional parameters to highlight.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* DyFM_Log.highlighted('A highlighted message: {highlightedMessage}', highlightedMessage);
|
|
231
|
+
* ```
|
|
185
232
|
*/
|
|
186
233
|
static highlighted(message: string, ...optionalParams: any[]): void {
|
|
187
234
|
if (0 < optionalParams.length) {
|
|
@@ -196,6 +243,16 @@ export class DyFM_Log {
|
|
|
196
243
|
}
|
|
197
244
|
}
|
|
198
245
|
|
|
246
|
+
/**
|
|
247
|
+
* Logs a small log message.
|
|
248
|
+
* @param message - The message to log.
|
|
249
|
+
* @param optionalParams - The optional parameters to log.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* DyFM_Log.smallLog('A small log message: {smallLogMessage}', smallLogMessage);
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
199
256
|
static smallLog(message: string, ...optionalParams: any[]): void {
|
|
200
257
|
console.log(
|
|
201
258
|
this.h_small +
|
|
@@ -209,6 +266,11 @@ export class DyFM_Log {
|
|
|
209
266
|
* Tests a log message.
|
|
210
267
|
* @param message - The message to test.
|
|
211
268
|
* @param optionalParams - The optional parameters to test.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* DyFM_Log.testLog('A test log message: {testLogMessage}', testLogMessage);
|
|
273
|
+
* ```
|
|
212
274
|
*/
|
|
213
275
|
static testLog(message: string, ...optionalParams: any[]): void {
|
|
214
276
|
this.log(
|
|
@@ -224,6 +286,11 @@ export class DyFM_Log {
|
|
|
224
286
|
* Logs a highlighted log message.
|
|
225
287
|
* @param message - The message to highlight.
|
|
226
288
|
* @param optionalParams - The optional parameters to highlight.
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```ts
|
|
292
|
+
* DyFM_Log.highlightedLog('A highlighted log message: {highlightedLogMessage}', highlightedLogMessage);
|
|
293
|
+
* ```
|
|
227
294
|
*/
|
|
228
295
|
static highlightedLog(message: string, ...optionalParams: any[]): void {
|
|
229
296
|
this.log(
|
|
@@ -238,6 +305,16 @@ export class DyFM_Log {
|
|
|
238
305
|
}
|
|
239
306
|
static readonly H_log = DyFM_Log.highlightedLog;
|
|
240
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Logs a small info message.
|
|
310
|
+
* @param message - The message to log.
|
|
311
|
+
* @param optionalParams - The optional parameters to log.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* DyFM_Log.smallInfo('A small info message: {smallInfoMessage}', smallInfoMessage);
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
241
318
|
static smallInfo(message: string, ...optionalParams: any[]): void {
|
|
242
319
|
this.info(
|
|
243
320
|
this.h_small +
|
|
@@ -251,6 +328,11 @@ export class DyFM_Log {
|
|
|
251
328
|
* Tests an info message.
|
|
252
329
|
* @param message - The message to test.
|
|
253
330
|
* @param optionalParams - The optional parameters to test.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```ts
|
|
334
|
+
* DyFM_Log.testInfo('A test info message: {testInfoMessage}', testInfoMessage);
|
|
335
|
+
* ```
|
|
254
336
|
*/
|
|
255
337
|
static testInfo(message: string, ...optionalParams: any[]): void {
|
|
256
338
|
this.info(
|
|
@@ -265,6 +347,11 @@ export class DyFM_Log {
|
|
|
265
347
|
* Logs a highlighted info message.
|
|
266
348
|
* @param message - The message to highlight.
|
|
267
349
|
* @param optionalParams - The optional parameters to highlight.
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* DyFM_Log.highlightedInfo('A highlighted info message: {highlightedInfoMessage}', highlightedInfoMessage);
|
|
354
|
+
* ```
|
|
268
355
|
*/
|
|
269
356
|
static highlightedInfo(message: string, ...optionalParams: any[]): void {
|
|
270
357
|
this.info(
|
|
@@ -279,6 +366,16 @@ export class DyFM_Log {
|
|
|
279
366
|
}
|
|
280
367
|
static readonly H_info = DyFM_Log.highlightedInfo;
|
|
281
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Logs a small error message.
|
|
371
|
+
* @param message - The message to log.
|
|
372
|
+
* @param optionalParams - The optional parameters to log.
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```ts
|
|
376
|
+
* DyFM_Log.smallError('A small error message: {smallErrorMessage}', smallErrorMessage);
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
282
379
|
static smallError(message: string, ...optionalParams: any[]): void {
|
|
283
380
|
this.error(
|
|
284
381
|
this.h_small +
|
|
@@ -292,6 +389,11 @@ export class DyFM_Log {
|
|
|
292
389
|
* Tests an error message.
|
|
293
390
|
* @param message - The message to test.
|
|
294
391
|
* @param optionalParams - The optional parameters to test.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```ts
|
|
395
|
+
* DyFM_Log.testError('A test error message: {testErrorMessage}', testErrorMessage);
|
|
396
|
+
* ```
|
|
295
397
|
*/
|
|
296
398
|
static testError(message: string, ...optionalParams: any[]): void {
|
|
297
399
|
this.error(
|
|
@@ -306,6 +408,11 @@ export class DyFM_Log {
|
|
|
306
408
|
* Logs a highlighted error message.
|
|
307
409
|
* @param message - The message to highlight.
|
|
308
410
|
* @param optionalParams - The optional parameters to highlight.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* DyFM_Log.highlightedError('A highlighted error message: {highlightedErrorMessage}', highlightedErrorMessage);
|
|
415
|
+
* ```
|
|
309
416
|
*/
|
|
310
417
|
static highlightedError(message: string, ...optionalParams: any[]): void {
|
|
311
418
|
this.error(
|
|
@@ -320,6 +427,16 @@ export class DyFM_Log {
|
|
|
320
427
|
}
|
|
321
428
|
static readonly H_error = DyFM_Log.highlightedError;
|
|
322
429
|
|
|
430
|
+
/**
|
|
431
|
+
* Logs a small warning message.
|
|
432
|
+
* @param message - The message to log.
|
|
433
|
+
* @param optionalParams - The optional parameters to log.
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* ```ts
|
|
437
|
+
* DyFM_Log.smallWarn('A small warning message: {smallWarnMessage}', smallWarnMessage);
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
323
440
|
static smallWarn(message: string, ...optionalParams: any[]): void {
|
|
324
441
|
this.warn(
|
|
325
442
|
this.h_small +
|
|
@@ -333,6 +450,11 @@ export class DyFM_Log {
|
|
|
333
450
|
* Tests a warning message.
|
|
334
451
|
* @param message - The message to test.
|
|
335
452
|
* @param optionalParams - The optional parameters to test.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```ts
|
|
456
|
+
* DyFM_Log.testWarn('A test warning message: {testWarnMessage}', testWarnMessage);
|
|
457
|
+
* ```
|
|
336
458
|
*/
|
|
337
459
|
static testWarn(message: string, ...optionalParams: any[]): void {
|
|
338
460
|
this.warn(
|
|
@@ -347,6 +469,11 @@ export class DyFM_Log {
|
|
|
347
469
|
* Logs a highlighted warning message.
|
|
348
470
|
* @param message - The message to highlight.
|
|
349
471
|
* @param optionalParams - The optional parameters to highlight.
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```ts
|
|
475
|
+
* DyFM_Log.highlightedWarn('A highlighted warning message: {highlightedWarnMessage}', highlightedWarnMessage);
|
|
476
|
+
* ```
|
|
350
477
|
*/
|
|
351
478
|
static highlightedWarn(message: string, ...optionalParams: any[]): void {
|
|
352
479
|
this.warn(
|
|
@@ -361,6 +488,16 @@ export class DyFM_Log {
|
|
|
361
488
|
}
|
|
362
489
|
static readonly H_warn = DyFM_Log.highlightedWarn;
|
|
363
490
|
|
|
491
|
+
/**
|
|
492
|
+
* Logs a small success message.
|
|
493
|
+
* @param message - The message to log.
|
|
494
|
+
* @param optionalParams - The optional parameters to log.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```ts
|
|
498
|
+
* DyFM_Log.smallSuccess('A small success message: {smallSuccessMessage}', smallSuccessMessage);
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
364
501
|
static smallSuccess(message: string, ...optionalParams: any[]): void {
|
|
365
502
|
this.success(
|
|
366
503
|
this.h_small +
|
|
@@ -374,6 +511,11 @@ export class DyFM_Log {
|
|
|
374
511
|
* Tests a success message.
|
|
375
512
|
* @param message - The message to test.
|
|
376
513
|
* @param optionalParams - The optional parameters to test.
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```ts
|
|
517
|
+
* DyFM_Log.testSuccess('A test success message: {testSuccessMessage}', testSuccessMessage);
|
|
518
|
+
* ```
|
|
377
519
|
*/
|
|
378
520
|
static testSuccess(message: string, ...optionalParams: any[]): void {
|
|
379
521
|
this.success(
|
|
@@ -417,6 +559,11 @@ export class DyFM_Log {
|
|
|
417
559
|
|
|
418
560
|
/**
|
|
419
561
|
* Silences all logs.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```ts
|
|
565
|
+
* DyFM_Log.silenceLogs();
|
|
566
|
+
* ```
|
|
420
567
|
*/
|
|
421
568
|
static silenceLogs(): void {
|
|
422
569
|
console.log = (): void => {};
|
|
@@ -424,6 +571,11 @@ export class DyFM_Log {
|
|
|
424
571
|
|
|
425
572
|
/**
|
|
426
573
|
* Silences non-error logs.
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```ts
|
|
577
|
+
* DyFM_Log.silenceNonErrorLogs();
|
|
578
|
+
* ```
|
|
427
579
|
*/
|
|
428
580
|
static silenceNonErrorLogs(): void {
|
|
429
581
|
console.log = (): void => {};
|
|
@@ -433,6 +585,11 @@ export class DyFM_Log {
|
|
|
433
585
|
|
|
434
586
|
/**
|
|
435
587
|
* Silences all logs.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```ts
|
|
591
|
+
* DyFM_Log.silenceConsole();
|
|
592
|
+
* ```
|
|
436
593
|
*/
|
|
437
594
|
static silenceConsole(): void {
|
|
438
595
|
console.log = (): void => {};
|
|
@@ -445,6 +602,13 @@ export class DyFM_Log {
|
|
|
445
602
|
* Adds breaks and tabs to the string parameters.
|
|
446
603
|
* @param params - The parameters to add the breaks and tabs to.
|
|
447
604
|
* @returns The parameters with the breaks and tabs added.
|
|
605
|
+
*
|
|
606
|
+
* @example
|
|
607
|
+
* ```ts
|
|
608
|
+
* const params = [ 'Hello, world!', 'Hello, world!', 'Hello, world!' ];
|
|
609
|
+
* const result = DyFM_Log.addBreaksAndTabsToStringParams(params);
|
|
610
|
+
* console.log(result); // [ 'Hello, world!', 'Hello, world!', 'Hello, world!' ]
|
|
611
|
+
* ```
|
|
448
612
|
*/
|
|
449
613
|
static addBreaksAndTabsToStringParams(params: any[]): any[] {
|
|
450
614
|
return params.map((param: any): string => {
|
|
@@ -456,11 +620,37 @@ export class DyFM_Log {
|
|
|
456
620
|
});
|
|
457
621
|
}
|
|
458
622
|
|
|
623
|
+
/**
|
|
624
|
+
* Adds spaces for each line.
|
|
625
|
+
* @param message - The message to add the spaces to.
|
|
626
|
+
* @param spaces - The number of spaces to add.
|
|
627
|
+
* @returns The message with the spaces added.
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* ```ts
|
|
631
|
+
* const message = 'Hello, world!\nHello, world!\nHello, world!';
|
|
632
|
+
* const result = DyFM_Log.addSpacesForEachLine(message, 2);
|
|
633
|
+
* console.log(result); // Hello, world! Hello, world! Hello, world!
|
|
634
|
+
* ```
|
|
635
|
+
*/
|
|
459
636
|
static addSpacesForEachLine(message: string, spaces: number): string {
|
|
460
637
|
return message.replaceAll('\n', '\n' + ' '.repeat(spaces));
|
|
461
638
|
}
|
|
462
639
|
private static asfel = this.addSpacesForEachLine;
|
|
463
640
|
|
|
641
|
+
/**
|
|
642
|
+
* Adds spaces for each string optional parameter.
|
|
643
|
+
* @param params - The parameters to add the spaces to.
|
|
644
|
+
* @param spaces - The number of spaces to add.
|
|
645
|
+
* @returns The parameters with the spaces added.
|
|
646
|
+
*
|
|
647
|
+
* @example
|
|
648
|
+
* ```ts
|
|
649
|
+
* const params = [ 'Hello, world!', 'Hello, world!', 'Hello, world!' ];
|
|
650
|
+
* const result = DyFM_Log.addSpacesForEachStringOptionalParam(params, 2);
|
|
651
|
+
* console.log(result); // [ 'Hello, world! Hello, world! Hello, world!' ]
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
464
654
|
static addSpacesForEachStringOptionalParam(params: any[], spaces: number): any[] {
|
|
465
655
|
return params.map((param: any): any => {
|
|
466
656
|
if (typeof param === 'string') {
|
|
@@ -9,6 +9,13 @@ import { DyFM_Vector2_Util } from './vector2.util';
|
|
|
9
9
|
* is that static functions return new BoxBounds,
|
|
10
10
|
* while instance functions change the current BoxBounds and returns itself.
|
|
11
11
|
* (if this is not true, report it as a bug)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const boxBounds = new DyFM_BoxBounds_Util({ x: 0, y: 0 }, { x: 10, y: 10 });
|
|
16
|
+
* boxBounds.pos = { x: 5, y: 5 };
|
|
17
|
+
* console.log(boxBounds.pos);
|
|
18
|
+
* ```
|
|
12
19
|
*/
|
|
13
20
|
export class DyFM_BoxBounds_Util {
|
|
14
21
|
private readonly _pos: DyFM_Vector2_Util;
|
|
@@ -83,6 +90,12 @@ export class DyFM_BoxBounds_Util {
|
|
|
83
90
|
/**
|
|
84
91
|
* sets the position and size of the box bounds
|
|
85
92
|
* (this will also recalculate the center and centerMargin)
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* const boxBounds = new DyFM_BoxBounds_Util({ x: 0, y: 0 }, { x: 10, y: 10 });
|
|
97
|
+
* boxBounds.newValues({ x: 5, y: 5 }, { x: 20, y: 20 });
|
|
98
|
+
* ```
|
|
86
99
|
*/
|
|
87
100
|
newValues(position: DyFM_Vector2, size: DyFM_Vector2): void {
|
|
88
101
|
if (position === undefined) {
|
|
@@ -101,6 +114,14 @@ export class DyFM_BoxBounds_Util {
|
|
|
101
114
|
|
|
102
115
|
/**
|
|
103
116
|
* returns true if the position is within the box bounds
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const boxBounds = new DyFM_BoxBounds_Util({ x: 0, y: 0 }, { x: 10, y: 10 });
|
|
121
|
+
* const position = new DyFM_Vector2({ x: 5, y: 5 });
|
|
122
|
+
* const isWithinBounds = DyFM_BoxBounds_Util.bounds(boxBounds, position);
|
|
123
|
+
* console.log(isWithinBounds);
|
|
124
|
+
* ```
|
|
104
125
|
*/
|
|
105
126
|
static bounds(box: DyFM_BoxBounds_Util, position: DyFM_Vector2): boolean {
|
|
106
127
|
return box.pos.x <= position.x && position.x <= box.pos.x + box.size.x &&
|
|
@@ -108,6 +129,13 @@ export class DyFM_BoxBounds_Util {
|
|
|
108
129
|
}
|
|
109
130
|
/**
|
|
110
131
|
* returns true if the position is within the box bounds
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* const boxBounds = new DyFM_BoxBounds_Util({ x: 0, y: 0 }, { x: 10, y: 10 });
|
|
136
|
+
* const isWithinBounds = boxBounds.bounds(new DyFM_Vector2({ x: 5, y: 5 });
|
|
137
|
+
* console.log(isWithinBounds);
|
|
138
|
+
* ```
|
|
111
139
|
*/
|
|
112
140
|
bounds(position: DyFM_Vector2): boolean {
|
|
113
141
|
return DyFM_BoxBounds_Util.bounds(this, position);
|
|
@@ -115,6 +143,8 @@ export class DyFM_BoxBounds_Util {
|
|
|
115
143
|
|
|
116
144
|
/**
|
|
117
145
|
* calculates the center and centerMargin of the box bounds
|
|
146
|
+
*
|
|
147
|
+
* only usable inside the class
|
|
118
148
|
*/
|
|
119
149
|
private calcCenter(): void {
|
|
120
150
|
const halfSize = DyFM_Vector2_Util.divide(this.size, 2);
|
|
@@ -139,6 +169,12 @@ export class DyFM_BoxBounds_Util {
|
|
|
139
169
|
|
|
140
170
|
/**
|
|
141
171
|
* returns a new DyFM_BoxBounds_Util with the same position and size
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const boxBounds = new DyFM_BoxBounds_Util({ x: 0, y: 0 }, { x: 10, y: 10 });
|
|
176
|
+
* const clonedBoxBounds = boxBounds.clone();
|
|
177
|
+
* ```
|
|
142
178
|
*/
|
|
143
179
|
clone(): DyFM_BoxBounds_Util {
|
|
144
180
|
return new DyFM_BoxBounds_Util(this._pos.clone(), this._size.clone());
|
|
@@ -36,16 +36,6 @@ describe('| DyFM_Math', () => {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
describe('| getRandomInt', () => {
|
|
40
|
-
it('| should return an integer within the specified range', () => {
|
|
41
|
-
const min = 1;
|
|
42
|
-
const max = 10;
|
|
43
|
-
const result = DyFM_Math.getRandomInt(min, max);
|
|
44
|
-
expect(result).toBeGreaterThanOrEqual(min);
|
|
45
|
-
expect(result).toBeLessThanOrEqual(max);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
39
|
describe('| round', () => {
|
|
50
40
|
it('| should round a number to the specified number of decimals', () => {
|
|
51
41
|
expect(DyFM_Math.round(1.2345, 2)).toBe(1.23);
|
|
@@ -8,6 +8,12 @@ export class DyFM_Math {
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* returns true if the value is between the min and max
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const isBetween = DyFM_Math.between(5, 1, 10);
|
|
15
|
+
* console.log(isBetween);
|
|
16
|
+
* ```
|
|
11
17
|
*/
|
|
12
18
|
static between(value: number, minExclusive: number, maxExclusive: number): boolean {
|
|
13
19
|
return minExclusive < value && value < maxExclusive;
|
|
@@ -15,30 +21,26 @@ export class DyFM_Math {
|
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* returns true if the value is between the target and the range
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const isAround = DyFM_Math.around(5, 5, 1);
|
|
28
|
+
* console.log(isAround);
|
|
29
|
+
* ```
|
|
18
30
|
*/
|
|
19
31
|
static around(value: number, target: number, range: number): boolean {
|
|
20
32
|
return this.between(value, target - range, target + range);
|
|
21
33
|
}
|
|
22
34
|
|
|
23
|
-
/**
|
|
24
|
-
* returns a random integer between the min and max
|
|
25
|
-
*/
|
|
26
|
-
static getRandomInt(
|
|
27
|
-
/**
|
|
28
|
-
* the minimum value (inclusive)
|
|
29
|
-
*/
|
|
30
|
-
min: number,
|
|
31
|
-
/**
|
|
32
|
-
* the maximum value (inclusive)
|
|
33
|
-
*/
|
|
34
|
-
max: number
|
|
35
|
-
): number {
|
|
36
|
-
return min + Math.round((max - min) * Math.random());
|
|
37
|
-
}
|
|
38
|
-
|
|
39
35
|
static readonly toFixed = this.round;
|
|
40
36
|
/**
|
|
41
37
|
* returns a number rounded to the specified number of decimals
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const roundedNumber = DyFM_Math.round(1.2345, 2);
|
|
42
|
+
* console.log(roundedNumber); // 1.23
|
|
43
|
+
* ```
|
|
42
44
|
*/
|
|
43
45
|
static round(value: number, decimals: number = 2): number {
|
|
44
46
|
if (0 <= decimals) {
|
|
@@ -52,6 +54,12 @@ export class DyFM_Math {
|
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
56
|
* returns a number with spaces between the thousands
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const numberWithSpaces = DyFM_Math.numberWithSpaces(1000);
|
|
61
|
+
* console.log(numberWithSpaces); // '1 000'
|
|
62
|
+
* ```
|
|
55
63
|
*/
|
|
56
64
|
static numberWithSpaces(x: number): string {
|
|
57
65
|
return x?.toString()?.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
@@ -59,6 +67,12 @@ export class DyFM_Math {
|
|
|
59
67
|
|
|
60
68
|
/**
|
|
61
69
|
* returns a number with shorter units
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const numberWithShorters = DyFM_Math.numberWithShorters(1000);
|
|
74
|
+
* console.log(numberWithShorters); // '1.0k'
|
|
75
|
+
* ```
|
|
62
76
|
*/
|
|
63
77
|
static numberWithShorters(x: number): string {
|
|
64
78
|
if (x < 1000) {
|
|
@@ -74,6 +88,12 @@ export class DyFM_Math {
|
|
|
74
88
|
|
|
75
89
|
/**
|
|
76
90
|
* returns a number with shorter units and spaces between the thousands
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const numberWithShortersAndSpaces = DyFM_Math.numberWithShortersAndSpaces(1000);
|
|
95
|
+
* console.log(numberWithShortersAndSpaces); // '1.0k'
|
|
96
|
+
* ```
|
|
77
97
|
*/
|
|
78
98
|
static numberWithShortersAndSpaces(x: number): string {
|
|
79
99
|
return this.numberWithShorters(x)?.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
@@ -81,6 +101,12 @@ export class DyFM_Math {
|
|
|
81
101
|
|
|
82
102
|
/**
|
|
83
103
|
* returns a number with spaces between the thousands
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const floatingNumberWithSpaces = DyFM_Math.floatingNumberWithSpaces(1234.567);
|
|
108
|
+
* console.log(floatingNumberWithSpaces); // '1 234.567'
|
|
109
|
+
* ```
|
|
84
110
|
*/
|
|
85
111
|
static floatingNumberWithSpaces(x: number): string {
|
|
86
112
|
const parts: string[] = x?.toString()?.split('.');
|
|
@@ -92,6 +118,12 @@ export class DyFM_Math {
|
|
|
92
118
|
|
|
93
119
|
/**
|
|
94
120
|
* returns a number with spaces between the thousands
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const decimals = DyFM_Math.decimals(1234.567, ',');
|
|
125
|
+
* console.log(decimals); // '1,234.567'
|
|
126
|
+
* ```
|
|
95
127
|
*/
|
|
96
128
|
static decimals(x: number, useSpacer: string = ','): string {
|
|
97
129
|
const parts: string[] = x?.toString()?.split('.');
|
|
@@ -9,6 +9,16 @@ import { DyFM_Log } from '../log.util';
|
|
|
9
9
|
export class DyFM_Random {
|
|
10
10
|
/**
|
|
11
11
|
* returns a random weighted integer between the min and max
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const randomWeightedInt = DyFM_Random.getRandomWeightedInt(1, 10, [
|
|
16
|
+
* { chance: 0.1, result: 1 },
|
|
17
|
+
* { chance: 0.3, result: 2 },
|
|
18
|
+
* { chance: 0.6, result: 3 }
|
|
19
|
+
* ]);
|
|
20
|
+
* console.log(randomWeightedInt);
|
|
21
|
+
* ```
|
|
12
22
|
*/
|
|
13
23
|
static getRandomWeightedInt(
|
|
14
24
|
min: number,
|
|
@@ -48,6 +58,12 @@ export class DyFM_Random {
|
|
|
48
58
|
* @param min - the minimum value (inclusive)
|
|
49
59
|
* @param max - the maximum value (inclusive)
|
|
50
60
|
* @returns a random integer between the min and max
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const randomInt = DyFM_Random.getRandomInt(1, 10);
|
|
65
|
+
* console.log(randomInt); // 5
|
|
66
|
+
* ```
|
|
51
67
|
*/
|
|
52
68
|
static getRandomInt(min: number, max: number): number {
|
|
53
69
|
return min + Math.round((max - min) * Math.random());
|
|
@@ -57,6 +73,12 @@ export class DyFM_Random {
|
|
|
57
73
|
* returns null if list is empty
|
|
58
74
|
* @param list
|
|
59
75
|
* @returns
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const randomListElement = DyFM_Random.getRandomListElement([1, 2, 3, 4, 5]);
|
|
80
|
+
* console.log(randomListElement); // 3
|
|
81
|
+
* ```
|
|
60
82
|
*/
|
|
61
83
|
static getRandomListElement<T>(list: T[]): T | null {
|
|
62
84
|
if (0 < list.length) {
|
|
@@ -71,6 +93,14 @@ export class DyFM_Random {
|
|
|
71
93
|
* (returns null if list is empty)
|
|
72
94
|
* @param weights
|
|
73
95
|
* @returns
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const randomWeightedElement = DyFM_Random.getRandomWeighted([
|
|
100
|
+
* { chance: 0.1, result: '1' },
|
|
101
|
+
* { chance: 0.3, result: '2' },
|
|
102
|
+
* { chance: 0.6, result: '3' }
|
|
103
|
+
* ]);
|
|
74
104
|
*/
|
|
75
105
|
static getRandomWeighted<T>(weights: DyFM_RandomWeight<T>[]): T | null {
|
|
76
106
|
if (!weights?.length) {
|