@futdevpro/fsm-dynamo 1.7.3 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/.eslintrc.json +138 -0
  2. package/lib/_constants/error-defaults.const.d.ts.map +1 -1
  3. package/lib/_constants/error-defaults.const.js.map +1 -1
  4. package/lib/_constants/module-settings/usage-module-settings.const.js +1 -1
  5. package/lib/_constants/module-settings/usage-module-settings.const.js.map +1 -1
  6. package/lib/_enums/day-of-week.enum.d.ts +13 -0
  7. package/lib/_enums/day-of-week.enum.d.ts.map +1 -0
  8. package/lib/_enums/day-of-week.enum.js +25 -0
  9. package/lib/_enums/day-of-week.enum.js.map +1 -0
  10. package/lib/_enums/index.d.ts +4 -0
  11. package/lib/_enums/index.d.ts.map +1 -1
  12. package/lib/_enums/index.js +4 -0
  13. package/lib/_enums/index.js.map +1 -1
  14. package/lib/_enums/month.enum.d.ts +15 -0
  15. package/lib/_enums/month.enum.d.ts.map +1 -0
  16. package/lib/_enums/month.enum.js +19 -0
  17. package/lib/_enums/month.enum.js.map +1 -0
  18. package/lib/_enums/relative-date.enum.d.ts +9 -0
  19. package/lib/_enums/relative-date.enum.d.ts.map +1 -0
  20. package/lib/_enums/relative-date.enum.js +13 -0
  21. package/lib/_enums/relative-date.enum.js.map +1 -0
  22. package/lib/_models/control-models/daily-usage-data.control-model.d.ts +1 -1
  23. package/lib/_models/control-models/daily-usage-data.control-model.js.map +1 -1
  24. package/lib/_models/control-models/data-params.control-model.js.map +1 -1
  25. package/lib/_models/control-models/data-property-params.control-model.d.ts +4 -2
  26. package/lib/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
  27. package/lib/_models/control-models/data-property-params.control-model.js +6 -3
  28. package/lib/_models/control-models/data-property-params.control-model.js.map +1 -1
  29. package/lib/_models/control-models/error.control-model.d.ts +28 -24
  30. package/lib/_models/control-models/error.control-model.d.ts.map +1 -1
  31. package/lib/_models/control-models/error.control-model.js +39 -16
  32. package/lib/_models/control-models/error.control-model.js.map +1 -1
  33. package/lib/_models/control-models/error.control-model.spec.js +3 -2
  34. package/lib/_models/control-models/error.control-model.spec.js.map +1 -1
  35. package/lib/_models/control-models/poll.control-model.d.ts +2 -2
  36. package/lib/_models/control-models/poll.control-model.d.ts.map +1 -1
  37. package/lib/_models/control-models/poll.control-model.js +2 -1
  38. package/lib/_models/control-models/poll.control-model.js.map +1 -1
  39. package/lib/_models/control-models/range-value.control-model.d.ts +25 -2
  40. package/lib/_models/control-models/range-value.control-model.d.ts.map +1 -1
  41. package/lib/_models/control-models/range-value.control-model.js +83 -1
  42. package/lib/_models/control-models/range-value.control-model.js.map +1 -1
  43. package/lib/_models/control-models/usage-action.control-model.js +0 -1
  44. package/lib/_models/control-models/usage-action.control-model.js.map +1 -1
  45. package/lib/_models/control-models/usage-data.control-model.js.map +1 -1
  46. package/lib/_models/data-models/custom-data.data-model.d.ts.map +1 -1
  47. package/lib/_models/data-models/custom-data.data-model.js.map +1 -1
  48. package/lib/_models/data-models/metadata.data-model.d.ts.map +1 -1
  49. package/lib/_models/data-models/metadata.data-model.js.map +1 -1
  50. package/lib/_models/data-models/usage-session.data-model.d.ts.map +1 -1
  51. package/lib/_models/data-models/usage-session.data-model.js.map +1 -1
  52. package/lib/_models/interfaces/paged.interace.d.ts +8 -0
  53. package/lib/_models/interfaces/paged.interace.d.ts.map +1 -0
  54. package/lib/_models/interfaces/paged.interace.js +3 -0
  55. package/lib/_models/interfaces/paged.interace.js.map +1 -0
  56. package/lib/_utils/array.util.d.ts +5 -0
  57. package/lib/_utils/array.util.d.ts.map +1 -1
  58. package/lib/_utils/array.util.js +26 -0
  59. package/lib/_utils/array.util.js.map +1 -1
  60. package/lib/_utils/array.util.spec.js.map +1 -1
  61. package/lib/_utils/box-bounds.util.d.ts +18 -0
  62. package/lib/_utils/box-bounds.util.d.ts.map +1 -0
  63. package/lib/_utils/box-bounds.util.js +57 -0
  64. package/lib/_utils/box-bounds.util.js.map +1 -0
  65. package/lib/_utils/index.d.ts +3 -0
  66. package/lib/_utils/index.d.ts.map +1 -1
  67. package/lib/_utils/index.js +3 -0
  68. package/lib/_utils/index.js.map +1 -1
  69. package/lib/_utils/location.util.d.ts.map +1 -1
  70. package/lib/_utils/location.util.js +4 -2
  71. package/lib/_utils/location.util.js.map +1 -1
  72. package/lib/_utils/log.util.d.ts.map +1 -1
  73. package/lib/_utils/log.util.js +4 -1
  74. package/lib/_utils/log.util.js.map +1 -1
  75. package/lib/_utils/math.util.d.ts +10 -0
  76. package/lib/_utils/math.util.d.ts.map +1 -0
  77. package/lib/_utils/math.util.js +32 -0
  78. package/lib/_utils/math.util.js.map +1 -0
  79. package/lib/_utils/metadata.util.d.ts.map +1 -1
  80. package/lib/_utils/metadata.util.js.map +1 -1
  81. package/lib/_utils/random.util.d.ts.map +1 -1
  82. package/lib/_utils/random.util.js +8 -4
  83. package/lib/_utils/random.util.js.map +1 -1
  84. package/lib/_utils/regex/password-regex.util.d.ts +3 -0
  85. package/lib/_utils/regex/password-regex.util.d.ts.map +1 -0
  86. package/lib/_utils/regex/password-regex.util.js +49 -0
  87. package/lib/_utils/regex/password-regex.util.js.map +1 -0
  88. package/lib/_utils/regex/username-regex.util.d.ts +2 -0
  89. package/lib/_utils/regex/username-regex.util.d.ts.map +1 -0
  90. package/lib/_utils/regex/username-regex.util.js +32 -0
  91. package/lib/_utils/regex/username-regex.util.js.map +1 -0
  92. package/lib/_utils/regex.util.d.ts.map +1 -1
  93. package/lib/_utils/regex.util.js +1 -1
  94. package/lib/_utils/regex.util.js.map +1 -1
  95. package/lib/_utils/regions.util.d.ts.map +1 -1
  96. package/lib/_utils/regions.util.js +5 -5
  97. package/lib/_utils/regions.util.js.map +1 -1
  98. package/lib/_utils/round-list.util.d.ts.map +1 -1
  99. package/lib/_utils/round-list.util.js.map +1 -1
  100. package/lib/_utils/shared.static-service.d.ts.map +1 -1
  101. package/lib/_utils/shared.static-service.js +1 -1
  102. package/lib/_utils/shared.static-service.js.map +1 -1
  103. package/lib/_utils/time.util.d.ts +82 -0
  104. package/lib/_utils/time.util.d.ts.map +1 -1
  105. package/lib/_utils/time.util.js +135 -0
  106. package/lib/_utils/time.util.js.map +1 -1
  107. package/lib/_utils/trigonometry.util.d.ts.map +1 -1
  108. package/lib/_utils/trigonometry.util.js +3 -1
  109. package/lib/_utils/trigonometry.util.js.map +1 -1
  110. package/lib/_utils/type-cloning-facility.util.d.ts +27 -0
  111. package/lib/_utils/type-cloning-facility.util.d.ts.map +1 -0
  112. package/lib/_utils/type-cloning-facility.util.js +77 -0
  113. package/lib/_utils/type-cloning-facility.util.js.map +1 -0
  114. package/lib/_utils/utilities.util.d.ts +3 -2
  115. package/lib/_utils/utilities.util.d.ts.map +1 -1
  116. package/lib/_utils/utilities.util.js +8 -4
  117. package/lib/_utils/utilities.util.js.map +1 -1
  118. package/lib/_utils/vector2.util.d.ts +22 -2
  119. package/lib/_utils/vector2.util.d.ts.map +1 -1
  120. package/lib/_utils/vector2.util.js +64 -14
  121. package/lib/_utils/vector2.util.js.map +1 -1
  122. package/lib/tsconfig.tsbuildinfo +1 -1
  123. package/nodemon.json +1 -1
  124. package/package.json +5 -1
  125. package/src/_constants/error-defaults.const.ts +1 -1
  126. package/src/_constants/module-settings/usage-module-settings.const.ts +1 -1
  127. package/src/_enums/day-of-week.enum.ts +27 -0
  128. package/src/_enums/index.ts +4 -0
  129. package/src/_enums/month.enum.ts +16 -0
  130. package/src/_enums/relative-date.enum.ts +13 -0
  131. package/src/_models/control-models/daily-usage-data.control-model.ts +1 -1
  132. package/src/_models/control-models/data-property-params.control-model.ts +12 -4
  133. package/src/_models/control-models/error.control-model.spec.ts +189 -178
  134. package/src/_models/control-models/error.control-model.ts +118 -57
  135. package/src/_models/control-models/poll.control-model.ts +15 -9
  136. package/src/_models/control-models/range-value.control-model.ts +119 -4
  137. package/src/_models/control-models/usage-action.control-model.ts +1 -1
  138. package/src/_models/control-models/usage-data.control-model.ts +1 -1
  139. package/src/_models/data-models/custom-data.data-model.ts +1 -1
  140. package/src/_models/data-models/metadata.data-model.ts +5 -0
  141. package/src/_models/data-models/usage-session.data-model.ts +1 -1
  142. package/src/_models/interfaces/paged.interace.ts +11 -0
  143. package/src/_utils/array.util.spec.ts +8 -7
  144. package/src/_utils/array.util.ts +48 -3
  145. package/src/_utils/box-bounds.util.ts +71 -0
  146. package/src/_utils/index.ts +3 -0
  147. package/src/_utils/location.util.ts +11 -3
  148. package/src/_utils/log.util.ts +51 -23
  149. package/src/_utils/math.util.ts +53 -0
  150. package/src/_utils/metadata.util.ts +1 -0
  151. package/src/_utils/random.util.ts +18 -7
  152. package/src/_utils/regex/password-regex.util.ts +53 -0
  153. package/src/_utils/regex/username-regex.util.ts +33 -0
  154. package/src/_utils/regex.util.ts +1 -1
  155. package/src/_utils/regions.util.ts +19 -7
  156. package/src/_utils/round-list.util.ts +1 -0
  157. package/src/_utils/shared.static-service.ts +30 -5
  158. package/src/_utils/time.util.ts +163 -4
  159. package/src/_utils/trigonometry.util.ts +8 -1
  160. package/src/_utils/type-cloning-facility.util.ts +121 -0
  161. package/src/_utils/utilities.util.ts +33 -8
  162. package/src/_utils/vector2.util.ts +83 -16
