diff --git a/README.md b/README.md index eeeb540..8a9e8af 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # assignment_node_dictionary_reader I CAN HAS SPELLZ IN "Node"? K THNX BYE +Ann Allan diff --git a/warmup/index.js b/warmup/index.js new file mode 100644 index 0000000..207f8c7 --- /dev/null +++ b/warmup/index.js @@ -0,0 +1,44 @@ +function one () { + // Start listening to STDIN + process.stdin.resume() + process.stdin.setEncoding('utf8') + + // Inline function to handle + // message output + var showMessage = (err) => { + console.log('State one') + console.log('Type "next" to continue') + if (err) { + console.error(err) + } + } + + // Display message + showMessage() + + // Handler for STDIN data + // event + var onData = (data) => { + data = data.trim() + + // If user input "next" + // let's go to the next + // state + if (data === 'next') { + process.stdin.pause() + process.stdin.removeListener('data', onData) + + // ---------------------------------------- + // Go to next view here + // ---------------------------------------- + } else { + // All other input is invalid + showMessage(`Invalid: ${data}`) + } + } + // Set the listener + process.stdin.on('data', onData) +} + +// Start the app +one()