@@ -38,61 +38,41 @@ export const getCurrentCmdArry = (history: string[]) =>
38
38
39
39
/**
40
40
* Check current render makes redirect
41
- * @param {string[] } arg - arg of the command
42
41
* @param {boolean } rerender - is submitted or not
43
42
* @param {string[] } currentCommand - current submitted command
44
43
* @param {string } command - the command of the function
45
44
* @returns {boolean } redirect - true | false
46
45
*/
47
46
export const checkRedirect = (
48
- arg : string [ ] ,
49
47
rerender : boolean ,
50
48
currentCommand : string [ ] ,
51
49
command : string
52
- ) : boolean => {
53
- if (
54
- arg . length > 0 && // contains arg
55
- arg [ 0 ] === "go" && // first arg is 'go'
56
- rerender && // is submitted
57
- currentCommand [ 0 ] === command && // current command starts with ('socials'|'projects')
58
- currentCommand . length > 1 && // current command has arg
59
- currentCommand . length < 4 && // if num of arg is valid (not `projects go 1 sth`)
60
- _ . includes ( [ 1 , 2 , 3 , 4 ] , parseInt ( currentCommand [ 2 ] ) ) // arg last part is one of id
61
- ) {
62
- return true ;
63
- } else {
64
- return false ;
65
- }
66
- } ;
50
+ ) : boolean =>
51
+ rerender && // is submitted
52
+ currentCommand [ 0 ] === command && // current command starts with ('socials'|'projects')
53
+ currentCommand [ 1 ] === "go" && // first arg is 'go'
54
+ currentCommand . length > 1 && // current command has arg
55
+ currentCommand . length < 4 && // if num of arg is valid (not `projects go 1 sth`)
56
+ _ . includes ( [ 1 , 2 , 3 , 4 ] , parseInt ( currentCommand [ 2 ] ) ) ; // arg last part is one of id
67
57
68
58
/**
69
59
* Check current render makes redirect for theme
70
- * @param {string[] } arg - arg of the command
71
60
* @param {boolean } rerender - is submitted or not
72
61
* @param {string[] } currentCommand - current submitted command
73
62
* @param {string[] } themes - the command of the function
74
63
* @returns {boolean } redirect - true | false
75
64
*/
76
65
export const checkThemeSwitch = (
77
- arg : string [ ] ,
78
66
rerender : boolean ,
79
67
currentCommand : string [ ] ,
80
68
themes : string [ ]
81
- ) : boolean => {
82
- if (
83
- arg . length > 0 && // contains arg
84
- arg [ 0 ] === "set" && // first arg is 'set'
85
- rerender && // is submitted
86
- currentCommand [ 0 ] === "themes" && // current command starts with ('themes')
87
- currentCommand . length > 1 && // current command has arg
88
- currentCommand . length < 4 && // if num of arg is valid (not `themes set light sth`)
89
- _ . includes ( themes , currentCommand [ 2 ] ) // arg last part is one of id
90
- ) {
91
- return true ;
92
- } else {
93
- return false ;
94
- }
95
- } ;
69
+ ) : boolean =>
70
+ rerender && // is submitted
71
+ currentCommand [ 0 ] === "themes" && // current command starts with 'themes'
72
+ currentCommand [ 1 ] === "set" && // first arg is 'set'
73
+ currentCommand . length > 1 && // current command has arg
74
+ currentCommand . length < 4 && // if num of arg is valid (not `themes set light sth`)
75
+ _ . includes ( themes , currentCommand [ 2 ] ) ; // arg last part is one of id
96
76
97
77
/**
98
78
* Perform advanced tab actions
0 commit comments