Reputation: 51
In nodejs, how do I display and update text on the same line, like a running clock or currrent download speed?
Upvotes: 0
Views: 363
Reputation: 13812
'use strict';
const rl = require('readline');
function clearLine() {
rl.cursorTo(process.stdout, 0);
rl.clearLine(process.stdout, 0);
}
setInterval(() => {
clearLine();
process.stdout.write(new Date().toString());
}, 1000);
Upvotes: 1