@@ -1,15 +1,22 @@
1
+ import { Dynamo_Paged } from '../_models/interfaces/paged.interace';
1
2
 
2
3
 
3
4
  export type D_Array = Dynamo_Array;
4
5
  export class Dynamo_Array {
5
6
 
6
- static async asyncForEach<T>(list: T[], func: (element: T, index?: number, array?: T[]) => Promise<void>): Promise<void> {
7
+ static async asyncForEach<T>(
8
+ list: T[],
9
+ func: (element: T, index?: number, array?: T[]) => Promise<void>
10
+ ): Promise<void> {
7
11
  for (let i = 0; i < list.length; i++) {
8
12
  await func(list[i], i, list);
9
13
  }
10
14
  }
11
15
 
12
- static async asyncMapArray<T, R>(list: T[], mapFunc: (element: T, index?: number, array?: T[]) => Promise<R>): Promise<R[]> {
16
+ static async asyncMapArray<T, R>(
17
+ list: T[],
18
+ mapFunc: (element: T, index?: number, array?: T[]) => Promise<R>
19
+ ): Promise<R[]> {
13
20
  const resultList: R[] = [];
14
21
 
15
22
  for (let i = 0; i < list.length; i++) {
@@ -29,7 +36,10 @@ export class Dynamo_Array {
29
36
  return array;
30
37
  }
31
38
 
32
- static findNRemove<T>(array: T[], func: (element: T, index?: number, array?: T[]) => boolean): T[] {
39
+ static findNRemove<T>(
40
+ array: T[],
41
+ func: (element: T, index?: number, array?: T[]) => boolean
42
+ ): T[] {
33
43
  const index = array.findIndex(func);
34
44
 
35
45
  if (-1 < index) {
@@ -38,6 +48,41 @@ export class Dynamo_Array {
38
48
 
39
49
  return array;
40
50
  }
51
+
52
+ static shuffle<T>(array: T[]): T[] {
53
+ let currentIndex = array.length;
54
+ let randomIndex: number;
55
+
56
+ while (0 < currentIndex) {
57
+ randomIndex = Math.floor(Math.random() * currentIndex);
58
+ currentIndex--;
59
+
60
+ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
61
+ }
62
+
63
+ return array;
64
+ }
65
+
66
+ static page<T>(array: T[], pageIndex: number, pageSize: number): T[] {
67
+ return array.slice(pageIndex * pageSize, (pageIndex + 1) * pageSize);
68
+ }
69
+
70
+ static paged<T>(array: T[], pageIndex: number, pageSize: number): Dynamo_Paged<T> {
71
+ return {
72
+ pageIndex,
73
+ pageSize,
74
+ total: array.length,
75
+ totalPageCount: Math.ceil(array.length / pageSize),
76
+ items: this.page(array, pageIndex, pageSize)
77
+ };
78
+ }
79
+
80
+ static swap<T>(array: T[], indexA: number, indexB: number): T[] {
81
+ [array[indexA], array[indexB]] = [array[indexB], array[indexA]];
82
+
83
+ return array;
84
+ }
85
+
41
86
  }
42
87
 
43
88
 
@@ -0,0 +1,71 @@
1
+ import { Vector2 } from './vector2.util';
2
+
3
+ export class BoxBounds {
4
+ private _pos: Vector2;
5
+ set pos(value: Vector2) {
6
+ this._pos = value;
7
+
8
+ this.calcCenter();
9
+ }
10
+ get pos(): Vector2 {
11
+ return this._pos;
12
+ }
13
+
14
+ private _size: Vector2;
15
+ set size(value: Vector2) {
16
+ this._size = value;
17
+
18
+ this.calcCenter();
19
+ }
20
+ get size(): Vector2 {
21
+ return this._size;
22
+ }
23
+
24
+ private _center: Vector2;
25
+ get center(): Vector2 {
26
+ return this._center;
27
+ }
28
+
29
+ constructor(
30
+ position: Vector2 = new Vector2(),
31
+ size: Vector2 = new Vector2()
32
+ ) {
33
+ this._pos = position;
34
+ this._size = size;
35
+
36
+ this.calcCenter();
37
+ }
38
+
39
+ newValues(position: Vector2, size: Vector2): void {
40
+ if (position === undefined) {
41
+ throw new Error('new position is undefined!');
42
+ }
43
+
44
+ if (size === undefined) {
45
+ throw new Error('new size is undefined!');
46
+ }
47
+
48
+ this._pos = position;
49
+ this._size = size;
50
+
51
+ this.calcCenter();
52
+ }
53
+
54
+ static bounds(box: BoxBounds, position: Vector2): boolean {
55
+ return box.pos.x <= position.x && position.x <= box.pos.x + box.size.x &&
56
+ box.pos.y <= position.y && position.y <= box.pos.y + box.size.y;
57
+ }
58
+ bounds(position: Vector2): boolean {
59
+ return BoxBounds.bounds(this, position);
60
+ }
61
+
62
+ private calcCenter(): void {
63
+ this._center = Vector2.plus(this.pos, Vector2.divide(this.size, 2));
64
+ }
65
+
66
+ clone(): BoxBounds {
67
+ return new BoxBounds(this.pos.clone(), this.size.clone());
68
+ }
69
+ }
70
+
71
+
@@ -1,8 +1,10 @@
1
1
 
2
2
  // TOOLS
3
3
  export * from './array.util';
4
+ export * from './box-bounds.util';
4
5
  export * from './location.util';
5
6
  export * from './log.util';
7
+ export * from './math.util';
6
8
  export * from './metadata.util';
7
9
  export * from './random.util';
8
10
  export * from './regex.util';
@@ -11,6 +13,7 @@ export * from './round-list.util';
11
13
  export * from './shared.static-service';
12
14
  export * from './time.util';
13
15
  export * from './trigonometry.util';
16
+ export * from './type-cloning-facility.util';
14
17
  export * from './utilities.util';
15
18
  export * from './vector2.util';
16
19
 
@@ -25,7 +25,11 @@ export class Dynamo_Location {
25
25
  return R * c;
26
26
  }
27
27
 
28
- static getLocationDegByKilometers(latiOrLong: 'latitude' | 'longitude', distanceInKm: number, latitude?: number): number {
28
+ static getLocationDegByKilometers(
29
+ latiOrLong: 'latitude' | 'longitude',
30
+ distanceInKm: number,
31
+ latitude?: number
32
+ ): number {
29
33
  if (latiOrLong === 'latitude') {
30
34
  return distanceInKm / 110.574;
31
35
  } else {
@@ -36,8 +40,12 @@ export class Dynamo_Location {
36
40
  status: 417,
37
41
  errorCode: 'FSM-DSS-505',
38
42
  addECToUserMsg: true,
39
- message: `When using getLocationDegByKilometers for longitude, you need to give latitude! (latiOrLong: ${latiOrLong}, distanceInKm: ${distanceInKm}, latitude: ${latitude})`,
40
- userMessage: `We encountered an uncought BackEnd Error, please contact the responsible development team.`
43
+ message:
44
+ `When using getLocationDegByKilometers for longitude, you need to give latitude! ` +
45
+ `(latiOrLong: ${latiOrLong}, distanceInKm: ${distanceInKm}, latitude: ${latitude})`,
46
+ userMessage:
47
+ `We encountered an uncought BackEnd Error, ` +
48
+ `please contact the responsible development team.`
41
49
  });
42
50
  }
43
51
  }
@@ -10,7 +10,8 @@ export class Dynamo_Log {
10
10
 
11
11
  static setStyle(styles: Dynamo_LogStyle[]): void {
12
12
  let styleSets = '';
13
- styles.forEach((style: Dynamo_LogStyle) => {
13
+
14
+ styles.forEach((style: Dynamo_LogStyle): void => {
14
15
  styleSets += style;
15
16
  });
16
17
  console.log(styleSets);
@@ -21,61 +22,79 @@ export class Dynamo_Log {
21
22
 
22
23
  static addStyle(input: string, styles: Dynamo_LogStyle[], dontReset?: boolean): string {
23
24
  let result = '';
24
- styles.forEach((style: Dynamo_LogStyle) => {
25
+
26
+ styles.forEach((style: Dynamo_LogStyle): void => {
25
27
  result += style;
26
28
  });
27
29
  result += input;
30
+
28
31
  if (!dontReset) {
29
32
  result += Dynamo_LogStyle.reset;
30
33
  }
34
+
31
35
  return result;
32
36
  }
33
37
 
34
38
  static success(message: string, ...optionalParams: any[]): void {
35
39
  if (0 < optionalParams.length) {
36
- console.log(`${Dynamo_LogStyle.green}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
40
+ console.log(
41
+ `${Dynamo_LogStyle.green}${Dynamo_LogStyle.bright}${message}`,
42
+ ...optionalParams, Dynamo_LogStyle.reset
43
+ );
37
44
  } else {
38
- console.log(`${Dynamo_LogStyle.green}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
45
+ console.log(
46
+ `${Dynamo_LogStyle.green}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`
47
+ );
39
48
  }
40
49
  }
41
50
  /**
42
51
  * @deprecated use Dynamo_Log.success instead
43
52
  */
44
- static logSuccess(message: string, ...optionalParams: any[]) {
53
+ static logSuccess(message: string, ...optionalParams: any[]): void {
45
54
  this.success(message, ...optionalParams);
46
55
  }
47
56
 
48
57
  static error(message: string, ...optionalParams: any[]): void {
49
58
  if (0 < optionalParams.length) {
50
- console.error(`${Dynamo_LogStyle.red}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
59
+ console.error(
60
+ `${Dynamo_LogStyle.red}${Dynamo_LogStyle.bright}${message}`,
61
+ ...optionalParams, Dynamo_LogStyle.reset
62
+ );
51
63
  } else {
52
- console.error(`${Dynamo_LogStyle.red}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
64
+ console.error(
65
+ `${Dynamo_LogStyle.red}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`
66
+ );
53
67
  }
54
68
  }
55
69
  /**
56
70
  * @deprecated use Dynamo_Log.error instead
57
71
  */
58
- static logError(message: string, ...optionalParams: any[]) {
72
+ static logError(message: string, ...optionalParams: any[]): void {
59
73
  this.error(message, ...optionalParams);
60
74
  }
61
75
 
62
76
  static warn(message: string, ...optionalParams: any[]): void {
63
77
  if (0 < optionalParams.length) {
64
- console.warn(`${Dynamo_LogStyle.yellow}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
78
+ console.warn(
79
+ `${Dynamo_LogStyle.yellow}${Dynamo_LogStyle.bright}${message}`,
80
+ ...optionalParams, Dynamo_LogStyle.reset
81
+ );
65
82
  } else {
66
- console.warn(`${Dynamo_LogStyle.yellow}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
83
+ console.warn(
84
+ `${Dynamo_LogStyle.yellow}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`
85
+ );
67
86
  }
68
87
  }
69
88
  /**
70
89
  * @deprecated use Dynamo_Log.warn instead
71
90
  */
72
- static warning(message: string, ...optionalParams: any[]) {
91
+ static warning(message: string, ...optionalParams: any[]): void {
73
92
  this.warn(message, ...optionalParams);
74
93
  }
75
94
  /**
76
95
  * @deprecated use Dynamo_Log.warn instead
77
96
  */
78
- static logWarning(message: string, ...optionalParams: any[]) {
97
+ static logWarning(message: string, ...optionalParams: any[]): void {
79
98
  this.warn(message, ...optionalParams);
80
99
  }
81
100
 
@@ -89,9 +108,14 @@ export class Dynamo_Log {
89
108
 
90
109
  static highlighted(message: string, ...optionalParams: any[]): void {
91
110
  if (0 < optionalParams.length) {
92
- console.log(`${Dynamo_LogStyle.white}${Dynamo_LogStyle.bright}${message}`, ...optionalParams, Dynamo_LogStyle.reset);
111
+ console.log(
112
+ `${Dynamo_LogStyle.white}${Dynamo_LogStyle.bright}${message}`,
113
+ ...optionalParams, Dynamo_LogStyle.reset
114
+ );
93
115
  } else {
94
- console.log(`${Dynamo_LogStyle.white}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`);
116
+ console.log(
117
+ `${Dynamo_LogStyle.white}${Dynamo_LogStyle.bright}${message}${Dynamo_LogStyle.reset}`
118
+ );
95
119
  }
96
120
  }
97
121
  static testLog(message: string, ...optionalParams: any[]): void {
@@ -180,32 +204,36 @@ export class Dynamo_Log {
180
204
  }
181
205
  static H_success = Dynamo_Log.highlightedSuccess;
182
206
 
207
+ // eslint-disable-next-line max-len
183
208
  private static h_solid: string = '|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||';
209
+ // eslint-disable-next-line max-len
184
210
  private static h_before: string = '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\';
211
+ // eslint-disable-next-line max-len
185
212
  private static h_after: string = '/////////////////////////////////////////////////////////////////////////////';
186
213
 
187
214
  static removeLogStyles(message: string): string {
188
- for (let styleKey of Object(Dynamo_LogStyle)) {
215
+ for (const styleKey of Object(Dynamo_LogStyle)) {
189
216
  message = message.replace(new RegExp(Dynamo_LogStyle[styleKey], 'g'), '');
190
217
  }
218
+
191
219
  return message;
192
220
  }
193
221
 
194
222
  static silenceLogs(): void {
195
- console.log = () => {};
223
+ console.log = (): void => {};
196
224
  }
197
225
 
198
226
  static silenceNonErrorLogs(): void {
199
- console.log = () => {};
200
- console.info = () => {};
201
- console.warn = () => {};
227
+ console.log = (): void => {};
228
+ console.info = (): void => {};
229
+ console.warn = (): void => {};
202
230
  }
203
231
 
204
232
  static silenceConsole(): void {
205
- console.log = () => {};
206
- console.info = () => {};
207
- console.warn = () => {};
208
- console.error = () => {};
233
+ console.log = (): void => {};
234
+ console.info = (): void => {};
235
+ console.warn = (): void => {};
236
+ console.error = (): void => {};
209
237
  }
210
238
  }
211
239
 
@@ -0,0 +1,53 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ export class Dynamo_Math {
11
+
12
+ static between(value: number, minExclusive: number, maxExclusive: number): boolean {
13
+ return minExclusive < value && value < maxExclusive;
14
+ }
15
+
16
+ static around(value: number, target: number, range: number): boolean {
17
+ return this.between(value, target - range, target + range);
18
+ }
19
+
20
+ static getRandomInt(min: number, max: number): number {
21
+ return min + Math.round((max - min) * Math.random());
22
+ }
23
+
24
+ static round(value: number, decimals: number = 2): number {
25
+ return Number(value.toFixed(decimals));
26
+ }
27
+
28
+ static numberWithSpaces(x: number): string {
29
+ return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
30
+ }
31
+
32
+ static floatingNumberWithSpaces(x: number): string {
33
+ const parts: string[] = x.toString().split('.');
34
+
35
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
36
+
37
+ return parts.join('.');
38
+ }
39
+
40
+ static decimals(x: number, useSpacer: string = ','): string {
41
+ const parts: string[] = x.toString().split('.');
42
+
43
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, useSpacer);
44
+
45
+ return parts.join('.');
46
+ }
47
+ }
48
+
49
+
50
+
51
+
52
+
53
+
@@ -15,6 +15,7 @@ export class Dynamo_Metadata_Tool {
15
15
  if (!data.__created) {
16
16
  data.__created = new Date();
17
17
  }
18
+
18
19
  if (!data.__createdBy) {
19
20
  data.__createdBy = issuer;
20
21
  }
@@ -4,18 +4,22 @@ import { RandomWeight } from '../_models/interfaces/random-weight.interface';
4
4
  export type D_Random = Dynamo_Random;
5
5
  export class Dynamo_Random {
6
6
  static getRandomWeightedInt(min: number, max: number, weights: RandomWeight<number>[]): number {
7
- weights = weights.sort((a, b) => b.chance - a.chance);
7
+ weights = weights.sort((a, b): number => b.chance - a.chance);
8
8
  let weightChanceSum = 0;
9
- weights.forEach(weight => weightChanceSum += weight.chance);
9
+
10
+ weights.forEach((weight): void => { weightChanceSum += weight.chance; });
11
+
10
12
  if (1 < weightChanceSum) {
11
- weights.forEach(weights => weights.chance = weights.chance / weightChanceSum);
13
+ weights.forEach((weights): void => { weights.chance = weights.chance / weightChanceSum; });
12
14
  }
13
15
 
14
16
  const randomChance: number = Math.random();
15
17
  let result: number;
16
18
  let chancer = 0;
19
+
17
20
  for (let i = 0; i < weights.length && result === undefined; i++) {
18
21
  chancer += weights[i].chance;
22
+
19
23
  if (randomChance < chancer) {
20
24
  result = weights[i].result;
21
25
  }
@@ -45,21 +49,28 @@ export class Dynamo_Random {
45
49
  return null;
46
50
  }
47
51
 
48
- weights = weights.sort((a, b) => b.chance - a.chance);
52
+ weights = weights.sort((a, b): number => b.chance - a.chance);
49
53
  let weightChanceSum = 0;
50
- weights.forEach(weight => weightChanceSum += weight.chance);
51
- weights.forEach(weights => weights.chance = weights.chance / weightChanceSum);
54
+
55
+ weights.forEach((weight): void => {
56
+ weightChanceSum += weight.chance;
57
+ });
58
+ weights.forEach((weights): void => {
59
+ weights.chance = weights.chance / weightChanceSum;
60
+ });
52
61
 
53
62
  const randomChance: number = Math.random();
54
63
  let result: T;
55
64
  let chancer = 0;
65
+
56
66
  for (let i = 0; i < weights.length && result === undefined; i++) {
57
67
  chancer += weights[i].chance;
68
+
58
69
  if (randomChance < chancer) {
59
70
  result = weights[i].result;
60
71
  }
61
72
  }
62
73
 
63
- return result
74
+ return result;
64
75
  }
65
76
  }
@@ -0,0 +1,53 @@
1
+
2
+ export const Dynamo_passwordRegex: RegExp = new RegExp(
3
+ '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*]){6,}'
4
+ );
5
+
6
+ /* export const Dynamo_ALLPasswordRegexUserMessages: string =
7
+ 'Password must include at least one lowercase letter. ' +
8
+ 'Password must include at least one uppercase letter.' +
9
+ 'Password must include at least one digit.' +
10
+ 'Password must include at least one of the !@#$%^&* characters.' +
11
+ 'Password must be at least 6 characters long.'; */
12
+
13
+ export function getPasswordErrors(password: string): string[] {
14
+ const errors: string[] = [];
15
+
16
+ passwordErrorsOneByOne.forEach((error) => {
17
+ if (!error.regex.test(password)) {
18
+ errors.push(error.message);
19
+ }
20
+ });
21
+
22
+ return errors;
23
+ }
24
+
25
+ const passwordErrorsOneByOne = [
26
+ {
27
+ regex: new RegExp('^(?=.*[a-z])'),
28
+ code: 'pwErrorLowercase',
29
+ message: 'Password must include at least one lowercase letter.'
30
+ },
31
+ {
32
+ regex: new RegExp('^(?=.*[A-Z])'),
33
+ code: 'pwErrorUppercase',
34
+ message: 'Password must include at least one uppercase letter.'
35
+ },
36
+ {
37
+ regex: new RegExp('^(?=.*[0-9])'),
38
+ code: 'pwErrorDigit',
39
+ message: 'Password must include at least one digit.'
40
+ },
41
+ {
42
+ regex: new RegExp('^(?=.*[!@#$%^&*])'),
43
+ code: 'pwErrorSpecialChar',
44
+ message: 'Password must include at least one of the !@#$%^&* characters.'
45
+ },
46
+ {
47
+ regex: new RegExp('^(?=.{6,})'),
48
+ code: 'pwErrorLength',
49
+ message: 'Password must be at least 6 characters long.'
50
+ },
51
+ ];
52
+
53
+ //'!@#$%^&*+-_<>?.,;:|~'
@@ -0,0 +1,33 @@
1
+
2
+ export const FDP_usernameRegex: RegExp = new RegExp('^[a-zA-Z0-9-_#$%&^|*]{6,}$');
3
+
4
+ /* export const FDP_usernameRegexUserMessage: string =
5
+ 'Username must be at least 6 characters long and can only contain letters, ' +
6
+ 'numbers, and the following special characters: -_#$%&^|*'; */
7
+
8
+ /* export function getUsernameErrors(username: string): string[] {
9
+ const errors: string[] = [];
10
+
11
+ usernameErrorsOneByOne.forEach((error) => {
12
+ if (!error.regex.test(username)) {
13
+ errors.push(error.message);
14
+ }
15
+ });
16
+
17
+ return errors;
18
+ } */
19
+
20
+ const usernameErrorsOneByOne = [
21
+ {
22
+ regex: new RegExp('^(?=.{6,})'),
23
+ code: 'usernameErrorLength',
24
+ /* message: 'Username must be at least 6 characters long.' */
25
+ },
26
+ {
27
+ regex: new RegExp('^(?=.*[a-zA-Z0-9-_#$%&^|*])'),
28
+ code: 'usernameErrorSpecialChar',
29
+ /* message:
30
+ 'Username can only contain letters, numbers, and the following special characters: -_#$%&^|*' */
31
+ },
32
+ ];
33
+
@@ -1,4 +1,4 @@
1
1
 
2
2
 
3
- export const emailRegex: RegExp = new RegExp('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$');
3
+ export const emailRegex: RegExp = new RegExp('^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$');
4
4
 
@@ -25,20 +25,26 @@ export class Dynamo_Regions {
25
25
  private static getAllPhoneCodes(): CountryPhoneCode[] {
26
26
  return JSONListify(PhoneCodes);
27
27
  }
28
- /* private static getSubdivisionCollection(): DivisionCollection {
28
+
29
+ /* private static getSubdivisionCollection(): DivisionCollection {
29
30
  return Divisions as DivisionCollection;
30
31
  } */
31
32
  private static getAllCountryISO(): CountryISO[] {
32
33
  const result: CountryISO[] = JSONListify(ISOs);
33
- result.forEach((iso: CountryISO) => {
34
- iso.phoneCode = this.phoneCodes.find((pc: CountryPhoneCode) => pc.iso === iso.iso2)?.code;
35
- iso.divisions = this.divisions.filter((d: CountryDivision) => d.iso === iso.iso2);
34
+
35
+ result.forEach((iso: CountryISO): void => {
36
+ iso.phoneCode = this.phoneCodes.find(
37
+ (pc: CountryPhoneCode): boolean => pc.iso === iso.iso2
38
+ )?.code;
39
+ iso.divisions = this.divisions.filter((d: CountryDivision): boolean => d.iso === iso.iso2);
36
40
  });
41
+
37
42
  return result;
38
43
  }
39
44
 
40
45
  static isoToCountryIso(iso2: string): CountryISO {
41
- const country: CountryISO = this.ISOs.find(iso => iso.iso2 == iso2);
46
+ const country: CountryISO = this.ISOs.find((iso: CountryISO): boolean => iso.iso2 == iso2);
47
+
42
48
  if (!country) {
43
49
  throw new Dynamo_Error({
44
50
  message: `Cannot find ISO-3166 code for this: ${iso2}`
@@ -49,7 +55,10 @@ export class Dynamo_Regions {
49
55
  }
50
56
 
51
57
  static isoToRegion(iso2: string): Dynamo_Region {
52
- const region: Dynamo_Region = this.ISOs.find(iso => iso.iso2 == iso2).region;
58
+ const region: Dynamo_Region = this.ISOs.find(
59
+ (iso: CountryISO): boolean => iso.iso2 == iso2
60
+ )?.region;
61
+
53
62
  if (!region) {
54
63
  throw new Dynamo_Error({
55
64
  message: `Cannot find ISO-3166 code for this: ${iso2}`
@@ -60,7 +69,10 @@ export class Dynamo_Regions {
60
69
  }
61
70
 
62
71
  static isoToPhoneCode(iso2: string): CountryPhoneCode {
63
- const phoneCode: CountryPhoneCode = this.phoneCodes.find(code => code.iso == iso2);
72
+ const phoneCode: CountryPhoneCode = this.phoneCodes.find(
73
+ (code: CountryPhoneCode): boolean => code.iso == iso2
74
+ );
75
+
64
76
  if (!phoneCode) {
65
77
  throw new Dynamo_Error({
66
78
  message: `Cannot find ISO-3166 code for this: ${iso2}`
@@ -11,6 +11,7 @@ export class Dynamo_RoundList {
11
11
  outboundIndex = outboundIndex % listLength;
12
12
  outboundIndex = listLength + outboundIndex;
13
13
  }
14
+
14
15
  if (listLength <= outboundIndex) {
15
16
  outboundIndex = outboundIndex % listLength;
16
17
  }