The writable.write() method is an inbuilt application programming interface of Stream module which is used to write some data to the Writable stream. The callback function is called once the data has been completely handled.
writable.write( chunk, encoding, callback)
Parameters: This method accepts three parameters as mentioned above and described below:
- chunk: It is an optional data to write. The value of chunk must be a string, buffer or Uint8Array. For object mode, the chunk value may be anything other than null.
- encoding: It holds the encoding value if chunk is a string value.
- callback: It is an optional callback function for stream.
Return Value: It returns false if the ‘drain’ event is emitted before this method otherwise returns true.
Below examples illustrate the use of writable.write() method in Node.js:
GfG true CS-Portal!