The writable.cork() method is an inbuilt application programming interface of Stream module which is used to write every data into the buffer memory. When we use stream.uncork() or stream.end() methods then the buffer data will be flushed.
Parameters: This method does not accept any parameters.
Return Value: If this method is used then the data written after this method is not displayed in the output as these data are stored in the memory and can be again shown using some other specific methods.
Below examples illustrate the use of writable.cork() method in Node.js:
Here, in the above example the data written before cork() method is only displayed and the data written after it is corked i.e. stored in the memory.
hi hello world
In the above example, the cork() method is written at last so, none of the data is being stored in the memory. Therefore, all the written data is displayed in the output.