diff options
author | Rebecca Turner <me@re-becca.org> | 2016-03-16 03:47:46 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2016-03-17 22:33:25 +0300 |
commit | 8defb0f7b3ebdbe15c9ef5036052c10eda7e3161 (patch) | |
tree | 9e2c7d4a5371af0e88a9b84a0b062a245850e059 /node_modules/readable-stream | |
parent | 672502a4614b814850e0eba1de41930d35e8eaf1 (diff) |
readable-stream@2.0.6
Fix sync write issue on 0.10 (but not 0.8).
Credit: @calvinmetcalf
Diffstat (limited to 'node_modules/readable-stream')
17 files changed, 825 insertions, 1073 deletions
diff --git a/node_modules/readable-stream/.travis.yml b/node_modules/readable-stream/.travis.yml index cfe1c9439..1b8211846 100644 --- a/node_modules/readable-stream/.travis.yml +++ b/node_modules/readable-stream/.travis.yml @@ -6,6 +6,10 @@ before_install: notifications: email: false matrix: + fast_finish: true + allow_failures: + - env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="6.0..latest" + - env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="6.0..latest" include: - node_js: '0.8' env: TASK=test @@ -25,24 +29,22 @@ matrix: env: TASK=test - node_js: 5 env: TASK=test - - node_js: node - env: TASK=test - - node_js: node - env: TASK=browser BROWSER_NAME=opera BROWSER_VERSION="11..latest" - - node_js: node + - node_js: 5 + env: TASK=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest" + - node_js: 5 env: TASK=browser BROWSER_NAME=ie BROWSER_VERSION="9..latest" - - node_js: node - env: TASK=browser BROWSER_NAME=chrome BROWSER_VERSION="41..beta" - - node_js: node - env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="36..latest" - - node_js: node - env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="['6.1', '7.1', '8.2']" - - node_js: node - env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="['6.1', '7.1', '8.2']" - - node_js: node + - node_js: 5 + env: TASK=browser BROWSER_NAME=opera BROWSER_VERSION="11..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=chrome BROWSER_VERSION="-3..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="-3..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="6.0..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="6.0..latest" + - node_js: 5 env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest" - - node_js: node - env: TASK=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest" script: "npm run $TASK" env: global: diff --git a/node_modules/readable-stream/README.md b/node_modules/readable-stream/README.md index f9fb52059..86b95a3bf 100644 --- a/node_modules/readable-stream/README.md +++ b/node_modules/readable-stream/README.md @@ -1,6 +1,6 @@ # readable-stream -***Node-core streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream) +***Node-core v5.8.0 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream) [![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/) diff --git a/node_modules/readable-stream/doc/stream.markdown b/node_modules/readable-stream/doc/stream.markdown index 5602f0736..0bc3819e6 100644 --- a/node_modules/readable-stream/doc/stream.markdown +++ b/node_modules/readable-stream/doc/stream.markdown @@ -3,27 +3,25 @@ Stability: 2 - Stable A stream is an abstract interface implemented by various objects in -Node.js. For example a [request to an HTTP server][] is a stream, as is -[stdout][]. Streams are readable, writable, or both. All streams are -instances of [EventEmitter][] +Node.js. For example a [request to an HTTP server][http-incoming-message] is a +stream, as is [`process.stdout`][]. Streams are readable, writable, or both. All +streams are instances of [`EventEmitter`][]. You can load the Stream base classes by doing `require('stream')`. There are base classes provided for [Readable][] streams, [Writable][] streams, [Duplex][] streams, and [Transform][] streams. -This document is split up into 3 sections. The first explains the -parts of the API that you need to be aware of to use streams in your -programs. If you never implement a streaming API yourself, you can -stop there. +This document is split up into 3 sections: -The second section explains the parts of the API that you need to use -if you implement your own custom streams yourself. The API is -designed to make this easy for you to do. - -The third section goes into more depth about how streams work, -including some of the internal mechanisms and functions that you -should probably not modify unless you definitely know what you are -doing. +1. The first section explains the parts of the API that you need to be + aware of to use streams in your programs. +2. The second section explains the parts of the API that you need to + use if you implement your own custom streams yourself. The API is designed to + make this easy for you to do. +3. The third section goes into more depth about how streams work, + including some of the internal mechanisms and functions that you + should probably not modify unless you definitely know what you are + doing. ## API for Stream Consumers @@ -37,22 +35,22 @@ and properties depending on whether they are Readable, Writable, or Duplex. If a stream is both Readable and Writable, then it implements all of -the methods and events below. So, a [Duplex][] or [Transform][] stream is +the methods and events. So, a [Duplex][] or [Transform][] stream is fully described by this API, though their implementation may be somewhat different. It is not necessary to implement Stream interfaces in order to consume -streams in your programs. If you **are** implementing streaming +streams in your programs. If you **are** implementing streaming interfaces in your own program, please also refer to -[API for Stream Implementors][] below. +[API for Stream Implementors][]. Almost all Node.js programs, no matter how simple, use Streams in some way. Here is an example of using Streams in an Node.js program: -```javascript -var http = require('http'); +```js +const http = require('http'); -var server = http.createServer(function (req, res) { +var 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 @@ -62,18 +60,18 @@ var server = http.createServer(function (req, res) { req.setEncoding('utf8'); // Readable streams emit 'data' events once a listener is added - req.on('data', function (chunk) { + req.on('data', (chunk) => { body += chunk; }); // the end event tells you that you have entire body - req.on('end', function () { + req.on('end', () => { try { var data = JSON.parse(body); } catch (er) { // uh oh! bad json! res.statusCode = 400; - return res.end('error: ' + er.message); + return res.end(`error: ${er.message}`); } // write back something interesting to the user: @@ -95,65 +93,66 @@ server.listen(1337); ### Class: stream.Duplex Duplex streams are streams that implement both the [Readable][] and -[Writable][] interfaces. See above for usage. +[Writable][] interfaces. Examples of Duplex streams include: -* [tcp sockets][] -* [zlib streams][] -* [crypto streams][] +* [TCP sockets][] +* [zlib streams][zlib] +* [crypto streams][crypto] ### Class: stream.Readable <!--type=class--> The Readable stream interface is the abstraction for a *source* of -data that you are reading from. In other words, data comes *out* of a +data that you are reading from. In other words, data comes *out* of a Readable stream. A Readable stream will not start emitting data until you indicate that you are ready to receive it. Readable streams have two "modes": a **flowing mode** and a **paused -mode**. When in flowing mode, data is read from the underlying system -and provided to your program as fast as possible. In paused mode, you -must explicitly call `stream.read()` to get chunks of data out. +mode**. When in flowing mode, data is read from the underlying system +and provided to your program as fast as possible. In paused mode, you +must explicitly call [`stream.read()`][stream-read] to get chunks of data out. Streams start out in paused mode. **Note**: If no data event handlers are attached, and there are no -[`pipe()`][] destinations, and the stream is switched into flowing +[`stream.pipe()`][] destinations, and the stream is switched into flowing mode, then data will be lost. You can switch to flowing mode by doing any of the following: -* Adding a [`'data'` event][] handler to listen for data. -* Calling the [`resume()`][] method to explicitly open the flow. -* Calling the [`pipe()`][] method to send the data to a [Writable][]. +* Adding a [`'data'`][] event handler to listen for data. +* Calling the [`stream.resume()`][stream-resume] method to explicitly open the + flow. +* Calling the [`stream.pipe()`][] method to send the data to a [Writable][]. You can switch back to paused mode by doing either of the following: -* If there are no pipe destinations, by calling the [`pause()`][] - method. -* If there are pipe destinations, by removing any [`'data'` event][] +* If there are no pipe destinations, by calling the + [`stream.pause()`][stream-pause] method. +* If there are pipe destinations, by removing any [`'data'`][] event handlers, and removing all pipe destinations by calling the - [`unpipe()`][] method. + [`stream.unpipe()`][] method. -Note that, for backwards compatibility reasons, removing `'data'` -event handlers will **not** automatically pause the stream. Also, if -there are piped destinations, then calling `pause()` will not -guarantee that the stream will *remain* paused once those +Note that, for backwards compatibility reasons, removing [`'data'`][] +event handlers will **not** automatically pause the stream. Also, if +there are piped destinations, then calling [`stream.pause()`][stream-pause] will +not guarantee that the stream will *remain* paused once those destinations drain and ask for more data. Examples of readable streams include: -* [http responses, on the client][] -* [http requests, on the server][] +* [HTTP responses, on the client][http-incoming-message] +* [HTTP requests, on the server][http-incoming-message] * [fs read streams][] -* [zlib streams][] -* [crypto streams][] -* [tcp sockets][] +* [zlib streams][zlib] +* [crypto streams][crypto] +* [TCP sockets][] * [child process stdout and stderr][] -* [process.stdin][] +* [`process.stdin`][] #### Event: 'close' @@ -161,22 +160,22 @@ Emitted when the stream and any of its underlying resources (a file descriptor, for example) have been closed. The event indicates that no more events will be emitted, and no further computation will occur. -Not all streams will emit the 'close' event. +Not all streams will emit the `'close'` event. #### Event: 'data' -* `chunk` {Buffer | String} The chunk of data. +* `chunk` {Buffer|String} The chunk of data. -Attaching a `data` event listener to a stream that has not been +Attaching a `'data'` event listener to a stream that has not been explicitly paused will switch the stream into flowing mode. Data will then be passed as soon as it is available. If you just want to get all the data out of the stream as fast as possible, this is the best way to do so. -```javascript +```js var readable = getReadableStreamSomehow(); -readable.on('data', function(chunk) { +readable.on('data', (chunk) => { console.log('got %d bytes of data', chunk.length); }); ``` @@ -185,16 +184,17 @@ readable.on('data', function(chunk) { This event fires when there will be no more data to read. -Note that the `end` event **will not fire** unless the data is -completely consumed. This can be done by switching into flowing mode, -or by calling `read()` repeatedly until you get to the end. +Note that the `'end'` event **will not fire** unless the data is +completely consumed. This can be done by switching into flowing mode, +or by calling [`stream.read()`][stream-read] repeatedly until you get to the +end. -```javascript +```js var readable = getReadableStreamSomehow(); -readable.on('data', function(chunk) { +readable.on('data', (chunk) => { console.log('got %d bytes of data', chunk.length); }); -readable.on('end', function() { +readable.on('end', () => { console.log('there will be no more data.'); }); ``` @@ -216,30 +216,30 @@ hadn't already. ```javascript var readable = getReadableStreamSomehow(); -readable.on('readable', function() { +readable.on('readable', () => { // there is some data to read now }); ``` -Once the internal buffer is drained, a `readable` event will fire +Once the internal buffer is drained, a `'readable'` event will fire again when more data is available. -The `readable` event is not emitted in the "flowing" mode with the +The `'readable'` event is not emitted in the "flowing" mode with the sole exception of the last one, on end-of-stream. -The 'readable' event indicates that the stream has new information: +The `'readable'` event indicates that the stream has new information: either new data is available or the end of the stream has been reached. -In the former case, `.read()` will return that data. In the latter case, -`.read()` will return null. For instance, in the following example, `foo.txt` -is an empty file: +In the former case, [`stream.read()`][stream-read] will return that data. In the +latter case, [`stream.read()`][stream-read] will return null. For instance, in +the following example, `foo.txt` is an empty file: -```javascript -var fs = require('fs'); +```js +const fs = require('fs'); var rr = fs.createReadStream('foo.txt'); -rr.on('readable', function() { +rr.on('readable', () => { console.log('readable:', rr.read()); }); -rr.on('end', function() { +rr.on('end', () => { console.log('end'); }); ``` @@ -247,20 +247,20 @@ rr.on('end', function() { The output of running this script is: ``` -bash-3.2$ node test.js +$ node test.js readable: null end ``` #### readable.isPaused() -* Return: `Boolean` +* Return: {Boolean} This method returns whether or not the `readable` has been **explicitly** -paused by client code (using `readable.pause()` without a corresponding -`readable.resume()`). +paused by client code (using [`stream.pause()`][stream-pause] without a +corresponding [`stream.resume()`][stream-resume]). -```javascript +```js var readable = new stream.Readable readable.isPaused() // === false @@ -275,16 +275,16 @@ readable.isPaused() // === false * Return: `this` This method will cause a stream in flowing mode to stop emitting -`data` events, switching out of flowing mode. Any data that becomes +[`'data'`][] events, switching out of flowing mode. Any data that becomes available will remain in the internal buffer. -```javascript +```js var readable = getReadableStreamSomehow(); -readable.on('data', function(chunk) { +readable.on('data', (chunk) => { console.log('got %d bytes of data', chunk.length); readable.pause(); console.log('there will be no more data for 1 second'); - setTimeout(function() { + setTimeout(() => { console.log('now data will start flowing again'); readable.resume(); }, 1000); @@ -293,7 +293,7 @@ readable.on('data', function(chunk) { #### readable.pipe(destination[, options]) -* `destination` {[Writable][] Stream} The destination for writing data +* `destination` {stream.Writable} The destination for writing data * `options` {Object} Pipe options * `end` {Boolean} End the writer when the reader ends. Default = `true` @@ -303,7 +303,7 @@ the destination is not overwhelmed by a fast readable stream. Multiple destinations can be piped to safely. -```javascript +```js var readable = getReadableStreamSomehow(); var writable = fs.createWriteStream('file.txt'); // All the data from readable goes into 'file.txt' @@ -313,7 +313,7 @@ readable.pipe(writable); This function returns the destination stream, so you can set up pipe chains like so: -```javascript +```js var r = fs.createReadStream('file.txt'); var z = zlib.createGzip(); var w = fs.createWriteStream('file.txt.gz'); @@ -322,51 +322,51 @@ r.pipe(z).pipe(w); For example, emulating the Unix `cat` command: -```javascript +```js process.stdin.pipe(process.stdout); ``` -By default [`end()`][] is called on the destination when the source stream -emits `end`, so that `destination` is no longer writable. Pass `{ end: -false }` as `options` to keep the destination stream open. +By default [`stream.end()`][stream-end] is called on the destination when the +source stream emits [`'end'`][], so that `destination` is no longer writable. +Pass `{ end: false }` as `options` to keep the destination stream open. This keeps `writer` open so that "Goodbye" can be written at the end. -```javascript +```js reader.pipe(writer, { end: false }); -reader.on('end', function() { +reader.on('end', () => { writer.end('Goodbye\n'); }); ``` -Note that `process.stderr` and `process.stdout` are never closed until +Note that [`process.stderr`][] and [`process.stdout`][] are never closed until the 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} +* Return {String|Buffer|Null} The `read()` method pulls some data out of the internal buffer and -returns it. If there is no data available, then it will return +returns it. If there is no data available, then it will return `null`. If you pass in a `size` argument, then it will return that many -bytes. If `size` bytes are not available, then it will return `null`, +bytes. If `size` bytes are not available, then it will return `null`, unless we've ended, in which case it will return the data remaining in the buffer. If you do not specify a `size` argument, then it will return all the data in the internal buffer. -This method should only be called in paused mode. In flowing mode, +This method should only be called in paused mode. In flowing mode, this method is called automatically until the internal buffer is drained. -```javascript +```js var readable = getReadableStreamSomehow(); -readable.on('readable', function() { +readable.on('readable', () => { var chunk; while (null !== (chunk = readable.read())) { console.log('got %d bytes of data', chunk.length); @@ -375,27 +375,27 @@ readable.on('readable', function() { ``` If this method returns a data chunk, then it will also trigger the -emission of a [`'data'` event][]. +emission of a [`'data'`][] event. -Note that calling `readable.read([size])` after the `end` event has been -triggered will return `null`. No runtime error will be raised. +Note that calling [`stream.read([size])`][stream-read] after the [`'end'`][] +event has been triggered will return `null`. No runtime error will be raised. #### readable.resume() * Return: `this` -This method will cause the readable stream to resume emitting `data` +This method will cause the readable stream to resume emitting [`'data'`][] events. -This method will switch the stream into flowing mode. If you do *not* +This method will switch the stream into flowing mode. If you do *not* want to consume the data from a stream, but you *do* want to get to -its `end` event, you can call [`readable.resume()`][] to open the flow of -data. +its [`'end'`][] event, you can call [`stream.resume()`][stream-resume] to open +the flow of data. -```javascript +```js var readable = getReadableStreamSomehow(); readable.resume(); -readable.on('end', function() { +readable.on('end', () => { console.log('got to the end, but did not read anything'); }); ``` @@ -405,22 +405,25 @@ readable.on('end', function() { * `encoding` {String} The encoding to use. * Return: `this` -Call this function to cause the stream to return strings of the -specified encoding instead of Buffer objects. For example, if you do -`readable.setEncoding('utf8')`, then the output data will be -interpreted as UTF-8 data, and returned as strings. If you do -`readable.setEncoding('hex')`, then the data will be encoded in -hexadecimal string format. +Call this function to cause the stream to return strings of the specified +encoding instead of Buffer objects. For example, if you do +`readable.setEncoding('utf8')`, then the output data will be interpreted as +UTF-8 data, and returned as strings. If you do `readable.setEncoding('hex')`, +then the data will be encoded in hexadecimal string format. This properly handles multi-byte characters that would otherwise be potentially mangled if you simply pulled the Buffers directly and -called `buf.toString(encoding)` on them. If you want to read the data +called [`buf.toString(encoding)`][] on them. If you want to read the data as strings, always use this method. -```javascript +Also you can disable any encoding at all with `readable.setEncoding(null)`. +This approach is very useful if you deal with binary data or with large +multi-byte strings spread out over multiple chunks. + +```js var readable = getReadableStreamSomehow(); readable.setEncoding('utf8'); -readable.on('data', function(chunk) { +readable.on('data', (chunk) => { assert.equal(typeof chunk, 'string'); console.log('got %d characters of string data', chunk.length); }); @@ -428,22 +431,23 @@ readable.on('data', function(chunk) { #### readable.unpipe([destination]) -* `destination` {[Writable][] Stream} Optional specific stream to unpipe +* `destination` {stream.Writable} Optional specific stream to unpipe -This method will remove the hooks set up for a previous `pipe()` call. +This method will remove the hooks set up for a previous [`stream.pipe()`][] +call. If the destination is not specified, then all pipes are removed. If the destination is specified, but no pipe is set up for it, then this is a no-op. -```javascript +```js var readable = getReadableStreamSomehow(); var writable = fs.createWriteStream('file.txt'); // All the data from readable goes into 'file.txt', // but only for the first second readable.pipe(writable); -setTimeout(function() { +setTimeout(() => { console.log('stop writing to file.txt'); readable.unpipe(writable); console.log('manually close the file stream'); @@ -453,25 +457,25 @@ setTimeout(function() { #### readable.unshift(chunk) -* `chunk` {Buffer | String} Chunk of data to unshift onto the read queue +* `chunk` {Buffer|String} Chunk of data to unshift onto the read queue This is useful in certain cases where a stream is being consumed by a parser, which needs to "un-consume" some data that it has optimistically pulled out of the source, so that the stream can be passed on to some other party. -Note that `stream.unshift(chunk)` cannot be called after the `end` event +Note that `stream.unshift(chunk)` cannot be called after the [`'end'`][] event has been triggered; a runtime error will be raised. If you find that you must often call `stream.unshift(chunk)` in your -programs, consider implementing a [Transform][] stream instead. (See API -for Stream Implementors, below.) +programs, consider implementing a [Transform][] stream instead. (See [API +for Stream Implementors][].) -```javascript +```js // Pull off a header delimited by \n\n // use unshift() if we get too much // Call the callback with (error, header, stream) -var StringDecoder = require('string_decoder').StringDecoder; +const StringDecoder = require('string_decoder').StringDecoder; function parseHeader(stream, callback) { stream.on('error', callback); stream.on('readable', onReadable); @@ -501,39 +505,41 @@ function parseHeader(stream, callback) { } } ``` -Note that, unlike `stream.push(chunk)`, `stream.unshift(chunk)` will not -end the reading process by resetting the internal reading state of the -stream. This can cause unexpected results if `unshift` is called during a -read (i.e. from within a `_read` implementation on a custom stream). Following -the call to `unshift` with an immediate `stream.push('')` will reset the -reading state appropriately, however it is best to simply avoid calling -`unshift` while in the process of performing a read. + +Note that, unlike [`stream.push(chunk)`][stream-push], `stream.unshift(chunk)` +will not end the reading process by resetting the internal reading state of the +stream. This can cause unexpected results if `unshift()` is called during a +read (i.e. from within a [`stream._read()`][stream-_read] implementation on a +custom stream). Following the call to `unshift()` with an immediate +[`stream.push('')`][stream-push] will reset the reading state appropriately, +however it is best to simply avoid calling `unshift()` while in the process of +performing a read. #### readable.wrap(stream) * `stream` {Stream} An "old style" readable stream Versions of Node.js prior to v0.10 had streams that did not implement the -entire Streams API as it is today. (See "Compatibility" below for +entire Streams API as it is today. (See [Compatibility][] for more information.) -If you are using an older Node.js library that emits `'data'` events and -has a [`pause()`][] method that is advisory only, then you can use the -`wrap()` method to create a [Readable][] stream that uses the old stream -as its data source. +If you are using an older Node.js library that emits [`'data'`][] events and +has a [`stream.pause()`][stream-pause] method that is advisory only, then you +can use the `wrap()` method to create a [Readable][] stream that uses the old +stream as its data source. You will very rarely ever need to call this function, but it exists as a convenience for interacting with old Node.js programs and libraries. For example: -```javascript -var OldReader = require('./old-api-module.js').OldReader; -var oreader = new OldReader; -var Readable = require('stream').Readable; -var myReader = new Readable().wrap(oreader); +```js +const OldReader = require('./old-api-module.js').OldReader; +const Readable = require('stream').Readable; +const oreader = new OldReader; +const myReader = new Readable().wrap(oreader); -myReader.on('readable', function() { +myReader.on('readable', () => { myReader.read(); // etc. }); ``` @@ -541,13 +547,13 @@ myReader.on('readable', function() { ### Class: stream.Transform Transform streams are [Duplex][] streams where the output is in some way -computed from the input. They implement both the [Readable][] and -[Writable][] interfaces. See above for usage. +computed from the input. They implement both the [Readable][] and +[Writable][] interfaces. Examples of Transform streams include: -* [zlib streams][] -* [crypto streams][] +* [zlib streams][zlib] +* [crypto streams][crypto] ### Class: stream.Writable @@ -558,22 +564,22 @@ that you are writing data *to*. Examples of writable streams include: -* [http requests, on the client][] -* [http responses, on the server][] +* [HTTP requests, on the client][] +* [HTTP responses, on the server][] * [fs write streams][] -* [zlib streams][] -* [crypto streams][] -* [tcp sockets][] +* [zlib streams][zlib] +* [crypto streams][crypto] +* [TCP sockets][] * [child process stdin][] -* [process.stdout][], [process.stderr][] +* [`process.stdout`][], [`process.stderr`][] #### Event: 'drain' -If a [`writable.write(chunk)`][] call returns false, then the `drain` -event will indicate when it is appropriate to begin writing more data +If a [`stream.write(chunk)`][stream-write] call returns `false`, then the +`'drain'` event will indicate when it is appropriate to begin writing more data to the stream. -```javascript +```js // Write the data to the supplied writable stream one million times. // Be attentive to back-pressure. function writeOneMillionTimes(writer, data, encoding, callback) { @@ -603,37 +609,37 @@ function writeOneMillionTimes(writer, data, encoding, callback) { #### Event: 'error' -* {Error object} +* {Error} Emitted if there was an error when writing or piping data. #### Event: 'finish' -When the [`end()`][] method has been called, and all data has been flushed -to the underlying system, this event is emitted. +When the [`stream.end()`][stream-end] method has been called, and all data has +been flushed to the underlying system, this event is emitted. ```javascript var writer = getWritableStreamSomehow(); for (var i = 0; i < 100; i ++) { - writer.write('hello, #' + i + '!\n'); + writer.write('hello, #${i}!\n'); } writer.end('this is the end\n'); -writer.on('finish', function() { +writer.on('finish', () => { console.error('all writes are now complete.'); }); ``` #### Event: 'pipe' -* `src` {[Readable][] Stream} source stream that is piping to this writable +* `src` {stream.Readable} source stream that is piping to this writable -This is emitted whenever the `pipe()` method is called on a readable +This is emitted whenever the [`stream.pipe()`][] method is called on a readable stream, adding this writable to its set of destinations. -```javascript +```js var writer = getWritableStreamSomehow(); var reader = getReadableStreamSomehow(); -writer.on('pipe', function(src) { +writer.on('pipe', (src) => { console.error('something is piping into the writer'); assert.equal(src, reader); }); @@ -642,15 +648,16 @@ reader.pipe(writer); #### Event: 'unpipe' -* `src` {[Readable][] Stream} The source stream that [unpiped][] this writable +* `src` {[Readable][] Stream} The source stream that + [unpiped][`stream.unpipe()`] this writable -This is emitted whenever the [`unpipe()`][] method is called on a +This is emitted whenever the [`stream.unpipe()`][] method is called on a readable stream, removing this writable from its set of destinations. -```javascript +```js var writer = getWritableStreamSomehow(); var reader = getReadableStreamSomehow(); -writer.on('unpipe', function(src) { +writer.on('unpipe', (src) => { console.error('something has stopped piping into the writer'); assert.equal(src, reader); }); @@ -662,20 +669,22 @@ reader.unpipe(writer); Forces buffering of all writes. -Buffered data will be flushed either at `.uncork()` or at `.end()` call. +Buffered data will be flushed either at [`stream.uncork()`][] or at +[`stream.end()`][stream-end] call. #### writable.end([chunk][, encoding][, callback]) -* `chunk` {String | Buffer} Optional data to write +* `chunk` {String|Buffer} Optional data to write * `encoding` {String} The encoding, if `chunk` is a String * `callback` {Function} Optional callback for when the stream is finished -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. +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. +Calling [`stream.write()`][stream-write] after calling +[`stream.end()`][stream-end] will raise an error. -```javascript +```js // write 'hello, ' and then end with 'world!' var file = fs.createWriteStream('example.txt'); file.write('hello, '); @@ -691,26 +700,26 @@ Sets the default encoding for a writable stream. #### writable.uncork() -Flush all data, buffered since `.cork()` call. +Flush all data, buffered since [`stream.cork()`][] call. #### writable.write(chunk[, encoding][, callback]) -* `chunk` {String | Buffer} The data to write +* `chunk` {String|Buffer} The data to write * `encoding` {String} The encoding, if `chunk` is a String * `callback` {Function} Callback for when this chunk of data is flushed -* Returns: {Boolean} True if the data was handled completely. +* Returns: {Boolean} `true` if the data was handled completely. This method writes some data to the underlying system, and calls the supplied callback once the data has been fully handled. The return value indicates if you should continue writing right now. If the data had to be buffered internally, then it will return -`false`. Otherwise, it will return `true`. +`false`. Otherwise, it will return `true`. -This return value is strictly advisory. You MAY continue to write, -even if it returns `false`. However, writes will be buffered in -memory, so it is best not to do this excessively. Instead, wait for -the `drain` event before writing more data. +This return value is strictly advisory. You MAY continue to write, +even if it returns `false`. However, writes will be buffered in +memory, so it is best not to do this excessively. Instead, wait for +the [`'drain'`][] event before writing more data. ## API for Stream Implementors @@ -719,11 +728,11 @@ the `drain` event before writing more data. To implement any sort of stream, the pattern is the same: -1. Extend the appropriate parent class in your own subclass. (The - [`util.inherits`][] method is particularly helpful for this.) +1. Extend the appropriate parent class in your own subclass. (The + [`util.inherits()`][] method is particularly helpful for this.) 2. Call the appropriate parent class constructor in your constructor, to be sure that the internal mechanisms are set up properly. -2. Implement one or more specific methods, as detailed below. +3. Implement one or more specific methods, as detailed below. The class to extend and the method(s) to implement depend on the sort of stream class you are writing: @@ -750,7 +759,7 @@ of stream class you are writing: <p>[Readable](#stream_class_stream_readable_1)</p> </td> <td> - <p><code>[_read][]</code></p> + <p><code>[_read][stream-_read]</code></p> </td> </tr> <tr> @@ -761,7 +770,7 @@ of stream class you are writing: <p>[Writable](#stream_class_stream_writable_1)</p> </td> <td> - <p><code>[_write][]</code>, <code>_writev</code></p> + <p><code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code></p> </td> </tr> <tr> @@ -772,7 +781,7 @@ of stream class you are writing: <p>[Duplex](#stream_class_stream_duplex_1)</p> </td> <td> - <p><code>[_read][]</code>, <code>[_write][]</code>, <code>_writev</code></p> + <p><code>[_read][stream-_read]</code>, <code>[_write][stream-_write]</code>, <code>[_writev][stream-_writev]</code></p> </td> </tr> <tr> @@ -783,45 +792,45 @@ of stream class you are writing: <p>[Transform](#stream_class_stream_transform_1)</p> </td> <td> - <p><code>_transform</code>, <code>_flush</code></p> + <p><code>[_transform][stream-_transform]</code>, <code>[_flush][stream-_flush]</code></p> </td> </tr> </table> -In your implementation code, it is very important to never call the -methods described in [API for Stream Consumers][] above. Otherwise, you -can potentially cause adverse side effects in programs that consume -your streaming interfaces. +In your implementation code, it is very important to never call the methods +described in [API for Stream Consumers][]. Otherwise, you can potentially cause +adverse side effects in programs that consume your streaming interfaces. ### Class: stream.Duplex <!--type=class--> -A "duplex" stream is one that is both Readable and Writable, such as a -TCP socket connection. +A "duplex" stream is one that is both Readable and Writable, such as a TCP +socket connection. Note that `stream.Duplex` is an abstract class designed to be extended -with an underlying implementation of the `_read(size)` and -[`_write(chunk, encoding, callback)`][] methods as you would with a -Readable or Writable stream class. +with an underlying implementation of the [`stream._read(size)`][stream-_read] +and [`stream._write(chunk, encoding, callback)`][stream-_write] methods as you +would with a Readable or Writable stream class. -Since JavaScript doesn't have multiple prototypal inheritance, this -class prototypally inherits from Readable, and then parasitically from -Writable. It is thus up to the user to implement both the lowlevel -`_read(n)` method as well as the lowlevel -[`_write(chunk, encoding, callback)`][] method on extension duplex classes. +Since JavaScript doesn't have multiple prototypal inheritance, this class +prototypally inherits from Readable, and then parasitically from Writable. It is +thus up to the user to implement both the low-level +[`stream._read(n)`][stream-_read] method as well as the low-level +[`stream._write(chunk, encoding, callback)`][stream-_write] method on extension +duplex classes. #### new stream.Duplex(options) * `options` {Object} Passed to both Writable and Readable constructors. Also has the following fields: - * `allowHalfOpen` {Boolean} Default=true. If set to `false`, then + * `allowHalfOpen` {Boolean} Default = `true`. If set to `false`, then the stream will automatically end the readable side when the writable side ends and vice versa. - * `readableObjectMode` {Boolean} Default=false. Sets `objectMode` + * `readableObjectMode` {Boolean} Default = `false`. Sets `objectMode` for readable side of the stream. Has no effect if `objectMode` is `true`. - * `writableObjectMode` {Boolean} Default=false. Sets `objectMode` + * `writableObjectMode` {Boolean} Default = `false`. Sets `objectMode` for writable side of the stream. Has no effect if `objectMode` is `true`. @@ -832,7 +841,7 @@ initialized. ### Class: stream.PassThrough This is a trivial implementation of a [Transform][] stream that simply -passes the input bytes across to the output. Its purpose is mainly +passes the input bytes across to the output. Its purpose is mainly for examples and testing, but there are occasionally use cases where it can come in handy as a building block for novel sorts of streams. @@ -841,10 +850,10 @@ it can come in handy as a building block for novel sorts of streams. <!--type=class--> `stream.Readable` is an abstract class designed to be extended with an -underlying implementation of the [`_read(size)`][] method. +underlying implementation of the [`stream._read(size)`][stream-_read] method. -Please see above under [API for Stream Consumers][] for how to consume -streams in your programs. What follows is an explanation of how to +Please see [API for Stream Consumers][] for how to consume +streams in your programs. What follows is an explanation of how to implement Readable streams in your programs. #### new stream.Readable([options]) @@ -852,12 +861,14 @@ implement Readable streams in your programs. * `options` {Object} * `highWaterMark` {Number} The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying - resource. Default=16kb, or 16 for `objectMode` streams + resource. Default = `16384` (16kb), or `16` for `objectMode` streams * `encoding` {String} If specified, then buffers will be decoded to - strings using the specified encoding. Default=null + strings using the specified encoding. Default = `null` * `objectMode` {Boolean} Whether this stream should behave - as a stream of objects. Meaning that stream.read(n) returns - a single value instead of a Buffer of size n. Default=false + as a stream of objects. Meaning that [`stream.read(n)`][stream-read] returns + a single value instead of a Buffer of size n. Default = `false` + * `read` {Function} Implementation for the [`stream._read()`][stream-_read] + method. In classes that extend the Readable class, make sure to call the Readable constructor so that the buffering settings can be properly @@ -871,29 +882,31 @@ Note: **Implement this method, but do NOT call it directly.** This method is prefixed with an underscore because it is internal to the class that defines it and should only be called by the internal Readable -class methods. All Readable stream implementations must provide a _read +class methods. All Readable stream implementations must provide a \_read method to fetch data from the underlying resource. -When _read is called, if data is available from the resource, `_read` should -start pushing that data into the read queue by calling `this.push(dataChunk)`. -`_read` should continue reading from the resource and pushing data until push -returns false, at which point it should stop reading from the resource. Only -when _read is called again after it has stopped should it start reading -more data from the resource and pushing that data onto the queue. +When `_read()` is called, if data is available from the resource, the `_read()` +implementation should start pushing that data into the read queue by calling +[`this.push(dataChunk)`][stream-push]. `_read()` should continue reading from +the resource and pushing data until push returns `false`, at which point it +should stop reading from the resource. Only when `_read()` is called again after +it has stopped should it start reading more data from the resource and pushing +that data onto the queue. Note: once the `_read()` method is called, it will not be called again until -the `push` method is called. +the [`stream.push()`][stream-push] method is called. -The `size` argument is advisory. Implementations where a "read" is a +The `size` argument is advisory. Implementations where a "read" is a single call that returns data can use this to know how much data to -fetch. Implementations where that is not relevant, such as TCP or +fetch. Implementations where that is not relevant, such as TCP or TLS, may ignore this argument, and simply provide data whenever it -becomes available. There is no need, for example to "wait" until -`size` bytes are available before calling [`stream.push(chunk)`][]. +becomes available. There is no need, for example to "wait" until +`size` bytes are available before calling [`stream.push(chunk)`][stream-push]. #### readable.push(chunk[, encoding]) -* `chunk` {Buffer | null | String} Chunk of data to push into the read queue + +* `chunk` {Buffer|Null|String} Chunk of data to push into the read queue * `encoding` {String} Encoding of String chunks. Must be a valid Buffer encoding, such as `'utf8'` or `'ascii'` * return {Boolean} Whether or not more pushes should be performed @@ -906,15 +919,15 @@ into the queue for subsequent stream processors to consume. If `null` is passed, it signals the end of the stream (EOF), after which no more data can be written. -The data added with `push` can be pulled out by calling the `read()` method -when the `'readable'`event fires. +The data added with `push()` can be pulled out by calling the +[`stream.read()`][stream-read] method when the [`'readable'`][] event fires. -This API is designed to be as flexible as possible. For example, +This API is designed to be as flexible as possible. For example, you may be wrapping a lower-level source which has some sort of -pause/resume mechanism, and a data callback. In those cases, you +pause/resume mechanism, and a data callback. In those cases, you could wrap the low-level source object by doing something like this: -```javascript +```js // source is an object with readStop() and readStart() methods, // and an `ondata` member that gets called when it has data, and // an `onend` member that gets called when the data is over. @@ -925,18 +938,17 @@ function SourceWrapper(options) { Readable.call(this, options); this._source = getLowlevelSourceObject(); - var self = this; // Every time there's data, we push it into the internal buffer. - this._source.ondata = function(chunk) { + this._source.ondata = (chunk) => { // if push() returns false, then we need to stop reading from source - if (!self.push(chunk)) - self._source.readStop(); + if (!this.push(chunk)) + this._source.readStop(); }; // When the source ends, we push the EOF-signaling `null` chunk - this._source.onend = function() { - self.push(null); + this._source.onend = () => { + this.push(null); }; } @@ -951,12 +963,12 @@ SourceWrapper.prototype._read = function(size) { <!--type=example--> -This is a basic example of a Readable stream. It emits the numerals +This is a basic example of a Readable stream. It emits the numerals from 1 to 1,000,000 in ascending order, and then ends. -```javascript -var Readable = require('stream').Readable; -var util = require('util'); +```js +const Readable = require('stream').Readable; +const util = require('util'); util.inherits(Counter, Readable); function Counter(opt) { @@ -979,24 +991,25 @@ Counter.prototype._read = function() { #### Example: SimpleProtocol v1 (Sub-optimal) -This is similar to the `parseHeader` function described above, but -implemented as a custom stream. Also, note that this implementation -does not convert the incoming data to a string. +This is similar to the `parseHeader` function described +[here](#stream_readable_unshift_chunk), but implemented as a custom stream. +Also, note that this implementation does not convert the incoming data to a +string. -However, this would be better implemented as a [Transform][] stream. See -below for a better implementation. +However, this would be better implemented as a [Transform][] stream. See +[SimpleProtocol v2][] for a better implementation. -```javascript +```js // A parser for a simple data protocol. // The "header" is a JSON object, followed by 2 \n characters, and // then a message body. // // NOTE: This can be done more simply as a Transform stream! -// Using Readable directly for this is sub-optimal. See the +// Using Readable directly for this is sub-optimal. See the // alternative example below under the Transform section. -var Readable = require('stream').Readable; -var util = require('util'); +const Readable = require('stream').Readable; +const util = require('util'); util.inherits(SimpleProtocol, Readable); @@ -1012,13 +1025,13 @@ function SimpleProtocol(source, options) { this._source = source; var self = this; - source.on('end', function() { + source.on('end', () => { self.push(null); }); // give it a kick whenever the source is readable // read(0) will not consume any bytes - source.on('readable', function() { + source.on('readable', () => { self.read(0); }); @@ -1098,19 +1111,24 @@ connected in some way to the input, such as a [zlib][] stream or a [crypto][] stream. There is no requirement that the output be the same size as the input, -the same number of chunks, or arrive at the same time. For example, a +the same number of chunks, or arrive at the same time. For example, a Hash stream will only ever have a single chunk of output which is -provided when the input is ended. A zlib stream will produce output +provided when the input is ended. A zlib stream will produce output that is either much smaller or much larger than its input. -Rather than implement the [`_read()`][] and [`_write()`][] methods, Transform -classes must implement the `_transform()` method, and may optionally -also implement the `_flush()` method. (See below.) +Rather than implement the [`stream._read()`][stream-_read] and +[`stream._write()`][stream-_write] methods, Transform classes must implement the +[`stream._transform()`][stream-_transform] method, and may optionally +also implement the [`stream._flush()`][stream-_flush] method. (See below.) #### new stream.Transform([options]) * `options` {Object} Passed to both Writable and Readable - constructors. + constructors. Also has the following fields: + * `transform` {Function} Implementation for the + [`stream._transform()`][stream-_transform] method. + * `flush` {Function} Implementation for the [`stream._flush()`][stream-_flush] + method. In classes that extend the Transform class, make sure to call the constructor so that the buffering settings can be properly @@ -1118,11 +1136,12 @@ initialized. #### Events: 'finish' and 'end' -The [`finish`][] and [`end`][] events are from the parent Writable -and Readable classes respectively. The `finish` event is fired after -`.end()` is called and all chunks have been processed by `_transform`, -`end` is fired after all data has been output which is after the callback -in `_flush` has been called. +The [`'finish'`][] and [`'end'`][] events are from the parent Writable +and Readable classes respectively. The `'finish'` event is fired after +[`stream.end()`][stream-end] is called and all chunks have been processed by +[`stream._transform()`][stream-_transform], `'end'` is fired after all data has +been output which is after the callback in [`stream._flush()`][stream-_flush] +has been called. #### transform.\_flush(callback) @@ -1134,26 +1153,26 @@ by child classes, and if so, will be called by the internal Transform class methods only. In some cases, your transform operation may need to emit a bit more -data at the end of the stream. For example, a `Zlib` compression +data at the end of the stream. For example, a `Zlib` compression stream will store up some internal state so that it can optimally -compress the output. At the end, however, it needs to do the best it +compress the output. At the end, however, it needs to do the best it can with what is left, so that the data will be complete. -In those cases, you can implement a `_flush` method, which will be +In those cases, you can implement a `_flush()` method, which will be called at the very end, after all the written data is consumed, but -before emitting `end` to signal the end of the readable side. Just -like with `_transform`, call `transform.push(chunk)` zero or more -times, as appropriate, and call `callback` when the flush operation is -complete. +before emitting [`'end'`][] to signal the end of the readable side. Just +like with [`stream._transform()`][stream-_transform], call +`transform.push(chunk)` zero or more times, as appropriate, and call `callback` +when the flush operation is complete. This method is prefixed with an underscore because it is internal to the class that defines it, and should not be called directly by user -programs. However, you **are** expected to override this method in +programs. However, you **are** expected to override this method in your own extension classes. #### transform.\_transform(chunk, encoding, callback) -* `chunk` {Buffer | String} The chunk to be transformed. Will **always** +* `chunk` {Buffer|String} The chunk to be transformed. Will **always** be a buffer unless the `decodeStrings` option was set to `false`. * `encoding` {String} If the chunk is a string, then this is the encoding type. If chunk is a buffer, then this is the special @@ -1165,12 +1184,12 @@ Note: **This function MUST NOT be called directly.** It should be implemented by child classes, and called by the internal Transform class methods only. -All Transform stream implementations must provide a `_transform` +All Transform stream implementations must provide a `_transform()` method to accept input and produce output. -`_transform` should do whatever has to be done in this specific +`_transform()` should do whatever has to be done in this specific Transform class, to handle the bytes being written, and pass them off -to the readable portion of the interface. Do asynchronous I/O, +to the readable portion of the interface. Do asynchronous I/O, process things, and so on. Call `transform.push(outputChunk)` 0 or more times to generate output @@ -1178,12 +1197,12 @@ from this input chunk, depending on how much data you want to output as a result of this chunk. Call the callback function only when the current chunk is completely -consumed. Note that there may or may not be output as a result of any +consumed. Note that there may or may not be output as a result of any particular input chunk. If you supply a second argument to the callback it will be passed to the push method. In other words the following are equivalent: -```javascript +```js transform.prototype._transform = function (data, encoding, callback) { this.push(data); callback(); @@ -1196,22 +1215,23 @@ transform.prototype._transform = function (data, encoding, callback) { This method is prefixed with an underscore because it is internal to the class that defines it, and should not be called directly by user -programs. However, you **are** expected to override this method in +programs. However, you **are** expected to override this method in your own extension classes. #### Example: `SimpleProtocol` parser v2 -The example above of a simple protocol parser can be implemented -simply by using the higher level [Transform][] stream class, similar to -the `parseHeader` and `SimpleProtocol v1` examples above. +The example [here](#stream_example_simpleprotocol_v1_sub_optimal) of a simple +protocol parser can be implemented simply by using the higher level +[Transform][] stream class, similar to the `parseHeader` and `SimpleProtocol +v1` examples. In this example, rather than providing the input as an argument, it would be piped into the parser, which is a more idiomatic Node.js stream approach. ```javascript -var util = require('util'); -var Transform = require('stream').Transform; +const util = require('util'); +const Transform = require('stream').Transform; util.inherits(SimpleProtocol, Transform); function SimpleProtocol(options) { @@ -1282,22 +1302,30 @@ SimpleProtocol.prototype._transform = function(chunk, encoding, done) { <!--type=class--> `stream.Writable` is an abstract class designed to be extended with an -underlying implementation of the [`_write(chunk, encoding, callback)`][] method. +underlying implementation of the +[`stream._write(chunk, encoding, callback)`][stream-_write] method. -Please see above under [API for Stream Consumers][] for how to consume -writable streams in your programs. What follows is an explanation of +Please see [API for Stream Consumers][] for how to consume +writable streams in your programs. What follows is an explanation of how to implement Writable streams in your programs. #### new stream.Writable([options]) * `options` {Object} - * `highWaterMark` {Number} Buffer level when [`write()`][] starts - returning false. Default=16kb, or 16 for `objectMode` streams + * `highWaterMark` {Number} Buffer level when + [`stream.write()`][stream-write] starts returning `false`. Default = `16384` + (16kb), or `16` for `objectMode` streams. * `decodeStrings` {Boolean} Whether or not to decode strings into - Buffers before passing them to [`_write()`][]. Default=true - * `objectMode` {Boolean} Whether or not the `write(anyObj)` is - a valid operation. If set you can write arbitrary data instead - of only `Buffer` / `String` data. Default=false + Buffers before passing them to [`stream._write()`][stream-_write]. + Default = `true` + * `objectMode` {Boolean} Whether or not the + [`stream.write(anyObj)`][stream-write] is a valid operation. If set you can + write arbitrary data instead of only `Buffer` / `String` data. + Default = `false` + * `write` {Function} Implementation for the + [`stream._write()`][stream-_write] method. + * `writev` {Function} Implementation for the + [`stream._writev()`][stream-_writev] method. In classes that extend the Writable class, make sure to call the constructor so that the buffering settings can be properly @@ -1305,7 +1333,7 @@ initialized. #### writable.\_write(chunk, encoding, callback) -* `chunk` {Buffer | String} The chunk to be written. Will **always** +* `chunk` {Buffer|String} The chunk to be written. Will **always** be a buffer unless the `decodeStrings` option was set to `false`. * `encoding` {String} If the chunk is a string, then this is the encoding type. If chunk is a buffer, then this is the special @@ -1313,8 +1341,9 @@ initialized. * `callback` {Function} Call this function (optionally with an error argument) when you are done processing the supplied chunk. -All Writable stream implementations must provide a [`_write()`][] -method to send data to the underlying resource. +All Writable stream implementations must provide a +[`stream._write()`][stream-_write] method to send data to the underlying +resource. Note: **This function MUST NOT be called directly.** It should be implemented by child classes, and called by the internal Writable @@ -1325,20 +1354,20 @@ signal that the write completed successfully or with an error. If the `decodeStrings` flag is set in the constructor options, then `chunk` may be a string rather than a Buffer, and `encoding` will -indicate the sort of string that it is. This is to support +indicate the sort of string that it is. This is to support implementations that have an optimized handling for certain string -data encodings. If you do not explicitly set the `decodeStrings` +data encodings. If you do not explicitly set the `decodeStrings` option to `false`, then you can safely ignore the `encoding` argument, and assume that `chunk` will always be a Buffer. This method is prefixed with an underscore because it is internal to the class that defines it, and should not be called directly by user -programs. However, you **are** expected to override this method in +programs. However, you **are** expected to override this method in your own extension classes. #### writable.\_writev(chunks, callback) -* `chunks` {Array} The chunks to be written. Each chunk has following +* `chunks` {Array} The chunks to be written. Each chunk has following format: `{ chunk: ..., encoding: ... }`. * `callback` {Function} Call this function (optionally with an error argument) when you are done processing the supplied chunks. @@ -1348,7 +1377,7 @@ implemented by child classes, and called by the internal Writable class methods only. This function is completely optional to implement. In most cases it is -unnecessary. If implemented, it will be called with all the chunks +unnecessary. If implemented, it will be called with all the chunks that are buffered in the write queue. @@ -1356,14 +1385,16 @@ that are buffered in the write queue. <!--type=misc--> -In simple cases there is now the added benefit of being able to construct a stream without inheritance. +In simple cases there is now the added benefit of being able to construct a +stream without inheritance. This can be done by passing the appropriate methods as constructor options: Examples: ### Duplex -```javascript + +```js var duplex = new stream.Duplex({ read: function(n) { // sets this._read under the hood @@ -1400,7 +1431,8 @@ var duplex = new stream.Duplex({ ``` ### Readable -```javascript + +```js var readable = new stream.Readable({ read: function(n) { // sets this._read under the hood @@ -1413,7 +1445,8 @@ var readable = new stream.Readable({ ``` ### Transform -```javascript + +```js var transform = new stream.Transform({ transform: function(chunk, encoding, next) { // sets this._transform under the hood @@ -1436,7 +1469,8 @@ var transform = new stream.Transform({ ``` ### Writable -```javascript + +```js var writable = new stream.Writable({ write: function(chunk, encoding, next) { // sets this._write under the hood @@ -1467,21 +1501,21 @@ var writable = new stream.Writable({ <!--type=misc--> Both Writable and Readable streams will buffer data on an internal -object which can be retrieved from `_writableState.getBuffer()` or +object which can be retrieved from `_writableState.getBuffer()` or `_readableState.buffer`, respectively. The amount of data that will potentially be buffered depends on the `highWaterMark` option which is passed into the constructor. Buffering in Readable streams happens when the implementation calls -[`stream.push(chunk)`][]. If the consumer of the Stream does not call -`stream.read()`, then the data will sit in the internal queue until it -is consumed. +[`stream.push(chunk)`][stream-push]. If the consumer of the Stream does not +call [`stream.read()`][stream-read], then the data will sit in the internal +queue until it is consumed. Buffering in Writable streams happens when the user calls -[`stream.write(chunk)`][] repeatedly, even when `write()` returns `false`. +[`stream.write(chunk)`][stream-write] repeatedly, even when it returns `false`. -The purpose of streams, especially with the `pipe()` method, is to +The purpose of streams, especially with the [`stream.pipe()`][] method, is to limit the buffering of data to acceptable levels, so that sources and destinations of varying speed will not overwhelm the available memory. @@ -1492,36 +1526,37 @@ destinations of varying speed will not overwhelm the available memory. In versions of Node.js prior to v0.10, the Readable stream interface was simpler, but also less powerful and less useful. -* Rather than waiting for you to call the `read()` method, `'data'` - events would start emitting immediately. If you needed to do some - I/O to decide how to handle data, then you had to store the chunks +* Rather than waiting for you to call the [`stream.read()`][stream-read] method, + [`'data'`][] events would start emitting immediately. If you needed to do + some I/O to decide how to handle data, then you had to store the chunks in some kind of buffer so that they would not be lost. -* The [`pause()`][] method was advisory, rather than guaranteed. This - meant that you still had to be prepared to receive `'data'` events - even when the stream was in a paused state. +* The [`stream.pause()`][stream-pause] method was advisory, rather than + guaranteed. This meant that you still had to be prepared to receive + [`'data'`][] events even when the stream was in a paused state. -In Node.js v0.10, the Readable class described below was added. +In Node.js v0.10, the [Readable][] class was added. For backwards compatibility with older Node.js programs, Readable streams -switch into "flowing mode" when a `'data'` event handler is added, or -when the [`resume()`][] method is called. The effect is that, even if -you are not using the new `read()` method and `'readable'` event, you -no longer have to worry about losing `'data'` chunks. +switch into "flowing mode" when a [`'data'`][] event handler is added, or +when the [`stream.resume()`][stream-resume] method is called. The effect is +that, even if you are not using the new [`stream.read()`][stream-read] method +and [`'readable'`][] event, you no longer have to worry about losing +[`'data'`][] chunks. -Most programs will continue to function normally. However, this +Most programs will continue to function normally. However, this introduces an edge case in the following conditions: -* No [`'data'` event][] handler is added. -* The [`resume()`][] method is never called. +* No [`'data'`][] event handler is added. +* The [`stream.resume()`][stream-resume] method is never called. * The stream is not piped to any writable destination. For example, consider the following code: -```javascript +```js // WARNING! BROKEN! -net.createServer(function(socket) { +net.createServer((socket) => { // we add an 'end' method, but never consume the data - socket.on('end', function() { + socket.on('end', () => { // It will never get here. socket.end('I got your message (but didnt read it)\n'); }); @@ -1530,17 +1565,17 @@ net.createServer(function(socket) { ``` In versions of Node.js prior to v0.10, the incoming message data would be -simply discarded. However, in Node.js v0.10 and beyond, +simply discarded. However, in Node.js v0.10 and beyond, the socket will remain paused forever. -The workaround in this situation is to call the `resume()` method to -start the flow of data: +The workaround in this situation is to call the +[`stream.resume()`][stream-resume] method to start the flow of data: -```javascript +```js // Workaround -net.createServer(function(socket) { +net.createServer((socket) => { - socket.on('end', function() { + socket.on('end', () => { socket.end('I got your message (but didnt read it)\n'); }); @@ -1552,7 +1587,7 @@ net.createServer(function(socket) { In addition to new Readable streams switching into flowing mode, pre-v0.10 style streams can be wrapped in a Readable class using the -`wrap()` method. +[`stream.wrap()`][] method. ### Object Mode @@ -1565,33 +1600,33 @@ Streams that are in **object mode** can emit generic JavaScript values other than Buffers and Strings. A Readable stream in object mode will always return a single item from -a call to `stream.read(size)`, regardless of what the size argument -is. +a call to [`stream.read(size)`][stream-read], regardless of what the size +argument is. A Writable stream in object mode will always ignore the `encoding` -argument to `stream.write(data, encoding)`. +argument to [`stream.write(data, encoding)`][stream-write]. The special value `null` still retains its special value for object -mode streams. That is, for object mode readable streams, `null` as a -return value from `stream.read()` indicates that there is no more -data, and [`stream.push(null)`][] will signal the end of stream data +mode streams. That is, for object mode readable streams, `null` as a +return value from [`stream.read()`][stream-read] indicates that there is no more +data, and [`stream.push(null)`][stream-push] will signal the end of stream data (`EOF`). -No streams in Node.js core are object mode streams. This pattern is only +No streams in Node.js core are object mode streams. This pattern is only used by userland streaming libraries. You should set `objectMode` in your stream child class constructor on -the options object. Setting `objectMode` mid-stream is not safe. +the options object. Setting `objectMode` mid-stream is not safe. For Duplex streams `objectMode` can be set exclusively for readable or writable side with `readableObjectMode` and `writableObjectMode` respectively. These options can be used to implement parsers and serializers with Transform streams. -```javascript -var util = require('util'); -var StringDecoder = require('string_decoder').StringDecoder; -var Transform = require('stream').Transform; +```js +const util = require('util'); +const StringDecoder = require('string_decoder').StringDecoder; +const Transform = require('stream').Transform; util.inherits(JSONParseStream, Transform); // Gets \n-delimited JSON string data, and emits the parsed objects @@ -1646,12 +1681,12 @@ JSONParseStream.prototype._flush = function(cb) { There are some cases where you want to trigger a refresh of the underlying readable stream mechanisms, without actually consuming any -data. In that case, you can call `stream.read(0)`, which will always +data. In that case, you can call `stream.read(0)`, which will always return null. If the internal read buffer is below the `highWaterMark`, and the -stream is not currently reading, then calling `read(0)` will trigger -a low-level `_read` call. +stream is not currently reading, then calling `stream.read(0)` will trigger +a low-level [`stream._read()`][stream-_read] call. There is almost never a need to do this. However, you will see some cases in Node.js's internals where this is done, particularly in the @@ -1660,71 +1695,66 @@ Readable stream class internals. ### `stream.push('')` Pushing a zero-byte string or Buffer (when not in [Object mode][]) has an -interesting side effect. Because it *is* a call to -[`stream.push()`][], it will end the `reading` process. However, it +interesting side effect. Because it *is* a call to +[`stream.push()`][stream-push], it will end the `reading` process. However, it does *not* add any data to the readable buffer, so there's nothing for a user to consume. Very rarely, there are cases where you have no data to provide now, but the consumer of your stream (or, perhaps, another bit of your own -code) will know when to check again, by calling `stream.read(0)`. In -those cases, you *may* call `stream.push('')`. +code) will know when to check again, by calling [`stream.read(0)`][stream-read]. +In those cases, you *may* call `stream.push('')`. So far, the only use case for this functionality is in the -[tls.CryptoStream][] class, which is deprecated in Node.js/io.js v1.0. If you +[`tls.CryptoStream`][] class, which is deprecated in Node.js/io.js v1.0. If you find that you have to use `stream.push('')`, please consider another approach, because it almost certainly indicates that something is horribly wrong. -[request to an HTTP server]: https://nodejs.org/docs/v5.1.0/api/http.html#http_http_incomingmessage -[EventEmitter]: https://nodejs.org/docs/v5.1.0/api/events.html#events_class_events_eventemitter -[Object mode]: #stream_object_mode -[`stream.push(chunk)`]: #stream_readable_push_chunk_encoding -[`stream.push(null)`]: #stream_readable_push_chunk_encoding -[`stream.push()`]: #stream_readable_push_chunk_encoding -[`unpipe()`]: #stream_readable_unpipe_destination -[unpiped]: #stream_readable_unpipe_destination -[tcp sockets]: https://nodejs.org/docs/v5.1.0/api/net.html#net_class_net_socket -[http responses, on the client]: https://nodejs.org/docs/v5.1.0/api/http.html#http_http_incomingmessage -[http requests, on the server]: https://nodejs.org/docs/v5.1.0/api/http.html#http_http_incomingmessage -[http requests, on the client]: https://nodejs.org/docs/v5.1.0/api/http.html#http_class_http_clientrequest -[http responses, on the server]: https://nodejs.org/docs/v5.1.0/api/http.html#http_class_http_serverresponse -[fs read streams]: https://nodejs.org/docs/v5.1.0/api/fs.html#fs_class_fs_readstream -[fs write streams]: https://nodejs.org/docs/v5.1.0/api/fs.html#fs_class_fs_writestream -[zlib streams]: zlib.html -[zlib]: zlib.html -[crypto streams]: crypto.html -[crypto]: crypto.html -[tls.CryptoStream]: https://nodejs.org/docs/v5.1.0/api/tls.html#tls_class_cryptostream -[process.stdin]: https://nodejs.org/docs/v5.1.0/api/process.html#process_process_stdin -[stdout]: https://nodejs.org/docs/v5.1.0/api/process.html#process_process_stdout -[process.stdout]: https://nodejs.org/docs/v5.1.0/api/process.html#process_process_stdout -[process.stderr]: https://nodejs.org/docs/v5.1.0/api/process.html#process_process_stderr -[child process stdout and stderr]: https://nodejs.org/docs/v5.1.0/api/child_process.html#child_process_child_stdout -[child process stdin]: https://nodejs.org/docs/v5.1.0/api/child_process.html#child_process_child_stdin +[`'data'`]: #stream_event_data +[`'drain'`]: #stream_event_drain +[`'end'`]: #stream_event_end +[`'finish'`]: #stream_event_finish +[`'readable'`]: #stream_event_readable +[`buf.toString(encoding)`]: https://nodejs.org/docs/v5.8.0/api/buffer.html#buffer_buf_tostring_encoding_start_end +[`EventEmitter`]: https://nodejs.org/docs/v5.8.0/api/events.html#events_class_eventemitter +[`process.stderr`]: https://nodejs.org/docs/v5.8.0/api/process.html#process_process_stderr +[`process.stdin`]: https://nodejs.org/docs/v5.8.0/api/process.html#process_process_stdin +[`process.stdout`]: https://nodejs.org/docs/v5.8.0/api/process.html#process_process_stdout +[`stream.cork()`]: #stream_writable_cork +[`stream.pipe()`]: #stream_readable_pipe_destination_options +[`stream.uncork()`]: #stream_writable_uncork +[`stream.unpipe()`]: #stream_readable_unpipe_destination +[`stream.wrap()`]: #stream_readable_wrap_stream +[`tls.CryptoStream`]: https://nodejs.org/docs/v5.8.0/api/tls.html#tls_class_cryptostream +[`util.inherits()`]: https://nodejs.org/docs/v5.8.0/api/util.html#util_util_inherits_constructor_superconstructor [API for Stream Consumers]: #stream_api_for_stream_consumers [API for Stream Implementors]: #stream_api_for_stream_implementors -[Readable]: #stream_class_stream_readable -[Writable]: #stream_class_stream_writable +[child process stdin]: https://nodejs.org/docs/v5.8.0/api/child_process.html#child_process_child_stdin +[child process stdout and stderr]: https://nodejs.org/docs/v5.8.0/api/child_process.html#child_process_child_stdout +[Compatibility]: #stream_compatibility_with_older_node_js_versions +[crypto]: crypto.html [Duplex]: #stream_class_stream_duplex +[fs read streams]: https://nodejs.org/docs/v5.8.0/api/fs.html#fs_class_fs_readstream +[fs write streams]: https://nodejs.org/docs/v5.8.0/api/fs.html#fs_class_fs_writestream +[HTTP requests, on the client]: https://nodejs.org/docs/v5.8.0/api/http.html#http_class_http_clientrequest +[HTTP responses, on the server]: https://nodejs.org/docs/v5.8.0/api/http.html#http_class_http_serverresponse +[http-incoming-message]: https://nodejs.org/docs/v5.8.0/api/http.html#http_class_http_incomingmessage +[Object mode]: #stream_object_mode +[Readable]: #stream_class_stream_readable +[SimpleProtocol v2]: #stream_example_simpleprotocol_parser_v2 +[stream-_flush]: #stream_transform_flush_callback +[stream-_read]: #stream_readable_read_size_1 +[stream-_transform]: #stream_transform_transform_chunk_encoding_callback +[stream-_write]: #stream_writable_write_chunk_encoding_callback_1 +[stream-_writev]: #stream_writable_writev_chunks_callback +[stream-end]: #stream_writable_end_chunk_encoding_callback +[stream-pause]: #stream_readable_pause +[stream-push]: #stream_readable_push_chunk_encoding +[stream-read]: #stream_readable_read_size +[stream-resume]: #stream_readable_resume +[stream-write]: #stream_writable_write_chunk_encoding_callback +[TCP sockets]: https://nodejs.org/docs/v5.8.0/api/net.html#net_class_net_socket [Transform]: #stream_class_stream_transform -[`end`]: #stream_event_end -[`finish`]: #stream_event_finish -[`_read(size)`]: #stream_readable_read_size_1 -[`_read()`]: #stream_readable_read_size_1 -[_read]: #stream_readable_read_size_1 -[`writable.write(chunk)`]: #stream_writable_write_chunk_encoding_callback -[`write(chunk, encoding, callback)`]: #stream_writable_write_chunk_encoding_callback -[`write()`]: #stream_writable_write_chunk_encoding_callback -[`stream.write(chunk)`]: #stream_writable_write_chunk_encoding_callback -[`_write(chunk, encoding, callback)`]: #stream_writable_write_chunk_encoding_callback_1 -[`_write()`]: #stream_writable_write_chunk_encoding_callback_1 -[_write]: #stream_writable_write_chunk_encoding_callback_1 -[`util.inherits`]: https://nodejs.org/docs/v5.1.0/api/util.html#util_util_inherits_constructor_superconstructor -[`end()`]: #stream_writable_end_chunk_encoding_callback -[`'data'` event]: #stream_event_data -[`resume()`]: #stream_readable_resume -[`readable.resume()`]: #stream_readable_resume -[`pause()`]: #stream_readable_pause -[`unpipe()`]: #stream_readable_unpipe_destination -[`pipe()`]: #stream_readable_pipe_destination_options +[Writable]: #stream_class_stream_writable +[zlib]: zlib.html diff --git a/node_modules/readable-stream/lib/_stream_duplex.js b/node_modules/readable-stream/lib/_stream_duplex.js index 69558af03..736693b84 100644 --- a/node_modules/readable-stream/lib/_stream_duplex.js +++ b/node_modules/readable-stream/lib/_stream_duplex.js @@ -6,22 +6,21 @@ 'use strict'; /*<replacement>*/ + var objectKeys = Object.keys || function (obj) { var keys = []; - for (var key in obj) keys.push(key); - return keys; -} + for (var key in obj) { + keys.push(key); + }return keys; +}; /*</replacement>*/ - module.exports = Duplex; /*<replacement>*/ var processNextTick = require('process-nextick-args'); /*</replacement>*/ - - /*<replacement>*/ var util = require('core-util-is'); util.inherits = require('inherits'); @@ -35,26 +34,21 @@ util.inherits(Duplex, Readable); var keys = objectKeys(Writable.prototype); for (var v = 0; v < keys.length; v++) { var method = keys[v]; - if (!Duplex.prototype[method]) - Duplex.prototype[method] = Writable.prototype[method]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; } function Duplex(options) { - if (!(this instanceof Duplex)) - return new Duplex(options); + if (!(this instanceof Duplex)) return new Duplex(options); Readable.call(this, options); Writable.call(this, options); - if (options && options.readable === false) - this.readable = false; + if (options && options.readable === false) this.readable = false; - if (options && options.writable === false) - this.writable = false; + if (options && options.writable === false) this.writable = false; this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) - this.allowHalfOpen = false; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; this.once('end', onend); } @@ -63,8 +57,7 @@ function Duplex(options) { function onend() { // if we allow half-open state, or if the writable side ended, // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) - return; + if (this.allowHalfOpen || this._writableState.ended) return; // no more data can be written. // But allow more writes to happen in this tick. @@ -75,8 +68,8 @@ function onEndNT(self) { self.end(); } -function forEach (xs, f) { +function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xs[i], i); } -} +}
\ No newline at end of file diff --git a/node_modules/readable-stream/lib/_stream_passthrough.js b/node_modules/readable-stream/lib/_stream_passthrough.js index bddfdd015..d06f71f18 100644 --- a/node_modules/readable-stream/lib/_stream_passthrough.js +++ b/node_modules/readable-stream/lib/_stream_passthrough.js @@ -16,12 +16,11 @@ util.inherits = require('inherits'); util.inherits(PassThrough, Transform); function PassThrough(options) { - if (!(this instanceof PassThrough)) - return new PassThrough(options); + if (!(this instanceof PassThrough)) return new PassThrough(options); Transform.call(this, options); } -PassThrough.prototype._transform = function(chunk, encoding, cb) { +PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); -}; +};
\ No newline at end of file diff --git a/node_modules/readable-stream/lib/_stream_readable.js b/node_modules/readable-stream/lib/_stream_readable.js index 50852aee7..54a9d5c55 100644 --- a/node_modules/readable-stream/lib/_stream_readable.js +++ b/node_modules/readable-stream/lib/_stream_readable.js @@ -6,12 +6,10 @@ module.exports = Readable; var processNextTick = require('process-nextick-args'); /*</replacement>*/ - /*<replacement>*/ var isArray = require('isarray'); /*</replacement>*/ - /*<replacement>*/ var Buffer = require('buffer').Buffer; /*</replacement>*/ @@ -21,21 +19,20 @@ Readable.ReadableState = ReadableState; var EE = require('events'); /*<replacement>*/ -var EElistenerCount = function(emitter, type) { +var EElistenerCount = function (emitter, type) { return emitter.listeners(type).length; }; /*</replacement>*/ - - /*<replacement>*/ var Stream; -(function (){try{ - Stream = require('st' + 'ream'); -}catch(_){}finally{ - if (!Stream) - Stream = require('events').EventEmitter; -}}()) +(function () { + try { + Stream = require('st' + 'ream'); + } catch (_) {} finally { + if (!Stream) Stream = require('events').EventEmitter; + } +})(); /*</replacement>*/ var Buffer = require('buffer').Buffer; @@ -45,11 +42,9 @@ var util = require('core-util-is'); util.inherits = require('inherits'); /*</replacement>*/ - - /*<replacement>*/ var debugUtil = require('util'); -var debug; +var debug = undefined; if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); } else { @@ -71,17 +66,16 @@ function ReadableState(options, stream) { // make all the buffer merging and length checks go away this.objectMode = !!options.objectMode; - if (stream instanceof Duplex) - this.objectMode = this.objectMode || !!options.readableObjectMode; + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever" var hwm = options.highWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; - this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. - this.highWaterMark = ~~this.highWaterMark; + this.highWaterMark = ~ ~this.highWaterMark; this.buffer = []; this.length = 0; @@ -103,6 +97,7 @@ function ReadableState(options, stream) { this.needReadable = false; this.emittedReadable = false; this.readableListening = false; + this.resumeScheduled = false; // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. @@ -122,8 +117,7 @@ function ReadableState(options, stream) { this.decoder = null; this.encoding = null; if (options.encoding) { - if (!StringDecoder) - StringDecoder = require('string_decoder/').StringDecoder; + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; this.decoder = new StringDecoder(options.encoding); this.encoding = options.encoding; } @@ -133,16 +127,14 @@ var Duplex; function Readable(options) { Duplex = Duplex || require('./_stream_duplex'); - if (!(this instanceof Readable)) - return new Readable(options); + if (!(this instanceof Readable)) return new Readable(options); this._readableState = new ReadableState(options, this); // legacy this.readable = true; - if (options && typeof options.read === 'function') - this._read = options.read; + if (options && typeof options.read === 'function') this._read = options.read; Stream.call(this); } @@ -151,7 +143,7 @@ function Readable(options) { // This returns true if the highWaterMark has not been hit yet, // similar to how Writable.write() returns true if you should // write() some more. -Readable.prototype.push = function(chunk, encoding) { +Readable.prototype.push = function (chunk, encoding) { var state = this._readableState; if (!state.objectMode && typeof chunk === 'string') { @@ -166,12 +158,12 @@ Readable.prototype.push = function(chunk, encoding) { }; // Unshift should *always* be something directly out of read() -Readable.prototype.unshift = function(chunk) { +Readable.prototype.unshift = function (chunk) { var state = this._readableState; return readableAddChunk(this, state, chunk, '', true); }; -Readable.prototype.isPaused = function() { +Readable.prototype.isPaused = function () { return this._readableState.flowing === false; }; @@ -190,26 +182,28 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) { var e = new Error('stream.unshift() after end event'); stream.emit('error', e); } else { - if (state.decoder && !addToFront && !encoding) + var skipAdd; + if (state.decoder && !addToFront && !encoding) { chunk = state.decoder.write(chunk); + skipAdd = !state.objectMode && chunk.length === 0; + } - if (!addToFront) - state.reading = false; - - // if we want the data now, just emit it. - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) - state.buffer.unshift(chunk); - else - state.buffer.push(chunk); - - if (state.needReadable) - emitReadable(stream); + if (!addToFront) state.reading = false; + + // Don't add to the buffer if we've decoded to an empty string chunk and + // we're not in object mode + if (!skipAdd) { + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } } maybeReadMore(stream, state); @@ -221,7 +215,6 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) { return needMoreData(state); } - // if it's past the high water mark, we can push in some more. // Also, if we have no data yet, we can stand some // more bytes. This is to work around cases where hwm=0, @@ -230,16 +223,12 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) { // needReadable was set, then we ought to push more, so that another // 'readable' event will be triggered. function needMoreData(state) { - return !state.ended && - (state.needReadable || - state.length < state.highWaterMark || - state.length === 0); + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); } // backwards compatibility. -Readable.prototype.setEncoding = function(enc) { - if (!StringDecoder) - StringDecoder = require('string_decoder/').StringDecoder; +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; this._readableState.decoder = new StringDecoder(enc); this._readableState.encoding = enc; return this; @@ -264,29 +253,22 @@ function computeNewHighWaterMark(n) { } function howMuchToRead(n, state) { - if (state.length === 0 && state.ended) - return 0; + if (state.length === 0 && state.ended) return 0; - if (state.objectMode) - return n === 0 ? 0 : 1; + if (state.objectMode) return n === 0 ? 0 : 1; if (n === null || isNaN(n)) { // only flow one buffer at a time - if (state.flowing && state.buffer.length) - return state.buffer[0].length; - else - return state.length; + if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length; } - if (n <= 0) - return 0; + if (n <= 0) return 0; // If we're asking for more than the target buffer level, // then raise the water mark. Bump up to the next highest // power of 2, to prevent increasing it excessively in tiny // amounts. - if (n > state.highWaterMark) - state.highWaterMark = computeNewHighWaterMark(n); + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); // don't have that much. return null, unless we've ended. if (n > state.length) { @@ -302,25 +284,19 @@ function howMuchToRead(n, state) { } // you can override either this method, or the async _read(n) below. -Readable.prototype.read = function(n) { +Readable.prototype.read = function (n) { debug('read', n); var state = this._readableState; var nOrig = n; - if (typeof n !== 'number' || n > 0) - state.emittedReadable = false; + if (typeof n !== 'number' || n > 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we // already have a bunch of data in the buffer, then just trigger // the 'readable' event and move on. - if (n === 0 && - state.needReadable && - (state.length >= state.highWaterMark || state.ended)) { + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { debug('read: emitReadable', state.length, state.ended); - if (state.length === 0 && state.ended) - endReadable(this); - else - emitReadable(this); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); return null; } @@ -328,8 +304,7 @@ Readable.prototype.read = function(n) { // if we've ended, and we're now clear, then finish it up. if (n === 0 && state.ended) { - if (state.length === 0) - endReadable(this); + if (state.length === 0) endReadable(this); return null; } @@ -377,8 +352,7 @@ Readable.prototype.read = function(n) { state.reading = true; state.sync = true; // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) - state.needReadable = true; + if (state.length === 0) state.needReadable = true; // call internal read method this._read(state.highWaterMark); state.sync = false; @@ -386,14 +360,10 @@ Readable.prototype.read = function(n) { // If _read pushed data synchronously, then `reading` will be false, // and we need to re-evaluate how much data we can return to the user. - if (doRead && !state.reading) - n = howMuchToRead(nOrig, state); + if (doRead && !state.reading) n = howMuchToRead(nOrig, state); var ret; - if (n > 0) - ret = fromList(n, state); - else - ret = null; + if (n > 0) ret = fromList(n, state);else ret = null; if (ret === null) { state.needReadable = true; @@ -404,32 +374,24 @@ Readable.prototype.read = function(n) { // If we have nothing in the buffer, then we want to know // as soon as we *do* get something into the buffer. - if (state.length === 0 && !state.ended) - state.needReadable = true; + if (state.length === 0 && !state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended && state.length === 0) - endReadable(this); + if (nOrig !== n && state.ended && state.length === 0) endReadable(this); - if (ret !== null) - this.emit('data', ret); + if (ret !== null) this.emit('data', ret); return ret; }; function chunkInvalid(state, chunk) { var er = null; - if (!(Buffer.isBuffer(chunk)) && - typeof chunk !== 'string' && - chunk !== null && - chunk !== undefined && - !state.objectMode) { + if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { er = new TypeError('Invalid non-string/buffer chunk'); } return er; } - function onEofChunk(stream, state) { if (state.ended) return; if (state.decoder) { @@ -454,10 +416,7 @@ function emitReadable(stream) { if (!state.emittedReadable) { debug('emitReadable', state.flowing); state.emittedReadable = true; - if (state.sync) - processNextTick(emitReadable_, stream); - else - emitReadable_(stream); + if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); } } @@ -467,7 +426,6 @@ function emitReadable_(stream) { flow(stream); } - // at this point, the user has presumably seen the 'readable' event, // and called read() to consume some data. that may have triggered // in turn another _read(n) call, in which case reading = true if @@ -483,15 +441,12 @@ function maybeReadMore(stream, state) { function maybeReadMore_(stream, state) { var len = state.length; - while (!state.reading && !state.flowing && !state.ended && - state.length < state.highWaterMark) { + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { debug('maybeReadMore read 0'); stream.read(0); if (len === state.length) // didn't get any data, stop spinning. - break; - else - len = state.length; + break;else len = state.length; } state.readingMore = false; } @@ -500,11 +455,11 @@ function maybeReadMore_(stream, state) { // call cb(er, data) where data is <= n in length. // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. -Readable.prototype._read = function(n) { +Readable.prototype._read = function (n) { this.emit('error', new Error('not implemented')); }; -Readable.prototype.pipe = function(dest, pipeOpts) { +Readable.prototype.pipe = function (dest, pipeOpts) { var src = this; var state = this._readableState; @@ -522,15 +477,10 @@ Readable.prototype.pipe = function(dest, pipeOpts) { state.pipesCount += 1; debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - var doEnd = (!pipeOpts || pipeOpts.end !== false) && - dest !== process.stdout && - dest !== process.stderr; + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; var endFn = doEnd ? onend : cleanup; - if (state.endEmitted) - processNextTick(endFn); - else - src.once('end', endFn); + if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); dest.on('unpipe', onunpipe); function onunpipe(readable) { @@ -572,9 +522,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) { // flowing again. // So, if this is awaiting a drain, then we just call it now. // If we don't know, then assume that we are waiting for one. - if (state.awaitDrain && - (!dest._writableState || dest._writableState.needDrain)) - ondrain(); + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } src.on('data', ondata); @@ -585,10 +533,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) { // If the user unpiped during `dest.write()`, it is possible // to get stuck in a permanently paused state if that write // also returned false. - if (state.pipesCount === 1 && - state.pipes[0] === dest && - src.listenerCount('data') === 1 && - !cleanedUp) { + if (state.pipesCount === 1 && state.pipes[0] === dest && src.listenerCount('data') === 1 && !cleanedUp) { debug('false write response, pause', src._readableState.awaitDrain); src._readableState.awaitDrain++; } @@ -602,18 +547,11 @@ Readable.prototype.pipe = function(dest, pipeOpts) { debug('onerror', er); unpipe(); dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) - dest.emit('error', er); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); } // This is a brutally ugly hack to make sure that our error handler // is attached before any userland ones. NEVER DO THIS. - if (!dest._events || !dest._events.error) - dest.on('error', onerror); - else if (isArray(dest._events.error)) - dest._events.error.unshift(onerror); - else - dest._events.error = [onerror, dest._events.error]; - + if (!dest._events || !dest._events.error) dest.on('error', onerror);else if (isArray(dest._events.error)) dest._events.error.unshift(onerror);else dest._events.error = [onerror, dest._events.error]; // Both close and finish should trigger unpipe, but only once. function onclose() { @@ -646,11 +584,10 @@ Readable.prototype.pipe = function(dest, pipeOpts) { }; function pipeOnDrain(src) { - return function() { + return function () { var state = src._readableState; debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) - state.awaitDrain--; + if (state.awaitDrain) state.awaitDrain--; if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { state.flowing = true; flow(src); @@ -658,29 +595,24 @@ function pipeOnDrain(src) { }; } - -Readable.prototype.unpipe = function(dest) { +Readable.prototype.unpipe = function (dest) { var state = this._readableState; // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) - return this; + if (state.pipesCount === 0) return this; // just one destination. most common case. if (state.pipesCount === 1) { // passed in one, but it's not the right one. - if (dest && dest !== state.pipes) - return this; + if (dest && dest !== state.pipes) return this; - if (!dest) - dest = state.pipes; + if (!dest) dest = state.pipes; // got a match. state.pipes = null; state.pipesCount = 0; state.flowing = false; - if (dest) - dest.emit('unpipe', this); + if (dest) dest.emit('unpipe', this); return this; } @@ -694,20 +626,18 @@ Readable.prototype.unpipe = function(dest) { state.pipesCount = 0; state.flowing = false; - for (var i = 0; i < len; i++) - dests[i].emit('unpipe', this); - return this; + for (var _i = 0; _i < len; _i++) { + dests[_i].emit('unpipe', this); + }return this; } // try to find the right one. var i = indexOf(state.pipes, dest); - if (i === -1) - return this; + if (i === -1) return this; state.pipes.splice(i, 1); state.pipesCount -= 1; - if (state.pipesCount === 1) - state.pipes = state.pipes[0]; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; dest.emit('unpipe', this); @@ -716,7 +646,7 @@ Readable.prototype.unpipe = function(dest) { // set up data events if they are asked for // Ensure readable listeners eventually get something -Readable.prototype.on = function(ev, fn) { +Readable.prototype.on = function (ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); // If listening to data, and it has not explicitly been paused, @@ -725,7 +655,7 @@ Readable.prototype.on = function(ev, fn) { this.resume(); } - if (ev === 'readable' && this.readable) { + if (ev === 'readable' && !this._readableState.endEmitted) { var state = this._readableState; if (!state.readableListening) { state.readableListening = true; @@ -750,7 +680,7 @@ function nReadingNextTick(self) { // pause() and resume() are remnants of the legacy readable stream API // If the user uses them, then switch into old mode. -Readable.prototype.resume = function() { +Readable.prototype.resume = function () { var state = this._readableState; if (!state.flowing) { debug('resume'); @@ -776,11 +706,10 @@ function resume_(stream, state) { state.resumeScheduled = false; stream.emit('resume'); flow(stream); - if (state.flowing && !state.reading) - stream.read(0); + if (state.flowing && !state.reading) stream.read(0); } -Readable.prototype.pause = function() { +Readable.prototype.pause = function () { debug('call pause flowing=%j', this._readableState.flowing); if (false !== this._readableState.flowing) { debug('pause'); @@ -803,32 +732,27 @@ function flow(stream) { // wrap an old-style stream as the async data source. // This is *not* part of the readable stream interface. // It is an ugly unfortunate mess of history. -Readable.prototype.wrap = function(stream) { +Readable.prototype.wrap = function (stream) { var state = this._readableState; var paused = false; var self = this; - stream.on('end', function() { + stream.on('end', function () { debug('wrapped end'); if (state.decoder && !state.ended) { var chunk = state.decoder.end(); - if (chunk && chunk.length) - self.push(chunk); + if (chunk && chunk.length) self.push(chunk); } self.push(null); }); - stream.on('data', function(chunk) { + stream.on('data', function (chunk) { debug('wrapped data'); - if (state.decoder) - chunk = state.decoder.write(chunk); + if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode - if (state.objectMode && (chunk === null || chunk === undefined)) - return; - else if (!state.objectMode && (!chunk || !chunk.length)) - return; + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; var ret = self.push(chunk); if (!ret) { @@ -841,21 +765,23 @@ Readable.prototype.wrap = function(stream) { // important when wrapping filters and duplexes. for (var i in stream) { if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function(method) { return function() { - return stream[method].apply(stream, arguments); - }; }(i); + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); } } // proxy certain important events. var events = ['error', 'close', 'destroy', 'pause', 'resume']; - forEach(events, function(ev) { + forEach(events, function (ev) { stream.on(ev, self.emit.bind(self, ev)); }); // when we try to consume some more bytes, simply unpause the // underlying stream. - self._read = function(n) { + self._read = function (n) { debug('wrapped _read', n); if (paused) { paused = false; @@ -866,7 +792,6 @@ Readable.prototype.wrap = function(stream) { return self; }; - // exposed for testing purposes only. Readable._fromList = fromList; @@ -880,21 +805,11 @@ function fromList(n, state) { var ret; // nothing in the list, definitely empty. - if (list.length === 0) - return null; + if (list.length === 0) return null; - if (length === 0) - ret = null; - else if (objectMode) - ret = list.shift(); - else if (!n || n >= length) { + if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) { // read it all, truncate the array. - if (stringMode) - ret = list.join(''); - else if (list.length === 1) - ret = list[0]; - else - ret = Buffer.concat(list, length); + if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length); list.length = 0; } else { // read just some of it. @@ -910,25 +825,16 @@ function fromList(n, state) { } else { // complex case. // we have enough to cover it, but it spans past the first buffer. - if (stringMode) - ret = ''; - else - ret = new Buffer(n); + if (stringMode) ret = '';else ret = new Buffer(n); var c = 0; for (var i = 0, l = list.length; i < l && c < n; i++) { var buf = list[0]; var cpy = Math.min(n - c, buf.length); - if (stringMode) - ret += buf.slice(0, cpy); - else - buf.copy(ret, c, 0, cpy); + if (stringMode) ret += buf.slice(0, cpy);else buf.copy(ret, c, 0, cpy); - if (cpy < buf.length) - list[0] = buf.slice(cpy); - else - list.shift(); + if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift(); c += cpy; } @@ -943,8 +849,7 @@ function endReadable(stream) { // If we get here before consuming all the bytes, then that is a // bug in node. Should never happen. - if (state.length > 0) - throw new Error('endReadable called on non-empty stream'); + if (state.length > 0) throw new Error('endReadable called on non-empty stream'); if (!state.endEmitted) { state.ended = true; @@ -961,15 +866,15 @@ function endReadableNT(state, stream) { } } -function forEach (xs, f) { +function forEach(xs, f) { for (var i = 0, l = xs.length; i < l; i++) { f(xs[i], i); } } -function indexOf (xs, x) { +function indexOf(xs, x) { for (var i = 0, l = xs.length; i < l; i++) { if (xs[i] === x) return i; } return -1; -} +}
\ No newline at end of file diff --git a/node_modules/readable-stream/lib/_stream_transform.js b/node_modules/readable-stream/lib/_stream_transform.js index 3675d18d9..625cdc176 100644 --- a/node_modules/readable-stream/lib/_stream_transform.js +++ b/node_modules/readable-stream/lib/_stream_transform.js @@ -53,9 +53,8 @@ util.inherits = require('inherits'); util.inherits(Transform, Duplex); - function TransformState(stream) { - this.afterTransform = function(er, data) { + this.afterTransform = function (er, data) { return afterTransform(stream, er, data); }; @@ -63,6 +62,7 @@ function TransformState(stream) { this.transforming = false; this.writecb = null; this.writechunk = null; + this.writeencoding = null; } function afterTransform(stream, er, data) { @@ -71,17 +71,14 @@ function afterTransform(stream, er, data) { var cb = ts.writecb; - if (!cb) - return stream.emit('error', new Error('no writecb in Transform class')); + if (!cb) return stream.emit('error', new Error('no writecb in Transform class')); ts.writechunk = null; ts.writecb = null; - if (data !== null && data !== undefined) - stream.push(data); + if (data !== null && data !== undefined) stream.push(data); - if (cb) - cb(er); + cb(er); var rs = stream._readableState; rs.reading = false; @@ -90,10 +87,8 @@ function afterTransform(stream, er, data) { } } - function Transform(options) { - if (!(this instanceof Transform)) - return new Transform(options); + if (!(this instanceof Transform)) return new Transform(options); Duplex.call(this, options); @@ -111,24 +106,19 @@ function Transform(options) { this._readableState.sync = false; if (options) { - if (typeof options.transform === 'function') - this._transform = options.transform; + if (typeof options.transform === 'function') this._transform = options.transform; - if (typeof options.flush === 'function') - this._flush = options.flush; + if (typeof options.flush === 'function') this._flush = options.flush; } - this.once('prefinish', function() { - if (typeof this._flush === 'function') - this._flush(function(er) { - done(stream, er); - }); - else - done(stream); + this.once('prefinish', function () { + if (typeof this._flush === 'function') this._flush(function (er) { + done(stream, er); + });else done(stream); }); } -Transform.prototype.push = function(chunk, encoding) { +Transform.prototype.push = function (chunk, encoding) { this._transformState.needTransform = false; return Duplex.prototype.push.call(this, chunk, encoding); }; @@ -143,28 +133,25 @@ Transform.prototype.push = function(chunk, encoding) { // Call `cb(err)` when you are done with this chunk. If you pass // an error, then that'll put the hurt on the whole operation. If you // never call cb(), then you'll never get another chunk. -Transform.prototype._transform = function(chunk, encoding, cb) { +Transform.prototype._transform = function (chunk, encoding, cb) { throw new Error('not implemented'); }; -Transform.prototype._write = function(chunk, encoding, cb) { +Transform.prototype._write = function (chunk, encoding, cb) { var ts = this._transformState; ts.writecb = cb; ts.writechunk = chunk; ts.writeencoding = encoding; if (!ts.transforming) { var rs = this._readableState; - if (ts.needTransform || - rs.needReadable || - rs.length < rs.highWaterMark) - this._read(rs.highWaterMark); + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); } }; // Doesn't matter what the args are here. // _transform does all the work. // That we got here means that the readable side wants more data. -Transform.prototype._read = function(n) { +Transform.prototype._read = function (n) { var ts = this._transformState; if (ts.writechunk !== null && ts.writecb && !ts.transforming) { @@ -177,21 +164,17 @@ Transform.prototype._read = function(n) { } }; - function done(stream, er) { - if (er) - return stream.emit('error', er); + if (er) return stream.emit('error', er); // if there's nothing in the write buffer, then that means // that nothing more will ever be provided var ws = stream._writableState; var ts = stream._transformState; - if (ws.length) - throw new Error('calling transform done when ws.length != 0'); + if (ws.length) throw new Error('calling transform done when ws.length != 0'); - if (ts.transforming) - throw new Error('calling transform done when still transforming'); + if (ts.transforming) throw new Error('calling transform done when still transforming'); return stream.push(null); -} +}
\ No newline at end of file diff --git a/node_modules/readable-stream/lib/_stream_writable.js b/node_modules/readable-stream/lib/_stream_writable.js index 1fa5eb695..95916c992 100644 --- a/node_modules/readable-stream/lib/_stream_writable.js +++ b/node_modules/readable-stream/lib/_stream_writable.js @@ -10,6 +10,9 @@ module.exports = Writable; var processNextTick = require('process-nextick-args'); /*</replacement>*/ +/*<replacement>*/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; +/*</replacement>*/ /*<replacement>*/ var Buffer = require('buffer').Buffer; @@ -17,29 +20,26 @@ var Buffer = require('buffer').Buffer; Writable.WritableState = WritableState; - /*<replacement>*/ var util = require('core-util-is'); util.inherits = require('inherits'); /*</replacement>*/ - /*<replacement>*/ var internalUtil = { deprecate: require('util-deprecate') }; /*</replacement>*/ - - /*<replacement>*/ var Stream; -(function (){try{ - Stream = require('st' + 'ream'); -}catch(_){}finally{ - if (!Stream) - Stream = require('events').EventEmitter; -}}()) +(function () { + try { + Stream = require('st' + 'ream'); + } catch (_) {} finally { + if (!Stream) Stream = require('events').EventEmitter; + } +})(); /*</replacement>*/ var Buffer = require('buffer').Buffer; @@ -65,18 +65,17 @@ function WritableState(options, stream) { // contains buffers or objects. this.objectMode = !!options.objectMode; - if (stream instanceof Duplex) - this.objectMode = this.objectMode || !!options.writableObjectMode; + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false // Note: 0 is a valid value, means that we always return false if // the entire buffer is not flushed immediately on write() var hwm = options.highWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; - this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; // cast to ints. - this.highWaterMark = ~~this.highWaterMark; + this.highWaterMark = ~ ~this.highWaterMark; this.needDrain = false; // at the start of calling end() @@ -120,7 +119,7 @@ function WritableState(options, stream) { this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) - this.onwrite = function(er) { + this.onwrite = function (er) { onwrite(stream, er); }; @@ -143,6 +142,14 @@ function WritableState(options, stream) { // True if the error was already emitted and should not be thrown again this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // create the two objects needed to store the corked requests + // they are not a linked list, as no new elements are inserted in there + this.corkedRequestsFree = new CorkedRequest(this); + this.corkedRequestsFree.next = new CorkedRequest(this); } WritableState.prototype.getBuffer = function writableStateGetBuffer() { @@ -155,15 +162,15 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() { return out; }; -(function (){try { -Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function() { - return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + - 'instead.') -}); -}catch(_){}}()); - +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') + }); + } catch (_) {} +})(); var Duplex; function Writable(options) { @@ -171,8 +178,7 @@ function Writable(options) { // Writable ctor is applied to Duplexes, though they're not // instanceof Writable, they're instanceof Readable. - if (!(this instanceof Writable) && !(this instanceof Duplex)) - return new Writable(options); + if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options); this._writableState = new WritableState(options, this); @@ -180,22 +186,19 @@ function Writable(options) { this.writable = true; if (options) { - if (typeof options.write === 'function') - this._write = options.write; + if (typeof options.write === 'function') this._write = options.write; - if (typeof options.writev === 'function') - this._writev = options.writev; + if (typeof options.writev === 'function') this._writev = options.writev; } Stream.call(this); } // Otherwise people can pipe Writable streams, which is just wrong. -Writable.prototype.pipe = function() { +Writable.prototype.pipe = function () { this.emit('error', new Error('Cannot pipe. Not readable.')); }; - function writeAfterEnd(stream, cb) { var er = new Error('write after end'); // TODO: defer error events consistently everywhere, not just the cb @@ -211,11 +214,7 @@ function writeAfterEnd(stream, cb) { function validChunk(stream, state, chunk, cb) { var valid = true; - if (!(Buffer.isBuffer(chunk)) && - typeof chunk !== 'string' && - chunk !== null && - chunk !== undefined && - !state.objectMode) { + if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { var er = new TypeError('Invalid non-string/buffer chunk'); stream.emit('error', er); processNextTick(cb, er); @@ -224,7 +223,7 @@ function validChunk(stream, state, chunk, cb) { return valid; } -Writable.prototype.write = function(chunk, encoding, cb) { +Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; @@ -233,17 +232,11 @@ Writable.prototype.write = function(chunk, encoding, cb) { encoding = null; } - if (Buffer.isBuffer(chunk)) - encoding = 'buffer'; - else if (!encoding) - encoding = state.defaultEncoding; + if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - if (typeof cb !== 'function') - cb = nop; + if (typeof cb !== 'function') cb = nop; - if (state.ended) - writeAfterEnd(this, cb); - else if (validChunk(this, state, chunk, cb)) { + if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) { state.pendingcb++; ret = writeOrBuffer(this, state, chunk, encoding, cb); } @@ -251,42 +244,31 @@ Writable.prototype.write = function(chunk, encoding, cb) { return ret; }; -Writable.prototype.cork = function() { +Writable.prototype.cork = function () { var state = this._writableState; state.corked++; }; -Writable.prototype.uncork = function() { +Writable.prototype.uncork = function () { var state = this._writableState; if (state.corked) { state.corked--; - if (!state.writing && - !state.corked && - !state.finished && - !state.bufferProcessing && - state.bufferedRequest) - clearBuffer(this, state); + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } }; Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { // node::ParseEncoding() requires lower case. - if (typeof encoding === 'string') - encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', -'ucs2', 'ucs-2','utf16le', 'utf-16le', 'raw'] -.indexOf((encoding + '').toLowerCase()) > -1)) - throw new TypeError('Unknown encoding: ' + encoding); + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); this._writableState.defaultEncoding = encoding; }; function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && - state.decodeStrings !== false && - typeof chunk === 'string') { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { chunk = new Buffer(chunk, encoding); } return chunk; @@ -298,16 +280,14 @@ function decodeChunk(state, chunk, encoding) { function writeOrBuffer(stream, state, chunk, encoding, cb) { chunk = decodeChunk(state, chunk, encoding); - if (Buffer.isBuffer(chunk)) - encoding = 'buffer'; + if (Buffer.isBuffer(chunk)) encoding = 'buffer'; var len = state.objectMode ? 1 : chunk.length; state.length += len; var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. - if (!ret) - state.needDrain = true; + if (!ret) state.needDrain = true; if (state.writing || state.corked) { var last = state.lastBufferedRequest; @@ -317,6 +297,7 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) { } else { state.bufferedRequest = state.lastBufferedRequest; } + state.bufferedRequestCount += 1; } else { doWrite(stream, state, false, len, chunk, encoding, cb); } @@ -329,19 +310,13 @@ function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writecb = cb; state.writing = true; state.sync = true; - if (writev) - stream._writev(chunk, state.onwrite); - else - stream._write(chunk, encoding, state.onwrite); + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); state.sync = false; } function onwriteError(stream, state, sync, er, cb) { --state.pendingcb; - if (sync) - processNextTick(cb, er); - else - cb(er); + if (sync) processNextTick(cb, er);else cb(er); stream._writableState.errorEmitted = true; stream.emit('error', er); @@ -361,30 +336,26 @@ function onwrite(stream, er) { onwriteStateUpdate(state); - if (er) - onwriteError(stream, state, sync, er, cb); - else { + if (er) onwriteError(stream, state, sync, er, cb);else { // Check if we're actually ready to finish, but don't emit yet var finished = needFinish(state); - if (!finished && - !state.corked && - !state.bufferProcessing && - state.bufferedRequest) { + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { clearBuffer(stream, state); } if (sync) { - processNextTick(afterWrite, stream, state, finished, cb); + /*<replacement>*/ + asyncWrite(afterWrite, stream, state, finished, cb); + /*</replacement>*/ } else { - afterWrite(stream, state, finished, cb); - } + afterWrite(stream, state, finished, cb); + } } } function afterWrite(stream, state, finished, cb) { - if (!finished) - onwriteDrain(stream, state); + if (!finished) onwriteDrain(stream, state); state.pendingcb--; cb(); finishMaybe(stream, state); @@ -400,7 +371,6 @@ function onwriteDrain(stream, state) { } } - // if there's something in the buffer waiting, then process it function clearBuffer(stream, state) { state.bufferProcessing = true; @@ -408,26 +378,26 @@ function clearBuffer(stream, state) { if (stream._writev && entry && entry.next) { // Fast case, write everything using _writev() - var buffer = []; - var cbs = []; + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; while (entry) { - cbs.push(entry.callback); - buffer.push(entry); + buffer[count] = entry; entry = entry.next; + count += 1; } - // count the one we are adding, as well. - // TODO(isaacs) clean this up + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is always async, defer these to save a bit of time + // as the hot path ends with doWrite state.pendingcb++; state.lastBufferedRequest = null; - doWrite(stream, state, true, state.length, buffer, '', function(err) { - for (var i = 0; i < cbs.length; i++) { - state.pendingcb--; - cbs[i](err); - } - }); - - // Clear buffer + state.corkedRequestsFree = holder.next; + holder.next = null; } else { // Slow case, write chunks one-by-one while (entry) { @@ -447,20 +417,21 @@ function clearBuffer(stream, state) { } } - if (entry === null) - state.lastBufferedRequest = null; + if (entry === null) state.lastBufferedRequest = null; } + + state.bufferedRequestCount = 0; state.bufferedRequest = entry; state.bufferProcessing = false; } -Writable.prototype._write = function(chunk, encoding, cb) { +Writable.prototype._write = function (chunk, encoding, cb) { cb(new Error('not implemented')); }; Writable.prototype._writev = null; -Writable.prototype.end = function(chunk, encoding, cb) { +Writable.prototype.end = function (chunk, encoding, cb) { var state = this._writableState; if (typeof chunk === 'function') { @@ -472,8 +443,7 @@ Writable.prototype.end = function(chunk, encoding, cb) { encoding = null; } - if (chunk !== null && chunk !== undefined) - this.write(chunk, encoding); + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks if (state.corked) { @@ -482,17 +452,11 @@ Writable.prototype.end = function(chunk, encoding, cb) { } // ignore unnecessary end() calls. - if (!state.ending && !state.finished) - endWritable(this, state, cb); + if (!state.ending && !state.finished) endWritable(this, state, cb); }; - function needFinish(state) { - return (state.ending && - state.length === 0 && - state.bufferedRequest === null && - !state.finished && - !state.writing); + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } function prefinish(stream, state) { @@ -520,10 +484,33 @@ function endWritable(stream, state, cb) { state.ending = true; finishMaybe(stream, state); if (cb) { - if (state.finished) - processNextTick(cb); - else - stream.once('finish', cb); + if (state.finished) processNextTick(cb);else stream.once('finish', cb); } state.ended = true; + stream.writable = false; } + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + + this.finish = function (err) { + var entry = _this.entry; + _this.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = _this; + } else { + state.corkedRequestsFree = _this; + } + }; +}
\ No newline at end of file diff --git a/node_modules/readable-stream/node_modules/isarray/.npmignore b/node_modules/readable-stream/node_modules/isarray/.npmignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/node_modules/readable-stream/node_modules/isarray/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/readable-stream/node_modules/isarray/.travis.yml b/node_modules/readable-stream/node_modules/isarray/.travis.yml new file mode 100644 index 000000000..cc4dba29d --- /dev/null +++ b/node_modules/readable-stream/node_modules/isarray/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: + - "0.8" + - "0.10" diff --git a/node_modules/readable-stream/node_modules/isarray/Makefile b/node_modules/readable-stream/node_modules/isarray/Makefile new file mode 100644 index 000000000..787d56e1e --- /dev/null +++ b/node_modules/readable-stream/node_modules/isarray/Makefile @@ -0,0 +1,6 @@ + +test: + @node_modules/.bin/tape test.js + +.PHONY: test + diff --git a/node_modules/readable-stream/node_modules/isarray/README.md b/node_modules/readable-stream/node_modules/isarray/README.md index 052a62b8d..16d2c59c6 100644 --- a/node_modules/readable-stream/node_modules/isarray/README.md +++ b/node_modules/readable-stream/node_modules/isarray/README.md @@ -3,6 +3,12 @@ `Array#isArray` for older browsers. +[![build status](https://secure.travis-ci.org/juliangruber/isarray.svg)](http://travis-ci.org/juliangruber/isarray) +[![downloads](https://img.shields.io/npm/dm/isarray.svg)](https://www.npmjs.org/package/isarray) + +[![browser support](https://ci.testling.com/juliangruber/isarray.png) +](https://ci.testling.com/juliangruber/isarray) + ## Usage ```js diff --git a/node_modules/readable-stream/node_modules/isarray/build/build.js b/node_modules/readable-stream/node_modules/isarray/build/build.js deleted file mode 100644 index ec58596ae..000000000 --- a/node_modules/readable-stream/node_modules/isarray/build/build.js +++ /dev/null @@ -1,209 +0,0 @@ - -/** - * Require the given path. - * - * @param {String} path - * @return {Object} exports - * @api public - */ - -function require(path, parent, orig) { - var resolved = require.resolve(path); - - // lookup failed - if (null == resolved) { - orig = orig || path; - parent = parent || 'root'; - var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); - err.path = orig; - err.parent = parent; - err.require = true; - throw err; - } - - var module = require.modules[resolved]; - - // perform real require() - // by invoking the module's - // registered function - if (!module.exports) { - module.exports = {}; - module.client = module.component = true; - module.call(this, module.exports, require.relative(resolved), module); - } - - return module.exports; -} - -/** - * Registered modules. - */ - -require.modules = {}; - -/** - * Registered aliases. - */ - -require.aliases = {}; - -/** - * Resolve `path`. - * - * Lookup: - * - * - PATH/index.js - * - PATH.js - * - PATH - * - * @param {String} path - * @return {String} path or null - * @api private - */ - -require.resolve = function(path) { - if (path.charAt(0) === '/') path = path.slice(1); - var index = path + '/index.js'; - - var paths = [ - path, - path + '.js', - path + '.json', - path + '/index.js', - path + '/index.json' - ]; - - for (var i = 0; i < paths.length; i++) { - var path = paths[i]; - if (require.modules.hasOwnProperty(path)) return path; - } - - if (require.aliases.hasOwnProperty(index)) { - return require.aliases[index]; - } -}; - -/** - * Normalize `path` relative to the current path. - * - * @param {String} curr - * @param {String} path - * @return {String} - * @api private - */ - -require.normalize = function(curr, path) { - var segs = []; - - if ('.' != path.charAt(0)) return path; - - curr = curr.split('/'); - path = path.split('/'); - - for (var i = 0; i < path.length; ++i) { - if ('..' == path[i]) { - curr.pop(); - } else if ('.' != path[i] && '' != path[i]) { - segs.push(path[i]); - } - } - - return curr.concat(segs).join('/'); -}; - -/** - * Register module at `path` with callback `definition`. - * - * @param {String} path - * @param {Function} definition - * @api private - */ - -require.register = function(path, definition) { - require.modules[path] = definition; -}; - -/** - * Alias a module definition. - * - * @param {String} from - * @param {String} to - * @api private - */ - -require.alias = function(from, to) { - if (!require.modules.hasOwnProperty(from)) { - throw new Error('Failed to alias "' + from + '", it does not exist'); - } - require.aliases[to] = from; -}; - -/** - * Return a require function relative to the `parent` path. - * - * @param {String} parent - * @return {Function} - * @api private - */ - -require.relative = function(parent) { - var p = require.normalize(parent, '..'); - - /** - * lastIndexOf helper. - */ - - function lastIndexOf(arr, obj) { - var i = arr.length; - while (i--) { - if (arr[i] === obj) return i; - } - return -1; - } - - /** - * The relative require() itself. - */ - - function localRequire(path) { - var resolved = localRequire.resolve(path); - return require(resolved, parent, path); - } - - /** - * Resolve relative to the parent. - */ - - localRequire.resolve = function(path) { - var c = path.charAt(0); - if ('/' == c) return path.slice(1); - if ('.' == c) return require.normalize(p, path); - - // resolve deps by returning - // the dep in the nearest "deps" - // directory - var segs = parent.split('/'); - var i = lastIndexOf(segs, 'deps') + 1; - if (!i) i = 0; - path = segs.slice(0, i + 1).join('/') + '/deps/' + path; - return path; - }; - - /** - * Check if module is defined at `path`. - */ - - localRequire.exists = function(path) { - return require.modules.hasOwnProperty(localRequire.resolve(path)); - }; - - return localRequire; -}; -require.register("isarray/index.js", function(exports, require, module){ -module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; -}; - -}); -require.alias("isarray/index.js", "isarray/index.js"); - diff --git a/node_modules/readable-stream/node_modules/isarray/index.js b/node_modules/readable-stream/node_modules/isarray/index.js index 5f5ad45d4..a57f63495 100644 --- a/node_modules/readable-stream/node_modules/isarray/index.js +++ b/node_modules/readable-stream/node_modules/isarray/index.js @@ -1,3 +1,5 @@ +var toString = {}.toString; + module.exports = Array.isArray || function (arr) { - return Object.prototype.toString.call(arr) == '[object Array]'; + return toString.call(arr) == '[object Array]'; }; diff --git a/node_modules/readable-stream/node_modules/isarray/package.json b/node_modules/readable-stream/node_modules/isarray/package.json index 85d3a3b5f..a6ff18fbc 100644 --- a/node_modules/readable-stream/node_modules/isarray/package.json +++ b/node_modules/readable-stream/node_modules/isarray/package.json @@ -1,38 +1,37 @@ { "_args": [ [ - "isarray@0.0.1", - "/Users/rebecca/code/npm/node_modules/npm-registry-couchapp/node_modules/readable-stream" - ], - [ - "isarray@0.0.1", + "isarray@~1.0.0", "/Users/rebecca/code/npm/node_modules/readable-stream" ] ], - "_from": "isarray@0.0.1", - "_id": "isarray@0.0.1", + "_from": "isarray@>=1.0.0 <1.1.0", + "_id": "isarray@1.0.0", "_inCache": true, "_installable": true, "_location": "/readable-stream/isarray", + "_nodeVersion": "5.1.0", "_npmUser": { "email": "julian@juliangruber.com", "name": "juliangruber" }, - "_npmVersion": "1.2.18", + "_npmVersion": "3.3.12", "_phantomChildren": {}, "_requested": { "name": "isarray", - "raw": "isarray@0.0.1", - "rawSpec": "0.0.1", + "raw": "isarray@~1.0.0", + "rawSpec": "~1.0.0", "scope": null, - "spec": "0.0.1", - "type": "version" + "spec": ">=1.0.0 <1.1.0", + "type": "range" }, "_requiredBy": [ "/readable-stream" ], + "_resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "_shasum": "bb935d48582cba168c06834957a54a3e07124f11", "_shrinkwrap": null, - "_spec": "isarray@0.0.1", + "_spec": "isarray@~1.0.0", "_where": "/Users/rebecca/code/npm/node_modules/readable-stream", "author": { "email": "mail@juliangruber.com", @@ -45,25 +44,26 @@ "dependencies": {}, "description": "Array#isArray for older browsers", "devDependencies": { - "tap": "*" + "tape": "~2.13.4" }, "directories": {}, "dist": { - "shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", - "tarball": "http://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + "shasum": "bb935d48582cba168c06834957a54a3e07124f11", + "tarball": "http://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" }, + "gitHead": "2a23a281f369e9ae06394c0fb4d2381355a6ba33", "homepage": "https://github.com/juliangruber/isarray", "keywords": [ - "array", "browser", - "isarray" + "isarray", + "array" ], "license": "MIT", "main": "index.js", "maintainers": [ { - "name": "juliangruber", - "email": "julian@juliangruber.com" + "email": "julian@juliangruber.com", + "name": "juliangruber" } ], "name": "isarray", @@ -74,7 +74,23 @@ "url": "git://github.com/juliangruber/isarray.git" }, "scripts": { - "test": "tap test/*.js" + "test": "tape test.js" + }, + "testling": { + "browsers": [ + "ie/8..latest", + "firefox/17..latest", + "firefox/nightly", + "chrome/22..latest", + "chrome/canary", + "opera/12..latest", + "opera/next", + "safari/5.1..latest", + "ipad/6.0..latest", + "iphone/6.0..latest", + "android-browser/4.2..latest" + ], + "files": "test.js" }, - "version": "0.0.1" + "version": "1.0.0" } diff --git a/node_modules/readable-stream/node_modules/isarray/test.js b/node_modules/readable-stream/node_modules/isarray/test.js new file mode 100644 index 000000000..e0c3444d8 --- /dev/null +++ b/node_modules/readable-stream/node_modules/isarray/test.js @@ -0,0 +1,20 @@ +var isArray = require('./'); +var test = require('tape'); + +test('is array', function(t){ + t.ok(isArray([])); + t.notOk(isArray({})); + t.notOk(isArray(null)); + t.notOk(isArray(false)); + + var obj = {}; + obj[0] = true; + t.notOk(isArray(obj)); + + var arr = []; + arr.foo = 'bar'; + t.ok(isArray(arr)); + + t.end(); +}); + diff --git a/node_modules/readable-stream/package.json b/node_modules/readable-stream/package.json index 8a47aedf7..eca885b9a 100644 --- a/node_modules/readable-stream/package.json +++ b/node_modules/readable-stream/package.json @@ -1,44 +1,51 @@ { "_args": [ [ - "readable-stream@2.0.5", + "readable-stream@~2.0.5", "/Users/rebecca/code/npm" ] ], - "_from": "readable-stream@2.0.5", - "_id": "readable-stream@2.0.5", + "_from": "readable-stream@>=2.0.5 <2.1.0", + "_id": "readable-stream@2.0.6", "_inCache": true, "_installable": true, "_location": "/readable-stream", - "_nodeVersion": "5.1.1", + "_nodeVersion": "5.7.0", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/readable-stream-2.0.6.tgz_1457893507709_0.369257491780445" + }, "_npmUser": { "email": "calvin.metcalf@gmail.com", "name": "cwmma" }, - "_npmVersion": "3.3.12", + "_npmVersion": "3.6.0", "_phantomChildren": {}, "_requested": { "name": "readable-stream", - "raw": "readable-stream@2.0.5", - "rawSpec": "2.0.5", + "raw": "readable-stream@~2.0.5", + "rawSpec": "~2.0.5", "scope": null, - "spec": "2.0.5", - "type": "version" + "spec": ">=2.0.5 <2.1.0", + "type": "range" }, "_requiredBy": [ "/", "/fs-write-stream-atomic", "/npm-registry-client/concat-stream", + "/npmlog/are-we-there-yet", "/request/bl", "/sha", "/standard/standard-engine/eslint/concat-stream", + "/standard/standard-format/esformatter/npm-run/spawn-sync/concat-stream", "/tap", + "/tap/coveralls/request/bl", "/tap/tap-parser" ], - "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.5.tgz", - "_shasum": "a2426f8dcd4551c77a33f96edf2886a23c829669", + "_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", + "_shasum": "8f90341e68a53ccc928788dacfcd11b36eb9b78e", "_shrinkwrap": null, - "_spec": "readable-stream@2.0.5", + "_spec": "readable-stream@~2.0.5", "_where": "/Users/rebecca/code/npm", "browser": { "util": false @@ -49,47 +56,47 @@ "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.1", - "isarray": "0.0.1", + "isarray": "~1.0.0", "process-nextick-args": "~1.0.6", "string_decoder": "~0.10.x", "util-deprecate": "~1.0.1" }, - "description": "Streams3, a user-land copy of the stream library from iojs v2.x", + "description": "Streams3, a user-land copy of the stream library from Node.js", "devDependencies": { "tap": "~0.2.6", - "tape": "~4.0.0", - "zuul": "~3.0.0" + "tape": "~4.5.1", + "zuul": "~3.9.0" }, "directories": {}, "dist": { - "shasum": "a2426f8dcd4551c77a33f96edf2886a23c829669", - "tarball": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.5.tgz" + "shasum": "8f90341e68a53ccc928788dacfcd11b36eb9b78e", + "tarball": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz" }, - "gitHead": "a4f23d8e451267684a8160679ce16e16149fe72b", + "gitHead": "01fb5608a970b42c900b96746cadc13d27dd9d7e", "homepage": "https://github.com/nodejs/readable-stream#readme", "keywords": [ - "pipe", "readable", - "stream" + "stream", + "pipe" ], "license": "MIT", "main": "readable.js", "maintainers": [ { - "name": "isaacs", - "email": "isaacs@npmjs.com" + "email": "isaacs@npmjs.com", + "name": "isaacs" }, { - "name": "tootallnate", - "email": "nathan@tootallnate.net" + "email": "nathan@tootallnate.net", + "name": "tootallnate" }, { - "name": "rvagg", - "email": "rod@vagg.org" + "email": "rod@vagg.org", + "name": "rvagg" }, { - "name": "cwmma", - "email": "calvin.metcalf@gmail.com" + "email": "calvin.metcalf@gmail.com", + "name": "cwmma" } ], "name": "readable-stream", @@ -101,8 +108,8 @@ }, "scripts": { "browser": "npm run write-zuul && zuul -- test/browser.js", - "test": "tap test/parallel/*.js", + "test": "tap test/parallel/*.js test/ours/*.js", "write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml" }, - "version": "2.0.5" + "version": "2.0.6" } |