@@ -5,75 +5,75 @@ const today: Date = new Date();
5
5
* @description Basic helper used to wrap basic methods don't used on pages
6
6
*/
7
7
export default {
8
- /**
8
+ /**
9
9
* Sort array of strings
10
10
* @param arrayToSort {string[]} Array to sort
11
11
* @return {Promise<string[] }
12
12
*/
13
- async sortArray ( arrayToSort : string [ ] ) : Promise < string [ ] > {
14
- return arrayToSort . sort ( ( a : string , b : string ) : number => a . localeCompare ( b ) ) ;
15
- } ,
13
+ async sortArray ( arrayToSort : string [ ] ) : Promise < string [ ] > {
14
+ return arrayToSort . sort ( ( a : string , b : string ) : number => a . localeCompare ( b ) ) ;
15
+ } ,
16
16
17
- /**
17
+ /**
18
18
* Sort array of numbers
19
19
* @param arrayToSort {number[]} Array to sort
20
20
* @return {Promise<number[] }
21
21
*/
22
- async sortArrayNumber ( arrayToSort : number [ ] ) : Promise < number [ ] > {
23
- return arrayToSort . sort ( ( a : number , b : number ) : number => a - b ) ;
24
- } ,
22
+ async sortArrayNumber ( arrayToSort : number [ ] ) : Promise < number [ ] > {
23
+ return arrayToSort . sort ( ( a : number , b : number ) : number => a - b ) ;
24
+ } ,
25
25
26
- /**
26
+ /**
27
27
* Sort array of dates
28
28
* @param arrayToSort {string[]} Array to sort
29
29
* @return {Promise<string[] }
30
30
*/
31
- async sortArrayDate ( arrayToSort : string [ ] ) : Promise < string [ ] > {
32
- return arrayToSort . sort ( ( a : string , b : string ) : number => new Date ( a ) . getTime ( ) - new Date ( b ) . getTime ( ) ) ;
33
- } ,
31
+ async sortArrayDate ( arrayToSort : string [ ] ) : Promise < string [ ] > {
32
+ return arrayToSort . sort ( ( a : string , b : string ) : number => new Date ( a ) . getTime ( ) - new Date ( b ) . getTime ( ) ) ;
33
+ } ,
34
34
35
- /**
35
+ /**
36
36
* Calculate percentage
37
37
* @param num {number|float} Number to do the percentage
38
38
* @param percentage {number} Percentage value
39
39
* @returns {Promise<number|float> }
40
40
*/
41
- async percentage ( num : number , percentage : number ) : Promise < number > {
42
- return ( num / 100 ) * percentage ;
43
- } ,
41
+ async percentage ( num : number , percentage : number ) : Promise < number > {
42
+ return ( num / 100 ) * percentage ;
43
+ } ,
44
44
45
- /**
45
+ /**
46
46
* Calculate age
47
47
* @param birthdate {string} Date of birth
48
48
* @returns {Promise<number> }
49
49
*/
50
- async age ( birthdate : Date ) : Promise < number > {
51
- const age = today . getFullYear ( ) - birthdate . getFullYear ( ) ;
50
+ async age ( birthdate : Date ) : Promise < number > {
51
+ const age = today . getFullYear ( ) - birthdate . getFullYear ( ) ;
52
52
53
- if ( today . getMonth ( ) < birthdate . getMonth ( )
53
+ if ( today . getMonth ( ) < birthdate . getMonth ( )
54
54
|| ( today . getMonth ( ) === birthdate . getMonth ( ) && today . getDate ( ) < birthdate . getDate ( ) ) ) {
55
- return age - 1 ;
56
- }
55
+ return age - 1 ;
56
+ }
57
57
58
- return age ;
59
- } ,
58
+ return age ;
59
+ } ,
60
60
61
- /**
61
+ /**
62
62
* Make a string's first character uppercase
63
63
* @param value {string}
64
64
* @returns {string }
65
65
*/
66
- capitalize ( value : string ) : string {
67
- return value . charAt ( 0 ) . toUpperCase ( ) + value . slice ( 1 ) ;
68
- } ,
66
+ capitalize ( value : string ) : string {
67
+ return value . charAt ( 0 ) . toUpperCase ( ) + value . slice ( 1 ) ;
68
+ } ,
69
69
70
- /**
70
+ /**
71
71
* Search occurrence of a value in text
72
72
* @param text {string}
73
73
* @param searchedValue {string}
74
74
* @returns {string }
75
75
*/
76
- async searchOccurrence ( text : string , searchedValue : string ) : Promise < number > {
77
- return text . split ( searchedValue ) . length - 1 ;
78
- } ,
79
- } ;
76
+ async searchOccurrence ( text : string , searchedValue : string ) : Promise < number > {
77
+ return text . split ( searchedValue ) . length - 1 ;
78
+ } ,
79
+ } ;
0 commit comments