@futdevpro/fsm-dynamo 1.7.14 → 1.8.2
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/lib/_constants/error-defaults.const.d.ts +1 -1
- package/lib/_constants/error-defaults.const.d.ts.map +1 -1
- package/lib/_constants/error-defaults.const.js +2 -2
- package/lib/_constants/error-defaults.const.js.map +1 -1
- package/lib/_constants/module-settings/custom-data-module-settings.const.d.ts +2 -2
- package/lib/_constants/module-settings/custom-data-module-settings.const.d.ts.map +1 -1
- package/lib/_constants/module-settings/custom-data-module-settings.const.js +2 -2
- package/lib/_constants/module-settings/custom-data-module-settings.const.js.map +1 -1
- package/lib/_constants/module-settings/test-module-settings.const.d.ts +2 -2
- package/lib/_constants/module-settings/test-module-settings.const.d.ts.map +1 -1
- package/lib/_constants/module-settings/test-module-settings.const.js +2 -2
- package/lib/_constants/module-settings/test-module-settings.const.js.map +1 -1
- package/lib/_constants/module-settings/usage-module-settings.const.d.ts +2 -2
- package/lib/_constants/module-settings/usage-module-settings.const.d.ts.map +1 -1
- package/lib/_constants/module-settings/usage-module-settings.const.js +2 -2
- package/lib/_constants/module-settings/usage-module-settings.const.js.map +1 -1
- package/lib/_enums/data-model-type.enum.d.ts +10 -3
- package/lib/_enums/data-model-type.enum.d.ts.map +1 -1
- package/lib/_enums/data-model-type.enum.js +10 -3
- package/lib/_enums/data-model-type.enum.js.map +1 -1
- package/lib/_enums/day-of-week.enum.d.ts +3 -2
- package/lib/_enums/day-of-week.enum.d.ts.map +1 -1
- package/lib/_enums/day-of-week.enum.js +4 -3
- package/lib/_enums/day-of-week.enum.js.map +1 -1
- package/lib/_models/control-models/data-model-params.control-model.d.ts +19 -0
- package/lib/_models/control-models/data-model-params.control-model.d.ts.map +1 -0
- package/lib/_models/control-models/data-model-params.control-model.js +30 -0
- package/lib/_models/control-models/data-model-params.control-model.js.map +1 -0
- package/lib/_models/control-models/data-property-params.control-model.d.ts +14 -9
- package/lib/_models/control-models/data-property-params.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/data-property-params.control-model.js +16 -7
- package/lib/_models/control-models/data-property-params.control-model.js.map +1 -1
- package/lib/_models/control-models/error.control-model.js +13 -13
- package/lib/_models/control-models/error.control-model.js.map +1 -1
- package/lib/_models/control-models/error.control-model.spec.js +9 -9
- package/lib/_models/control-models/error.control-model.spec.js.map +1 -1
- package/lib/_models/control-models/index.d.ts +1 -1
- package/lib/_models/control-models/index.d.ts.map +1 -1
- package/lib/_models/control-models/index.js +1 -1
- package/lib/_models/control-models/index.js.map +1 -1
- package/lib/_models/control-models/range-value.control-model.d.ts +14 -14
- package/lib/_models/control-models/range-value.control-model.d.ts.map +1 -1
- package/lib/_models/control-models/range-value.control-model.js +3 -3
- package/lib/_models/control-models/range-value.control-model.js.map +1 -1
- package/lib/_models/data-models/custom-data.data-model.d.ts +5 -5
- package/lib/_models/data-models/custom-data.data-model.d.ts.map +1 -1
- package/lib/_models/data-models/custom-data.data-model.js +3 -3
- package/lib/_models/data-models/custom-data.data-model.js.map +1 -1
- package/lib/_models/data-models/metadata.data-model.d.ts +1 -0
- package/lib/_models/data-models/metadata.data-model.d.ts.map +1 -1
- package/lib/_models/data-models/metadata.data-model.js +18 -0
- package/lib/_models/data-models/metadata.data-model.js.map +1 -1
- package/lib/_models/data-models/usage-session.data-model.d.ts +4 -4
- package/lib/_models/data-models/usage-session.data-model.d.ts.map +1 -1
- package/lib/_models/data-models/usage-session.data-model.js +3 -3
- package/lib/_models/data-models/usage-session.data-model.js.map +1 -1
- package/lib/_models/interfaces/location/country-division.interface.d.ts +1 -1
- package/lib/_models/interfaces/location/country-division.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/location/country-iso.interface.d.ts +3 -3
- package/lib/_models/interfaces/location/country-iso.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/location/country-phone-code.interface.d.ts +1 -1
- package/lib/_models/interfaces/location/country-phone-code.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/location/division-collection.interface.d.ts +1 -1
- package/lib/_models/interfaces/location/division-collection.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/location/division-region-data.interface.d.ts +2 -2
- package/lib/_models/interfaces/location/division-region-data.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/location/geo-ip-location.interface.d.ts +1 -1
- package/lib/_models/interfaces/location/geo-ip-location.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/location/location-coordinates.interface.d.ts +1 -1
- package/lib/_models/interfaces/location/location-coordinates.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/random-weight.interface.d.ts +1 -1
- package/lib/_models/interfaces/random-weight.interface.d.ts.map +1 -1
- package/lib/_models/interfaces/route-settings.interface.d.ts +3 -3
- package/lib/_models/interfaces/route-settings.interface.d.ts.map +1 -1
- package/lib/_modules/data-modules.index.d.ts +1 -1
- package/lib/_modules/data-modules.index.d.ts.map +1 -1
- package/lib/_modules/data-modules.index.js +1 -1
- package/lib/_modules/data-modules.index.js.map +1 -1
- package/lib/_utils/array.util.d.ts +1 -1
- package/lib/_utils/array.util.d.ts.map +1 -1
- package/lib/_utils/array.util.js +2 -2
- package/lib/_utils/array.util.js.map +1 -1
- package/lib/_utils/array.util.spec.js +3 -3
- package/lib/_utils/array.util.spec.js.map +1 -1
- package/lib/_utils/box-bounds.util.d.ts +13 -12
- package/lib/_utils/box-bounds.util.d.ts.map +1 -1
- package/lib/_utils/box-bounds.util.js +10 -7
- package/lib/_utils/box-bounds.util.js.map +1 -1
- package/lib/_utils/location.util.d.ts +2 -2
- package/lib/_utils/location.util.d.ts.map +1 -1
- package/lib/_utils/location.util.js.map +1 -1
- package/lib/_utils/metadata.util.d.ts +1 -4
- package/lib/_utils/metadata.util.d.ts.map +1 -1
- package/lib/_utils/metadata.util.js +27 -20
- package/lib/_utils/metadata.util.js.map +1 -1
- package/lib/_utils/random.util.d.ts +3 -3
- package/lib/_utils/random.util.d.ts.map +1 -1
- package/lib/_utils/random.util.js.map +1 -1
- package/lib/_utils/regex/password-regex.util.d.ts +1 -1
- package/lib/_utils/regex/password-regex.util.d.ts.map +1 -1
- package/lib/_utils/regex/password-regex.util.js +3 -3
- package/lib/_utils/regex/password-regex.util.js.map +1 -1
- package/lib/_utils/regex/username-regex.util.d.ts +1 -1
- package/lib/_utils/regex/username-regex.util.d.ts.map +1 -1
- package/lib/_utils/regex/username-regex.util.js +2 -2
- package/lib/_utils/regex/username-regex.util.js.map +1 -1
- package/lib/_utils/regex.util.d.ts +1 -1
- package/lib/_utils/regex.util.d.ts.map +1 -1
- package/lib/_utils/regex.util.js +2 -2
- package/lib/_utils/regex.util.js.map +1 -1
- package/lib/_utils/regions.util.d.ts +8 -8
- package/lib/_utils/regions.util.d.ts.map +1 -1
- package/lib/_utils/regions.util.js +3 -3
- package/lib/_utils/regions.util.js.map +1 -1
- package/lib/_utils/shared.static-service.js +5 -5
- package/lib/_utils/shared.static-service.js.map +1 -1
- package/lib/_utils/time.util.d.ts +7 -0
- package/lib/_utils/time.util.d.ts.map +1 -1
- package/lib/_utils/time.util.js +7 -0
- package/lib/_utils/time.util.js.map +1 -1
- package/lib/_utils/utilities.util.d.ts +24 -12
- package/lib/_utils/utilities.util.d.ts.map +1 -1
- package/lib/_utils/utilities.util.js +34 -22
- package/lib/_utils/utilities.util.js.map +1 -1
- package/lib/_utils/vector2.util.d.ts +45 -43
- package/lib/_utils/vector2.util.d.ts.map +1 -1
- package/lib/_utils/vector2.util.js +47 -37
- package/lib/_utils/vector2.util.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/_constants/error-defaults.const.ts +1 -1
- package/src/_constants/module-settings/custom-data-module-settings.const.ts +2 -2
- package/src/_constants/module-settings/test-module-settings.const.ts +2 -2
- package/src/_constants/module-settings/usage-module-settings.const.ts +2 -2
- package/src/_enums/data-model-type.enum.ts +10 -3
- package/src/_enums/day-of-week.enum.ts +3 -2
- package/src/_models/control-models/data-model-params.control-model.ts +39 -0
- package/src/_models/control-models/data-property-params.control-model.ts +23 -9
- package/src/_models/control-models/error.control-model.spec.ts +10 -10
- package/src/_models/control-models/error.control-model.ts +14 -14
- package/src/_models/control-models/index.ts +1 -1
- package/src/_models/control-models/range-value.control-model.ts +17 -16
- package/src/_models/data-models/custom-data.data-model.ts +6 -6
- package/src/_models/data-models/metadata.data-model.ts +24 -0
- package/src/_models/data-models/usage-session.data-model.ts +5 -5
- package/src/_models/interfaces/location/country-division.interface.ts +1 -1
- package/src/_models/interfaces/location/country-iso.interface.ts +3 -3
- package/src/_models/interfaces/location/country-phone-code.interface.ts +1 -1
- package/src/_models/interfaces/location/division-collection.interface.ts +1 -1
- package/src/_models/interfaces/location/division-region-data.interface.ts +2 -2
- package/src/_models/interfaces/location/geo-ip-location.interface.ts +1 -1
- package/src/_models/interfaces/location/location-coordinates.interface.ts +1 -1
- package/src/_models/interfaces/random-weight.interface.ts +1 -1
- package/src/_models/interfaces/route-settings.interface.ts +3 -3
- package/src/_modules/data-modules.index.ts +1 -1
- package/src/_utils/array.util.spec.ts +4 -4
- package/src/_utils/array.util.ts +2 -2
- package/src/_utils/box-bounds.util.ts +24 -20
- package/src/_utils/location.util.ts +3 -3
- package/src/_utils/metadata.util.ts +2 -1
- package/src/_utils/random.util.ts +3 -3
- package/src/_utils/regex/password-regex.util.ts +1 -1
- package/src/_utils/regex/username-regex.util.ts +1 -1
- package/src/_utils/regex.util.ts +3 -1
- package/src/_utils/regions.util.ts +22 -22
- package/src/_utils/shared.static-service.ts +6 -6
- package/src/_utils/time.util.ts +9 -1
- package/src/_utils/utilities.util.ts +25 -13
- package/src/_utils/vector2.util.ts +85 -73
- package/lib/_models/control-models/data-params.control-model.d.ts +0 -13
- package/lib/_models/control-models/data-params.control-model.d.ts.map +0 -1
- package/lib/_models/control-models/data-params.control-model.js +0 -23
- package/lib/_models/control-models/data-params.control-model.js.map +0 -1
- package/src/_models/control-models/data-params.control-model.ts +0 -27
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Dynamo_Vector2 } from './vector2.util';
|
|
4
4
|
|
|
5
|
-
export class
|
|
6
|
-
private _pos:
|
|
7
|
-
set pos(value:
|
|
5
|
+
export class Dynamo_BoxBounds {
|
|
6
|
+
private _pos: Dynamo_Vector2;
|
|
7
|
+
set pos(value: Dynamo_Vector2) {
|
|
8
8
|
this._pos = value;
|
|
9
9
|
|
|
10
10
|
this.calcCenter();
|
|
11
11
|
}
|
|
12
|
-
get pos():
|
|
12
|
+
get pos(): Dynamo_Vector2 {
|
|
13
13
|
return this._pos;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
private _size:
|
|
17
|
-
set size(value:
|
|
16
|
+
private _size: Dynamo_Vector2;
|
|
17
|
+
set size(value: Dynamo_Vector2) {
|
|
18
18
|
this._size = value;
|
|
19
19
|
|
|
20
20
|
this.calcCenter();
|
|
21
21
|
}
|
|
22
|
-
get size():
|
|
22
|
+
get size(): Dynamo_Vector2 {
|
|
23
23
|
return this._size;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
private _center:
|
|
27
|
-
get center():
|
|
26
|
+
private _center: Dynamo_Vector2;
|
|
27
|
+
get center(): Dynamo_Vector2 {
|
|
28
28
|
return this._center;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
constructor(
|
|
32
|
-
position:
|
|
33
|
-
size:
|
|
32
|
+
position: Dynamo_Vector2 = new Dynamo_Vector2(),
|
|
33
|
+
size: Dynamo_Vector2 = new Dynamo_Vector2()
|
|
34
34
|
) {
|
|
35
35
|
this._pos = position;
|
|
36
36
|
this._size = size;
|
|
@@ -38,7 +38,11 @@ export class BoxBounds {
|
|
|
38
38
|
this.calcCenter();
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
constructed?(): boolean {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
newValues?(position: Dynamo_Vector2, size: Dynamo_Vector2): void {
|
|
42
46
|
if (position === undefined) {
|
|
43
47
|
throw new Error('new position is undefined!');
|
|
44
48
|
}
|
|
@@ -53,20 +57,20 @@ export class BoxBounds {
|
|
|
53
57
|
this.calcCenter();
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
static bounds(box:
|
|
60
|
+
static bounds(box: Dynamo_BoxBounds, position: Dynamo_Vector2): boolean {
|
|
57
61
|
return box.pos.x <= position.x && position.x <= box.pos.x + box.size.x &&
|
|
58
62
|
box.pos.y <= position.y && position.y <= box.pos.y + box.size.y;
|
|
59
63
|
}
|
|
60
|
-
bounds(position:
|
|
61
|
-
return
|
|
64
|
+
bounds?(position: Dynamo_Vector2): boolean {
|
|
65
|
+
return Dynamo_BoxBounds.bounds(this, position);
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
private calcCenter(): void {
|
|
65
|
-
this._center =
|
|
68
|
+
private calcCenter?(): void {
|
|
69
|
+
this._center = Dynamo_Vector2.plus(this.pos, Dynamo_Vector2.divide(this.size, 2));
|
|
66
70
|
}
|
|
67
71
|
|
|
68
|
-
clone():
|
|
69
|
-
return new
|
|
72
|
+
clone?(): Dynamo_BoxBounds {
|
|
73
|
+
return new Dynamo_BoxBounds(this.pos.clone(), this.size.clone());
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
import { Dynamo_Error } from '../_models/control-models/error.control-model';
|
|
3
3
|
import { Dynamo_Trigonometry } from './trigonometry.util';
|
|
4
|
-
import {
|
|
4
|
+
import { Dynamo_LocationCoordinates } from '../_models/interfaces/location/location-coordinates.interface';
|
|
5
5
|
|
|
6
6
|
export type D_Location = Dynamo_Location;
|
|
7
7
|
export class Dynamo_Location {
|
|
8
8
|
|
|
9
9
|
static getDistanceInKilometres(
|
|
10
|
-
from:
|
|
11
|
-
to:
|
|
10
|
+
from: Dynamo_LocationCoordinates,
|
|
11
|
+
to: Dynamo_LocationCoordinates
|
|
12
12
|
): number {
|
|
13
13
|
|
|
14
14
|
const R = 6371; // kilometres
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dynamo_Metadata } from '../_models';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/*
|
|
4
4
|
export class Dynamo_Metadata_Tool {
|
|
5
5
|
|
|
6
6
|
static updateMetadata<T extends Dynamo_Metadata>(data: T, issuer: string, id?: string): T {
|
|
@@ -28,3 +28,4 @@ export class Dynamo_Metadata_Tool {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { Dynamo_RandomWeight } from '../_models/interfaces/random-weight.interface';
|
|
3
3
|
|
|
4
4
|
export type D_Random = Dynamo_Random;
|
|
5
5
|
export class Dynamo_Random {
|
|
6
|
-
static getRandomWeightedInt(min: number, max: number, weights:
|
|
6
|
+
static getRandomWeightedInt(min: number, max: number, weights: Dynamo_RandomWeight<number>[]): number {
|
|
7
7
|
weights = weights.sort((a, b): number => b.chance - a.chance);
|
|
8
8
|
let weightChanceSum = 0;
|
|
9
9
|
|
|
@@ -44,7 +44,7 @@ export class Dynamo_Random {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
static getRandomWeighted<T>(weights:
|
|
47
|
+
static getRandomWeighted<T>(weights: Dynamo_RandomWeight<T>[]): T {
|
|
48
48
|
if (!weights?.length) {
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
@@ -10,7 +10,7 @@ export const Dynamo_passwordRegex: RegExp = new RegExp(
|
|
|
10
10
|
'Password must include at least one of the !@#$%^&* characters.' +
|
|
11
11
|
'Password must be at least 6 characters long.'; */
|
|
12
12
|
|
|
13
|
-
export function
|
|
13
|
+
export function Dynamo_getPasswordErrors(password: string): string[] {
|
|
14
14
|
const errors: string[] = [];
|
|
15
15
|
|
|
16
16
|
passwordErrorsOneByOne.forEach((error) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
export const
|
|
2
|
+
export const Dynamo_usernameRegex: RegExp = new RegExp('^[a-zA-Z0-9-_#$%&^|*]{6,}$');
|
|
3
3
|
|
|
4
4
|
/* export const FDP_usernameRegexUserMessage: string =
|
|
5
5
|
'Username must be at least 6 characters long and can only contain letters, ' +
|
package/src/_utils/regex.util.ts
CHANGED
|
@@ -6,44 +6,44 @@ import * as Divisions from '../_constants/location/country-divisions-ISO-3166-al
|
|
|
6
6
|
|
|
7
7
|
import { Dynamo_Region } from '../_enums/region.enum';
|
|
8
8
|
import { Dynamo_Error } from '../_models';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { Dynamo_CountryPhoneCode } from '../_models/interfaces/location/country-phone-code.interface';
|
|
10
|
+
import { Dynamo_CountryISO } from '../_models/interfaces/location/country-iso.interface';
|
|
11
|
+
import { Dynamo_CountryDivision } from '../_models/interfaces/location/country-division.interface';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { Dynamo_JSONListify } from './utilities.util';
|
|
14
14
|
|
|
15
15
|
export type D_Regions = Dynamo_Regions;
|
|
16
16
|
export class Dynamo_Regions {
|
|
17
17
|
/* static divisions: DivisionCollection = Dynamo_Regions.getSubdivisionCollection(); */
|
|
18
|
-
static divisions:
|
|
19
|
-
static phoneCodes:
|
|
20
|
-
static ISOs:
|
|
18
|
+
static divisions: Dynamo_CountryDivision[] = Dynamo_Regions.getAllDivisions();
|
|
19
|
+
static phoneCodes: Dynamo_CountryPhoneCode[] = Dynamo_Regions.getAllPhoneCodes();
|
|
20
|
+
static ISOs: Dynamo_CountryISO[] = Dynamo_Regions.getAllCountryISO();
|
|
21
21
|
|
|
22
|
-
private static getAllDivisions():
|
|
23
|
-
return
|
|
22
|
+
private static getAllDivisions(): Dynamo_CountryDivision[] {
|
|
23
|
+
return Dynamo_JSONListify(Divisions);
|
|
24
24
|
}
|
|
25
|
-
private static getAllPhoneCodes():
|
|
26
|
-
return
|
|
25
|
+
private static getAllPhoneCodes(): Dynamo_CountryPhoneCode[] {
|
|
26
|
+
return Dynamo_JSONListify(PhoneCodes);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/* private static getSubdivisionCollection(): DivisionCollection {
|
|
30
30
|
return Divisions as DivisionCollection;
|
|
31
31
|
} */
|
|
32
|
-
private static getAllCountryISO():
|
|
33
|
-
const result:
|
|
32
|
+
private static getAllCountryISO(): Dynamo_CountryISO[] {
|
|
33
|
+
const result: Dynamo_CountryISO[] = Dynamo_JSONListify(ISOs);
|
|
34
34
|
|
|
35
|
-
result.forEach((iso:
|
|
35
|
+
result.forEach((iso: Dynamo_CountryISO): void => {
|
|
36
36
|
iso.phoneCode = this.phoneCodes.find(
|
|
37
|
-
(pc:
|
|
37
|
+
(pc: Dynamo_CountryPhoneCode): boolean => pc.iso === iso.iso2
|
|
38
38
|
)?.code;
|
|
39
|
-
iso.divisions = this.divisions.filter((d:
|
|
39
|
+
iso.divisions = this.divisions.filter((d: Dynamo_CountryDivision): boolean => d.iso === iso.iso2);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
static isoToCountryIso(iso2: string):
|
|
46
|
-
const country:
|
|
45
|
+
static isoToCountryIso(iso2: string): Dynamo_CountryISO {
|
|
46
|
+
const country: Dynamo_CountryISO = this.ISOs.find((iso: Dynamo_CountryISO): boolean => iso.iso2 == iso2);
|
|
47
47
|
|
|
48
48
|
if (!country) {
|
|
49
49
|
throw new Dynamo_Error({
|
|
@@ -56,7 +56,7 @@ export class Dynamo_Regions {
|
|
|
56
56
|
|
|
57
57
|
static isoToRegion(iso2: string): Dynamo_Region {
|
|
58
58
|
const region: Dynamo_Region = this.ISOs.find(
|
|
59
|
-
(iso:
|
|
59
|
+
(iso: Dynamo_CountryISO): boolean => iso.iso2 == iso2
|
|
60
60
|
)?.region;
|
|
61
61
|
|
|
62
62
|
if (!region) {
|
|
@@ -68,9 +68,9 @@ export class Dynamo_Regions {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
static isoToPhoneCode(iso2: string):
|
|
72
|
-
const phoneCode:
|
|
73
|
-
(code:
|
|
71
|
+
static isoToPhoneCode(iso2: string): Dynamo_CountryPhoneCode {
|
|
72
|
+
const phoneCode: Dynamo_CountryPhoneCode = this.phoneCodes.find(
|
|
73
|
+
(code: Dynamo_CountryPhoneCode): boolean => code.iso == iso2
|
|
74
74
|
);
|
|
75
75
|
|
|
76
76
|
if (!phoneCode) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
2
|
+
import { Dynamo_clone } from './utilities.util';
|
|
3
3
|
|
|
4
4
|
export type D_Shared = Dynamo_Shared;
|
|
5
5
|
export class Dynamo_Shared {
|
|
@@ -55,7 +55,7 @@ export class Dynamo_Shared {
|
|
|
55
55
|
* @returns data from object by path
|
|
56
56
|
*/
|
|
57
57
|
static getNestedData(parentObj: object, nestedDataKeys: string[]): any {
|
|
58
|
-
let newData =
|
|
58
|
+
let newData = Dynamo_clone(parentObj); // {...parentObj};
|
|
59
59
|
|
|
60
60
|
nestedDataKeys.forEach((dk: string): void => {
|
|
61
61
|
if (newData) {
|
|
@@ -74,7 +74,7 @@ export class Dynamo_Shared {
|
|
|
74
74
|
* @returns modified data
|
|
75
75
|
*/
|
|
76
76
|
static nestData(parentObj: object, nestKeys: string[], dataToSet: any): object {
|
|
77
|
-
const newData =
|
|
77
|
+
const newData = Dynamo_clone(parentObj); // {...parentObj};
|
|
78
78
|
|
|
79
79
|
if (nestKeys.length > 1) {
|
|
80
80
|
const keys = [...nestKeys];
|
|
@@ -96,7 +96,7 @@ export class Dynamo_Shared {
|
|
|
96
96
|
* @returns modified data
|
|
97
97
|
*/
|
|
98
98
|
static addToNestedData(parentObj: object, nestKeys: string[], dataToAdd: any): object {
|
|
99
|
-
const newData =
|
|
99
|
+
const newData = Dynamo_clone(parentObj); // {...parentObj};
|
|
100
100
|
|
|
101
101
|
if (nestKeys.length > 1) {
|
|
102
102
|
const keys = [...nestKeys];
|
|
@@ -118,7 +118,7 @@ export class Dynamo_Shared {
|
|
|
118
118
|
* @returns modified data
|
|
119
119
|
*/
|
|
120
120
|
static pushToNestedData(parentObj: object, nestKeys: string[], dataToPush: any): object {
|
|
121
|
-
const newData =
|
|
121
|
+
const newData = Dynamo_clone(parentObj); // {...parentObj};
|
|
122
122
|
|
|
123
123
|
if (nestKeys.length > 1) {
|
|
124
124
|
const keys = [...nestKeys];
|
|
@@ -150,7 +150,7 @@ export class Dynamo_Shared {
|
|
|
150
150
|
nestIndexes: number[],
|
|
151
151
|
dataToSet: any
|
|
152
152
|
): T {
|
|
153
|
-
const newData =
|
|
153
|
+
const newData = Dynamo_clone(parentObj); // parentObj; // {...parentObj};
|
|
154
154
|
|
|
155
155
|
if (nestIndexes.length > 1) {
|
|
156
156
|
const indexes = [...nestIndexes];
|
package/src/_utils/time.util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { day, hour, month, week, year } from '../_constants/times.const';
|
|
2
|
+
import { day, hour, minute, month, second, week, year } from '../_constants/times.const';
|
|
3
3
|
import { Dynamo_Month } from '../_enums';
|
|
4
4
|
import { Dynamo_DayOfWeek } from '../_enums/day-of-week.enum';
|
|
5
5
|
import { Dynamo_RelativeDate } from '../_enums/relative-date.enum';
|
|
@@ -8,6 +8,14 @@ export type D_Time = Dynamo_Time;
|
|
|
8
8
|
export type D_T = Dynamo_Time;
|
|
9
9
|
export class Dynamo_Time {
|
|
10
10
|
|
|
11
|
+
static readonly second = second;
|
|
12
|
+
static readonly minute = minute;
|
|
13
|
+
static readonly hour = hour;
|
|
14
|
+
static readonly day = day;
|
|
15
|
+
static readonly week = week;
|
|
16
|
+
static readonly month = month;
|
|
17
|
+
static readonly year = year;
|
|
18
|
+
|
|
11
19
|
static getAge(birthDate: Date | number | string): number {
|
|
12
20
|
return this.getYear(+new Date() - +new Date(birthDate));
|
|
13
21
|
}
|
|
@@ -4,7 +4,7 @@ const defaultErrorMsg = ' failed. ' +
|
|
|
4
4
|
'containes object hooks for its own objects, therefore its creating an object loop. ' +
|
|
5
5
|
'See further information in the detailed error:\n\n';
|
|
6
6
|
|
|
7
|
-
export function
|
|
7
|
+
export function Dynamo_clone<T>(object: T): T {
|
|
8
8
|
try {
|
|
9
9
|
return object ? JSON.parse(JSON.stringify(object)) as T : object;
|
|
10
10
|
} catch (error) {
|
|
@@ -16,9 +16,11 @@ export function clone<T>(object: T): T {
|
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
export const
|
|
19
|
+
export const Dynamo_copy = Dynamo_clone;
|
|
20
|
+
export const D_clone = Dynamo_clone;
|
|
21
|
+
export const D_copy = Dynamo_clone;
|
|
20
22
|
|
|
21
|
-
export function
|
|
23
|
+
export function Dynamo_surfaceClone<T>(object: T): T {
|
|
22
24
|
try {
|
|
23
25
|
const result = {};
|
|
24
26
|
|
|
@@ -36,9 +38,11 @@ export function surfaceClone<T>(object: T): T {
|
|
|
36
38
|
throw error;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
|
-
export const
|
|
41
|
+
export const Dynamo_surfaceCopy = Dynamo_surfaceClone;
|
|
42
|
+
export const D_surfaceClone = Dynamo_surfaceClone;
|
|
43
|
+
export const D_surfaceCopy = Dynamo_surfaceClone;
|
|
40
44
|
|
|
41
|
-
export function
|
|
45
|
+
export function Dynamo_sameObjects<T>(objA: T, objB: T): boolean {
|
|
42
46
|
try {
|
|
43
47
|
return JSON.stringify(objA) === JSON.stringify(objB);
|
|
44
48
|
} catch (error) {
|
|
@@ -50,25 +54,30 @@ export function sameObjects<T>(objA: T, objB: T): boolean {
|
|
|
50
54
|
throw error;
|
|
51
55
|
}
|
|
52
56
|
}
|
|
57
|
+
export const D_sameObjects = Dynamo_sameObjects;
|
|
53
58
|
|
|
54
59
|
/**
|
|
55
60
|
* sets values if its existing on To, even if its null (but if undefined)
|
|
56
61
|
* @param setOn
|
|
57
62
|
* @param setTo
|
|
58
63
|
*/
|
|
59
|
-
export function
|
|
64
|
+
export function Dynamo_setExisitngValuesOnly(setOn: any, setTo: any): void {
|
|
60
65
|
for (const key in setTo) {
|
|
61
66
|
if (setTo[key] != undefined) {
|
|
62
67
|
setOn[key] = setTo[key];
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
}
|
|
71
|
+
export const D_setExisitngValuesOnly = Dynamo_setExisitngValuesOnly;
|
|
66
72
|
|
|
67
|
-
export function
|
|
73
|
+
export function Dynamo_delay(ms: number): Promise<void> {
|
|
68
74
|
return new Promise((resolve): any => setTimeout(resolve, ms));
|
|
69
75
|
}
|
|
70
|
-
export const
|
|
71
|
-
export const
|
|
76
|
+
export const Dynamo_sleep = Dynamo_delay;
|
|
77
|
+
export const Dynamo_wait = Dynamo_delay;
|
|
78
|
+
export const D_delay = Dynamo_delay;
|
|
79
|
+
export const D_sleep = Dynamo_delay;
|
|
80
|
+
export const D_wait = Dynamo_delay;
|
|
72
81
|
|
|
73
82
|
export type Dynamo_SortDirection = 0 | 1 | -1
|
|
74
83
|
|
|
@@ -83,11 +92,12 @@ export type Dynamo_SortDirection = 0 | 1 | -1
|
|
|
83
92
|
* @example
|
|
84
93
|
* codes.sort((a,b) => sortForTrue(a,b,(c: Code) => c.haveImg));
|
|
85
94
|
*/
|
|
86
|
-
export function
|
|
95
|
+
export function Dynamo_sortForTrue<T>(a: T, b: T, check: (a: T) => boolean): Dynamo_SortDirection {
|
|
87
96
|
const isA = check(a);
|
|
88
97
|
|
|
89
98
|
return isA === check(b) ? 0 : isA ? -1 : 1;
|
|
90
99
|
}
|
|
100
|
+
export const D_sortForTrue = Dynamo_sortForTrue;
|
|
91
101
|
|
|
92
102
|
/**
|
|
93
103
|
*
|
|
@@ -97,12 +107,13 @@ export function sortForTrue<T>(a: T, b: T, check: (a: T) => boolean): Dynamo_Sor
|
|
|
97
107
|
* @example
|
|
98
108
|
* codes.sort(getSortForTrueFn((c: Code) => c.haveImg));
|
|
99
109
|
*/
|
|
100
|
-
export function
|
|
110
|
+
export function Dynamo_getSortForTrueFn<T>(
|
|
101
111
|
checkFor: (a: T) => boolean): (a: T, b: T) => Dynamo_SortDirection {
|
|
102
|
-
return (a: T, b: T): Dynamo_SortDirection =>
|
|
112
|
+
return (a: T, b: T): Dynamo_SortDirection => Dynamo_sortForTrue<T>(a, b, checkFor);
|
|
103
113
|
}
|
|
114
|
+
export const D_getSortForTrueFn = Dynamo_getSortForTrueFn;
|
|
104
115
|
|
|
105
|
-
export function
|
|
116
|
+
export function Dynamo_JSONListify<T>(JSONList): T[] {
|
|
106
117
|
const result: T[] = [];
|
|
107
118
|
|
|
108
119
|
for (let i = 0; JSONList[i]; i++) {
|
|
@@ -111,4 +122,5 @@ export function JSONListify<T>(JSONList): T[] {
|
|
|
111
122
|
|
|
112
123
|
return result;
|
|
113
124
|
}
|
|
125
|
+
export const D_JSONListify = Dynamo_JSONListify;
|
|
114
126
|
|