The
writable.uncork() method is an inbuilt application programming interface of Stream module which is used to flush all the buffered data when stream.cork() method was called.
Syntax:
writable.uncork()
Parameters: This method does not accept any parameters.
Return Value: If this method is being called then the data which was being corked is again displayed in the output.
Below examples illustrate the use of
writable.uncork() method in Node.js:
Example 1:
Output:
hi
hello
world
In the above example, the data that was being corked is also returned in the output as uncork() function is called after that.
Example 2:
Output:
hi
hello
So, you need to call uncork() function the number of times you have called cork function. In the above example we have called cork() function two times so the uncork function is also called twice.
Reference: https://nodejs.org/api/stream.html#stream_writable_uncork