@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
|
@@ -4,47 +4,83 @@
|
|
|
4
4
|
export declare class DyFM_Math {
|
|
5
5
|
/**
|
|
6
6
|
* returns true if the value is between the min and max
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const isBetween = DyFM_Math.between(5, 1, 10);
|
|
11
|
+
* console.log(isBetween);
|
|
12
|
+
* ```
|
|
7
13
|
*/
|
|
8
14
|
static between(value: number, minExclusive: number, maxExclusive: number): boolean;
|
|
9
15
|
/**
|
|
10
16
|
* returns true if the value is between the target and the range
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const isAround = DyFM_Math.around(5, 5, 1);
|
|
21
|
+
* console.log(isAround);
|
|
22
|
+
* ```
|
|
11
23
|
*/
|
|
12
24
|
static around(value: number, target: number, range: number): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* returns a random integer between the min and max
|
|
15
|
-
*/
|
|
16
|
-
static getRandomInt(
|
|
17
|
-
/**
|
|
18
|
-
* the minimum value (inclusive)
|
|
19
|
-
*/
|
|
20
|
-
min: number,
|
|
21
|
-
/**
|
|
22
|
-
* the maximum value (inclusive)
|
|
23
|
-
*/
|
|
24
|
-
max: number): number;
|
|
25
25
|
static readonly toFixed: typeof DyFM_Math.round;
|
|
26
26
|
/**
|
|
27
27
|
* returns a number rounded to the specified number of decimals
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const roundedNumber = DyFM_Math.round(1.2345, 2);
|
|
32
|
+
* console.log(roundedNumber); // 1.23
|
|
33
|
+
* ```
|
|
28
34
|
*/
|
|
29
35
|
static round(value: number, decimals?: number): number;
|
|
30
36
|
/**
|
|
31
37
|
* returns a number with spaces between the thousands
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const numberWithSpaces = DyFM_Math.numberWithSpaces(1000);
|
|
42
|
+
* console.log(numberWithSpaces); // '1 000'
|
|
43
|
+
* ```
|
|
32
44
|
*/
|
|
33
45
|
static numberWithSpaces(x: number): string;
|
|
34
46
|
/**
|
|
35
47
|
* returns a number with shorter units
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const numberWithShorters = DyFM_Math.numberWithShorters(1000);
|
|
52
|
+
* console.log(numberWithShorters); // '1.0k'
|
|
53
|
+
* ```
|
|
36
54
|
*/
|
|
37
55
|
static numberWithShorters(x: number): string;
|
|
38
56
|
/**
|
|
39
57
|
* returns a number with shorter units and spaces between the thousands
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const numberWithShortersAndSpaces = DyFM_Math.numberWithShortersAndSpaces(1000);
|
|
62
|
+
* console.log(numberWithShortersAndSpaces); // '1.0k'
|
|
63
|
+
* ```
|
|
40
64
|
*/
|
|
41
65
|
static numberWithShortersAndSpaces(x: number): string;
|
|
42
66
|
/**
|
|
43
67
|
* returns a number with spaces between the thousands
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const floatingNumberWithSpaces = DyFM_Math.floatingNumberWithSpaces(1234.567);
|
|
72
|
+
* console.log(floatingNumberWithSpaces); // '1 234.567'
|
|
73
|
+
* ```
|
|
44
74
|
*/
|
|
45
75
|
static floatingNumberWithSpaces(x: number): string;
|
|
46
76
|
/**
|
|
47
77
|
* returns a number with spaces between the thousands
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const decimals = DyFM_Math.decimals(1234.567, ',');
|
|
82
|
+
* console.log(decimals); // '1,234.567'
|
|
83
|
+
* ```
|
|
48
84
|
*/
|
|
49
85
|
static decimals(x: number, useSpacer?: string): string;
|
|
50
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.util.d.ts","sourceRoot":"","sources":["../../../../src/_collections/utils/math/math.util.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,SAAS;IAEpB
|
|
1
|
+
{"version":3,"file":"math.util.d.ts","sourceRoot":"","sources":["../../../../src/_collections/utils/math/math.util.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,SAAS;IAEpB;;;;;;;;OAQG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;IAIlF;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAIpE,MAAM,CAAC,QAAQ,CAAC,OAAO,yBAAc;IACrC;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM;IAUzD;;;;;;;;OAQG;IACH,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAI1C;;;;;;;;OAQG;IACH,MAAM,CAAC,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAY5C;;;;;;;;OAQG;IACH,MAAM,CAAC,2BAA2B,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAIrD;;;;;;;;OAQG;IACH,MAAM,CAAC,wBAAwB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAQlD;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM;CAO5D"}
|
|
@@ -7,33 +7,37 @@ exports.DyFM_Math = void 0;
|
|
|
7
7
|
class DyFM_Math {
|
|
8
8
|
/**
|
|
9
9
|
* returns true if the value is between the min and max
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const isBetween = DyFM_Math.between(5, 1, 10);
|
|
14
|
+
* console.log(isBetween);
|
|
15
|
+
* ```
|
|
10
16
|
*/
|
|
11
17
|
static between(value, minExclusive, maxExclusive) {
|
|
12
18
|
return minExclusive < value && value < maxExclusive;
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
21
|
* returns true if the value is between the target and the range
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const isAround = DyFM_Math.around(5, 5, 1);
|
|
26
|
+
* console.log(isAround);
|
|
27
|
+
* ```
|
|
16
28
|
*/
|
|
17
29
|
static around(value, target, range) {
|
|
18
30
|
return this.between(value, target - range, target + range);
|
|
19
31
|
}
|
|
20
|
-
/**
|
|
21
|
-
* returns a random integer between the min and max
|
|
22
|
-
*/
|
|
23
|
-
static getRandomInt(
|
|
24
|
-
/**
|
|
25
|
-
* the minimum value (inclusive)
|
|
26
|
-
*/
|
|
27
|
-
min,
|
|
28
|
-
/**
|
|
29
|
-
* the maximum value (inclusive)
|
|
30
|
-
*/
|
|
31
|
-
max) {
|
|
32
|
-
return min + Math.round((max - min) * Math.random());
|
|
33
|
-
}
|
|
34
32
|
static toFixed = this.round;
|
|
35
33
|
/**
|
|
36
34
|
* returns a number rounded to the specified number of decimals
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const roundedNumber = DyFM_Math.round(1.2345, 2);
|
|
39
|
+
* console.log(roundedNumber); // 1.23
|
|
40
|
+
* ```
|
|
37
41
|
*/
|
|
38
42
|
static round(value, decimals = 2) {
|
|
39
43
|
if (0 <= decimals) {
|
|
@@ -46,12 +50,24 @@ class DyFM_Math {
|
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
52
|
* returns a number with spaces between the thousands
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const numberWithSpaces = DyFM_Math.numberWithSpaces(1000);
|
|
57
|
+
* console.log(numberWithSpaces); // '1 000'
|
|
58
|
+
* ```
|
|
49
59
|
*/
|
|
50
60
|
static numberWithSpaces(x) {
|
|
51
61
|
return x?.toString()?.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
52
62
|
}
|
|
53
63
|
/**
|
|
54
64
|
* returns a number with shorter units
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const numberWithShorters = DyFM_Math.numberWithShorters(1000);
|
|
69
|
+
* console.log(numberWithShorters); // '1.0k'
|
|
70
|
+
* ```
|
|
55
71
|
*/
|
|
56
72
|
static numberWithShorters(x) {
|
|
57
73
|
if (x < 1000) {
|
|
@@ -69,12 +85,24 @@ class DyFM_Math {
|
|
|
69
85
|
}
|
|
70
86
|
/**
|
|
71
87
|
* returns a number with shorter units and spaces between the thousands
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const numberWithShortersAndSpaces = DyFM_Math.numberWithShortersAndSpaces(1000);
|
|
92
|
+
* console.log(numberWithShortersAndSpaces); // '1.0k'
|
|
93
|
+
* ```
|
|
72
94
|
*/
|
|
73
95
|
static numberWithShortersAndSpaces(x) {
|
|
74
96
|
return this.numberWithShorters(x)?.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
75
97
|
}
|
|
76
98
|
/**
|
|
77
99
|
* returns a number with spaces between the thousands
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const floatingNumberWithSpaces = DyFM_Math.floatingNumberWithSpaces(1234.567);
|
|
104
|
+
* console.log(floatingNumberWithSpaces); // '1 234.567'
|
|
105
|
+
* ```
|
|
78
106
|
*/
|
|
79
107
|
static floatingNumberWithSpaces(x) {
|
|
80
108
|
const parts = x?.toString()?.split('.');
|
|
@@ -83,6 +111,12 @@ class DyFM_Math {
|
|
|
83
111
|
}
|
|
84
112
|
/**
|
|
85
113
|
* returns a number with spaces between the thousands
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const decimals = DyFM_Math.decimals(1234.567, ',');
|
|
118
|
+
* console.log(decimals); // '1,234.567'
|
|
119
|
+
* ```
|
|
86
120
|
*/
|
|
87
121
|
static decimals(x, useSpacer = ',') {
|
|
88
122
|
const parts = x?.toString()?.split('.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.util.js","sourceRoot":"","sources":["../../../../src/_collections/utils/math/math.util.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,SAAS;IAEpB
|
|
1
|
+
{"version":3,"file":"math.util.js","sourceRoot":"","sources":["../../../../src/_collections/utils/math/math.util.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,SAAS;IAEpB;;;;;;;;OAQG;IACH,MAAM,CAAC,OAAO,CAAC,KAAa,EAAE,YAAoB,EAAE,YAAoB;QACtE,OAAO,YAAY,GAAG,KAAK,IAAI,KAAK,GAAG,YAAY,CAAC;IACtD,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,CAAC,KAAa,EAAE,MAAc,EAAE,KAAa;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EA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AC5C,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,2BAA2B,CAAC,CAAS;QAC1C,OAAO,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,wBAAwB,CAAC,CAAS;QACvC,MAAM,KAAK,GAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAElD,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;QAE7D,OAAO,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAS,EAAE,YAAoB,GAAG;QAChD,MAAM,KAAK,GAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAElD,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC;QAEnE,OAAO,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;;AA/HH,8BAgIC"}
|
|
@@ -29,15 +29,6 @@ describe('| DyFM_Math', () => {
|
|
|
29
29
|
expect(math_util_1.DyFM_Math.around(7, 5, 1)).toBeFalse();
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
describe('| getRandomInt', () => {
|
|
33
|
-
it('| should return an integer within the specified range', () => {
|
|
34
|
-
const min = 1;
|
|
35
|
-
const max = 10;
|
|
36
|
-
const result = math_util_1.DyFM_Math.getRandomInt(min, max);
|
|
37
|
-
expect(result).toBeGreaterThanOrEqual(min);
|
|
38
|
-
expect(result).toBeLessThanOrEqual(max);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
32
|
describe('| round', () => {
|
|
42
33
|
it('| should round a number to the specified number of decimals', () => {
|
|
43
34
|
expect(math_util_1.DyFM_Math.round(1.2345, 2)).toBe(1.23);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.util.spec.js","sourceRoot":"","sources":["../../../../src/_collections/utils/math/math.util.spec.ts"],"names":[],"mappings":";;AACA,2CAAwC;AAExC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAE3B,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,wEAAwE,EAAE,GAAG,EAAE;YAChF,MAAM,CAAC,qBAAS,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;YACjE,MAAM,CAAC,qBAAS,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;YACjE,MAAM,CAAC,qBAAS,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;YAC7D,MAAM,CAAC,qBAAS,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;YAChD,MAAM,CAAC,qBAAS,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,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AAC,qBAAS,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;YAC9E,MAAM,CAAC,qBAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACvE,MAAM,CAAC,qBAAS,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,MAAM,CAAC,qBAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC5D,MAAM,CAAC,qBAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
|
|
@@ -5,6 +5,16 @@ import { DyFM_RandomWeight } from '../../../_models/interfaces/random-weight.int
|
|
|
5
5
|
export declare class DyFM_Random {
|
|
6
6
|
/**
|
|
7
7
|
* returns a random weighted integer between the min and max
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const randomWeightedInt = DyFM_Random.getRandomWeightedInt(1, 10, [
|
|
12
|
+
* { chance: 0.1, result: 1 },
|
|
13
|
+
* { chance: 0.3, result: 2 },
|
|
14
|
+
* { chance: 0.6, result: 3 }
|
|
15
|
+
* ]);
|
|
16
|
+
* console.log(randomWeightedInt);
|
|
17
|
+
* ```
|
|
8
18
|
*/
|
|
9
19
|
static getRandomWeightedInt(min: number, max: number, weights: DyFM_RandomWeight<number>[]): number;
|
|
10
20
|
/**
|
|
@@ -12,12 +22,24 @@ export declare class DyFM_Random {
|
|
|
12
22
|
* @param min - the minimum value (inclusive)
|
|
13
23
|
* @param max - the maximum value (inclusive)
|
|
14
24
|
* @returns a random integer between the min and max
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const randomInt = DyFM_Random.getRandomInt(1, 10);
|
|
29
|
+
* console.log(randomInt); // 5
|
|
30
|
+
* ```
|
|
15
31
|
*/
|
|
16
32
|
static getRandomInt(min: number, max: number): number;
|
|
17
33
|
/**
|
|
18
34
|
* returns null if list is empty
|
|
19
35
|
* @param list
|
|
20
36
|
* @returns
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const randomListElement = DyFM_Random.getRandomListElement([1, 2, 3, 4, 5]);
|
|
41
|
+
* console.log(randomListElement); // 3
|
|
42
|
+
* ```
|
|
21
43
|
*/
|
|
22
44
|
static getRandomListElement<T>(list: T[]): T | null;
|
|
23
45
|
/**
|
|
@@ -25,6 +47,14 @@ export declare class DyFM_Random {
|
|
|
25
47
|
* (returns null if list is empty)
|
|
26
48
|
* @param weights
|
|
27
49
|
* @returns
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const randomWeightedElement = DyFM_Random.getRandomWeighted([
|
|
54
|
+
* { chance: 0.1, result: '1' },
|
|
55
|
+
* { chance: 0.3, result: '2' },
|
|
56
|
+
* { chance: 0.6, result: '3' }
|
|
57
|
+
* ]);
|
|
28
58
|
*/
|
|
29
59
|
static getRandomWeighted<T>(weights: DyFM_RandomWeight<T>[]): T | null;
|
|
30
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.util.d.ts","sourceRoot":"","sources":["../../../../src/_collections/utils/math/random.util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAGxF;;GAEG;AACH,qBAAa,WAAW;IACtB
|
|
1
|
+
{"version":3,"file":"random.util.d.ts","sourceRoot":"","sources":["../../../../src/_collections/utils/math/random.util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAGxF;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,oBAAoB,CACzB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC,EAAE,GACnC,MAAM;IA6BT;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIrD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI;IAQnD;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI;CAkCvE"}
|
|
@@ -8,6 +8,16 @@ const log_util_1 = require("../log.util");
|
|
|
8
8
|
class DyFM_Random {
|
|
9
9
|
/**
|
|
10
10
|
* returns a random weighted integer between the min and max
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const randomWeightedInt = DyFM_Random.getRandomWeightedInt(1, 10, [
|
|
15
|
+
* { chance: 0.1, result: 1 },
|
|
16
|
+
* { chance: 0.3, result: 2 },
|
|
17
|
+
* { chance: 0.6, result: 3 }
|
|
18
|
+
* ]);
|
|
19
|
+
* console.log(randomWeightedInt);
|
|
20
|
+
* ```
|
|
11
21
|
*/
|
|
12
22
|
static getRandomWeightedInt(min, max, weights) {
|
|
13
23
|
weights = weights.sort((a, b) => b.chance - a.chance);
|
|
@@ -37,6 +47,12 @@ class DyFM_Random {
|
|
|
37
47
|
* @param min - the minimum value (inclusive)
|
|
38
48
|
* @param max - the maximum value (inclusive)
|
|
39
49
|
* @returns a random integer between the min and max
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const randomInt = DyFM_Random.getRandomInt(1, 10);
|
|
54
|
+
* console.log(randomInt); // 5
|
|
55
|
+
* ```
|
|
40
56
|
*/
|
|
41
57
|
static getRandomInt(min, max) {
|
|
42
58
|
return min + Math.round((max - min) * Math.random());
|
|
@@ -45,6 +61,12 @@ class DyFM_Random {
|
|
|
45
61
|
* returns null if list is empty
|
|
46
62
|
* @param list
|
|
47
63
|
* @returns
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const randomListElement = DyFM_Random.getRandomListElement([1, 2, 3, 4, 5]);
|
|
68
|
+
* console.log(randomListElement); // 3
|
|
69
|
+
* ```
|
|
48
70
|
*/
|
|
49
71
|
static getRandomListElement(list) {
|
|
50
72
|
if (0 < list.length) {
|
|
@@ -59,6 +81,14 @@ class DyFM_Random {
|
|
|
59
81
|
* (returns null if list is empty)
|
|
60
82
|
* @param weights
|
|
61
83
|
* @returns
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const randomWeightedElement = DyFM_Random.getRandomWeighted([
|
|
88
|
+
* { chance: 0.1, result: '1' },
|
|
89
|
+
* { chance: 0.3, result: '2' },
|
|
90
|
+
* { chance: 0.6, result: '3' }
|
|
91
|
+
* ]);
|
|
62
92
|
*/
|
|
63
93
|
static getRandomWeighted(weights) {
|
|
64
94
|
if (!weights?.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.util.js","sourceRoot":"","sources":["../../../../src/_collections/utils/math/random.util.ts"],"names":[],"mappings":";;;AAGA,0CAAuC;AAEvC;;GAEG;AACH,MAAa,WAAW;IACtB
|
|
1
|
+
{"version":3,"file":"random.util.js","sourceRoot":"","sources":["../../../../src/_collections/utils/math/random.util.ts"],"names":[],"mappings":";;;AAGA,0CAAuC;AAEvC;;GAEG;AACH,MAAa,WAAW;IACtB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,oBAAoB,CACzB,GAAW,EACX,GAAW,EACX,OAAoC;QAEpC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAU,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;QAC9D,IAAI,eAAe,GAAG,CAAC,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAQ,EAAE,GAAG,eAAe,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzE,IAAI,CAAC,GAAG,eAAe,EAAE,CAAC;YACxB,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC;QAED,MAAM,YAAY,GAAW,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3C,IAAI,MAA0B,CAAC;QAC/B,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;YAChE,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAE7B,IAAI,YAAY,GAAG,OAAO,EAAE,CAAC;gBAC3B,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,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O,CAAC,MAAM,GAAG,eAAe,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAW,IAAI,CAAC,MAAM,EAAE,CAAC;QAC3C,IAAI,MAAqB,CAAC;QAC1B,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;YAChE,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAE7B,IAAI,YAAY,GAAG,OAAO,EAAE,CAAC;gBAC3B,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,mBAAQ,CAAC,KAAK,CAAC,mEAAmE,CAAC,CAAC;YACpF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAlID,kCAkIC"}
|
|
@@ -9,6 +9,12 @@ export declare class DyFM_Trigonometry {
|
|
|
9
9
|
* @param c átfogó
|
|
10
10
|
* @param angle a befogó oldallal szemközti szög (fokban)
|
|
11
11
|
* @returns befogó
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const clamp = DyFM_Trigonometry.getClamp(10, 30);
|
|
16
|
+
* console.log(clamp); // 5
|
|
17
|
+
* ```
|
|
12
18
|
*/
|
|
13
19
|
static getClamp(c: number, angle?: number): number;
|
|
14
20
|
/**
|
|
@@ -17,6 +23,12 @@ export declare class DyFM_Trigonometry {
|
|
|
17
23
|
* @param a befogó
|
|
18
24
|
* @param c átfogó
|
|
19
25
|
* @returns befogó
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const clamp = DyFM_Trigonometry.getClampByClampAndHypotenuse(6, 10);
|
|
30
|
+
* console.log(clamp); // 8
|
|
31
|
+
* ```
|
|
20
32
|
*/
|
|
21
33
|
static getClampByClampAndHypotenuse(a: number, c: number): number;
|
|
22
34
|
/**
|
|
@@ -27,18 +39,36 @@ export declare class DyFM_Trigonometry {
|
|
|
27
39
|
* @param a egyik befogó
|
|
28
40
|
* @param b másik befogó
|
|
29
41
|
* @returns átfogó
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const hypotenuse = DyFM_Trigonometry.getHypotenuse(3, 4);
|
|
46
|
+
* console.log(hypotenuse); // 5
|
|
47
|
+
* ```
|
|
30
48
|
*/
|
|
31
49
|
static getHypotenuse(a: number, b?: number): number;
|
|
32
50
|
/**
|
|
33
51
|
* Szög fokmértéket átalakítja radiánsra
|
|
34
52
|
* @param angle szög fok
|
|
35
53
|
* @returns szög radiáns
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const radians = DyFM_Trigonometry.angleToRadians(180);
|
|
58
|
+
* console.log(radians); // 3.141592653589793
|
|
59
|
+
* ```
|
|
36
60
|
*/
|
|
37
61
|
static angleToRadians(angle: number): number;
|
|
38
62
|
/**
|
|
39
63
|
* Szög radiáns mértéket átalakítja fokra
|
|
40
64
|
* @param radians szög radiáns
|
|
41
65
|
* @returns szög fok
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const angle = DyFM_Trigonometry.radiansToAngle(3.141592653589793);
|
|
70
|
+
* console.log(angle); // 180
|
|
71
|
+
* ```
|
|
42
72
|
*/
|
|
43
73
|
static radiansToAngle(radians: number): number;
|
|
44
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigonometry.util.d.ts","sourceRoot":"","sources":["../../../../src/_collections/utils/math/trigonometry.util.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,SAAS,GAAG,iBAAiB,CAAC;AAC1C,MAAM,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACvC,qBAAa,iBAAiB;IAE5B
|
|
1
|
+
{"version":3,"file":"trigonometry.util.d.ts","sourceRoot":"","sources":["../../../../src/_collections/utils/math/trigonometry.util.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,SAAS,GAAG,iBAAiB,CAAC;AAC1C,MAAM,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACvC,qBAAa,iBAAiB;IAE5B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAMlD;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,4BAA4B,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAYjE;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAMnD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI5C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAG/C"}
|
|
@@ -10,6 +10,12 @@ class DyFM_Trigonometry {
|
|
|
10
10
|
* @param c átfogó
|
|
11
11
|
* @param angle a befogó oldallal szemközti szög (fokban)
|
|
12
12
|
* @returns befogó
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const clamp = DyFM_Trigonometry.getClamp(10, 30);
|
|
17
|
+
* console.log(clamp); // 5
|
|
18
|
+
* ```
|
|
13
19
|
*/
|
|
14
20
|
static getClamp(c, angle) {
|
|
15
21
|
angle = angle !== undefined ? angle : 45;
|
|
@@ -21,6 +27,12 @@ class DyFM_Trigonometry {
|
|
|
21
27
|
* @param a befogó
|
|
22
28
|
* @param c átfogó
|
|
23
29
|
* @returns befogó
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const clamp = DyFM_Trigonometry.getClampByClampAndHypotenuse(6, 10);
|
|
34
|
+
* console.log(clamp); // 8
|
|
35
|
+
* ```
|
|
24
36
|
*/
|
|
25
37
|
static getClampByClampAndHypotenuse(a, c) {
|
|
26
38
|
if (a > c) {
|
|
@@ -38,6 +50,12 @@ class DyFM_Trigonometry {
|
|
|
38
50
|
* @param a egyik befogó
|
|
39
51
|
* @param b másik befogó
|
|
40
52
|
* @returns átfogó
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const hypotenuse = DyFM_Trigonometry.getHypotenuse(3, 4);
|
|
57
|
+
* console.log(hypotenuse); // 5
|
|
58
|
+
* ```
|
|
41
59
|
*/
|
|
42
60
|
static getHypotenuse(a, b) {
|
|
43
61
|
b = b !== undefined ? b : a;
|
|
@@ -47,6 +65,12 @@ class DyFM_Trigonometry {
|
|
|
47
65
|
* Szög fokmértéket átalakítja radiánsra
|
|
48
66
|
* @param angle szög fok
|
|
49
67
|
* @returns szög radiáns
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const radians = DyFM_Trigonometry.angleToRadians(180);
|
|
72
|
+
* console.log(radians); // 3.141592653589793
|
|
73
|
+
* ```
|
|
50
74
|
*/
|
|
51
75
|
static angleToRadians(angle) {
|
|
52
76
|
return angle * Math.PI / 180;
|
|
@@ -55,6 +79,12 @@ class DyFM_Trigonometry {
|
|
|
55
79
|
* Szög radiáns mértéket átalakítja fokra
|
|
56
80
|
* @param radians szög radiáns
|
|
57
81
|
* @returns szög fok
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const angle = DyFM_Trigonometry.radiansToAngle(3.141592653589793);
|
|
86
|
+
* console.log(angle); // 180
|
|
87
|
+
* ```
|
|
58
88
|
*/
|
|
59
89
|
static radiansToAngle(radians) {
|
|
60
90
|
return radians / Math.PI * 180;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigonometry.util.js","sourceRoot":"","sources":["../../../../src/_collections/utils/math/trigonometry.util.ts"],"names":[],"mappings":";;;AAGA,MAAa,iBAAiB;IAE5B
|
|
1
|
+
{"version":3,"file":"trigonometry.util.js","sourceRoot":"","sources":["../../../../src/_collections/utils/math/trigonometry.util.ts"],"names":[],"mappings":";;;AAGA,MAAa,iBAAiB;IAE5B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAS,EAAE,KAAc;QACvC,KAAK,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAEzC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,4BAA4B,CAAC,CAAS,EAAE,CAAS;QACtD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAEV,MAAM;gBACJ,YAAY,EACV,0EAA0E,CAAC,QAAQ,CAAC,GAAG;aAC1F,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,aAAa,CAAC,CAAS,EAAE,CAAU;QACxC,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACt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