writable._final(callback)


  • callback <Function> 当结束写入所有剩余数据时的回调函数。

_final() 方法不能直接调用。 它应该由子类实现,且只能通过内部的 Writable 类的方法调用。

该方法会在流关闭之前被调用,且在 callback 被调用后触发 'finish' 事件。 主要用于在流结束之前关闭资源或写入缓冲的数据。

  • callback <Function> Call this function (optionally with an error argument) when finished writing any remaining data.

The _final() method must not be called directly. It may be implemented by child classes, and if so, will be called by the internal Writable class methods only.

This optional function will be called before the stream closes, delaying the 'finish' event until callback is called. This is useful to close resources or write buffered data before a stream ends.