Node.js writeStream.clearScreenDown() Method
The writeStream.clearScreenDown() method is an inbuilt application programming interface of class WriteStream within tty module which is used to clear this write stream object from the current cursor down.
Syntax:
writeStream.clearScreenDown([callback])
Parameters: This method does not accept any parameter but it invokes a callback function.
Return Value: This method returns boolean value true if the write object is clear otherwise false.
Example 1: Filename: index.js
var dgram = require( 'dgram' );
var client = dgram.createSocket( "udp4" );
var server = dgram.createSocket( "udp4" );
server.on( "message" , function (msg) {
let WriteStream = process.stdout;
const col = WriteStream.clearScreenDown();
process.stdout.write(msg + col);
process.exit();
})
.bind(1234, () => {
});
client.send( "The line is clear :- " ,
0, 26, 1234, "localhost" );
|
Output:
The line is clear :- true
Example 2: Filename: index.js
let WriteStream = process.stdout;
const col = WriteStream.clearScreenDown();
console.log( "The write stream object"
+ " is clear :- " + col);
|
Run the index.js file using the following command:
node index.js
Output:
The write stream object is clear :- true
Reference: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_writestream_clearscreendown_callback
Last Updated :
06 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...