Node.js readStream.isRaw Property
Last Updated :
11 Apr, 2023
The readStream.isRaw property is an inbuilt application programming interface of class ReadStream within tty module which is used to check if the read stream object is currently configured to operate as a raw device or not.
Syntax:
const status = ReadStream.isRaw;
Return Value: This property returns true if and only if the read stream object is currently configured to operate as a raw device.
Example 1: Filename: index.js
javascript
const dgram = require( 'dgram' );
let client = dgram.createSocket( "udp4" );
let server = dgram.createSocket( "udp4" );
server.on( "message" , function (msg) {
let ReadStream = process.stdin;
const status = ReadStream.isRaw;
if (status) {
process.stdout.write(msg
+ "configured" + "\n" );
} else {
process.stdout.write(msg
+ "not configured" + "\n" );
}
process.exit();
})
.bind(1234, () => {
});
client.send( "It is " , 0, 7, 1234, "localhost" );
|
Output:
It is not configured
Example 2: Filename: index.js
javascript
let ReadStream = process.stdin;
ReadStream.setRawMode( true );
const status = ReadStream.isRaw;
if (status) {
console.log( "It is configured" );
} else {
console.log( "it is not configured" );
}
|
Run the index.js file using the following command:
node index.js
Output:
It is configured
Reference: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_readstream_israw
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...