Created
January 7, 2019 04:15
-
-
Save brandonjyee/9af44711fb2e720e9f5c75dbda91d396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Node Notes | |
*/ | |
/* | |
========== Synchronous command line input w/o using external library ========== | |
*/ | |
process.stdin.setEncoding('utf8'); | |
function readlineSync() { | |
return new Promise((resolve, reject) => { | |
process.stdin.resume(); | |
process.stdin.on('data', function (data) { | |
process.stdin.pause(); // stops after one line reads | |
resolve(data); | |
}); | |
}); | |
} | |
async function main() { | |
let inputLine1 = await readlineSync(); | |
console.log('inputLine1 = ', inputLine1); | |
let inputLine2 = await readlineSync(); | |
console.log('inputLine2 = ', inputLine2); | |
console.log('bye'); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment