diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-26 17:04:35 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-26 17:04:55 +0100 |
commit | a851c3fb33335fb42de8280c6bad2a6699bb746f (patch) | |
tree | bbaea1b873ccdcbb453fdbb783fdc594da124909 /node_modules/readable-stream | |
parent | 5c17f4b61e8caaa365339c4916222a5892b2ec3a (diff) | |
download | wallet-core-a851c3fb33335fb42de8280c6bad2a6699bb746f.tar.xz |
update node_modules
Diffstat (limited to 'node_modules/readable-stream')
-rw-r--r-- | node_modules/readable-stream/.npmignore | 6 | ||||
-rw-r--r-- | node_modules/readable-stream/.travis.yml | 11 | ||||
-rw-r--r-- | node_modules/readable-stream/README.md | 8 | ||||
-rw-r--r-- | node_modules/readable-stream/lib/_stream_readable.js | 285 | ||||
-rw-r--r-- | node_modules/readable-stream/lib/_stream_transform.js | 16 | ||||
-rw-r--r-- | node_modules/readable-stream/lib/_stream_writable.js | 76 | ||||
-rw-r--r-- | node_modules/readable-stream/lib/internal/streams/BufferList.js | 64 | ||||
-rw-r--r-- | node_modules/readable-stream/package.json | 25 | ||||
-rw-r--r-- | node_modules/readable-stream/readable.js | 4 |
9 files changed, 154 insertions, 341 deletions
diff --git a/node_modules/readable-stream/.npmignore b/node_modules/readable-stream/.npmignore index 6d270c6cc..38344f87a 100644 --- a/node_modules/readable-stream/.npmignore +++ b/node_modules/readable-stream/.npmignore @@ -2,8 +2,4 @@ build/ test/ examples/ fs.js -zlib.js -.zuul.yml -.nyc_output -coverage -docs/ +zlib.js
\ No newline at end of file diff --git a/node_modules/readable-stream/.travis.yml b/node_modules/readable-stream/.travis.yml index 84504c98f..1b8211846 100644 --- a/node_modules/readable-stream/.travis.yml +++ b/node_modules/readable-stream/.travis.yml @@ -7,6 +7,9 @@ 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 @@ -26,8 +29,6 @@ matrix: env: TASK=test - node_js: 5 env: TASK=test - - node_js: 6 - env: TASK=test - node_js: 5 env: TASK=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest" - node_js: 5 @@ -39,9 +40,11 @@ matrix: - node_js: 5 env: TASK=browser BROWSER_NAME=firefox BROWSER_VERSION="-3..latest" - node_js: 5 - env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest" + env: TASK=browser BROWSER_NAME=ipad BROWSER_VERSION="6.0..latest" - node_js: 5 - env: TASK=browser BROWSER_NAME=microsoftedge BROWSER_VERSION=latest + env: TASK=browser BROWSER_NAME=iphone BROWSER_VERSION="6.0..latest" + - node_js: 5 + env: TASK=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest" script: "npm run $TASK" env: global: diff --git a/node_modules/readable-stream/README.md b/node_modules/readable-stream/README.md index 9be2adb15..86b95a3bf 100644 --- a/node_modules/readable-stream/README.md +++ b/node_modules/readable-stream/README.md @@ -1,6 +1,6 @@ # readable-stream -***Node-core v7.0.0 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/) @@ -16,9 +16,7 @@ npm install --save readable-stream ***Node-core streams for userland*** This package is a mirror of the Streams2 and Streams3 implementations in -Node-core. - -Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v7.1.0/docs/api/). +Node-core, including [documentation](doc/stream.markdown). If you want to guarantee a stable streams base, regardless of what version of Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html). @@ -36,5 +34,3 @@ As of version 2.0.0 **readable-stream** uses semantic versioning. * **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com> * **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com> * **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me> -* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com> - - Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E diff --git a/node_modules/readable-stream/lib/_stream_readable.js b/node_modules/readable-stream/lib/_stream_readable.js index 3a7d42d62..54a9d5c55 100644 --- a/node_modules/readable-stream/lib/_stream_readable.js +++ b/node_modules/readable-stream/lib/_stream_readable.js @@ -11,14 +11,14 @@ var isArray = require('isarray'); /*</replacement>*/ /*<replacement>*/ -var Duplex; +var Buffer = require('buffer').Buffer; /*</replacement>*/ Readable.ReadableState = ReadableState; -/*<replacement>*/ -var EE = require('events').EventEmitter; +var EE = require('events'); +/*<replacement>*/ var EElistenerCount = function (emitter, type) { return emitter.listeners(type).length; }; @@ -36,9 +36,6 @@ var Stream; /*</replacement>*/ var Buffer = require('buffer').Buffer; -/*<replacement>*/ -var bufferShim = require('buffer-shims'); -/*</replacement>*/ /*<replacement>*/ var util = require('core-util-is'); @@ -47,7 +44,7 @@ util.inherits = require('inherits'); /*<replacement>*/ var debugUtil = require('util'); -var debug = void 0; +var debug = undefined; if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); } else { @@ -55,25 +52,11 @@ if (debugUtil && debugUtil.debuglog) { } /*</replacement>*/ -var BufferList = require('./internal/streams/BufferList'); var StringDecoder; util.inherits(Readable, Stream); -function prependListener(emitter, event, fn) { - // Sadly this is not cacheable as some libraries bundle their own - // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') { - return emitter.prependListener(event, fn); - } else { - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; - } -} - +var Duplex; function ReadableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); @@ -94,10 +77,7 @@ function ReadableState(options, stream) { // cast to ints. this.highWaterMark = ~ ~this.highWaterMark; - // A linked list is used to store data chunks instead of an array because the - // linked list can remove elements from the beginning faster than - // array.shift() - this.buffer = new BufferList(); + this.buffer = []; this.length = 0; this.pipes = null; this.pipesCount = 0; @@ -143,6 +123,7 @@ function ReadableState(options, stream) { } } +var Duplex; function Readable(options) { Duplex = Duplex || require('./_stream_duplex'); @@ -168,7 +149,7 @@ Readable.prototype.push = function (chunk, encoding) { if (!state.objectMode && typeof chunk === 'string') { encoding = encoding || state.defaultEncoding; if (encoding !== state.encoding) { - chunk = bufferShim.from(chunk, encoding); + chunk = new Buffer(chunk, encoding); encoding = ''; } } @@ -198,8 +179,8 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) { var e = new Error('stream.push() after EOF'); stream.emit('error', e); } else if (state.endEmitted && addToFront) { - var _e = new Error('stream.unshift() after end event'); - stream.emit('error', _e); + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); } else { var skipAdd; if (state.decoder && !addToFront && !encoding) { @@ -259,8 +240,7 @@ function computeNewHighWaterMark(n) { if (n >= MAX_HWM) { n = MAX_HWM; } else { - // Get the next highest power of 2 to prevent increasing hwm excessively in - // tiny amounts + // Get the next highest power of 2 n--; n |= n >>> 1; n |= n >>> 2; @@ -272,34 +252,44 @@ function computeNewHighWaterMark(n) { return n; } -// This function is designed to be inlinable, so please take care when making -// changes to the function body. function howMuchToRead(n, state) { - if (n <= 0 || state.length === 0 && state.ended) return 0; - if (state.objectMode) return 1; - if (n !== n) { - // Only flow one buffer at a time - if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + if (state.length === 0 && state.ended) return 0; + + 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 we're asking for more than the current hwm, then raise the hwm. + + 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.length) return n; - // Don't have enough - if (!state.ended) { - state.needReadable = true; - return 0; + + // don't have that much. return null, unless we've ended. + if (n > state.length) { + if (!state.ended) { + state.needReadable = true; + return 0; + } else { + return state.length; + } } - return state.length; + + return n; } // you can override either this method, or the async _read(n) below. Readable.prototype.read = function (n) { debug('read', n); - n = parseInt(n, 10); var state = this._readableState; var nOrig = n; - if (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 @@ -355,7 +345,9 @@ Readable.prototype.read = function (n) { if (state.ended || state.reading) { doRead = false; debug('reading or ended', doRead); - } else if (doRead) { + } + + if (doRead) { debug('do read'); state.reading = true; state.sync = true; @@ -364,29 +356,28 @@ Readable.prototype.read = function (n) { // call internal read method this._read(state.highWaterMark); state.sync = false; - // 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 (!state.reading) n = howMuchToRead(nOrig, state); } + // 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); + var ret; if (n > 0) ret = fromList(n, state);else ret = null; if (ret === null) { state.needReadable = true; n = 0; - } else { - state.length -= n; } - if (state.length === 0) { - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; + state.length -= n; - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended) endReadable(this); - } + // 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 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 (ret !== null) this.emit('data', ret); @@ -465,7 +456,7 @@ function maybeReadMore_(stream, state) { // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. Readable.prototype._read = function (n) { - this.emit('error', new Error('_read() is not implemented')); + this.emit('error', new Error('not implemented')); }; Readable.prototype.pipe = function (dest, pipeOpts) { @@ -534,25 +525,17 @@ Readable.prototype.pipe = function (dest, pipeOpts) { if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; src.on('data', ondata); function ondata(chunk) { debug('ondata'); - increasedAwaitDrain = false; var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { + if (false === ret) { // If the user unpiped during `dest.write()`, it is possible // to get stuck in a permanently paused state if that write // also returned false. - // => Check whether `dest` is still a piping destination. - if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -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++; - increasedAwaitDrain = true; } src.pause(); } @@ -566,9 +549,9 @@ Readable.prototype.pipe = function (dest, pipeOpts) { dest.removeListener('error', onerror); if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); } - - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); + // 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]; // Both close and finish should trigger unpipe, but only once. function onclose() { @@ -643,16 +626,16 @@ Readable.prototype.unpipe = function (dest) { state.pipesCount = 0; state.flowing = false; - for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this); + for (var _i = 0; _i < len; _i++) { + dests[_i].emit('unpipe', this); }return this; } // try to find the right one. - var index = indexOf(state.pipes, dest); - if (index === -1) return this; + var i = indexOf(state.pipes, dest); + if (i === -1) return this; - state.pipes.splice(index, 1); + state.pipes.splice(i, 1); state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; @@ -666,14 +649,18 @@ Readable.prototype.unpipe = function (dest) { Readable.prototype.on = function (ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); - if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); - } else if (ev === 'readable') { + // If listening to data, and it has not explicitly been paused, + // then call resume to start the flow of data on the next tick. + if (ev === 'data' && false !== this._readableState.flowing) { + this.resume(); + } + + if (ev === 'readable' && !this._readableState.endEmitted) { var state = this._readableState; - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true; + if (!state.readableListening) { + state.readableListening = true; state.emittedReadable = false; + state.needReadable = true; if (!state.reading) { processNextTick(nReadingNextTick, this); } else if (state.length) { @@ -717,7 +704,6 @@ function resume_(stream, state) { } state.resumeScheduled = false; - state.awaitDrain = 0; stream.emit('resume'); flow(stream); if (state.flowing && !state.reading) stream.read(0); @@ -736,7 +722,11 @@ Readable.prototype.pause = function () { function flow(stream) { var state = stream._readableState; debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} + if (state.flowing) { + do { + var chunk = stream.read(); + } while (null !== chunk && state.flowing); + } } // wrap an old-style stream as the async data source. @@ -807,101 +797,50 @@ Readable._fromList = fromList; // Pluck off n bytes from an array of buffers. // Length is the combined lengths of all the buffers in the list. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. function fromList(n, state) { - // nothing buffered - if (state.length === 0) return null; - + var list = state.buffer; + var length = state.length; + var stringMode = !!state.decoder; + var objectMode = !!state.objectMode; var ret; - if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { - // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); - state.buffer.clear(); - } else { - // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); - } - return ret; -} + // nothing in the list, definitely empty. + if (list.length === 0) return null; -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); + 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); + list.length = 0; } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); - } - return ret; -} + // read just some of it. + if (n < list[0].length) { + // just take a part of the first list item. + // slice is the same for buffers and strings. + var buf = list[0]; + ret = buf.slice(0, n); + list[0] = buf.slice(n); + } else if (n === list[0].length) { + // first list is a perfect match + ret = list.shift(); + } else { + // complex case. + // we have enough to cover it, but it spans past the first buffer. + if (stringMode) ret = '';else ret = new Buffer(n); -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; -} + 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); -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = bufferShim.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); + if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift(); + + c += cpy; } - break; } - ++c; } - list.length -= c; + return ret; } @@ -910,7 +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; diff --git a/node_modules/readable-stream/lib/_stream_transform.js b/node_modules/readable-stream/lib/_stream_transform.js index cd2583207..625cdc176 100644 --- a/node_modules/readable-stream/lib/_stream_transform.js +++ b/node_modules/readable-stream/lib/_stream_transform.js @@ -94,6 +94,7 @@ function Transform(options) { this._transformState = new TransformState(this); + // when the writable side finishes, then flush out anything remaining. var stream = this; // start out asking for a readable event once data is transformed. @@ -110,10 +111,9 @@ function Transform(options) { if (typeof options.flush === 'function') this._flush = options.flush; } - // When the writable side finishes, then flush out anything remaining. this.once('prefinish', function () { - if (typeof this._flush === 'function') this._flush(function (er, data) { - done(stream, er, data); + if (typeof this._flush === 'function') this._flush(function (er) { + done(stream, er); });else done(stream); }); } @@ -134,7 +134,7 @@ Transform.prototype.push = function (chunk, encoding) { // 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) { - throw new Error('_transform() is not implemented'); + throw new Error('not implemented'); }; Transform.prototype._write = function (chunk, encoding, cb) { @@ -164,19 +164,17 @@ Transform.prototype._read = function (n) { } }; -function done(stream, er, data) { +function done(stream, er) { if (er) return stream.emit('error', er); - if (data !== null && data !== undefined) stream.push(data); - // 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 4d9c62ba6..95916c992 100644 --- a/node_modules/readable-stream/lib/_stream_writable.js +++ b/node_modules/readable-stream/lib/_stream_writable.js @@ -15,7 +15,7 @@ var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version. /*</replacement>*/ /*<replacement>*/ -var Duplex; +var Buffer = require('buffer').Buffer; /*</replacement>*/ Writable.WritableState = WritableState; @@ -43,9 +43,6 @@ var Stream; /*</replacement>*/ var Buffer = require('buffer').Buffer; -/*<replacement>*/ -var bufferShim = require('buffer-shims'); -/*</replacement>*/ util.inherits(Writable, Stream); @@ -58,6 +55,7 @@ function WriteReq(chunk, encoding, cb) { this.next = null; } +var Duplex; function WritableState(options, stream) { Duplex = Duplex || require('./_stream_duplex'); @@ -79,7 +77,6 @@ function WritableState(options, stream) { // cast to ints. this.highWaterMark = ~ ~this.highWaterMark; - // drain event flag. this.needDrain = false; // at the start of calling end() this.ending = false; @@ -149,12 +146,13 @@ function WritableState(options, stream) { // count buffered requests this.bufferedRequestCount = 0; - // allocate the first CorkedRequest, there is always - // one allocated and free to use, and we maintain at most two + // 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 getBuffer() { +WritableState.prototype.getBuffer = function writableStateGetBuffer() { var current = this.bufferedRequest; var out = []; while (current) { @@ -174,37 +172,13 @@ WritableState.prototype.getBuffer = function getBuffer() { } catch (_) {} })(); -// Test _writableState for inheritance to account for Duplex streams, -// whose prototype chain only points to Readable. -var realHasInstance; -if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { - realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { - if (realHasInstance.call(this, object)) return true; - - return object && object._writableState instanceof WritableState; - } - }); -} else { - realHasInstance = function (object) { - return object instanceof this; - }; -} - +var Duplex; function Writable(options) { Duplex = Duplex || require('./_stream_duplex'); - // Writable ctor is applied to Duplexes, too. - // `realHasInstance` is necessary because using plain `instanceof` - // would return false, as no `_writableState` property is attached. - - // Trying to use the custom `instanceof` for Writable here will also break the - // Node.js LazyTransform implementation, which has a non-trivial getter for - // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new 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); this._writableState = new WritableState(options, this); @@ -222,7 +196,7 @@ function Writable(options) { // Otherwise people can pipe Writable streams, which is just wrong. Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); + this.emit('error', new Error('Cannot pipe. Not readable.')); }; function writeAfterEnd(stream, cb) { @@ -239,16 +213,9 @@ function writeAfterEnd(stream, cb) { // how many bytes or characters. function validChunk(stream, state, chunk, cb) { var valid = true; - var er = false; - // Always throw error if a null is written - // if we are not in object mode then throw - // if it is not a buffer, string, or undefined. - if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - if (er) { + + 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); valid = false; @@ -298,12 +265,11 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(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; - return this; }; function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = bufferShim.from(chunk, encoding); + chunk = new Buffer(chunk, encoding); } return chunk; } @@ -426,16 +392,12 @@ function clearBuffer(stream, state) { doWrite(stream, state, true, state.length, buffer, '', holder.finish); - // doWrite is almost always async, defer these to save a bit of time + // doWrite is always async, defer these to save a bit of time // as the hot path ends with doWrite state.pendingcb++; state.lastBufferedRequest = null; - if (holder.next) { - state.corkedRequestsFree = holder.next; - holder.next = null; - } else { - state.corkedRequestsFree = new CorkedRequest(state); - } + state.corkedRequestsFree = holder.next; + holder.next = null; } else { // Slow case, write chunks one-by-one while (entry) { @@ -464,7 +426,7 @@ function clearBuffer(stream, state) { } Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); + cb(new Error('not implemented')); }; Writable.prototype._writev = null; diff --git a/node_modules/readable-stream/lib/internal/streams/BufferList.js b/node_modules/readable-stream/lib/internal/streams/BufferList.js deleted file mode 100644 index e4bfcf02d..000000000 --- a/node_modules/readable-stream/lib/internal/streams/BufferList.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -var Buffer = require('buffer').Buffer; -/*<replacement>*/ -var bufferShim = require('buffer-shims'); -/*</replacement>*/ - -module.exports = BufferList; - -function BufferList() { - this.head = null; - this.tail = null; - this.length = 0; -} - -BufferList.prototype.push = function (v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; -}; - -BufferList.prototype.unshift = function (v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; -}; - -BufferList.prototype.shift = function () { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; -}; - -BufferList.prototype.clear = function () { - this.head = this.tail = null; - this.length = 0; -}; - -BufferList.prototype.join = function (s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; -}; - -BufferList.prototype.concat = function (n) { - if (this.length === 0) return bufferShim.alloc(0); - if (this.length === 1) return this.head.data; - var ret = bufferShim.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - p.data.copy(ret, i); - i += p.data.length; - p = p.next; - } - return ret; -};
\ No newline at end of file diff --git a/node_modules/readable-stream/package.json b/node_modules/readable-stream/package.json index cef809cec..d77b090ec 100644 --- a/node_modules/readable-stream/package.json +++ b/node_modules/readable-stream/package.json @@ -1,33 +1,25 @@ { "name": "readable-stream", - "version": "2.2.2", + "version": "2.0.6", "description": "Streams3, a user-land copy of the stream library from Node.js", "main": "readable.js", "dependencies": { - "buffer-shims": "^1.0.0", "core-util-is": "~1.0.0", - "isarray": "~1.0.0", "inherits": "~2.0.1", + "isarray": "~1.0.0", "process-nextick-args": "~1.0.6", "string_decoder": "~0.10.x", "util-deprecate": "~1.0.1" }, "devDependencies": { - "assert": "~1.4.0", - "babel-polyfill": "^6.9.1", - "buffer": "^4.9.0", - "nyc": "^6.4.0", - "tap": "~0.7.1", + "tap": "~0.2.6", "tape": "~4.5.1", - "zuul": "~3.10.0" + "zuul": "~3.9.0" }, "scripts": { "test": "tap test/parallel/*.js test/ours/*.js", - "browser": "npm run write-zuul && zuul --browser-retries 2 -- test/browser.js", - "write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml", - "local": "zuul --local 3000 --no-coverage -- test/browser.js", - "cover": "nyc npm test", - "report": "nyc report --reporter=lcov" + "browser": "npm run write-zuul && zuul -- test/browser.js", + "write-zuul": "printf \"ui: tape\nbrowsers:\n - name: $BROWSER_NAME\n version: $BROWSER_VERSION\n\">.zuul.yml" }, "repository": { "type": "git", @@ -41,10 +33,5 @@ "browser": { "util": false }, - "nyc": { - "include": [ - "lib/**.js" - ] - }, "license": "MIT" } diff --git a/node_modules/readable-stream/readable.js b/node_modules/readable-stream/readable.js index be2688a07..6222a5798 100644 --- a/node_modules/readable-stream/readable.js +++ b/node_modules/readable-stream/readable.js @@ -10,7 +10,3 @@ exports.Writable = require('./lib/_stream_writable.js'); exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); - -if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) { - module.exports = Stream; -} |