From the course: Node.js Essential Training

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Reporting progress with setInterval

Reporting progress with setInterval - Node.js Tutorial

From the course: Node.js Essential Training

Reporting progress with setInterval

- [Narrator] So let's for the fun of it add one more thing. We're going to add this to our increment time function. So right underneath where we're saying current time and wait interval, we're going to create a value called p, and we're going to set that equal to Math.floor. Inside of this we're going to take our currentTime divided by our waitTime. We're going to multiply that by 100. And then we're going to say process.standard output.clearLine. We're going to say process, standard, output.cursorTo and we'll set the cursor to zero. So that first position will get rid of our other console message. And here we'll say process, standard output.right, waiting. And then we'll use that p value that we've set here. Let's go ahead and run it one more time. So now we see the waiting communicated as a percentage in place, and that's because standard output gives us the tools to manage how we write all of this data to the console.…

Contents