Sean Dittmar
Sean Dittmar

Reputation: 51

Nodejs, how to display and update text on the same line, like a running clock or download speed?

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

Answers (1)

vsemozhebuty
vsemozhebuty

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

Related Questions