Last active
March 16, 2017 03:28
-
-
Save kei0425/a81514bc2da5f17744b1c9c136d0a4a6 to your computer and use it in GitHub Desktop.
async/await 標準入力読み込み
This file contains 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
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
// Here your code ! | |
function getStdin() { | |
return new Promise((resolve, reject) => { | |
let input_string = ''; | |
process.stdin.on('data', function(chunk) { | |
input_string += chunk; | |
}); | |
process.stdin.on('end', function() { | |
resolve(input_string); | |
}); | |
}); | |
} | |
async function main() { | |
let input_string = await getStdin(); | |
console.log(input_string); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment