From c0cc2d24f2d3462415839b549c7792b2fc04dcbd Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Mon, 13 Jun 2016 10:32:44 -0400 Subject: [PATCH 01/12] adding added date to the Class Writable --- doc/api/stream.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/api/stream.md b/doc/api/stream.md index c7aa8f24170647..f9b58483e4030d 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -205,6 +205,9 @@ myStream.end('done writing data'); ``` #### Class: stream.Writable + From f0b4c26d01fd461b99bff96a6b8216cc353cb5cc Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Mon, 13 Jun 2016 10:45:37 -0400 Subject: [PATCH 02/12] using let instead var in the example --- doc/api/stream.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index f9b58483e4030d..08e220d504483d 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -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'); From 584473bd1b62c8653250d7a9ab0d089fe4e3d03b Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Mon, 13 Jun 2016 10:52:13 -0400 Subject: [PATCH 03/12] fixing date --- doc/api/stream.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 08e220d504483d..e4001e16b38e5b 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -206,7 +206,7 @@ myStream.end('done writing data'); #### Class: stream.Writable From 8427901df4158ff31fa1c901f0be6ce51d0aa3ea Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Mon, 13 Jun 2016 10:57:03 -0400 Subject: [PATCH 04/12] adding added date to the close event --- doc/api/stream.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/api/stream.md b/doc/api/stream.md index e4001e16b38e5b..612ffd68c63c4f 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -212,6 +212,9 @@ added: v0.9.4 ##### Event: 'close' + 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 From 2a3041cbe51edb6239dfccc745aa50cfdc855ef5 Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Mon, 13 Jun 2016 11:02:19 -0400 Subject: [PATCH 05/12] adding added date to the drain event --- doc/api/stream.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/api/stream.md b/doc/api/stream.md index 612ffd68c63c4f..895a0e70548c36 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -223,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' + 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 From f606d9f3e1db21a61c171ce0de771f839801cb85 Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Mon, 13 Jun 2016 14:32:52 -0400 Subject: [PATCH 06/12] using let instad var in the example --- doc/api/stream.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 895a0e70548c36..8795050be82c64 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -235,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; @@ -260,6 +260,9 @@ function writeOneMillionTimes(writer, data, encoding, callback) { ``` ##### Event: 'error' + * {Error} @@ -285,6 +288,9 @@ writer.on('finish', () => { ``` ##### Event: 'pipe' + * `src` {stream.Readable} source stream that is piping to this writable @@ -302,6 +308,9 @@ reader.pipe(writer); ``` ##### Event: 'unpipe' + * `src` {[Readable][] Stream} The source stream that [unpiped][`stream.unpipe()`] this writable @@ -400,6 +409,9 @@ process.nextTick(() => { ``` ##### writable.write(chunk[, encoding][, callback]) + * `chunk` {String|Buffer} The data to write * `encoding` {String} The encoding, if `chunk` is a String @@ -1588,7 +1600,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. From 6d917e437821f0b0cc253b93795ec2ce5ec60513 Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Mon, 13 Jun 2016 22:09:40 -0400 Subject: [PATCH 07/12] adding older dates --- doc/api/stream.md | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 8795050be82c64..602c44a287fda1 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -206,14 +206,14 @@ myStream.end('done writing data'); #### Class: stream.Writable ##### Event: 'close' The `'close'` event is emitted when the stream and any of its underlying @@ -224,7 +224,7 @@ Not all Writable streams will emit the `'close'` event. ##### Event: 'drain' If a call to [`stream.write(chunk)`][stream-write] returns `false`, the @@ -261,7 +261,7 @@ function writeOneMillionTimes(writer, data, encoding, callback) { ##### Event: 'error' * {Error} @@ -289,7 +289,7 @@ writer.on('finish', () => { ##### Event: 'pipe' * `src` {stream.Readable} source stream that is piping to this writable @@ -434,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 + Readable streams are an abstraction for a *source* from which data is consumed. @@ -541,6 +544,9 @@ use the [`EventEmitter`][] and `readable.pause()`/`readable.resume()` APIs. ##### Event: 'close' + 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 @@ -549,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' + * `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`. @@ -579,6 +588,9 @@ readable.on('data', (chunk) => { ``` ##### Event: 'end' + The `'end'` event is emitted when there is no more data to be consumed from the stream. @@ -599,6 +611,9 @@ readable.on('end', () => { ``` ##### Event: 'error' + * {Error} @@ -672,6 +687,9 @@ readable.isPaused() // === false ``` ##### readable.pause() + * Return: `this` @@ -795,6 +813,9 @@ event will also be emitted. event has been emitted will return `null`. No runtime error will be raised. ##### readable.resume() + * Return: `this` @@ -814,6 +835,9 @@ getReadableStreamSomehow() ``` ##### readable.setEncoding(encoding) + * `encoding` {String} The encoding to use. * Return: `this` From 052162bbc9147df6f8f6dd3738f152d24cd3b84f Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Sun, 19 Jun 2016 19:48:25 -0400 Subject: [PATCH 08/12] writable streams section --- doc/api/stream.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 602c44a287fda1..44178e0d933c39 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -206,14 +206,14 @@ myStream.end('done writing data'); #### Class: stream.Writable ##### Event: 'close' The `'close'` event is emitted when the stream and any of its underlying @@ -224,7 +224,7 @@ Not all Writable streams will emit the `'close'` event. ##### Event: 'drain' If a call to [`stream.write(chunk)`][stream-write] returns `false`, the @@ -261,7 +261,7 @@ function writeOneMillionTimes(writer, data, encoding, callback) { ##### Event: 'error' * {Error} @@ -272,6 +272,9 @@ data. The listener callback is passed a single `Error` argument when called. *Note*: The stream is not closed when the `'error'` event is emitted. ##### Event: 'finish' + The `'finish'` event is emitted after the [`stream.end()`][stream-end] method has been called, and all data has been flushed to the underlying system. @@ -289,7 +292,7 @@ writer.on('finish', () => { ##### Event: 'pipe' * `src` {stream.Readable} source stream that is piping to this writable @@ -331,6 +334,9 @@ reader.unpipe(writer); ``` ##### writable.cork() + The `writable.cork()` method forces all written data to be buffered in memory. The buffered data will be flushed when either the [`stream.uncork()`][] or @@ -343,6 +349,9 @@ implementations that implement the `writable.\_writev()` method can perform buffered writes in a more optimized manner. ##### writable.end([chunk][, encoding][, callback]) + * `chunk` {String|Buffer|any} Optional data to write. For streams not operating in object mode, `chunk` must be a string or a `Buffer`. For object mode @@ -368,6 +377,9 @@ file.end('world!'); ``` ##### writable.setDefaultEncoding(encoding) + * `encoding` {String} The new default encoding * Return: `this` @@ -376,6 +388,9 @@ The `writable.setDefaultEncoding()` method sets the default `encoding` for a [Writable][] stream. ##### writable.uncork() + The `writable.uncork()` method flushes all data buffered since [`stream.cork()`][] was called. From 93d92a533fa6877b4902099ef13efebaa7501ecb Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Mon, 20 Jun 2016 21:56:35 -0400 Subject: [PATCH 09/12] adding added date to the readable section --- doc/api/stream.md | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 44178e0d933c39..c9104e8b789864 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -449,9 +449,6 @@ should be paused until the `'drain'` event is emitted. A Writable stream in object mode will always ignore the `encoding` argument. ### Readable Streams - Readable streams are an abstraction for a *source* from which data is consumed. @@ -555,12 +552,15 @@ require more fine-grained control over the transfer and generation of data can use the [`EventEmitter`][] and `readable.pause()`/`readable.resume()` APIs. #### Class: stream.Readable + ##### Event: 'close' The `'close'` event is emitted when the stream and any of its underlying @@ -571,7 +571,7 @@ Not all [Readable][] streams will emit the `'close'` event. ##### Event: 'data' * `chunk` {Buffer|String|any} The chunk of data. For streams that are not @@ -604,7 +604,7 @@ readable.on('data', (chunk) => { ##### Event: 'end' The `'end'` event is emitted when there is no more data to be consumed from @@ -627,7 +627,7 @@ readable.on('end', () => { ##### Event: 'error' * {Error} @@ -640,6 +640,9 @@ to push an invalid chunk of data. The listener callback will be passed a single `Error` object. ##### Event: 'readable' + The `'readable'` event is emitted when there is data available to be read from the stream. In some cases, attaching a listener for the `'readable'` event will @@ -683,6 +686,9 @@ end preferred over the use of the `'readable'` event. ##### readable.isPaused() + * Return: {Boolean} @@ -703,7 +709,7 @@ readable.isPaused() // === false ##### readable.pause() * Return: `this` @@ -726,6 +732,9 @@ readable.on('data', (chunk) => { ``` ##### readable.pipe(destination[, options]) + * `destination` {stream.Writable} The destination for writing data * `options` {Object} Pipe options @@ -781,6 +790,9 @@ never closed until the Node.js process exits, regardless of the specified options. ##### readable.read([size]) + * `size` {Number} Optional argument to specify how much data to read. * Return {String|Buffer|Null} @@ -829,7 +841,7 @@ event has been emitted will return `null`. No runtime error will be raised. ##### readable.resume() * Return: `this` @@ -851,7 +863,7 @@ getReadableStreamSomehow() ##### readable.setEncoding(encoding) * `encoding` {String} The encoding to use. @@ -885,6 +897,9 @@ readable.on('data', (chunk) => { ``` ##### readable.unpipe([destination]) + * `destination` {stream.Writable} Optional specific stream to unpipe @@ -911,6 +926,9 @@ setTimeout(() => { ``` ##### readable.unshift(chunk) + * `chunk` {Buffer|String} Chunk of data to unshift onto the read queue @@ -971,6 +989,9 @@ appropriately, however it is best to simply avoid calling `readable.unshift()` while in the process of performing a read. ##### readable.wrap(stream) + * `stream` {Stream} An "old style" readable stream From 8946006fa51fe3c698fd4ca8b8657ea2c3331434 Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Tue, 12 Jul 2016 13:39:22 -0400 Subject: [PATCH 10/12] adding added date to Duplex class --- doc/api/stream.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/api/stream.md b/doc/api/stream.md index c9104e8b789864..493f0dac4f2ea0 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1024,6 +1024,9 @@ myReader.on('readable', () => { ### Duplex and Transform Streams #### Class: stream.Duplex + From 3a7a1db4477d81c1f6e6463786ba5499086eb896 Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Tue, 12 Jul 2016 13:39:43 -0400 Subject: [PATCH 11/12] Adding added date to Transform class --- doc/api/stream.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/api/stream.md b/doc/api/stream.md index 493f0dac4f2ea0..3b47522a9a5f57 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1040,6 +1040,9 @@ Examples of Duplex streams include: * [crypto streams][crypto] #### Class: stream.Transform + From 298269b0bb24b8b856e2f371dfd1c88a277277d3 Mon Sep 17 00:00:00 2001 From: "Italo A. Casas" Date: Tue, 12 Jul 2016 13:55:02 -0400 Subject: [PATCH 12/12] using the implemented version on .end() --- doc/api/stream.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/stream.md b/doc/api/stream.md index 3b47522a9a5f57..606d24c633a663 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -350,7 +350,7 @@ buffered writes in a more optimized manner. ##### writable.end([chunk][, encoding][, callback]) * `chunk` {String|Buffer|any} Optional data to write. For streams not operating