Reputation: 3665
I'm writing to a file (a writable steam) and I need to close the file once I'm done. I'm not sure of the difference between these two functions or if I need to call them both. Here's what the documentation says:
stream.end()
Terminates the stream with EOF or FIN. This call will allow queued write data to be sent before closing the stream.
stream.destroySoon()
After the write queue is drained, close the file descriptor. destroySoon()
can still destroy straight away, as long as there is no data left in the queue for writes.
Upvotes: 4
Views: 2315
Reputation: 3665
There is no difference.
From fs.js in the node source:
// There is no shutdown() for files.
WriteStream.prototype.destroySoon = WriteStream.prototype.end;
Upvotes: 6