{“ast”:null,“code”:“// Copyright Joyent, Inc. and other Node contributors.n//n// Permission is hereby granted, free of charge, to any person obtaining an// copy of this software and associated documentation files (then// "Software"), to deal in the Software without restriction, includingn// without limitation the rights to use, copy, modify, merge, publish,n// distribute, sublicense, and/or sell copies of the Software, and to permitn// persons to whom the Software is furnished to do so, subject to then// following conditions:n//n// The above copyright notice and this permission notice shall be includedn// in all copies or substantial portions of the Software.n//n// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSn// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFn// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INn// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT ORn// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THEn// USE OR OTHER DEALINGS IN THE SOFTWARE.n'use strict';n/*<replacement>*/nnvar pna = require('process-nextick-args');n/*</replacement>*/nnnmodule.exports = Readable;n/*<replacement>*/nnvar isArray = require('isarray');n/*</replacement>*/nn/*<replacement>*/nnnvar Duplex;n/*</replacement>*/nnReadable.ReadableState = ReadableState;n/*<replacement>*/nnvar EE = require('events').EventEmitter;nnvar EElistenerCount = function EElistenerCount(emitter, type) {n return emitter.listeners(type).length;n};n/*</replacement>*/nn/*<replacement>*/nnnvar Stream = require('./internal/streams/stream');n/*</replacement>*/nn/*<replacement>*/nnnvar Buffer = require('safe-buffer').Buffer;nnvar OurUint8Array = global.Uint8Array || function () {};nnfunction _uint8ArrayToBuffer(chunk) {n return Buffer.from(chunk);n}nnfunction _isUint8Array(obj) {n return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;n}n/*</replacement>*/nn/*<replacement>*/nnnvar util = require('core-util-is');nnutil.inherits = require('inherits');n/*</replacement>*/nn/*<replacement>*/nnvar debugUtil = require('util');nnvar debug = void 0;nnif (debugUtil && debugUtil.debuglog) {n debug = debugUtil.debuglog('stream');n} else {n debug = function debug() {};n}n/*</replacement>*/nnnvar BufferList = require('./internal/streams/BufferList');nnvar destroyImpl = require('./internal/streams/destroy');nnvar StringDecoder;nutil.inherits(Readable, Stream);nvar kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];nnfunction prependListener(emitter, event, fn) {n // Sadly this is not cacheable as some libraries bundle their ownn // event emitter implementation with them.n if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before anyn // userland ones. NEVER DO THIS. This is here only because this code needsn // to continue to work with older versions of Node.js that do not includen // the prependListener() method. The goal is to eventually remove this hack.nn if (!emitter._events || !emitter._events) emitter.on(event, fn);else if (isArray(emitter._events)) emitter._events.unshift(fn);else emitter._events = [fn, emitter._events];n}nnfunction ReadableState(options, stream) {n Duplex = Duplex || require('./_stream_duplex');n options = options || {}; // Duplex streams are both readable and writable, but sharen // the same options object.n // However, some cases require setting options to differentn // values for the readable and the writable sides of the duplex stream.n // These options can be provided separately as readableXXX and writableXXX.nn var isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and ton // make all the buffer merging and length checks go awaynn this.objectMode = !!options.objectMode;n if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffern // Note: 0 is a valid value, means "don't call _read preemptively ever"nn var hwm = options.highWaterMark;n var readableHwm = options.readableHighWaterMark;n var defaultHwm = this.objectMode ? 16 : 16 * 1024;n if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; // cast to ints.nn this.highWaterMark = Math.floor(this.highWaterMark); // A linked list is used to store data chunks instead of an array because then // linked list can remove elements from the beginning faster thann // array.shift()nn this.buffer = new BufferList();n this.length = 0;n this.pipes = null;n this.pipesCount = 0;n this.flowing = null;n this.ended = false;n this.endEmitted = false;n this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emittedn // immediately, or on a later tick. We set this to true at first, becausen // any actions that shouldn't happen until "later" should generally alson // not happen before the first read call.nn this.sync = true; // whenever we return null, then we set a flag to sayn // that we're awaiting a 'readable' event emission.nn this.needReadable = false;n this.emittedReadable = false;n this.readableListening = false;n this.resumeScheduled = false; // has it been destroyednn this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default stringn // encoding is 'binary' so we have to make this configurable.n // Everything else in the universe uses 'utf8', though.nn this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()snn this.awaitDrain = 0; // if true, a maybeReadMore has been schedulednn this.readingMore = false;n this.decoder = null;n this.encoding = null;nn if (options.encoding) {n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;n this.decoder = new StringDecoder(options.encoding);n this.encoding = options.encoding;n }n}nnfunction Readable(options) {n Duplex = Duplex || require('./_stream_duplex');n if (!(this instanceof Readable)) return new Readable(options);n this._readableState = new ReadableState(options, this); // legacynn this.readable = true;nn if (options) {n if (typeof options.read === 'function') this._read = options.read;n if (typeof options.destroy === 'function') this._destroy = options.destroy;n }nn Stream.call(this);n}nnObject.defineProperty(Readable.prototype, 'destroyed', {n get: function get() {n if (this._readableState === undefined) {n return false;n }nn return this._readableState.destroyed;n },n set: function set(value) {n // we ignore the value if the streamn // has not been initialized yetn if (!this._readableState) {n return;n } // backward compatibility, the user is explicitlyn // managing destroyednnn this._readableState.destroyed = value;n }n});nReadable.prototype.destroy = destroyImpl.destroy;nReadable.prototype._undestroy = destroyImpl.undestroy;nnReadable.prototype._destroy = function (err, cb) {n this.push(null);n cb(err);n}; // Manually shove something into the read() buffer.n// This returns true if the highWaterMark has not been hit yet,n// similar to how Writable.write() returns true if you shouldn// write() some more.nnnReadable.prototype.push = function (chunk, encoding) {n var state = this._readableState;n var skipChunkCheck;nn if (!state.objectMode) {n if (typeof chunk === 'string') {n encoding = encoding || state.defaultEncoding;nn if (encoding !== state.encoding) {n chunk = Buffer.from(chunk, encoding);n encoding = '';n }nn skipChunkCheck = true;n }n } else {n skipChunkCheck = true;n }nn return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);n}; // Unshift should always be something directly out of read()nnnReadable.prototype.unshift = function (chunk) {n return readableAddChunk(this, chunk, null, true, false);n};nnfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {n var state = stream._readableState;nn if (chunk === null) {n state.reading = false;n onEofChunk(stream, state);n } else {n var er;n if (!skipChunkCheck) er = chunkInvalid(state, chunk);nn if (er) {n stream.emit('error', er);n } else if (state.objectMode || chunk && chunk.length > 0) {n if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {n chunk = _uint8ArrayToBuffer(chunk);n }nn if (addToFront) {n if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);n } else if (state.ended) {n stream.emit('error', new Error('stream.push() after EOF'));n } else {n state.reading = false;nn if (state.decoder && !encoding) {n chunk = state.decoder.write(chunk);n if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);n } else {n addChunk(stream, state, chunk, false);n }n }n } else if (!addToFront) {n state.reading = false;n }n }nn return needMoreData(state);n}nnfunction addChunk(stream, state, chunk, addToFront) {n if (state.flowing && state.length === 0 && !state.sync) {n stream.emit('data', chunk);n stream.read(0);n } else {n // update the buffer info.n state.length += state.objectMode ? 1 : chunk.length;n if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);n if (state.needReadable) emitReadable(stream);n }nn maybeReadMore(stream, state);n}nnfunction chunkInvalid(state, chunk) {n var er;nn if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {n er = new TypeError('Invalid non-string/buffer chunk');n }nn return er;n} // if it's past the high water mark, we can push in some more.n// Also, if we have no data yet, we can stand somen// more bytes. This is to work around cases where hwm=0,n// such as the repl. Also, if the push() triggered an// readable event, and the user called read(largeNumber) such thatn// needReadable was set, then we ought to push more, so that anothern// 'readable' event will be triggered.nnnfunction needMoreData(state) {n return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);n}nnReadable.prototype.isPaused = function () {n return this._readableState.flowing === false;n}; // backwards compatibility.nnnReadable.prototype.setEncoding = function (enc) {n if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;n this._readableState.decoder = new StringDecoder(enc);n this._readableState.encoding = enc;n return this;n}; // Don't raise the hwm > 8MBnnnvar MAX_HWM = 0x800000;nnfunction computeNewHighWaterMark(n) {n if (n >= MAX_HWM) {n n = MAX_HWM;n } else {n // Get the next highest power of 2 to prevent increasing hwm excessively inn // tiny amountsn n–;n n |= n >>> 1;n n |= n >>> 2;n n |= n >>> 4;n n |= n >>> 8;n n |= n >>> 16;n n++;n }nn return n;n} // This function is designed to be inlinable, so please take care when makingn// changes to the function body.nnnfunction howMuchToRead(n, state) {n if (n <= 0 || state.length === 0 && state.ended) return 0;n if (state.objectMode) return 1;nn if (n !== n) {n // Only flow one buffer at a timen if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;n } // If we're asking for more than the current hwm, then raise the hwm.nnn if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);n if (n <= state.length) return n; // Don't have enoughnn if (!state.ended) {n state.needReadable = true;n return 0;n }nn return state.length;n} // you can override either this method, or the async _read(n) below.nnnReadable.prototype.read = function (n) {n debug('read', n);n n = parseInt(n, 10);n var state = this._readableState;n var nOrig = n;n if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but wen // already have a bunch of data in the buffer, then just triggern // the 'readable' event and move on.nn if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {n debug('read: emitReadable', state.length, state.ended);n if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);n return null;n }nn n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up.nn if (n === 0 && state.ended) {n if (state.length === 0) endReadable(this);n return null;n } // All the actual chunk generation logic needs to ben // below the call to _read. The reason is that in certainn // synthetic stream cases, such as passthrough streams, _readn // may be a completely synchronous operation which may changen // the state of the read buffer, providing enough data whenn // before there was not enough.n //n // So, the steps are:n // 1. Figure out what the state of things will be after we don // a read from the buffer.n //n // 2. If that resulting state will trigger a _read, then call _read.n // Note that this may be asynchronous, or synchronous. Yes, it isn // deeply ugly to write APIs this way, but that still doesn't meann // that the Readable class should behave improperly, as streams aren // designed to be sync/async agnostic.n // Take note if the _read call is sync or async (ie, if the read calln // has returned yet), so that we know whether or not it's safe to emitn // 'readable' etc.n //n // 3. Actually pull the requested chunks out of the buffer and return.n // if we need a readable event, then we need to do some reading.nnn var doRead = state.needReadable;n debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read somenn if (state.length === 0 || state.length - n < state.highWaterMark) {n doRead = true;n debug('length less than watermark', doRead);n } // however, if we've ended, then there's no point, and if we're alreadyn // reading, then it's unnecessary.nnn if (state.ended || state.reading) {n doRead = false;n debug('reading or ended', doRead);n } else if (doRead) {n debug('do read');n state.reading = true;n state.sync = true; // if the length is currently zero, then we need a readable event.nn if (state.length === 0) state.needReadable = true; // call internal read methodnn this._read(state.highWaterMark);nn state.sync = false; // If _read pushed data synchronously, then `reading` will be false,n // and we need to re-evaluate how much data we can return to the user.nn if (!state.reading) n = howMuchToRead(nOrig, state);n }nn var ret;n if (n > 0) ret = fromList(n, state);else ret = null;nn if (ret === null) {n state.needReadable = true;n n = 0;n } else {n state.length -= n;n }nn if (state.length === 0) {n // If we have nothing in the buffer, then we want to known // as soon as we do get something into the buffer.n if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick.nn if (nOrig !== n && state.ended) endReadable(this);n }nn if (ret !== null) this.emit('data', ret);n return ret;n};nnfunction onEofChunk(stream, state) {n if (state.ended) return;nn if (state.decoder) {n var chunk = state.decoder.end();nn if (chunk && chunk.length) {n state.buffer.push(chunk);n state.length += state.objectMode ? 1 : chunk.length;n }n }nn state.ended = true; // emit 'readable' now to make sure it gets picked up.nn emitReadable(stream);n} // Don't emit readable right away in sync mode, because this can triggern// another read() call => stack overflow. This way, it might triggern// a nextTick recursion warning, but that's not so bad.nnnfunction emitReadable(stream) {n var state = stream._readableState;n state.needReadable = false;nn if (!state.emittedReadable) {n debug('emitReadable', state.flowing);n state.emittedReadable = true;n if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);n }n}nnfunction emitReadable_(stream) {n debug('emit readable');n stream.emit('readable');n flow(stream);n} // at this point, the user has presumably seen the 'readable' event,n// and called read() to consume some data. that may have triggeredn// in turn another _read(n) call, in which case reading = true ifn// it's in progress.n// However, if we're not ended, or reading, and the length < hwm,n// then go ahead and try to read some more preemptively.nnnfunction maybeReadMore(stream, state) {n if (!state.readingMore) {n state.readingMore = true;n pna.nextTick(maybeReadMore_, stream, state);n }n}nnfunction maybeReadMore_(stream, state) {n var len = state.length;nn while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {n debug('maybeReadMore read 0');n stream.read(0);n if (len === state.length) // didn't get any data, stop spinning.n break;else len = state.length;n }nn state.readingMore = false;n} // abstract method. to be overridden in specific implementation classes.n// call cb(er, data) where data is <= n in length.n// for virtual (non-string, non-buffer) streams, "length" is somewhatn// arbitrary, and perhaps not very meaningful.nnnReadable.prototype._read = function (n) {n this.emit('error', new Error('_read() is not implemented'));n};nnReadable.prototype.pipe = function (dest, pipeOpts) {n var src = this;n var state = this._readableState;nn switch (state.pipesCount) {n case 0:n state.pipes = dest;n break;nn case 1:n state.pipes = [state.pipes, dest];n break;nn default:n state.pipes.push(dest);n break;n }nn state.pipesCount += 1;n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);n var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;n var endFn = doEnd ? onend : unpipe;n if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);n dest.on('unpipe', onunpipe);nn function onunpipe(readable, unpipeInfo) {n debug('onunpipe');nn if (readable === src) {n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {n unpipeInfo.hasUnpiped = true;n cleanup();n }n }n }nn function onend() {n debug('onend');n dest.end();n } // when the dest drains, it reduces the awaitDrain countern // on the source. This would be more elegant with a .once()n // handler in flow(), but adding and removing repeatedly isn // too slow.nnn var ondrain = pipeOnDrain(src);n dest.on('drain', ondrain);n var cleanedUp = false;nn function cleanup() {n debug('cleanup'); // cleanup event handlers once the pipe is brokennn dest.removeListener('close', onclose);n dest.removeListener('finish', onfinish);n dest.removeListener('drain', ondrain);n dest.removeListener('error', onerror);n dest.removeListener('unpipe', onunpipe);n src.removeListener('end', onend);n src.removeListener('end', unpipe);n src.removeListener('data', ondata);n cleanedUp = true; // if the reader is waiting for a drain event from thisn // specific writer, then it would cause it to never startn // flowing again.n // So, if this is awaiting a drain, then we just call it now.n // If we don't know, then assume that we are waiting for one.nn if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();n } // If the user pushes more data while we're writing to dest then we'll end upn // in ondata again. However, we only want to increase awaitDrain once becausen // dest will only emit one 'drain' event for the multiple writes.n // => Introduce a guard on increasing awaitDrain.nnn var increasedAwaitDrain = false;n src.on('data', ondata);nn function ondata(chunk) {n debug('ondata');n increasedAwaitDrain = false;n var ret = dest.write(chunk);nn if (false === ret && !increasedAwaitDrain) {n // If the user unpiped during `dest.write()`, it is possiblen // to get stuck in a permanently paused state if that writen // also returned false.n // => Check whether `dest` is still a piping destination.n if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {n debug('false write response, pause', src._readableState.awaitDrain);n src._readableState.awaitDrain++;n increasedAwaitDrain = true;n }nn src.pause();n }n } // if the dest has an error, then stop piping into it.n // however, don't suppress the throwing behavior for this.nnn function onerror(er) {n debug('onerror', er);n unpipe();n dest.removeListener('error', onerror);n if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);n } // Make sure our error handler is attached before userland ones.nnn prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once.nn function onclose() {n dest.removeListener('finish', onfinish);n unpipe();n }nn dest.once('close', onclose);nn function onfinish() {n debug('onfinish');n dest.removeListener('close', onclose);n unpipe();n }nn dest.once('finish', onfinish);nn function unpipe() {n debug('unpipe');n src.unpipe(dest);n } // tell the dest that it's being piped tonnn dest.emit('pipe', src); // start the flow if it hasn't been started already.nn if (!state.flowing) {n debug('pipe resume');n src.resume();n }nn return dest;n};nnfunction pipeOnDrain(src) {n return function () {n var state = src._readableState;n debug('pipeOnDrain', state.awaitDrain);n if (state.awaitDrain) state.awaitDrain–;nn if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {n state.flowing = true;n flow(src);n }n };n}nnReadable.prototype.unpipe = function (dest) {n var state = this._readableState;n var unpipeInfo = {n hasUnpiped: falsen }; // if we're not piping anywhere, then do nothing.nn if (state.pipesCount === 0) return this; // just one destination. most common case.nn if (state.pipesCount === 1) {n // passed in one, but it's not the right one.n if (dest && dest !== state.pipes) return this;n if (!dest) dest = state.pipes; // got a match.nn state.pipes = null;n state.pipesCount = 0;n state.flowing = false;n if (dest) dest.emit('unpipe', this, unpipeInfo);n return this;n } // slow case. multiple pipe destinations.nnn if (!dest) {n // remove all.n var dests = state.pipes;n var len = state.pipesCount;n state.pipes = null;n state.pipesCount = 0;n state.flowing = false;nn for (var i = 0; i < len; i++) {n dests.emit('unpipe', this, unpipeInfo);n }nn return this;n } // try to find the right one.nnn var index = indexOf(state.pipes, dest);n if (index === -1) return this;n state.pipes.splice(index, 1);n state.pipesCount -= 1;n if (state.pipesCount === 1) state.pipes = state.pipes;n dest.emit('unpipe', this, unpipeInfo);n return this;n}; // set up data events if they are asked forn// Ensure readable listeners eventually get somethingnnnReadable.prototype.on = function (ev, fn) {n var res = Stream.prototype.on.call(this, ev, fn);nn if (ev === 'data') {n // Start flowing on next tick if stream isn't explicitly pausedn if (this._readableState.flowing !== false) this.resume();n } else if (ev === 'readable') {n var state = this._readableState;nn if (!state.endEmitted && !state.readableListening) {n state.readableListening = state.needReadable = true;n state.emittedReadable = false;nn if (!state.reading) {n pna.nextTick(nReadingNextTick, this);n } else if (state.length) {n emitReadable(this);n }n }n }nn return res;n};nnReadable.prototype.addListener = Readable.prototype.on;nnfunction nReadingNextTick(self) {n debug('readable nexttick read 0');n self.read(0);n} // pause() and resume() are remnants of the legacy readable stream APIn// If the user uses them, then switch into old mode.nnnReadable.prototype.resume = function () {n var state = this._readableState;nn if (!state.flowing) {n debug('resume');n state.flowing = true;n resume(this, state);n }nn return this;n};nnfunction resume(stream, state) {n if (!state.resumeScheduled) {n state.resumeScheduled = true;n pna.nextTick(resume_, stream, state);n }n}nnfunction resume_(stream, state) {n if (!state.reading) {n debug('resume read 0');n stream.read(0);n }nn state.resumeScheduled = false;n state.awaitDrain = 0;n stream.emit('resume');n flow(stream);n if (state.flowing && !state.reading) stream.read(0);n}nnReadable.prototype.pause = function () {n debug('call pause flowing=%j', this._readableState.flowing);nn if (false !== this._readableState.flowing) {n debug('pause');n this._readableState.flowing = false;n this.emit('pause');n }nn return this;n};nnfunction flow(stream) {n var state = stream._readableState;n debug('flow', state.flowing);nn while (state.flowing && stream.read() !== null) {}n} // wrap an old-style stream as the async data source.n// This is not part of the readable stream interface.n// It is an ugly unfortunate mess of history.nnnReadable.prototype.wrap = function (stream) {n var _this = this;nn var state = this._readableState;n var paused = false;n stream.on('end', function () {n debug('wrapped end');nn if (state.decoder && !state.ended) {n var chunk = state.decoder.end();n if (chunk && chunk.length) _this.push(chunk);n }nn _this.push(null);n });n stream.on('data', function (chunk) {n debug('wrapped data');n if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectModenn if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;nn var ret = _this.push(chunk);nn if (!ret) {n paused = true;n stream.pause();n }n }); // proxy all the other methods.n // important when wrapping filters and duplexes.nn for (var i in stream) {n if (this === undefined && typeof stream === 'function') {n this = function (method) {n return function () {n return stream.apply(stream, arguments);n };n }(i);n }n } // proxy certain important events.nnn for (var n = 0; n < kProxyEvents.length; n++) {n stream.on(kProxyEvents, this.emit.bind(this, kProxyEvents));n } // when we try to consume some more bytes, simply unpause then // underlying stream.nnn this._read = function (n) {n debug('wrapped _read', n);nn if (paused) {n paused = false;n stream.resume();n }n };nn return this;n};nnObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {n // making it explicit this property is not enumerablen // because otherwise some prototype manipulation inn // userland will failn enumerable: false,n get: function get() {n return this._readableState.highWaterMark;n }n}); // exposed for testing purposes only.nnReadable._fromList = fromList; // Pluck off n bytes from an array of buffers.n// Length is the combined lengths of all the buffers in the list.n// This function is designed to be inlinable, so please take care when makingn// changes to the function body.nnfunction fromList(n, state) {n // nothing bufferedn if (state.length === 0) return null;n var ret;n if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {n // read it all, truncate the listn 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);n state.buffer.clear();n } else {n // read part of listn ret = fromListPartial(n, state.buffer, state.decoder);n }n return ret;n} // Extracts only enough buffered data to satisfy the amount requested.n// This function is designed to be inlinable, so please take care when makingn// changes to the function body.nnnfunction fromListPartial(n, list, hasStrings) {n var ret;nn if (n < list.head.data.length) {n // slice is the same for buffers and stringsn ret = list.head.data.slice(0, n);n list.head.data = list.head.data.slice(n);n } else if (n === list.head.data.length) {n // first chunk is a perfect matchn ret = list.shift();n } else {n // result spans more than one buffern ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);n }nn return ret;n} // Copies a specified amount of characters from the list of buffered datan// chunks.n// This function is designed to be inlinable, so please take care when makingn// changes to the function body.nnnfunction copyFromBufferString(n, list) {n var p = list.head;n var c = 1;n var ret = p.data;n n -= ret.length;nn while (p = p.next) {n var str = p.data;n var nb = n > str.length ? str.length : n;n if (nb === str.length) ret += str;else ret += str.slice(0, n);n n -= nb;nn if (n === 0) {n if (nb === str.length) {n ++c;n if (p.next) list.head = p.next;else list.head = list.tail = null;n } else {n list.head = p;n p.data = str.slice(nb);n }nn break;n }nn ++c;n }nn list.length -= c;n return ret;n} // Copies a specified amount of bytes from the list of buffered data chunks.n// This function is designed to be inlinable, so please take care when makingn// changes to the function body.nnnfunction copyFromBuffer(n, list) {n var ret = Buffer.allocUnsafe(n);n var p = list.head;n var c = 1;n p.data.copy(ret);n n -= p.data.length;nn while (p = p.next) {n var buf = p.data;n var nb = n > buf.length ? buf.length : n;n buf.copy(ret, ret.length - n, 0, nb);n n -= nb;nn if (n === 0) {n if (nb === buf.length) {n ++c;n if (p.next) list.head = p.next;else list.head = list.tail = null;n } else {n list.head = p;n p.data = buf.slice(nb);n }nn break;n }nn ++c;n }nn list.length -= c;n return ret;n}nnfunction endReadable(stream) {n var state = stream._readableState; // If we get here before consuming all the bytes, then that is an // bug in node. Should never happen.nn if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');nn if (!state.endEmitted) {n state.ended = true;n pna.nextTick(endReadableNT, state, stream);n }n}nnfunction endReadableNT(state, stream) {n // Check that we didn't get one last unshift.n if (!state.endEmitted && state.length === 0) {n state.endEmitted = true;n stream.readable = false;n stream.emit('end');n }n}nnfunction indexOf(xs, x) {n for (var i = 0, l = xs.length; i < l; i++) {n if (xs === x) return i;n }nn return -1;n}”,“map”:null,“metadata”:{},“sourceType”:“module”}