I am writing nodejs code for Hackerearth test. I am pressing enter key but the process.stdin.on('end',function(){}) is not getting called. So I want to know when this 'end' event will get called? Or Can I use any other library for user input on Hackerearth. I have also views multiple question on stackoverflow for same but didn't get answer.
process.stdin.resume();
process.stdin.setEncoding("utf-8");
var input = '';
process.stdin.on("data", function (n) {
input += n;
});
process.stdin.on("end",function(){
console.log(input)
})
endis called either when you close stdin (for example if you donode myscript.js < foo.txtand you've reached the last byte of the text file) or when you send the end-of-file character (usually by pressing ctrl-D)