diff options
author | AlexKVal <alexkval@gmail.com> | 2015-04-15 19:01:11 +0300 |
---|---|---|
committer | Julien Gilli <julien.gilli@joyent.com> | 2015-04-15 11:27:34 -0700 |
commit | 9800e0b42838e5c95f02422f138ce16c2e8eed3f (patch) | |
tree | 002816d84d940569cd349e9c4351649c8a7528ef | |
parent | de904033fa95f0993bd8583108ac0efcda8947af (diff) | |
download | node-9800e0b42838e5c95f02422f138ce16c2e8eed3f.tar.gz |
docs: clarify usage of stream.Writable.write
Add separate sample code for the write-after-end case to avoid
confusion.
PR: #15517
PR-URL: https://github.com/joyent/node/pull/15517
Reviewed-By: Julien Gilli <jgilli@fastmail.fm>
-rw-r--r-- | doc/api/stream.markdown | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/doc/api/stream.markdown b/doc/api/stream.markdown index 3230a5927..e0f7d72ba 100644 --- a/doc/api/stream.markdown +++ b/doc/api/stream.markdown @@ -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' |