-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: add added:
information for stream
#7287
Closed
Closed
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c0cc2d2
adding added date to the Class Writable
italoacasas f0b4c26
using let instead var in the example
italoacasas 584473b
fixing date
italoacasas 8427901
adding added date to the close event
italoacasas 2a3041c
adding added date to the drain event
italoacasas f606d9f
using let instad var in the example
italoacasas 6d917e4
adding older dates
italoacasas 052162b
writable streams section
italoacasas 93d92a5
adding added date to the readable section
italoacasas 8946006
adding added date to Duplex class
italoacasas 3a7a1db
Adding added date to Transform class
italoacasas 298269b
using the implemented version on .end()
italoacasas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,7 @@ const server = http.createServer( (req, res) => { | |
// req is an http.IncomingMessage, which is a Readable Stream | ||
// res is an http.ServerResponse, which is a Writable Stream | ||
|
||
var body = ''; | ||
let body = ''; | ||
// Get the data as utf8 strings. | ||
// If an encoding is not set, Buffer objects will be received. | ||
req.setEncoding('utf8'); | ||
|
@@ -205,10 +205,16 @@ myStream.end('done writing data'); | |
``` | ||
|
||
#### Class: stream.Writable | ||
<!-- YAML | ||
added: v0.3.0 | ||
--> | ||
|
||
<!--type=class--> | ||
|
||
##### Event: 'close' | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
|
||
The `'close'` event is emitted when the stream and any of its underlying | ||
resources (a file descriptor, for example) have been closed. The event indicates | ||
|
@@ -217,6 +223,9 @@ that no more events will be emitted, and no further computation will occur. | |
Not all Writable streams will emit the `'close'` event. | ||
|
||
##### Event: 'drain' | ||
<!-- YAML | ||
added: v0.3.0 | ||
--> | ||
|
||
If a call to [`stream.write(chunk)`][stream-write] returns `false`, the | ||
`'drain'` event will be emitted when it is appropriate to resume writing data | ||
|
@@ -226,7 +235,7 @@ to the stream. | |
// Write the data to the supplied writable stream one million times. | ||
// Be attentive to back-pressure. | ||
function writeOneMillionTimes(writer, data, encoding, callback) { | ||
var i = 1000000; | ||
let i = 1000000; | ||
write(); | ||
function write() { | ||
var ok = true; | ||
|
@@ -251,6 +260,9 @@ function writeOneMillionTimes(writer, data, encoding, callback) { | |
``` | ||
|
||
##### Event: 'error' | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
|
||
* {Error} | ||
|
||
|
@@ -276,6 +288,9 @@ writer.on('finish', () => { | |
``` | ||
|
||
##### Event: 'pipe' | ||
<!-- YAML | ||
added: v0.3.0 | ||
--> | ||
|
||
* `src` {stream.Readable} source stream that is piping to this writable | ||
|
||
|
@@ -293,6 +308,9 @@ reader.pipe(writer); | |
``` | ||
|
||
##### Event: 'unpipe' | ||
<!-- YAML | ||
added: v0.9.4 | ||
--> | ||
|
||
* `src` {[Readable][] Stream} The source stream that | ||
[unpiped][`stream.unpipe()`] this writable | ||
|
@@ -391,6 +409,9 @@ process.nextTick(() => { | |
``` | ||
|
||
##### writable.write(chunk[, encoding][, callback]) | ||
<!-- YAML | ||
added: v0.9.4 | ||
--> | ||
|
||
* `chunk` {String|Buffer} The data to write | ||
* `encoding` {String} The encoding, if `chunk` is a String | ||
|
@@ -413,6 +434,9 @@ should be paused until the `'drain'` event is emitted. | |
A Writable stream in object mode will always ignore the `encoding` argument. | ||
|
||
### Readable Streams | ||
<!-- YAML | ||
added: v0.3.0 | ||
--> | ||
|
||
Readable streams are an abstraction for a *source* from which data is | ||
consumed. | ||
|
@@ -520,6 +544,9 @@ use the [`EventEmitter`][] and `readable.pause()`/`readable.resume()` APIs. | |
<!--type=class--> | ||
|
||
##### Event: 'close' | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be an |
||
|
||
The `'close'` event is emitted when the stream and any of its underlying | ||
resources (a file descriptor, for example) have been closed. The event indicates | ||
|
@@ -528,6 +555,9 @@ that no more events will be emitted, and no further computation will occur. | |
Not all [Readable][] streams will emit the `'close'` event. | ||
|
||
##### Event: 'data' | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
|
||
* `chunk` {Buffer|String|any} The chunk of data. For streams that are not | ||
operating in object mode, the chunk will be either a string or `Buffer`. | ||
|
@@ -558,6 +588,9 @@ readable.on('data', (chunk) => { | |
``` | ||
|
||
##### Event: 'end' | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
|
||
The `'end'` event is emitted when there is no more data to be consumed from | ||
the stream. | ||
|
@@ -578,6 +611,9 @@ readable.on('end', () => { | |
``` | ||
|
||
##### Event: 'error' | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
|
||
* {Error} | ||
|
||
|
@@ -651,6 +687,9 @@ readable.isPaused() // === false | |
``` | ||
|
||
##### readable.pause() | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
|
||
* Return: `this` | ||
|
||
|
@@ -774,6 +813,9 @@ event will also be emitted. | |
event has been emitted will return `null`. No runtime error will be raised. | ||
|
||
##### readable.resume() | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
|
||
* Return: `this` | ||
|
||
|
@@ -793,6 +835,9 @@ getReadableStreamSomehow() | |
``` | ||
|
||
##### readable.setEncoding(encoding) | ||
<!-- YAML | ||
added: v0.3.1 | ||
--> | ||
|
||
* `encoding` {String} The encoding to use. | ||
* Return: `this` | ||
|
@@ -1579,7 +1624,7 @@ For Duplex streams, `objectMode` can be set exclusively for either the Readable | |
or Writable side using the `readableObjectMode` and `writableObjectMode` options | ||
respectively. | ||
|
||
In the following example, for instance, a new Transform stream (which is a | ||
In the following example, for instance, a new Transform stream (which is a | ||
type of [Duplex][] stream) is created that has an object mode Writable side | ||
that accepts JavaScript numbers that are converted to hexidecimal strings on | ||
the Readable side. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.9.4