Skip to content

Instantly share code, notes, and snippets.

@kei0425
Last active March 16, 2017 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kei0425/a81514bc2da5f17744b1c9c136d0a4a6 to your computer and use it in GitHub Desktop.
Save kei0425/a81514bc2da5f17744b1c9c136d0a4a6 to your computer and use it in GitHub Desktop.
async/await 標準入力読み込み
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