@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.
- package/.github/workflows/main.yml +11 -51
- package/build/_collections/constants/error-defaults.const.d.ts +8 -0
- package/build/_collections/constants/error-defaults.const.d.ts.map +1 -1
- package/build/_collections/constants/error-defaults.const.js +8 -0
- package/build/_collections/constants/error-defaults.const.js.map +1 -1
- package/build/_collections/constants/global-settings.const.d.ts +8 -0
- package/build/_collections/constants/global-settings.const.d.ts.map +1 -1
- package/build/_collections/constants/global-settings.const.js +9 -0
- package/build/_collections/constants/global-settings.const.js.map +1 -1
- package/build/_collections/constants/numbers.const.d.ts +32 -0
- package/build/_collections/constants/numbers.const.d.ts.map +1 -1
- package/build/_collections/constants/numbers.const.js +32 -0
- package/build/_collections/constants/numbers.const.js.map +1 -1
- package/build/_collections/constants/times.const.d.ts +31 -0
- package/build/_collections/constants/times.const.d.ts.map +1 -1
- package/build/_collections/constants/times.const.js +31 -0
- package/build/_collections/constants/times.const.js.map +1 -1
- package/build/_collections/utils/array.util.d.ts +136 -7
- package/build/_collections/utils/array.util.d.ts.map +1 -1
- package/build/_collections/utils/array.util.js +132 -2
- package/build/_collections/utils/array.util.js.map +1 -1
- package/build/_collections/utils/array.util.spec.js.map +1 -1
- package/build/_collections/utils/log.util.d.ts +123 -0
- package/build/_collections/utils/log.util.d.ts.map +1 -1
- package/build/_collections/utils/log.util.js +123 -0
- package/build/_collections/utils/log.util.js.map +1 -1
- package/build/_collections/utils/math/box-bounds.spec.js +2 -5
- package/build/_collections/utils/math/box-bounds.spec.js.map +1 -1
- package/build/_collections/utils/math/box-bounds.util.d.ts +52 -6
- package/build/_collections/utils/math/box-bounds.util.d.ts.map +1 -1
- package/build/_collections/utils/math/box-bounds.util.js +57 -5
- package/build/_collections/utils/math/box-bounds.util.js.map +1 -1
- package/build/_collections/utils/math/box-bounds.util.spec.js +1 -1
- package/build/_collections/utils/math/box-bounds.util.spec.js.map +1 -1
- package/build/_collections/utils/math/math.util.d.ts +30 -0
- package/build/_collections/utils/math/math.util.d.ts.map +1 -1
- package/build/_collections/utils/math/math.util.js +30 -0
- package/build/_collections/utils/math/math.util.js.map +1 -1
- package/build/_collections/utils/math/random.util.d.ts +19 -2
- package/build/_collections/utils/math/random.util.d.ts.map +1 -1
- package/build/_collections/utils/math/random.util.js +22 -0
- package/build/_collections/utils/math/random.util.js.map +1 -1
- package/build/_collections/utils/math/random.util.spec.js.map +1 -1
- package/build/_collections/utils/math/vector2.util.d.ts +142 -20
- package/build/_collections/utils/math/vector2.util.d.ts.map +1 -1
- package/build/_collections/utils/math/vector2.util.js +126 -0
- package/build/_collections/utils/math/vector2.util.js.map +1 -1
- package/build/_collections/utils/round-list.util.d.ts +36 -1
- package/build/_collections/utils/round-list.util.d.ts.map +1 -1
- package/build/_collections/utils/round-list.util.js +35 -0
- package/build/_collections/utils/round-list.util.js.map +1 -1
- package/build/_collections/utils/shared.util.js.map +1 -1
- package/build/_collections/utils/stack.util.js +3 -3
- package/build/_collections/utils/stack.util.js.map +1 -1
- package/build/_collections/utils/string.util.d.ts +8 -1
- package/build/_collections/utils/string.util.d.ts.map +1 -1
- package/build/_collections/utils/string.util.js +8 -1
- package/build/_collections/utils/string.util.js.map +1 -1
- package/build/_collections/utils/time.util.d.ts +29 -0
- package/build/_collections/utils/time.util.d.ts.map +1 -1
- package/build/_collections/utils/time.util.js +29 -0
- package/build/_collections/utils/time.util.js.map +1 -1
- package/build/_collections/utils/type-cloning-facility.util.d.ts +29 -3
- package/build/_collections/utils/type-cloning-facility.util.d.ts.map +1 -1
- package/build/_collections/utils/type-cloning-facility.util.js +53 -3
- package/build/_collections/utils/type-cloning-facility.util.js.map +1 -1
- package/build/_collections/utils/utilities.util.d.ts +49 -2
- package/build/_collections/utils/utilities.util.d.ts.map +1 -1
- package/build/_collections/utils/utilities.util.js +53 -1
- package/build/_collections/utils/utilities.util.js.map +1 -1
- package/build/_collections/utils/utilities.util.spec.js.map +1 -1
- package/build/_collections/utils/uuid.util.d.ts +5 -0
- package/build/_collections/utils/uuid.util.d.ts.map +1 -1
- package/build/_collections/utils/uuid.util.js +5 -0
- package/build/_collections/utils/uuid.util.js.map +1 -1
- package/build/_enums/basic-property-type.enum.d.ts +8 -0
- package/build/_enums/basic-property-type.enum.d.ts.map +1 -1
- package/build/_enums/basic-property-type.enum.js +8 -0
- package/build/_enums/basic-property-type.enum.js.map +1 -1
- package/build/_enums/data-model-type.enum.d.ts +8 -4
- package/build/_enums/data-model-type.enum.d.ts.map +1 -1
- package/build/_enums/data-model-type.enum.js +8 -4
- package/build/_enums/data-model-type.enum.js.map +1 -1
- package/build/_enums/environment-flag.enum.d.ts +18 -0
- package/build/_enums/environment-flag.enum.d.ts.map +1 -1
- package/build/_enums/environment-flag.enum.js +18 -0
- package/build/_enums/environment-flag.enum.js.map +1 -1
- package/build/_enums/error-level.enum.d.ts +10 -0
- package/build/_enums/error-level.enum.d.ts.map +1 -1
- package/build/_enums/error-level.enum.js +10 -0
- package/build/_enums/error-level.enum.js.map +1 -1
- package/build/_enums/http-call-type.enum.d.ts +6 -2
- package/build/_enums/http-call-type.enum.d.ts.map +1 -1
- package/build/_enums/http-call-type.enum.js +6 -2
- package/build/_enums/http-call-type.enum.js.map +1 -1
- package/build/_enums/http-response-type.enum.d.ts +8 -0
- package/build/_enums/http-response-type.enum.d.ts.map +1 -1
- package/build/_enums/http-response-type.enum.js +8 -0
- package/build/_enums/http-response-type.enum.js.map +1 -1
- package/build/_enums/log-style.enum.d.ts +8 -0
- package/build/_enums/log-style.enum.d.ts.map +1 -1
- package/build/_enums/log-style.enum.js +8 -0
- package/build/_enums/log-style.enum.js.map +1 -1
- package/build/_enums/time/day-of-week.enum.d.ts +13 -1
- package/build/_enums/time/day-of-week.enum.d.ts.map +1 -1
- package/build/_enums/time/day-of-week.enum.js +13 -1
- package/build/_enums/time/day-of-week.enum.js.map +1 -1
- package/build/_enums/time/month.enum.d.ts +8 -0
- package/build/_enums/time/month.enum.d.ts.map +1 -1
- package/build/_enums/time/month.enum.js +8 -0
- package/build/_enums/time/month.enum.js.map +1 -1
- package/build/_enums/time/relative-date.enum.d.ts +10 -0
- package/build/_enums/time/relative-date.enum.d.ts.map +1 -1
- package/build/_enums/time/relative-date.enum.js +10 -0
- package/build/_enums/time/relative-date.enum.js.map +1 -1
- package/build/_models/control-models/data-model-params.control-model.d.ts +4 -4
- 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.map +1 -1
- 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.map +1 -1
- package/build/_models/control-models/error.control-model.spec.js.map +1 -1
- package/build/_models/interfaces/box-bounds.interface.d.ts +8 -0
- package/build/_models/interfaces/box-bounds.interface.d.ts.map +1 -0
- package/build/_models/interfaces/box-bounds.interface.js +3 -0
- package/build/_models/interfaces/box-bounds.interface.js.map +1 -0
- package/build/_models/interfaces/environment/global-settings.interface.d.ts +1 -0
- package/build/_models/interfaces/environment/global-settings.interface.d.ts.map +1 -1
- package/build/_models/interfaces/route-settings.interface.d.ts +6 -1
- package/build/_models/interfaces/route-settings.interface.d.ts.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.d.ts +11 -17
- package/build/_modules/crypto/_collections/crypto.util.d.ts.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.js +74 -58
- package/build/_modules/crypto/_collections/crypto.util.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.spec.js +390 -0
- package/build/_modules/crypto/_collections/crypto.util.spec.js.map +1 -1
- package/build/_modules/custom-data/_collections/cud-module-settings.const.d.ts +6 -0
- package/build/_modules/custom-data/_collections/cud-module-settings.const.d.ts.map +1 -1
- package/build/_modules/custom-data/_collections/cud-module-settings.const.js +6 -0
- package/build/_modules/custom-data/_collections/cud-module-settings.const.js.map +1 -1
- package/build/_modules/custom-data/_models/cud.data-model.d.ts +3 -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 +3 -0
- package/build/_modules/custom-data/_models/cud.data-model.js.map +1 -1
- package/build/_modules/location/_collections/loc-country-divisions.const.d.ts +1 -0
- package/build/_modules/location/_collections/loc-country-divisions.const.d.ts.map +1 -1
- package/build/_modules/location/_collections/loc-country-divisions.const.js +1 -0
- package/build/_modules/location/_collections/loc-country-divisions.const.js.map +1 -1
- package/build/_modules/location/_collections/loc-regions.util.d.ts +4 -0
- package/build/_modules/location/_collections/loc-regions.util.d.ts.map +1 -1
- package/build/_modules/location/_collections/loc-regions.util.js +4 -0
- package/build/_modules/location/_collections/loc-regions.util.js.map +1 -1
- package/build/_modules/location/_collections/loc.util.d.ts +9 -0
- package/build/_modules/location/_collections/loc.util.d.ts.map +1 -1
- package/build/_modules/location/_collections/loc.util.js +9 -0
- package/build/_modules/location/_collections/loc.util.js.map +1 -1
- package/build/_modules/location/_enums/loc-region.enum.d.ts +3 -0
- package/build/_modules/location/_enums/loc-region.enum.d.ts.map +1 -1
- package/build/_modules/location/_enums/loc-region.enum.js +3 -0
- package/build/_modules/location/_enums/loc-region.enum.js.map +1 -1
- package/build/_modules/location/_enums/loc-sub-region.enum.d.ts +3 -0
- package/build/_modules/location/_enums/loc-sub-region.enum.d.ts.map +1 -1
- package/build/_modules/location/_enums/loc-sub-region.enum.js +3 -0
- package/build/_modules/location/_enums/loc-sub-region.enum.js.map +1 -1
- package/build/_modules/location/_enums/loc-subdivision-region-type.enum.d.ts +37 -34
- package/build/_modules/location/_enums/loc-subdivision-region-type.enum.d.ts.map +1 -1
- package/build/_modules/location/_enums/loc-subdivision-region-type.enum.js +3 -0
- package/build/_modules/location/_enums/loc-subdivision-region-type.enum.js.map +1 -1
- package/build/_modules/location/_models/loc-coordinates.interface.d.ts +1 -0
- package/build/_modules/location/_models/loc-coordinates.interface.d.ts.map +1 -1
- package/build/_modules/open-ai/_enums/open-ai-model.enum.d.ts +10 -7
- package/build/_modules/open-ai/_enums/open-ai-model.enum.d.ts.map +1 -1
- package/build/_modules/open-ai/_enums/open-ai-model.enum.js +3 -0
- package/build/_modules/open-ai/_enums/open-ai-model.enum.js.map +1 -1
- package/build/_modules/pipe/_enums/pip-range-pipe-setting.enum.d.ts +3 -0
- package/build/_modules/pipe/_enums/pip-range-pipe-setting.enum.d.ts.map +1 -1
- package/build/_modules/pipe/_enums/pip-range-pipe-setting.enum.js +3 -0
- package/build/_modules/pipe/_enums/pip-range-pipe-setting.enum.js.map +1 -1
- package/build/_modules/pipe/_enums/pip.enum.d.ts +14 -0
- package/build/_modules/pipe/_enums/pip.enum.d.ts.map +1 -1
- package/build/_modules/pipe/_enums/pip.enum.js +11 -0
- package/build/_modules/pipe/_enums/pip.enum.js.map +1 -1
- package/build/_modules/socket/_enums/sck-event-key.enum.d.ts +3 -0
- package/build/_modules/socket/_enums/sck-event-key.enum.d.ts.map +1 -1
- package/build/_modules/socket/_enums/sck-event-key.enum.js +3 -0
- package/build/_modules/socket/_enums/sck-event-key.enum.js.map +1 -1
- package/build/_modules/socket/_models/sck-client-params.control-model.d.ts +12 -0
- package/build/_modules/socket/_models/sck-client-params.control-model.d.ts.map +1 -1
- package/build/_modules/socket/_models/sck-client-params.control-model.js +12 -0
- package/build/_modules/socket/_models/sck-client-params.control-model.js.map +1 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts +12 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.d.ts.map +1 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.js +12 -1
- package/build/_modules/socket/_models/sck-socket-event.control-model.js.map +1 -1
- package/build/_modules/socket/_services/sck-client.service-base.d.ts +4 -0
- package/build/_modules/socket/_services/sck-client.service-base.d.ts.map +1 -1
- package/build/_modules/socket/_services/sck-client.service-base.js +4 -0
- package/build/_modules/socket/_services/sck-client.service-base.js.map +1 -1
- package/build/_modules/test/_collections/tst-module-settings.const.d.ts +9 -0
- package/build/_modules/test/_collections/tst-module-settings.const.d.ts.map +1 -1
- package/build/_modules/test/_collections/tst-module-settings.const.js +9 -0
- package/build/_modules/test/_collections/tst-module-settings.const.js.map +1 -1
- package/build/_modules/usage/_models/usg-action.control-model.d.ts +13 -0
- package/build/_modules/usage/_models/usg-action.control-model.d.ts.map +1 -1
- package/build/_modules/usage/_models/usg-action.control-model.js +13 -0
- package/build/_modules/usage/_models/usg-action.control-model.js.map +1 -1
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.d.ts +14 -0
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.d.ts.map +1 -1
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.js +14 -0
- package/build/_modules/usage/_models/usg-daily-usage-data.control-model.js.map +1 -1
- package/build/_modules/usage/_models/usg-data.control-model.d.ts +16 -0
- package/build/_modules/usage/_models/usg-data.control-model.d.ts.map +1 -1
- package/build/_modules/usage/_models/usg-data.control-model.js +16 -0
- package/build/_modules/usage/_models/usg-data.control-model.js.map +1 -1
- package/build/_modules/usage/_models/usg-session.data-model.d.ts +17 -0
- package/build/_modules/usage/_models/usg-session.data-model.d.ts.map +1 -1
- package/build/_modules/usage/_models/usg-session.data-model.js +17 -0
- package/build/_modules/usage/_models/usg-session.data-model.js.map +1 -1
- package/build/_modules/usage/_models/usg-session.data-model.spec.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/futdevpro-fsm-dynamo-01.10.39.tgz +0 -0
- package/package.json +9 -5
- package/src/_collections/constants/error-defaults.const.ts +8 -0
- package/src/_collections/constants/global-settings.const.ts +12 -2
- package/src/_collections/constants/numbers.const.ts +32 -0
- package/src/_collections/constants/times.const.ts +37 -0
- package/src/_collections/utils/array.util.spec.ts +36 -38
- package/src/_collections/utils/array.util.ts +146 -12
- package/src/_collections/utils/log.util.ts +126 -2
- package/src/_collections/utils/math/box-bounds.spec.ts +8 -13
- package/src/_collections/utils/math/box-bounds.util.spec.ts +3 -3
- package/src/_collections/utils/math/box-bounds.util.ts +65 -12
- package/src/_collections/utils/math/math.util.ts +30 -6
- package/src/_collections/utils/math/random.util.spec.ts +7 -7
- package/src/_collections/utils/math/random.util.ts +27 -4
- package/src/_collections/utils/math/vector2.util.ts +148 -21
- package/src/_collections/utils/round-list.util.ts +36 -3
- package/src/_collections/utils/shared.util.ts +17 -17
- package/src/_collections/utils/stack.util.ts +6 -6
- package/src/_collections/utils/string.util.ts +8 -1
- package/src/_collections/utils/time.util.ts +37 -2
- package/src/_collections/utils/type-cloning-facility.util.ts +57 -8
- package/src/_collections/utils/utilities.util.spec.ts +2 -2
- package/src/_collections/utils/utilities.util.ts +61 -8
- package/src/_collections/utils/uuid.util.ts +5 -0
- package/src/_enums/basic-property-type.enum.ts +8 -0
- package/src/_enums/data-model-type.enum.ts +11 -6
- package/src/_enums/environment-flag.enum.ts +18 -0
- package/src/_enums/error-level.enum.ts +10 -0
- package/src/_enums/http-call-type.enum.ts +6 -2
- package/src/_enums/http-response-type.enum.ts +8 -0
- package/src/_enums/log-style.enum.ts +8 -0
- package/src/_enums/time/day-of-week.enum.ts +13 -1
- package/src/_enums/time/month.enum.ts +8 -0
- package/src/_enums/time/relative-date.enum.ts +10 -0
- package/src/_models/control-models/data-model-params.control-model.ts +6 -6
- package/src/_models/control-models/data-property-params.control-model.ts +1 -1
- package/src/_models/control-models/error.control-model.spec.ts +2 -2
- package/src/_models/interfaces/box-bounds.interface.ts +8 -0
- package/src/_models/interfaces/environment/global-settings.interface.ts +2 -0
- package/src/_models/interfaces/route-settings.interface.ts +6 -1
- package/src/_modules/crypto/_collections/crypto.util.spec.ts +428 -0
- package/src/_modules/crypto/_collections/crypto.util.ts +88 -52
- package/src/_modules/custom-data/_collections/cud-module-settings.const.ts +6 -0
- package/src/_modules/custom-data/_models/cud.data-model.ts +3 -0
- package/src/_modules/location/_collections/loc-country-divisions.const.ts +2 -1
- package/src/_modules/location/_collections/loc-regions.util.ts +4 -0
- package/src/_modules/location/_collections/loc.util.ts +13 -5
- package/src/_modules/location/_enums/loc-region.enum.ts +3 -0
- package/src/_modules/location/_enums/loc-sub-region.enum.ts +3 -0
- package/src/_modules/location/_enums/loc-subdivision-region-type.enum.ts +37 -34
- package/src/_modules/location/_models/loc-coordinates.interface.ts +1 -0
- package/src/_modules/open-ai/_enums/open-ai-model.enum.ts +11 -8
- package/src/_modules/pipe/_enums/pip-range-pipe-setting.enum.ts +3 -0
- package/src/_modules/pipe/_enums/pip.enum.ts +17 -3
- package/src/_modules/socket/_enums/sck-event-key.enum.ts +3 -0
- package/src/_modules/socket/_models/sck-client-params.control-model.ts +12 -0
- package/src/_modules/socket/_models/sck-socket-event.control-model.ts +12 -1
- package/src/_modules/socket/_services/sck-client.service-base.ts +4 -0
- package/src/_modules/test/_collections/tst-module-settings.const.ts +9 -0
- package/src/_modules/usage/_models/usg-action.control-model.ts +13 -0
- package/src/_modules/usage/_models/usg-daily-usage-data.control-model.ts +14 -0
- package/src/_modules/usage/_models/usg-data.control-model.ts +16 -0
- package/src/_modules/usage/_models/usg-session.data-model.spec.ts +2 -1
- package/src/_modules/usage/_models/usg-session.data-model.ts +17 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +1 -0
- 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:
|
|
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
|
|
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(
|
|
68
|
+
expect(clonedBoxBounds).toBeInstanceOf(DyFM_BoxBounds_Util);
|
|
74
69
|
expect(clonedBoxBounds).toEqual(boxBounds);
|
|
75
70
|
});
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
|
|
72
|
+
|
|
78
73
|
|
|
79
74
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
76
|
+
/**
|
|
77
|
+
* returns true if the box bounds has been constructed
|
|
78
|
+
*/
|
|
79
|
+
constructed(): boolean {
|
|
56
80
|
return true;
|
|
57
81
|
}
|
|
58
82
|
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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
|
-
|
|
90
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|