Node.js readStream.setRawMode() Method Last Updated : 11 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The readStream.setRawMode() method is an inbuilt application programming interface of class ReadStream within 'tty' module which is used to set the raw mode of the Read stream object to work as a raw device. Syntax: const readStream.setRawMode( mode ) Parameters: This method takes the Boolean value as an argument. Return Value: This method does not return any value. Example 1: Filename: index.js JavaScript // Node.js program to demonstrate the // readStream.setRawMode() method // Importing dgram module const dgram = require('dgram'); // Creating and initializing client // and server socket const client = dgram.createSocket("udp4"); const server = dgram.createSocket("udp4"); // Catching the message event server.on("message", function (msg) { // Creating and initializing a // ReadStream object let ReadStream = process.stdin; // Setting the read stream Raw mode // by using setRawMode() method ReadStream.setRawMode(false); // Checking if it is configured or not // by using isRaw() method const status = ReadStream.isRaw; // Displaying the result if (status) process.stdout.write(msg + "configured" + "\n"); else process.stdout.write(msg + "not configured" + "\n"); // Exiting process process.exit(); }) // Binding server with port .bind(1234, () => { }); // Client sending message to server client.send("It is ", 0, 7, 1234, "localhost"); Output: It is not configured Example 2: Filename: index.js JavaScript // Node.js program to demonstrate the // readStream.setRawMode() method // Creating and initializing a ReadStream object let ReadStream = process.stdin; // Setting the read stream Raw mode // by using setRawMode() method ReadStream.setRawMode(true); // Checking if it is configured or not // by using isRaw() method const status = ReadStream.isRaw; // Displaying the result if (status) console.log("It is configured"); else console.log("It is not configured"); Output: It is configured Run the index.js file using the following command: node index.js Reference: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_readstream_setrawmode_mode Comment More infoAdvertise with us Next Article Node.js Stream readable.resume() Method R rohitprasad3 Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods Similar Reads Node.js Stream readable.read() Method The readable.read() method is an inbuilt application programming interface of Stream module which is used to read the data out of the internal buffer. It returns data as a buffer object if no encoding is being specified or if the stream is working in object mode. Syntax: readable.read( size ) Parame 2 min read Node.js Stream readable.resume() Method Node.js streams are powerful tools for handling data transfer efficiently, especially when dealing with large datasets or real-time data. The readable.resume() method is a part of the readable stream interface, playing a crucial role in managing the flow of data. This article will delve into what re 4 min read Node.js Stream readable.unshift() Method The readable.unshift() method in a Readable Stream is utilized to push a chunk of data back into the internal buffer. However, when a stream is being fully consumed and it needs to be "un-consumed" then this method is helpful. Syntax: readable.unshift( chunk, encoding ) Parameters: This method accep 2 min read Node.js Stream readable.unpipe() Method The readable.unpipe() method in a Readable Stream is used to detach a Writable stream which was previously attached while using the stream.pipe() method. Syntax: readable.unpipe( destination ) Parameters: This method accepts single parameter destination which is the destination of writable stream to 1 min read Node.js stream.Readable.from() Method The stream.Readable.from() method is an inbuilt application programming interface of the Stream module which is used to construct Readable Streams out of iterators. Syntax: stream.Readable.from( iterable, options ) Parameters: This method accept two parameters as mentioned above and described below: 2 min read Node.js Stream readable.pipe() Method The readable.pipe() method in a Readable Stream is used to attach a Writable stream to the readable stream so that it consequently switches into flowing mode and then pushes all the data that it has to the attached Writable. Syntax:readable.pipe( destination, options )Parameters: This method accepts 2 min read Like