stream: add final method · nodejs/node@07c7f19
@@ -1198,7 +1198,8 @@ on the type of stream being created, as detailed in the chart below:
11981198 <p>[Writable](#stream_class_stream_writable)</p>
11991199</td>
12001200<td>
1201- <p><code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code></p>
1201+ <p><code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code>,
1202+ <code>[_final][stream-_final]</code></p>
12021203</td>
12031204</tr>
12041205<tr>
@@ -1209,7 +1210,8 @@ on the type of stream being created, as detailed in the chart below:
12091210 <p>[Duplex](#stream_class_stream_duplex)</p>
12101211</td>
12111212<td>
1212- <p><code>[_read][stream-_read]</code>, <code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code></p>
1213+ <p><code>[_read][stream-_read]</code>, <code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code>,
1214+ <code>[_final][stream-_final]</code></p>
12131215</td>
12141216</tr>
12151217<tr>
@@ -1220,7 +1222,8 @@ on the type of stream being created, as detailed in the chart below:
12201222 <p>[Transform](#stream_class_stream_transform)</p>
12211223</td>
12221224<td>
1223- <p><code>[_transform][stream-_transform]</code>, <code>[_flush][stream-_flush]</code></p>
1225+ <p><code>[_transform][stream-_transform]</code>, <code>[_flush][stream-_flush]</code>,
1226+ <code>[_final][stream-_final]</code></p>
12241227</td>
12251228</tr>
12261229</table>
@@ -1279,6 +1282,8 @@ constructor and implement the `writable._write()` method. The
12791282[`stream._writev()`][stream-_writev] method.
12801283* `destroy` {Function} Implementation for the
12811284[`stream._destroy()`][writable-_destroy] method.
1285+* `final` {Function} Implementation for the
1286+[`stream._final()`][stream-_final] method.
1282128712831288For example:
12841289@@ -1398,6 +1403,22 @@ added: REPLACEME
13981403* `callback` {Function} A callback function that takes an optional error argument
13991404 which is invoked when the writable is destroyed.
140014051406+#### writable.\_final(callback)
1407+<!-- YAML
1408+added: REPLACEME
1409+-->
1410+1411+* `callback` {Function} Call this function (optionally with an error
1412+ argument) when you are done writing any remaining data.
1413+1414+Note: `_final()` **must not** be called directly. It MAY be implemented
1415+by child classes, and if so, will be called by the internal Writable
1416+class methods only.
1417+1418+This optional function will be called before the stream closes, delaying the
1419+`finish` event until `callback` is called. This is useful to close resources
1420+or write buffered data before a stream ends.
1421+14011422#### Errors While Writing
1402142314031424It is recommended that errors occurring during the processing of the
@@ -2115,6 +2136,7 @@ readable buffer so there is nothing for a user to consume.
21152136[stream-_transform]: #stream_transform_transform_chunk_encoding_callback
21162137[stream-_write]: #stream_writable_write_chunk_encoding_callback_1
21172138[stream-_writev]: #stream_writable_writev_chunks_callback
2139+[stream-_final]: #stream_writable_final_callback
21182140[stream-end]: #stream_writable_end_chunk_encoding_callback
21192141[stream-pause]: #stream_readable_pause
21202142[stream-push]: #stream_readable_push_chunk_encoding