Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 9800e0b

Browse files
AlexKValJulien Gilli
authored and
Julien Gilli
committed
docs: clarify usage of stream.Writable.write
Add separate sample code for the write-after-end case to avoid confusion. PR: #15517 PR-URL: #15517 Reviewed-By: Julien Gilli <[email protected]>
1 parent de90403 commit 9800e0b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

doc/api/stream.markdown

+9-3
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,20 @@ function writeOneMillionTimes(writer, data, encoding, callback) {
517517
Call this method when no more data will be written to the stream. If
518518
supplied, the callback is attached as a listener on the `finish` event.
519519

520-
Calling [`write()`][] after calling [`end()`][] will raise an error.
521-
522520
```javascript
523521
// write 'hello, ' and then end with 'world!'
524522
var file = fs.createWriteStream('example.txt');
525523
file.write('hello, ');
526524
file.end('world!');
527-
// writing more now is not allowed!
525+
```
526+
527+
Calling [`write()`][] after calling [`end()`][] will raise an error:
528+
529+
```javascript
530+
// end with 'world!' and then write with 'hello, ' will raise an error
531+
var file = fs.createWriteStream('example.txt');
532+
file.end('world!');
533+
file.write('hello, ');
528534
```
529535

530536
#### Event: 'finish'

0 commit comments

Comments
 (0)