Skip to content

Commit

Permalink
docs: clarify usage of stream.Writable.write
Browse files Browse the repository at this point in the history
Add separate sample code for the write-after-end case to avoid
confusion.

PR: #15517
PR-URL: nodejs/node-v0.x-archive#15517
Reviewed-By: Julien Gilli <jgilli@fastmail.fm>
  • Loading branch information
AlexKVal authored and Julien Gilli committed Apr 15, 2015
1 parent de90403 commit 9800e0b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions doc/api/stream.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,20 @@ function writeOneMillionTimes(writer, data, encoding, callback) {
Call this method when no more data will be written to the stream. If
supplied, the callback is attached as a listener on the `finish` event.

Calling [`write()`][] after calling [`end()`][] will raise an error.

```javascript
// write 'hello, ' and then end with 'world!'
var file = fs.createWriteStream('example.txt');
file.write('hello, ');
file.end('world!');
// writing more now is not allowed!
```

Calling [`write()`][] after calling [`end()`][] will raise an error:

```javascript
// end with 'world!' and then write with 'hello, ' will raise an error
var file = fs.createWriteStream('example.txt');
file.end('world!');
file.write('hello, ');
```

#### Event: 'finish'
Expand Down

0 comments on commit 9800e0b

Please sign in to comment.