File tree 1 file changed +37
-3
lines changed
Roadmap/07 - PILAS Y COLAS/typescript 1 file changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -26,19 +26,53 @@ queue.shift()
26
26
console . log ( 'Después de eliminar un elemento:' , queue )
27
27
28
28
//EXTRA
29
- import * as readline from 'readline'
29
+ import * as readline from 'node: readline/promises '
30
30
31
31
const rl = readline . createInterface ( {
32
32
input : process . stdin ,
33
33
output : process . stdout ,
34
34
} )
35
35
36
- //Sistema de navegacion
36
+ //Sistema de navegación
37
37
function browser ( ) : void {
38
- const stack = [ ]
38
+ const pagesStack : string [ ] = [ ]
39
+
40
+ function menu ( ) : void {
41
+ if ( pagesStack . length > 0 ) {
42
+ console . log ( `\nActualmente estas en ${ pagesStack [ pagesStack . length - 1 ] } ` )
43
+ } else {
44
+ console . log ( '\nEstas en la pagina de inicio' )
45
+ }
46
+
47
+ rl . question (
48
+ 'Elige una opcion\n1. Avanzar\n2. Retroceder\n3. Salir del navegador\nIr a otra pagina '
49
+ ) . then ( ( answer ) => {
50
+ if ( answer === '1' ) {
51
+ menu ( )
52
+ } else if ( answer === '2' ) {
53
+ pagesStack . pop ( )
54
+ menu ( )
55
+ } else if ( answer === '3' ) {
56
+ console . log ( '\nSaliendo del navegador...' )
57
+ printer ( )
58
+ } else {
59
+ pagesStack . push ( answer )
60
+ menu ( )
61
+ }
62
+ } )
63
+ }
64
+
65
+ menu ( )
39
66
}
40
67
68
+ browser ( )
69
+
41
70
//Impresora compartida
42
71
function printer ( ) : void {
43
72
const queue = [ ]
73
+
74
+ console . log ( 'Hola' )
75
+ rl . close ( )
76
+
77
+ function menu ( ) { }
44
78
}
You can’t perform that action at this time.
0 commit comments