I want to display data on two lines of the console. I just want to update the two lines everytime.
What I have done till now is -
var _logInline = function(alpha, bravo) {
process.stdout.cursorTo(0, 0);
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(alpha.toString());
process.stdout.write('\n');
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(bravo.toString());
process.stdout.write('\n');
};
var delay = 1000;
var time = 0;
setInterval(function() {
time++;
_logInline('alpha-' + time, 'bravo-' + time * time);
}, delay);
The obvious problem with this solution is that the cursor goes to the top of the window. I don't want that, instead it should display the content where ever the cursor is at the moment. Probably I need to get the current cursor position first in my logic. Is there a way to do that?
Alternative and the most preferred solution would be to get a lib which can do the same thing
EDIT: I have seen some questions on stackoverflow which give an option of logging without new line but this is not exactly what I want. I want multiple no-new-line logging.