readline.clearScreenDown(stream)
The
readline.clearScreenDown() method clears the given TTY stream from the current
position of the cursor down.
/* Import readline module */ var readline = require('readline'); console.log("Hello World"); console.log("Hello World"); console.log("Hello World"); console.log("Hello World"); console.log("After 2 seconds, I am going to clear the complete screen"); /* Wait for 2 seconds */ var seconds = 2; var waitTill = new Date(new Date().getTime() + seconds * 1000); while(waitTill > new Date()){} readline.cursorTo(process.stdout, 0, 0) readline.clearScreenDown(process.stdout);
Once
you ran HelloWorld application, it shows below output.
Hello
World
Hello
World
Hello
World
Hello
World
After
2 seconds, I am going to clear the complete screen
After
2 seconds, it clears the previous displayed lines from terminal.
No comments:
Post a Comment