@@ -38,61 +38,41 @@ export const getCurrentCmdArry = (history: string[]) =>
3838
3939/**
4040 * Check current render makes redirect
41- * @param {string[] } arg - arg of the command
4241 * @param {boolean } rerender - is submitted or not
4342 * @param {string[] } currentCommand - current submitted command
4443 * @param {string } command - the command of the function
4544 * @returns {boolean } redirect - true | false
4645 */
4746export const checkRedirect = (
48- arg : string [ ] ,
4947 rerender : boolean ,
5048 currentCommand : string [ ] ,
5149 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
6757
6858/**
6959 * Check current render makes redirect for theme
70- * @param {string[] } arg - arg of the command
7160 * @param {boolean } rerender - is submitted or not
7261 * @param {string[] } currentCommand - current submitted command
7362 * @param {string[] } themes - the command of the function
7463 * @returns {boolean } redirect - true | false
7564 */
7665export const checkThemeSwitch = (
77- arg : string [ ] ,
7866 rerender : boolean ,
7967 currentCommand : string [ ] ,
8068 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
9676
9777/**
9878 * Perform advanced tab actions
0 commit comments