The writeStream.rows property is an inbuilt application programming interface of class WriteStream within tty module which is used to get the number of rows this write Stream object has.
Syntax:
const writeStream.rows
Parameters: This property does not hold any parameter.
Return Value: This property returns the number of rows this write Stream object has.
Example 1: Filename: index.js
// Node.js program to demonstrate the // writeStream.rows property // Importing dgram module var dgram = require( 'dgram' );
// Creating and initializing client // and server socket var client = dgram.createSocket( "udp4" );
var server = dgram.createSocket( "udp4" );
// Handling the message event server.on( "message" , function (msg) {
// Creating and initializing a
// WriteStream object
let WriteStream = process.stdout;
// Getting number of rows
// by using rows API
const col = WriteStream.rows;
// Displaying the result
process.stdout.write(msg + col);
// Exiting process
process.exit();
}) // Binding server with port .bind(1234, () => { }); // Client sending message to server client.send( "Number of rows :- " ,
0, 21, 1234, "localhost" );
|
Output:
Number of rows :- 10
Example 2: Filename: index.js
// Node.js program to demonstrate the // writeStream.rows property // Creating and initializing a // WriteStream object let WriteStream = process.stdout; // Getting number of rows // by using rows API const col = WriteStream.rows; // Displaying the result console.log( "Number of rows :- " + col);
|
Run the index.js file using the following command:
node index.js
Output:
Number of rows :- 10
Reference: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_writestream_rows