Answer the question
In order to leave comments, you need to log in
How to get data through readline node js?
Hello. I'm trying to solve a problem in Node js, where the inputs are strings, the number of strings can be different, in one task there are 3 of them, in another there are 2, in the third there are 5 lines of data. From this question, how can I understand that the input data has ended and I can start processing this data? I dug into the documentation and found the line method, which allows you to read these lines, but how to know that the input data has ended and you can start working with the data, there must be some kind of check inside the readline.on (line) construct that should return apparently , and after all this construction, I should apparently start working with the code, if I understand everything correctly
Example of input data for the task
1
2
3
1
const readline = require('readline').createInterface(process.stdin, process.stdout);
readline.on('line', (line) => {
console.log(line)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question