Skip to content

Instantly share code, notes, and snippets.

@demurgos

demurgos/url.json

Last active Aug 26, 2018
Embed
What would you like to do?
[
"/data/projects/web/v8-to-istanbul/src/test/fixtures/esm-hello-world/main.js",
"_stream_duplex.js",
"_stream_passthrough.js",
"_stream_readable.js",
"_stream_transform.js",
"_stream_writable.js",
"assert.js",
"buffer.js",
"cjs-facade:file:///data/projects/web/v8-to-istanbul/src/test/fixtures/esm-hello-world/main.js",
"console.js",
"events.js",
"file:///data/projects/web/v8-to-istanbul/src/test/fixtures/esm-hello-world/hello-world.mjs",
"file:///data/projects/web/v8-to-istanbul/src/test/fixtures/esm-hello-world/main.js",
"fs.js",
"internal/assert.js",
"internal/async_hooks.js",
"internal/bootstrap/loaders.js",
"internal/bootstrap/node.js",
"internal/buffer.js",
"internal/constants.js",
"internal/encoding.js",
"internal/errors.js",
"internal/fixed_queue.js",
"internal/fs/read_file_context.js",
"internal/fs/streams.js",
"internal/fs/utils.js",
"internal/inspector_async_hook.js",
"internal/linkedlist.js",
"internal/modules/cjs/helpers.js",
"internal/modules/cjs/loader.js",
"internal/modules/esm/create_dynamic_module.js",
"internal/modules/esm/default_resolve.js",
"internal/modules/esm/loader.js",
"internal/modules/esm/module_job.js",
"internal/modules/esm/module_map.js",
"internal/modules/esm/translators.js",
"internal/net.js",
"internal/process/esm_loader.js",
"internal/process/main_thread_only.js",
"internal/process/next_tick.js",
"internal/process/per_thread.js",
"internal/process/promises.js",
"internal/process/stdio.js",
"internal/process/warning.js",
"internal/querystring.js",
"internal/safe_globals.js",
"internal/stream_base_commons.js",
"internal/streams/buffer_list.js",
"internal/streams/destroy.js",
"internal/streams/end-of-stream.js",
"internal/streams/legacy.js",
"internal/streams/pipeline.js",
"internal/streams/state.js",
"internal/timers.js",
"internal/url.js",
"internal/util.js",
"internal/util/types.js",
"internal/validators.js",
"internal/vm/source_text_module.js",
"net.js",
"path.js",
"stream.js",
"timers.js",
"url.js",
"util.js",
"vm.js"
]
This file has been truncated, but you can view the full file.
[
{
"url": "/data/projects/web/v8-to-istanbul/src/test/fixtures/esm-hello-world/main.js",
"source": "(function (exports, require, module, __filename, __dirname) { import('./hello-world')\n .then(helloWorld => helloWorld.helloWorld())\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 137,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 1,
"endOffset": 135,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "then.helloWorld",
"ranges": [
{
"startOffset": 94,
"endOffset": 131,
"count": 1
}
],
"isBlockCoverage": true
}
]
},
{
"url": "_stream_duplex.js",
"source": "(function (exports, require, module, process) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// 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 OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a duplex stream is just a stream that is both readable and writable.\n// Since JS doesn't have multiple prototypal inheritance, this class\n// prototypally inherits from Readable, and then parasitically from\n// Writable.\n\n'use strict';\n\nmodule.exports = Duplex;\n\nconst util = require('util');\nconst Readable = require('_stream_readable');\nconst Writable = require('_stream_writable');\n\nutil.inherits(Duplex, Readable);\n\n{\n // Allow the keys array to be GC'ed.\n const keys = Object.keys(Writable.prototype);\n for (var v = 0; v < keys.length; v++) {\n const method = keys[v];\n if (!Duplex.prototype[method])\n Duplex.prototype[method] = Writable.prototype[method];\n }\n}\n\nfunction Duplex(options) {\n if (!(this instanceof Duplex))\n return new Duplex(options);\n\n Readable.call(this, options);\n Writable.call(this, options);\n this.allowHalfOpen = true;\n\n if (options) {\n if (options.readable === false)\n this.readable = false;\n\n if (options.writable === false)\n this.writable = false;\n\n if (options.allowHalfOpen === false) {\n this.allowHalfOpen = false;\n this.once('end', onend);\n }\n }\n}\n\nObject.defineProperty(Duplex.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get() {\n return this._writableState.highWaterMark;\n }\n});\n\nObject.defineProperty(Duplex.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\n\nObject.defineProperty(Duplex.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get() {\n return this._writableState.length;\n }\n});\n\n// the no-half-open enforcer\nfunction onend() {\n // If the writable side ended, then we're ok.\n if (this._writableState.ended)\n return;\n\n // no more data can be written.\n // But allow more writes to happen in this tick.\n process.nextTick(onEndNT, this);\n}\n\nfunction onEndNT(self) {\n self.end();\n}\n\nObject.defineProperty(Duplex.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get() {\n if (this._readableState === undefined ||\n this._writableState === undefined) {\n return false;\n }\n return this._readableState.destroyed && this._writableState.destroyed;\n },\n set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (this._readableState === undefined ||\n this._writableState === undefined) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n this._writableState.destroyed = value;\n }\n});\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 4296,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 1,
"endOffset": 4294,
"count": 1
},
{
"startOffset": 1731,
"endOffset": 1860,
"count": 11
},
{
"startOffset": 1802,
"endOffset": 1856,
"count": 7
}
],
"isBlockCoverage": true
},
{
"functionName": "Duplex",
"ranges": [
{
"startOffset": 1864,
"endOffset": 2319,
"count": 2
},
{
"startOffset": 1928,
"endOffset": 1955,
"count": 0
},
{
"startOffset": 2176,
"endOffset": 2198,
"count": 0
},
{
"startOffset": 2241,
"endOffset": 2313,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 2545,
"endOffset": 2602,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 2830,
"endOffset": 2913,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 3136,
"endOffset": 3186,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "onend",
"ranges": [
{
"startOffset": 3221,
"endOffset": 3455,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "onEndNT",
"ranges": [
{
"startOffset": 3457,
"endOffset": 3497,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 3711,
"endOffset": 3913,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "set",
"ranges": [
{
"startOffset": 3917,
"endOffset": 4287,
"count": 0
}
],
"isBlockCoverage": false
}
]
},
{
"url": "_stream_passthrough.js",
"source": "(function (exports, require, module, process) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// 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 OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a passthrough stream.\n// basically just the most minimal sort of Transform stream.\n// Every written chunk gets output as-is.\n\n'use strict';\n\nmodule.exports = PassThrough;\n\nconst Transform = require('_stream_transform');\nconst util = require('util');\nutil.inherits(PassThrough, Transform);\n\nfunction PassThrough(options) {\n if (!(this instanceof PassThrough))\n return new PassThrough(options);\n\n Transform.call(this, options);\n}\n\nPassThrough.prototype._transform = function(chunk, encoding, cb) {\n cb(null, chunk);\n};\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 1711,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 1,
"endOffset": 1709,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "PassThrough",
"ranges": [
{
"startOffset": 1474,
"endOffset": 1616,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "PassThrough._transform",
"ranges": [
{
"startOffset": 1653,
"endOffset": 1705,
"count": 0
}
],
"isBlockCoverage": false
}
]
},
{
"url": "_stream_readable.js",
"source": "(function (exports, require, module, process) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// 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 OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nmodule.exports = Readable;\nReadable.ReadableState = ReadableState;\n\nconst EE = require('events');\nconst Stream = require('stream');\nconst { Buffer } = require('buffer');\nconst util = require('util');\nconst debug = util.debuglog('stream');\nconst BufferList = require('internal/streams/buffer_list');\nconst destroyImpl = require('internal/streams/destroy');\nconst { getHighWaterMark } = require('internal/streams/state');\nconst {\n ERR_INVALID_ARG_TYPE,\n ERR_STREAM_PUSH_AFTER_EOF,\n ERR_METHOD_NOT_IMPLEMENTED,\n ERR_STREAM_UNSHIFT_AFTER_END_EVENT\n} = require('internal/errors').codes;\nconst { emitExperimentalWarning } = require('internal/util');\n\n// Lazy loaded to improve the startup performance.\nlet StringDecoder;\nlet ReadableAsyncIterator;\n\nutil.inherits(Readable, Stream);\n\nconst kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];\n\nfunction prependListener(emitter, event, fn) {\n // Sadly this is not cacheable as some libraries bundle their own\n // event emitter implementation with them.\n if (typeof emitter.prependListener === 'function')\n return emitter.prependListener(event, fn);\n\n // This is a hack to make sure that our error handler is attached before any\n // userland ones. NEVER DO THIS. This is here only because this code needs\n // to continue to work with older versions of Node.js that do not include\n // the prependListener() method. The goal is to eventually remove this hack.\n if (!emitter._events || !emitter._events[event])\n emitter.on(event, fn);\n else if (Array.isArray(emitter._events[event]))\n emitter._events[event].unshift(fn);\n else\n emitter._events[event] = [fn, emitter._events[event]];\n}\n\nfunction ReadableState(options, stream, isDuplex) {\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n if (typeof isDuplex !== 'boolean')\n isDuplex = stream instanceof Stream.Duplex;\n\n // object stream flag. Used to make read(n) ignore n and to\n // make all the buffer merging and length checks go away\n this.objectMode = !!options.objectMode;\n\n if (isDuplex)\n this.objectMode = this.objectMode || !!options.readableObjectMode;\n\n // the point at which it stops calling _read() to fill the buffer\n // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark',\n isDuplex);\n\n // A linked list is used to store data chunks instead of an array because the\n // linked list can remove elements from the beginning faster than\n // array.shift()\n 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;\n\n // a flag to be able to tell if the event 'readable'/'data' is emitted\n // immediately, or on a later tick. We set this to true at first, because\n // any actions that shouldn't happen until \"later\" should generally also\n // not happen before the first read call.\n this.sync = true;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n this.emittedReadable = false;\n this.readableListening = false;\n this.resumeScheduled = false;\n\n // Should close be emitted on destroy. Defaults to true.\n this.emitClose = options.emitClose !== false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // the number of writers that are awaiting a drain event in .pipe()s\n this.awaitDrain = 0;\n\n // if true, a maybeReadMore has been scheduled\n this.readingMore = false;\n\n this.decoder = null;\n this.encoding = null;\n if (options.encoding) {\n if (!StringDecoder)\n StringDecoder = require('string_decoder').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n this.encoding = options.encoding;\n }\n}\n\nfunction Readable(options) {\n if (!(this instanceof Readable))\n return new Readable(options);\n\n // Checking for a Stream.Duplex instance is faster here instead of inside\n // the ReadableState constructor, at least with V8 6.5\n const isDuplex = (this instanceof Stream.Duplex);\n\n this._readableState = new ReadableState(options, this, isDuplex);\n\n // legacy\n this.readable = true;\n\n if (options) {\n if (typeof options.read === 'function')\n this._read = options.read;\n\n if (typeof options.destroy === 'function')\n this._destroy = options.destroy;\n }\n\n Stream.call(this);\n}\n\nObject.defineProperty(Readable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get() {\n if (this._readableState === undefined) {\n return false;\n }\n return this._readableState.destroyed;\n },\n set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._readableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._readableState.destroyed = value;\n }\n});\n\nReadable.prototype.destroy = destroyImpl.destroy;\nReadable.prototype._undestroy = destroyImpl.undestroy;\nReadable.prototype._destroy = function(err, cb) {\n cb(err);\n};\n\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 should\n// write() some more.\nReadable.prototype.push = function(chunk, encoding) {\n var state = this._readableState;\n var skipChunkCheck;\n\n if (!state.objectMode) {\n if (typeof chunk === 'string') {\n encoding = encoding || state.defaultEncoding;\n if (encoding !== state.encoding) {\n chunk = Buffer.from(chunk, encoding);\n encoding = '';\n }\n skipChunkCheck = true;\n }\n } else {\n skipChunkCheck = true;\n }\n\n return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);\n};\n\n// Unshift should *always* be something directly out of read()\nReadable.prototype.unshift = function(chunk) {\n return readableAddChunk(this, chunk, null, true, false);\n};\n\nfunction readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {\n debug('readableAddChunk', chunk);\n var state = stream._readableState;\n if (chunk === null) {\n state.reading = false;\n onEofChunk(stream, state);\n } else {\n var er;\n if (!skipChunkCheck)\n er = chunkInvalid(state, chunk);\n if (er) {\n stream.emit('error', er);\n } else if (state.objectMode || chunk && chunk.length > 0) {\n if (typeof chunk !== 'string' &&\n !state.objectMode &&\n Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = Stream._uint8ArrayToBuffer(chunk);\n }\n\n if (addToFront) {\n if (state.endEmitted)\n stream.emit('error', new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());\n else\n addChunk(stream, state, chunk, true);\n } else if (state.ended) {\n stream.emit('error', new ERR_STREAM_PUSH_AFTER_EOF());\n } else if (state.destroyed) {\n return false;\n } else {\n state.reading = false;\n if (state.decoder && !encoding) {\n chunk = state.decoder.write(chunk);\n if (state.objectMode || chunk.length !== 0)\n addChunk(stream, state, chunk, false);\n else\n maybeReadMore(stream, state);\n } else {\n addChunk(stream, state, chunk, false);\n }\n }\n } else if (!addToFront) {\n state.reading = false;\n maybeReadMore(stream, state);\n }\n }\n\n // We can push more data if we are below the highWaterMark.\n // Also, if we have no data yet, we can stand some more bytes.\n // This is to work around cases where hwm=0, such as the repl.\n return !state.ended &&\n (state.length < state.highWaterMark || state.length === 0);\n}\n\nfunction addChunk(stream, state, chunk, addToFront) {\n if (state.flowing && state.length === 0 && !state.sync) {\n state.awaitDrain = 0;\n stream.emit('data', chunk);\n } else {\n // update the buffer info.\n state.length += state.objectMode ? 1 : chunk.length;\n if (addToFront)\n state.buffer.unshift(chunk);\n else\n state.buffer.push(chunk);\n\n if (state.needReadable)\n emitReadable(stream);\n }\n maybeReadMore(stream, state);\n}\n\nfunction chunkInvalid(state, chunk) {\n var er;\n if (!Stream._isUint8Array(chunk) &&\n typeof chunk !== 'string' &&\n chunk !== undefined &&\n !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE(\n 'chunk', ['string', 'Buffer', 'Uint8Array'], chunk);\n }\n return er;\n}\n\n\nReadable.prototype.isPaused = function() {\n return this._readableState.flowing === false;\n};\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function(enc) {\n if (!StringDecoder)\n StringDecoder = require('string_decoder').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n // if setEncoding(null), decoder.encoding equals utf8\n this._readableState.encoding = this._readableState.decoder.encoding;\n return this;\n};\n\n// Don't raise the hwm > 8MB\nconst MAX_HWM = 0x800000;\nfunction 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 in\n // tiny amounts\n n--;\n n |= n >>> 1;\n n |= n >>> 2;\n n |= n >>> 4;\n n |= n >>> 8;\n n |= n >>> 16;\n n++;\n }\n return n;\n}\n\n// This function is designed to be inlinable, so please take care when making\n// changes to the function body.\nfunction howMuchToRead(n, state) {\n if (n <= 0 || (state.length === 0 && state.ended))\n return 0;\n if (state.objectMode)\n return 1;\n if (Number.isNaN(n)) {\n // Only flow one buffer at a time\n if (state.flowing && state.length)\n return state.buffer.head.data.length;\n else\n return state.length;\n }\n // If we're asking for more than the current hwm, then raise the hwm.\n if (n > state.highWaterMark)\n state.highWaterMark = computeNewHighWaterMark(n);\n if (n <= state.length)\n return n;\n // Don't have enough\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n }\n return state.length;\n}\n\n// you can override either this method, or the async _read(n) below.\nReadable.prototype.read = function(n) {\n debug('read', n);\n n = parseInt(n, 10);\n var state = this._readableState;\n var nOrig = n;\n\n if (n !== 0)\n state.emittedReadable = false;\n\n // if we're doing read(0) to trigger a readable event, but we\n // already have a bunch of data in the buffer, then just trigger\n // the 'readable' event and move on.\n if (n === 0 &&\n state.needReadable &&\n ((state.highWaterMark !== 0 ?\n state.length >= state.highWaterMark :\n state.length > 0) ||\n state.ended)) {\n debug('read: emitReadable', state.length, state.ended);\n if (state.length === 0 && state.ended)\n endReadable(this);\n else\n emitReadable(this);\n return null;\n }\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n if (state.length === 0)\n endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // 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 is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n debug('need readable', doRead);\n\n // if we currently have less than the highWaterMark, then also read some\n if (state.length === 0 || state.length - n < state.highWaterMark) {\n doRead = true;\n debug('length less than watermark', doRead);\n }\n\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n 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;\n // if the length is currently zero, then we *need* a readable event.\n if (state.length === 0)\n state.needReadable = true;\n // call internal read method\n this._read(state.highWaterMark);\n state.sync = false;\n // 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.\n if (!state.reading)\n n = howMuchToRead(nOrig, state);\n }\n\n var ret;\n if (n > 0)\n ret = fromList(n, state);\n else\n ret = null;\n\n if (ret === null) {\n state.needReadable = true;\n n = 0;\n } else {\n state.length -= n;\n state.awaitDrain = 0;\n }\n\n if (state.length === 0) {\n // If we have nothing in the buffer, then we want to know\n // as soon as we *do* get something into the buffer.\n if (!state.ended)\n state.needReadable = true;\n\n // If we tried to read() past the EOF, then emit end on the next tick.\n if (nOrig !== n && state.ended)\n endReadable(this);\n }\n\n if (ret !== null)\n this.emit('data', ret);\n\n return ret;\n};\n\nfunction onEofChunk(stream, state) {\n if (state.ended) return;\n if (state.decoder) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length) {\n state.buffer.push(chunk);\n state.length += state.objectMode ? 1 : chunk.length;\n }\n }\n state.ended = true;\n\n if (state.sync) {\n // if we are sync, wait until next tick to emit the data.\n // Otherwise we risk emitting data in the flow()\n // the readable code triggers during a read() call\n emitReadable(stream);\n } else {\n // emit 'readable' now to make sure it gets picked up.\n state.needReadable = false;\n if (!state.emittedReadable) {\n state.emittedReadable = true;\n emitReadable_(stream);\n }\n }\n}\n\n// Don't emit readable right away in sync mode, because this can trigger\n// another read() call => stack overflow. This way, it might trigger\n// a nextTick recursion warning, but that's not so bad.\nfunction emitReadable(stream) {\n var state = stream._readableState;\n state.needReadable = false;\n if (!state.emittedReadable) {\n debug('emitReadable', state.flowing);\n state.emittedReadable = true;\n process.nextTick(emitReadable_, stream);\n }\n}\n\nfunction emitReadable_(stream) {\n var state = stream._readableState;\n debug('emit readable');\n if (!state.destroyed && (state.length || state.ended)) {\n stream.emit('readable');\n }\n\n // The stream needs another readable event if\n // 1. It is not flowing, as the flow mechanism will take\n // care of it.\n // 2. It is not ended.\n // 3. It is below the highWaterMark, so we can schedule\n // another readable later.\n state.needReadable =\n !state.flowing &&\n !state.ended &&\n state.length <= state.highWaterMark;\n flow(stream);\n}\n\n\n// at this point, the user has presumably seen the 'readable' event,\n// and called read() to consume some data. that may have triggered\n// in turn another _read(n) call, in which case reading = true if\n// 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.\nfunction maybeReadMore(stream, state) {\n if (!state.readingMore) {\n state.readingMore = true;\n process.nextTick(maybeReadMore_, stream, state);\n }\n}\n\nfunction maybeReadMore_(stream, state) {\n var len = state.length;\n while (!state.reading && !state.ended &&\n state.length < state.highWaterMark) {\n debug('maybeReadMore read 0');\n stream.read(0);\n if (len === state.length)\n // didn't get any data, stop spinning.\n break;\n else\n len = state.length;\n }\n state.readingMore = false;\n}\n\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 somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function(n) {\n this.emit('error', new ERR_METHOD_NOT_IMPLEMENTED('_read()'));\n};\n\nReadable.prototype.pipe = function(dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n\n switch (state.pipesCount) {\n case 0:\n state.pipes = dest;\n break;\n case 1:\n state.pipes = [state.pipes, dest];\n break;\n default:\n state.pipes.push(dest);\n break;\n }\n state.pipesCount += 1;\n debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\n var doEnd = (!pipeOpts || pipeOpts.end !== false) &&\n dest !== process.stdout &&\n dest !== process.stderr;\n\n var endFn = doEnd ? onend : unpipe;\n if (state.endEmitted)\n process.nextTick(endFn);\n else\n src.once('end', endFn);\n\n dest.on('unpipe', onunpipe);\n function onunpipe(readable, unpipeInfo) {\n debug('onunpipe');\n if (readable === src) {\n if (unpipeInfo && unpipeInfo.hasUnpiped === false) {\n unpipeInfo.hasUnpiped = true;\n cleanup();\n }\n }\n }\n\n function onend() {\n debug('onend');\n dest.end();\n }\n\n // when the dest drains, it reduces the awaitDrain counter\n // on the source. This would be more elegant with a .once()\n // handler in flow(), but adding and removing repeatedly is\n // too slow.\n var ondrain = pipeOnDrain(src);\n dest.on('drain', ondrain);\n\n var cleanedUp = false;\n function cleanup() {\n debug('cleanup');\n // cleanup event handlers once the pipe is broken\n 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\n cleanedUp = true;\n\n // if the reader is waiting for a drain event from this\n // specific writer, then it would cause it to never start\n // 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.\n if (state.awaitDrain &&\n (!dest._writableState || dest._writableState.needDrain))\n ondrain();\n }\n\n src.on('data', ondata);\n function ondata(chunk) {\n debug('ondata');\n var ret = dest.write(chunk);\n debug('dest.write', ret);\n if (ret === false) {\n // If the user unpiped during `dest.write()`, it is possible\n // to get stuck in a permanently paused state if that write\n // also returned false.\n // => Check whether `dest` is still a piping destination.\n if (((state.pipesCount === 1 && state.pipes === dest) ||\n (state.pipesCount > 1 && state.pipes.indexOf(dest) !== -1)) &&\n !cleanedUp) {\n debug('false write response, pause', state.awaitDrain);\n state.awaitDrain++;\n }\n src.pause();\n }\n }\n\n // if the dest has an error, then stop piping into it.\n // however, don't suppress the throwing behavior for this.\n function onerror(er) {\n debug('onerror', er);\n unpipe();\n dest.removeListener('error', onerror);\n if (EE.listenerCount(dest, 'error') === 0)\n dest.emit('error', er);\n }\n\n // Make sure our error handler is attached before userland ones.\n prependListener(dest, 'error', onerror);\n\n // Both close and finish should trigger unpipe, but only once.\n function onclose() {\n dest.removeListener('finish', onfinish);\n unpipe();\n }\n dest.once('close', onclose);\n function onfinish() {\n debug('onfinish');\n dest.removeListener('close', onclose);\n unpipe();\n }\n dest.once('finish', onfinish);\n\n function unpipe() {\n debug('unpipe');\n src.unpipe(dest);\n }\n\n // tell the dest that it's being piped to\n dest.emit('pipe', src);\n\n // start the flow if it hasn't been started already.\n if (!state.flowing) {\n debug('pipe resume');\n src.resume();\n }\n\n return dest;\n};\n\nfunction pipeOnDrain(src) {\n return function pipeOnDrainFunctionResult() {\n var state = src._readableState;\n debug('pipeOnDrain', state.awaitDrain);\n if (state.awaitDrain)\n state.awaitDrain--;\n if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) {\n state.flowing = true;\n flow(src);\n }\n };\n}\n\n\nReadable.prototype.unpipe = function(dest) {\n var state = this._readableState;\n var unpipeInfo = { hasUnpiped: false };\n\n // if we're not piping anywhere, then do nothing.\n if (state.pipesCount === 0)\n return this;\n\n // just one destination. most common case.\n if (state.pipesCount === 1) {\n // passed in one, but it's not the right one.\n if (dest && dest !== state.pipes)\n return this;\n\n if (!dest)\n dest = state.pipes;\n\n // got a match.\n state.pipes = null;\n state.pipesCount = 0;\n state.flowing = false;\n if (dest)\n dest.emit('unpipe', this, unpipeInfo);\n return this;\n }\n\n // slow case. multiple pipe destinations.\n\n 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;\n\n for (var i = 0; i < len; i++)\n dests[i].emit('unpipe', this, { hasUnpiped: false });\n return this;\n }\n\n // try to find the right one.\n var index = state.pipes.indexOf(dest);\n if (index === -1)\n return this;\n\n state.pipes.splice(index, 1);\n state.pipesCount -= 1;\n if (state.pipesCount === 1)\n state.pipes = state.pipes[0];\n\n dest.emit('unpipe', this, unpipeInfo);\n\n return this;\n};\n\n// set up data events if they are asked for\n// Ensure readable listeners eventually get something\nReadable.prototype.on = function(ev, fn) {\n const res = Stream.prototype.on.call(this, ev, fn);\n const state = this._readableState;\n\n if (ev === 'data') {\n // update readableListening so that resume() may be a no-op\n // a few lines down. This is needed to support once('readable').\n state.readableListening = this.listenerCount('readable') > 0;\n\n // Try start flowing on next tick if stream isn't explicitly paused\n if (state.flowing !== false)\n this.resume();\n } else if (ev === 'readable') {\n if (!state.endEmitted && !state.readableListening) {\n state.readableListening = state.needReadable = true;\n state.emittedReadable = false;\n debug('on readable', state.length, state.reading);\n if (state.length) {\n emitReadable(this);\n } else if (!state.reading) {\n process.nextTick(nReadingNextTick, this);\n }\n }\n }\n\n return res;\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\nReadable.prototype.removeListener = function(ev, fn) {\n const res = Stream.prototype.removeListener.call(this, ev, fn);\n\n if (ev === 'readable') {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nReadable.prototype.removeAllListeners = function(ev) {\n const res = Stream.prototype.removeAllListeners.apply(this, arguments);\n\n if (ev === 'readable' || ev === undefined) {\n // We need to check if there is someone still listening to\n // readable and reset the state. However this needs to happen\n // after readable has been emitted but before I/O (nextTick) to\n // support once('readable', fn) cycles. This means that calling\n // resume within the same tick will have no\n // effect.\n process.nextTick(updateReadableListening, this);\n }\n\n return res;\n};\n\nfunction updateReadableListening(self) {\n self._readableState.readableListening = self.listenerCount('readable') > 0;\n}\n\nfunction nReadingNextTick(self) {\n debug('readable nexttick read 0');\n self.read(0);\n}\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function() {\n var state = this._readableState;\n if (!state.flowing) {\n debug('resume');\n // we flow only if there is no one listening\n // for readable\n state.flowing = !state.readableListening;\n resume(this, state);\n }\n return this;\n};\n\nfunction resume(stream, state) {\n if (!state.resumeScheduled) {\n state.resumeScheduled = true;\n process.nextTick(resume_, stream, state);\n }\n}\n\nfunction resume_(stream, state) {\n debug('resume', state.reading);\n if (!state.reading) {\n stream.read(0);\n }\n\n state.resumeScheduled = false;\n stream.emit('resume');\n flow(stream);\n if (state.flowing && !state.reading)\n stream.read(0);\n}\n\nReadable.prototype.pause = function() {\n debug('call pause flowing=%j', this._readableState.flowing);\n if (this._readableState.flowing !== false) {\n debug('pause');\n this._readableState.flowing = false;\n this.emit('pause');\n }\n return this;\n};\n\nfunction flow(stream) {\n const state = stream._readableState;\n debug('flow', state.flowing);\n while (state.flowing && stream.read() !== null);\n}\n\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.\nReadable.prototype.wrap = function(stream) {\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', () => {\n debug('wrapped end');\n if (state.decoder && !state.ended) {\n var chunk = state.decoder.end();\n if (chunk && chunk.length)\n this.push(chunk);\n }\n\n this.push(null);\n });\n\n stream.on('data', (chunk) => {\n debug('wrapped data');\n if (state.decoder)\n chunk = state.decoder.write(chunk);\n\n // don't skip over falsy values in objectMode\n if (state.objectMode && (chunk === null || chunk === undefined))\n return;\n else if (!state.objectMode && (!chunk || !chunk.length))\n return;\n\n var ret = this.push(chunk);\n if (!ret) {\n paused = true;\n stream.pause();\n }\n });\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (this[i] === undefined && typeof stream[i] === 'function') {\n this[i] = function methodWrap(method) {\n return function methodWrapReturnFunction() {\n return stream[method].apply(stream, arguments);\n };\n }(i);\n }\n }\n\n // proxy certain important events.\n for (var n = 0; n < kProxyEvents.length; n++) {\n stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));\n }\n\n // when we try to consume some more bytes, simply unpause the\n // underlying stream.\n this._read = (n) => {\n debug('wrapped _read', n);\n if (paused) {\n paused = false;\n stream.resume();\n }\n };\n\n return this;\n};\n\nReadable.prototype[Symbol.asyncIterator] = function() {\n emitExperimentalWarning('Readable[Symbol.asyncIterator]');\n if (ReadableAsyncIterator === undefined)\n ReadableAsyncIterator = require('internal/streams/async_iterator');\n return new ReadableAsyncIterator(this);\n};\n\nObject.defineProperty(Readable.prototype, 'readableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function() {\n return this._readableState.highWaterMark;\n }\n});\n\nObject.defineProperty(Readable.prototype, 'readableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function() {\n return this._readableState && this._readableState.buffer;\n }\n});\n\nObject.defineProperty(Readable.prototype, 'readableFlowing', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function() {\n return this._readableState.flowing;\n },\n set: function(state) {\n if (this._readableState) {\n this._readableState.flowing = state;\n }\n }\n});\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\nObject.defineProperty(Readable.prototype, 'readableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get() {\n return this._readableState.length;\n }\n});\n\n// 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 making\n// changes to the function body.\nfunction fromList(n, state) {\n // nothing buffered\n if (state.length === 0)\n return null;\n\n var ret;\n if (state.objectMode)\n ret = state.buffer.shift();\n else if (!n || n >= state.length) {\n // read it all, truncate the list\n if (state.decoder)\n ret = state.buffer.join('');\n else if (state.buffer.length === 1)\n ret = state.buffer.first();\n else\n ret = state.buffer.concat(state.length);\n state.buffer.clear();\n } else {\n // read part of list\n ret = state.buffer.consume(n, state.decoder);\n }\n\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n\n debug('endReadable', state.endEmitted);\n if (!state.endEmitted) {\n state.ended = true;\n process.nextTick(endReadableNT, state, stream);\n }\n}\n\nfunction endReadableNT(state, stream) {\n debug('endReadableNT', state.endEmitted, state.length);\n\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}\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 32304,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 1,
"endOffset": 32302,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "prependListener",
"ranges": [
{
"startOffset": 2049,
"endOffset": 2857,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "ReadableState",
"ranges": [
{
"startOffset": 2859,
"endOffset": 5596,
"count": 2
},
{
"startOffset": 2931,
"endOffset": 2936,
"count": 0
},
{
"startOffset": 3286,
"endOffset": 3329,
"count": 0
},
{
"startOffset": 5408,
"endOffset": 5594,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "Readable",
"ranges": [
{
"startOffset": 5598,
"endOffset": 6197,
"count": 2
},
{
"startOffset": 5666,
"endOffset": 5695,
"count": 0
},
{
"startOffset": 6056,
"endOffset": 6082,
"count": 0
},
{
"startOffset": 6137,
"endOffset": 6169,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 6413,
"endOffset": 6537,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "set",
"ranges": [
{
"startOffset": 6541,
"endOffset": 6810,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable._destroy",
"ranges": [
{
"startOffset": 6951,
"endOffset": 6983,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.push",
"ranges": [
{
"startOffset": 7212,
"endOffset": 7684,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.unshift",
"ranges": [
{
"startOffset": 7779,
"endOffset": 7857,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "readableAddChunk",
"ranges": [
{
"startOffset": 7860,
"endOffset": 9596,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "addChunk",
"ranges": [
{
"startOffset": 9598,
"endOffset": 10059,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "chunkInvalid",
"ranges": [
{
"startOffset": 10061,
"endOffset": 10350,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.isPaused",
"ranges": [
{
"startOffset": 10383,
"endOffset": 10445,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.setEncoding",
"ranges": [
{
"startOffset": 10509,
"endOffset": 10807,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "computeNewHighWaterMark",
"ranges": [
{
"startOffset": 10865,
"endOffset": 11179,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "howMuchToRead",
"ranges": [
{
"startOffset": 11292,
"endOffset": 11932,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.read",
"ranges": [
{
"startOffset": 12029,
"endOffset": 15676,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "onEofChunk",
"ranges": [
{
"startOffset": 15679,
"endOffset": 16388,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "emitReadable",
"ranges": [
{
"startOffset": 16589,
"endOffset": 16846,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "emitReadable_",
"ranges": [
{
"startOffset": 16848,
"endOffset": 17402,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "maybeReadMore",
"ranges": [
{
"startOffset": 17752,
"endOffset": 17908,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "maybeReadMore_",
"ranges": [
{
"startOffset": 17910,
"endOffset": 18279,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable._read",
"ranges": [
{
"startOffset": 18550,
"endOffset": 18630,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.pipe",
"ranges": [
{
"startOffset": 18659,
"endOffset": 22469,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "pipeOnDrain",
"ranges": [
{
"startOffset": 22472,
"endOffset": 22804,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.unpipe",
"ranges": [
{
"startOffset": 22835,
"endOffset": 24061,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.on",
"ranges": [
{
"startOffset": 24186,
"endOffset": 25063,
"count": 6
},
{
"startOffset": 24318,
"endOffset": 24649,
"count": 0
},
{
"startOffset": 24678,
"endOffset": 25046,
"count": 0
},
{
"startOffset": 25061,
"endOffset": 25062,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "Readable.removeListener",
"ranges": [
{
"startOffset": 25158,
"endOffset": 25672,
"count": 2
},
{
"startOffset": 25269,
"endOffset": 25655,
"count": 0
},
{
"startOffset": 25670,
"endOffset": 25671,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "Readable.removeAllListeners",
"ranges": [
{
"startOffset": 25715,
"endOffset": 26253,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "updateReadableListening",
"ranges": [
{
"startOffset": 26256,
"endOffset": 26376,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "nReadingNextTick",
"ranges": [
{
"startOffset": 26378,
"endOffset": 26466,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.resume",
"ranges": [
{
"startOffset": 26620,
"endOffset": 26873,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "resume",
"ranges": [
{
"startOffset": 26876,
"endOffset": 27026,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "resume_",
"ranges": [
{
"startOffset": 27028,
"endOffset": 27279,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.pause",
"ranges": [
{
"startOffset": 27308,
"endOffset": 27536,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "flow",
"ranges": [
{
"startOffset": 27539,
"endOffset": 27686,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.wrap",
"ranges": [
{
"startOffset": 27870,
"endOffset": 29380,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Readable.(anonymous function)",
"ranges": [
{
"startOffset": 29426,
"endOffset": 29658,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 29892,
"endOffset": 29954,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 30184,
"endOffset": 30262,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 30493,
"endOffset": 30549,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "set",
"ranges": [
{
"startOffset": 30558,
"endOffset": 30659,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 30954,
"endOffset": 31004,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "fromList",
"ranges": [
{
"startOffset": 31234,
"endOffset": 31793,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "endReadable",
"ranges": [
{
"startOffset": 31795,
"endOffset": 32014,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "endReadableNT",
"ranges": [
{
"startOffset": 32016,
"endOffset": 32299,
"count": 0
}
],
"isBlockCoverage": false
}
]
},
{
"url": "_stream_transform.js",
"source": "(function (exports, require, module, process) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// 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 OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// a transform stream is a readable/writable stream where you do\n// something with the data. Sometimes it's called a \"filter\",\n// but that's not a great name for it, since that implies a thing where\n// some bits pass through, and others are simply ignored. (That would\n// be a valid example of a transform, of course.)\n//\n// While the output is causally related to the input, it's not a\n// necessarily symmetric or synchronous transformation. For example,\n// a zlib stream might take multiple plain-text writes(), and then\n// emit a single compressed chunk some time in the future.\n//\n// Here's how this works:\n//\n// The Transform stream has all the aspects of the readable and writable\n// stream classes. When you write(chunk), that calls _write(chunk,cb)\n// internally, and returns false if there's a lot of pending writes\n// buffered up. When you call read(), that calls _read(n) until\n// there's enough pending readable data buffered up.\n//\n// In a transform stream, the written data is placed in a buffer. When\n// _read(n) is called, it transforms the queued up data, calling the\n// buffered _write cb's as it consumes chunks. If consuming a single\n// written chunk would result in multiple output chunks, then the first\n// outputted bit calls the readcb, and subsequent chunks just go into\n// the read buffer, and will cause it to emit 'readable' if necessary.\n//\n// This way, back-pressure is actually determined by the reading side,\n// since _read has to be called to start processing a new chunk. However,\n// a pathological inflate type of transform can cause excessive buffering\n// here. For example, imagine a stream where every byte of input is\n// interpreted as an integer from 0-255, and then results in that many\n// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n// 1kb of data being output. In this case, you could write a very small\n// amount of input, and end up with a very large amount of output. In\n// such a pathological inflating mechanism, there'd be no way to tell\n// the system to stop doing the transform. A single 4MB write could\n// cause the system to run out of memory.\n//\n// However, even in such a pathological case, only a single written chunk\n// would be consumed, and then the rest would wait (un-transformed) until\n// the results of the previous transformed chunk were consumed.\n\n'use strict';\n\nmodule.exports = Transform;\nconst {\n ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK,\n ERR_TRANSFORM_ALREADY_TRANSFORMING,\n ERR_TRANSFORM_WITH_LENGTH_0\n} = require('internal/errors').codes;\nconst Duplex = require('_stream_duplex');\nconst util = require('util');\nutil.inherits(Transform, Duplex);\n\n\nfunction afterTransform(er, data) {\n var ts = this._transformState;\n ts.transforming = false;\n\n var cb = ts.writecb;\n\n if (cb === null) {\n return this.emit('error', new ERR_MULTIPLE_CALLBACK());\n }\n\n ts.writechunk = null;\n ts.writecb = null;\n\n if (data != null) // single equals check for both `null` and `undefined`\n this.push(data);\n\n cb(er);\n\n var rs = this._readableState;\n rs.reading = false;\n if (rs.needReadable || rs.length < rs.highWaterMark) {\n this._read(rs.highWaterMark);\n }\n}\n\n\nfunction Transform(options) {\n if (!(this instanceof Transform))\n return new Transform(options);\n\n Duplex.call(this, options);\n\n this._transformState = {\n afterTransform: afterTransform.bind(this),\n needTransform: false,\n transforming: false,\n writecb: null,\n writechunk: null,\n writeencoding: null\n };\n\n // start out asking for a readable event once data is transformed.\n this._readableState.needReadable = true;\n\n // we have implemented the _read method, and done the other things\n // that Readable wants before the first _read call, so unset the\n // sync guard flag.\n this._readableState.sync = false;\n\n if (options) {\n if (typeof options.transform === 'function')\n this._transform = options.transform;\n\n if (typeof options.flush === 'function')\n this._flush = options.flush;\n }\n\n // When the writable side finishes, then flush out anything remaining.\n this.on('prefinish', prefinish);\n}\n\nfunction prefinish() {\n if (typeof this._flush === 'function' && !this._readableState.destroyed) {\n this._flush((er, data) => {\n done(this, er, data);\n });\n } else {\n done(this, null, null);\n }\n}\n\nTransform.prototype.push = function(chunk, encoding) {\n this._transformState.needTransform = false;\n return Duplex.prototype.push.call(this, chunk, encoding);\n};\n\n// This is the part where you do stuff!\n// override this function in implementation classes.\n// 'chunk' is an input chunk.\n//\n// Call `push(newChunk)` to pass along transformed output\n// to the readable side. You may call 'push' zero or more times.\n//\n// Call `cb(err)` when you are done with this chunk. If you pass\n// an error, then that'll put the hurt on the whole operation. If you\n// never call cb(), then you'll never get another chunk.\nTransform.prototype._transform = function(chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));\n};\n\nTransform.prototype._write = function(chunk, encoding, cb) {\n var ts = this._transformState;\n ts.writecb = cb;\n ts.writechunk = chunk;\n ts.writeencoding = encoding;\n if (!ts.transforming) {\n var rs = this._readableState;\n if (ts.needTransform ||\n rs.needReadable ||\n rs.length < rs.highWaterMark)\n this._read(rs.highWaterMark);\n }\n};\n\n// Doesn't matter what the args are here.\n// _transform does all the work.\n// That we got here means that the readable side wants more data.\nTransform.prototype._read = function(n) {\n var ts = this._transformState;\n\n if (ts.writechunk !== null && !ts.transforming) {\n ts.transforming = true;\n this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n } else {\n // mark that we need a transform, so that any data that comes in\n // will get processed, now that we've asked for it.\n ts.needTransform = true;\n }\n};\n\n\nTransform.prototype._destroy = function(err, cb) {\n Duplex.prototype._destroy.call(this, err, (err2) => {\n cb(err2);\n });\n};\n\n\nfunction done(stream, er, data) {\n if (er)\n return stream.emit('error', er);\n\n if (data != null) // single equals check for both `null` and `undefined`\n stream.push(data);\n\n // TODO(BridgeAR): Write a test for these two error cases\n // if there's nothing in the write buffer, then that means\n // that nothing more will ever be provided\n if (stream._writableState.length)\n throw new ERR_TRANSFORM_WITH_LENGTH_0();\n\n if (stream._transformState.transforming)\n throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();\n return stream.push(null);\n}\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 7856,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 1,
"endOffset": 7854,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "afterTransform",
"ranges": [
{
"startOffset": 3850,
"endOffset": 4361,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Transform",
"ranges": [
{
"startOffset": 4364,
"endOffset": 5305,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "prefinish",
"ranges": [
{
"startOffset": 5307,
"endOffset": 5519,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Transform.push",
"ranges": [
{
"startOffset": 5548,
"endOffset": 5683,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Transform._transform",
"ranges": [
{
"startOffset": 6166,
"endOffset": 6253,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Transform._write",
"ranges": [
{
"startOffset": 6285,
"endOffset": 6619,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Transform._read",
"ranges": [
{
"startOffset": 6791,
"endOffset": 7162,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Transform._destroy",
"ranges": [
{
"startOffset": 7197,
"endOffset": 7294,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "done",
"ranges": [
{
"startOffset": 7298,
"endOffset": 7851,
"count": 0
}
],
"isBlockCoverage": false
}
]
},
{
"url": "_stream_writable.js",
"source": "(function (exports, require, module, process) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// 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 OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// A bit simpler than readable streams.\n// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n// the drain event emission and buffering.\n\n'use strict';\n\nmodule.exports = Writable;\nWritable.WritableState = WritableState;\n\nconst util = require('util');\nconst internalUtil = require('internal/util');\nconst Stream = require('stream');\nconst { Buffer } = require('buffer');\nconst destroyImpl = require('internal/streams/destroy');\nconst { getHighWaterMark } = require('internal/streams/state');\nconst {\n ERR_INVALID_ARG_TYPE,\n ERR_METHOD_NOT_IMPLEMENTED,\n ERR_MULTIPLE_CALLBACK,\n ERR_STREAM_CANNOT_PIPE,\n ERR_STREAM_DESTROYED,\n ERR_STREAM_NULL_VALUES,\n ERR_STREAM_WRITE_AFTER_END,\n ERR_UNKNOWN_ENCODING\n} = require('internal/errors').codes;\n\nutil.inherits(Writable, Stream);\n\nfunction nop() {}\n\nfunction WritableState(options, stream, isDuplex) {\n options = options || {};\n\n // Duplex streams are both readable and writable, but share\n // the same options object.\n // However, some cases require setting options to different\n // values for the readable and the writable sides of the duplex stream.\n // These options can be provided separately as readableXXX and writableXXX.\n if (typeof isDuplex !== 'boolean')\n isDuplex = stream instanceof Stream.Duplex;\n\n // object stream flag to indicate whether or not this stream\n // contains buffers or objects.\n this.objectMode = !!options.objectMode;\n\n if (isDuplex)\n this.objectMode = this.objectMode || !!options.writableObjectMode;\n\n // the point at which write() starts returning false\n // Note: 0 is a valid value, means that we always return false if\n // the entire buffer is not flushed immediately on write()\n this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark',\n isDuplex);\n\n // if _final has been called\n this.finalCalled = false;\n\n // drain event flag.\n this.needDrain = false;\n // at the start of calling end()\n this.ending = false;\n // when end() has been called, and returned\n this.ended = false;\n // when 'finish' is emitted\n this.finished = false;\n\n // has it been destroyed\n this.destroyed = false;\n\n // should we decode strings into buffers before passing to _write?\n // this is here so that some node-core streams can optimize string\n // handling at a lower level.\n var noDecode = options.decodeStrings === false;\n this.decodeStrings = !noDecode;\n\n // Crypto is kind of old and crusty. Historically, its default string\n // encoding is 'binary' so we have to make this configurable.\n // Everything else in the universe uses 'utf8', though.\n this.defaultEncoding = options.defaultEncoding || 'utf8';\n\n // not an actual buffer we keep track of, but a measurement\n // of how much we're waiting to get pushed to some underlying\n // socket or file.\n this.length = 0;\n\n // a flag to see when we're in the middle of a write.\n this.writing = false;\n\n // when true all writes will be buffered until .uncork() call\n this.corked = 0;\n\n // a flag to be able to tell if the onwrite cb is called immediately,\n // or on a later tick. We set this to true at first, because any\n // actions that shouldn't happen until \"later\" should generally also\n // not happen before the first write call.\n this.sync = true;\n\n // a flag to know if we're processing previously buffered items, which\n // may call the _write() callback in the same tick, so that we don't\n // end up in an overlapped onwrite situation.\n this.bufferProcessing = false;\n\n // the callback that's passed to _write(chunk,cb)\n this.onwrite = onwrite.bind(undefined, stream);\n\n // the callback that the user supplies to write(chunk,encoding,cb)\n this.writecb = null;\n\n // the amount that is being written when _write is called.\n this.writelen = 0;\n\n this.bufferedRequest = null;\n this.lastBufferedRequest = null;\n\n // number of pending user-supplied write callbacks\n // this must be 0 before 'finish' can be emitted\n this.pendingcb = 0;\n\n // emit prefinish if the only thing we're waiting for is _write cbs\n // This is relevant for synchronous Transform streams\n this.prefinished = false;\n\n // True if the error was already emitted and should not be thrown again\n this.errorEmitted = false;\n\n // Should close be emitted on destroy. Defaults to true.\n this.emitClose = options.emitClose !== false;\n\n // count buffered requests\n this.bufferedRequestCount = 0;\n\n // allocate the first CorkedRequest, there is always\n // one allocated and free to use, and we maintain at most two\n var corkReq = { next: null, entry: null, finish: undefined };\n corkReq.finish = onCorkedFinish.bind(undefined, corkReq, this);\n this.corkedRequestsFree = corkReq;\n}\n\nWritableState.prototype.getBuffer = function getBuffer() {\n var current = this.bufferedRequest;\n var out = [];\n while (current) {\n out.push(current);\n current = current.next;\n }\n return out;\n};\n\nObject.defineProperty(WritableState.prototype, 'buffer', {\n get: internalUtil.deprecate(function writableStateBufferGetter() {\n return this.getBuffer();\n }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' +\n 'instead.', 'DEP0003')\n});\n\n// Test _writableState for inheritance to account for Duplex streams,\n// whose prototype chain only points to Readable.\nvar realHasInstance;\nif (typeof Symbol === 'function' && Symbol.hasInstance) {\n realHasInstance = Function.prototype[Symbol.hasInstance];\n Object.defineProperty(Writable, Symbol.hasInstance, {\n value: function(object) {\n if (realHasInstance.call(this, object))\n return true;\n if (this !== Writable)\n return false;\n\n return object && object._writableState instanceof WritableState;\n }\n });\n} else {\n realHasInstance = function(object) {\n return object instanceof this;\n };\n}\n\nfunction Writable(options) {\n // Writable ctor is applied to Duplexes, too.\n // `realHasInstance` is necessary because using plain `instanceof`\n // would return false, as no `_writableState` property is attached.\n\n // Trying to use the custom `instanceof` for Writable here will also break the\n // Node.js LazyTransform implementation, which has a non-trivial getter for\n // `_writableState` that would lead to infinite recursion.\n\n // Checking for a Stream.Duplex instance is faster here instead of inside\n // the WritableState constructor, at least with V8 6.5\n const isDuplex = (this instanceof Stream.Duplex);\n\n if (!isDuplex && !realHasInstance.call(Writable, this))\n return new Writable(options);\n\n this._writableState = new WritableState(options, this, isDuplex);\n\n // legacy.\n this.writable = true;\n\n if (options) {\n if (typeof options.write === 'function')\n this._write = options.write;\n\n if (typeof options.writev === 'function')\n this._writev = options.writev;\n\n if (typeof options.destroy === 'function')\n this._destroy = options.destroy;\n\n if (typeof options.final === 'function')\n this._final = options.final;\n }\n\n Stream.call(this);\n}\n\n// Otherwise people can pipe Writable streams, which is just wrong.\nWritable.prototype.pipe = function() {\n this.emit('error', new ERR_STREAM_CANNOT_PIPE());\n};\n\n\nfunction writeAfterEnd(stream, cb) {\n var er = new ERR_STREAM_WRITE_AFTER_END();\n // TODO: defer error events consistently everywhere, not just the cb\n stream.emit('error', er);\n process.nextTick(cb, er);\n}\n\n// Checks that a user-supplied chunk is valid, especially for the particular\n// mode the stream is in. Currently this means that `null` is never accepted\n// and undefined/non-string values are only allowed in object mode.\nfunction validChunk(stream, state, chunk, cb) {\n var er;\n\n if (chunk === null) {\n er = new ERR_STREAM_NULL_VALUES();\n } else if (typeof chunk !== 'string' && !state.objectMode) {\n er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);\n }\n if (er) {\n stream.emit('error', er);\n process.nextTick(cb, er);\n return false;\n }\n return true;\n}\n\nWritable.prototype.write = function(chunk, encoding, cb) {\n var state = this._writableState;\n var ret = false;\n var isBuf = !state.objectMode && Stream._isUint8Array(chunk);\n\n if (isBuf && Object.getPrototypeOf(chunk) !== Buffer.prototype) {\n chunk = Stream._uint8ArrayToBuffer(chunk);\n }\n\n if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (isBuf)\n encoding = 'buffer';\n else if (!encoding)\n encoding = state.defaultEncoding;\n\n if (typeof cb !== 'function')\n cb = nop;\n\n if (state.ending)\n writeAfterEnd(this, cb);\n else if (isBuf || validChunk(this, state, chunk, cb)) {\n state.pendingcb++;\n ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n }\n\n return ret;\n};\n\nWritable.prototype.cork = function() {\n this._writableState.corked++;\n};\n\nWritable.prototype.uncork = function() {\n var state = this._writableState;\n\n if (state.corked) {\n state.corked--;\n\n if (!state.writing &&\n !state.corked &&\n !state.bufferProcessing &&\n state.bufferedRequest)\n clearBuffer(this, state);\n }\n};\n\nWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n // node::ParseEncoding() requires lower case.\n if (typeof encoding === 'string')\n encoding = encoding.toLowerCase();\n if (!Buffer.isEncoding(encoding))\n throw new ERR_UNKNOWN_ENCODING(encoding);\n this._writableState.defaultEncoding = encoding;\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableBuffer', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function() {\n return this._writableState && this._writableState.getBuffer();\n }\n});\n\nfunction decodeChunk(state, chunk, encoding) {\n if (!state.objectMode &&\n state.decodeStrings !== false &&\n typeof chunk === 'string') {\n chunk = Buffer.from(chunk, encoding);\n }\n return chunk;\n}\n\nObject.defineProperty(Writable.prototype, 'writableHighWaterMark', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get: function() {\n return this._writableState.highWaterMark;\n }\n});\n\n// if we're already writing something, then just put this\n// in the queue, and wait our turn. Otherwise, call _write\n// If we return false, then we need a drain event, so set that flag.\nfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n if (!isBuf) {\n var newChunk = decodeChunk(state, chunk, encoding);\n if (chunk !== newChunk) {\n isBuf = true;\n encoding = 'buffer';\n chunk = newChunk;\n }\n }\n var len = state.objectMode ? 1 : chunk.length;\n\n state.length += len;\n\n var ret = state.length < state.highWaterMark;\n // we must ensure that previous needDrain will not be reset to false.\n if (!ret)\n state.needDrain = true;\n\n if (state.writing || state.corked) {\n var last = state.lastBufferedRequest;\n state.lastBufferedRequest = {\n chunk,\n encoding,\n isBuf,\n callback: cb,\n next: null\n };\n if (last) {\n last.next = state.lastBufferedRequest;\n } else {\n state.bufferedRequest = state.lastBufferedRequest;\n }\n state.bufferedRequestCount += 1;\n } else {\n doWrite(stream, state, false, len, chunk, encoding, cb);\n }\n\n return ret;\n}\n\nfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n state.writelen = len;\n state.writecb = cb;\n state.writing = true;\n state.sync = true;\n if (state.destroyed)\n state.onwrite(new ERR_STREAM_DESTROYED('write'));\n else if (writev)\n stream._writev(chunk, state.onwrite);\n else\n stream._write(chunk, encoding, state.onwrite);\n state.sync = false;\n}\n\nfunction onwriteError(stream, state, sync, er, cb) {\n --state.pendingcb;\n\n if (sync) {\n // defer the callback if we are being called synchronously\n // to avoid piling up things on the stack\n process.nextTick(cb, er);\n // this can emit finish, and it will always happen\n // after error\n process.nextTick(finishMaybe, stream, state);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n } else {\n // the caller expect this to happen before if\n // it is async\n cb(er);\n stream._writableState.errorEmitted = true;\n stream.emit('error', er);\n // this can emit finish, but finish must\n // always follow error\n finishMaybe(stream, state);\n }\n}\n\nfunction onwriteStateUpdate(state) {\n state.writing = false;\n state.writecb = null;\n state.length -= state.writelen;\n state.writelen = 0;\n}\n\nfunction onwrite(stream, er) {\n var state = stream._writableState;\n var sync = state.sync;\n var cb = state.writecb;\n\n if (typeof cb !== 'function')\n throw new ERR_MULTIPLE_CALLBACK();\n\n onwriteStateUpdate(state);\n\n if (er)\n onwriteError(stream, state, sync, er, cb);\n else {\n // Check if we're actually ready to finish, but don't emit yet\n var finished = needFinish(state);\n\n if (!finished &&\n !state.corked &&\n !state.bufferProcessing &&\n state.bufferedRequest) {\n clearBuffer(stream, state);\n }\n\n if (sync) {\n process.nextTick(afterWrite, stream, state, finished, cb);\n } else {\n afterWrite(stream, state, finished, cb);\n }\n }\n}\n\nfunction afterWrite(stream, state, finished, cb) {\n if (!finished)\n onwriteDrain(stream, state);\n state.pendingcb--;\n cb();\n finishMaybe(stream, state);\n}\n\n// Must force callback to be called on nextTick, so that we don't\n// emit 'drain' before the write() consumer gets the 'false' return\n// value, and has a chance to attach a 'drain' listener.\nfunction onwriteDrain(stream, state) {\n if (state.length === 0 && state.needDrain) {\n state.needDrain = false;\n stream.emit('drain');\n }\n}\n\n// if there's something in the buffer waiting, then process it\nfunction clearBuffer(stream, state) {\n state.bufferProcessing = true;\n var entry = state.bufferedRequest;\n\n if (stream._writev && entry && entry.next) {\n // Fast case, write everything using _writev()\n var l = state.bufferedRequestCount;\n var buffer = new Array(l);\n var holder = state.corkedRequestsFree;\n holder.entry = entry;\n\n var count = 0;\n var allBuffers = true;\n while (entry) {\n buffer[count] = entry;\n if (!entry.isBuf)\n allBuffers = false;\n entry = entry.next;\n count += 1;\n }\n buffer.allBuffers = allBuffers;\n\n doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\n // doWrite is almost always async, defer these to save a bit of time\n // as the hot path ends with doWrite\n state.pendingcb++;\n state.lastBufferedRequest = null;\n if (holder.next) {\n state.corkedRequestsFree = holder.next;\n holder.next = null;\n } else {\n var corkReq = { next: null, entry: null, finish: undefined };\n corkReq.finish = onCorkedFinish.bind(undefined, corkReq, state);\n state.corkedRequestsFree = corkReq;\n }\n state.bufferedRequestCount = 0;\n } else {\n // Slow case, write chunks one-by-one\n while (entry) {\n var chunk = entry.chunk;\n var encoding = entry.encoding;\n var cb = entry.callback;\n var len = state.objectMode ? 1 : chunk.length;\n\n doWrite(stream, state, false, len, chunk, encoding, cb);\n entry = entry.next;\n state.bufferedRequestCount--;\n // if we didn't call the onwrite immediately, then\n // it means that we need to wait until it does.\n // also, that means that the chunk and cb are currently\n // being processed, so move the buffer counter past them.\n if (state.writing) {\n break;\n }\n }\n\n if (entry === null)\n state.lastBufferedRequest = null;\n }\n\n state.bufferedRequest = entry;\n state.bufferProcessing = false;\n}\n\nWritable.prototype._write = function(chunk, encoding, cb) {\n cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));\n};\n\nWritable.prototype._writev = null;\n\nWritable.prototype.end = function(chunk, encoding, cb) {\n var state = this._writableState;\n\n if (typeof chunk === 'function') {\n cb = chunk;\n chunk = null;\n encoding = null;\n } else if (typeof encoding === 'function') {\n cb = encoding;\n encoding = null;\n }\n\n if (chunk !== null && chunk !== undefined)\n this.write(chunk, encoding);\n\n // .end() fully uncorks\n if (state.corked) {\n state.corked = 1;\n this.uncork();\n }\n\n // ignore unnecessary end() calls.\n if (!state.ending)\n endWritable(this, state, cb);\n\n return this;\n};\n\nObject.defineProperty(Writable.prototype, 'writableLength', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get() {\n return this._writableState.length;\n }\n});\n\nfunction needFinish(state) {\n return (state.ending &&\n state.length === 0 &&\n state.bufferedRequest === null &&\n !state.finished &&\n !state.writing);\n}\nfunction callFinal(stream, state) {\n stream._final((err) => {\n state.pendingcb--;\n if (err) {\n stream.emit('error', err);\n }\n state.prefinished = true;\n stream.emit('prefinish');\n finishMaybe(stream, state);\n });\n}\nfunction prefinish(stream, state) {\n if (!state.prefinished && !state.finalCalled) {\n if (typeof stream._final === 'function' && !state.destroyed) {\n state.pendingcb++;\n state.finalCalled = true;\n process.nextTick(callFinal, stream, state);\n } else {\n state.prefinished = true;\n stream.emit('prefinish');\n }\n }\n}\n\nfunction finishMaybe(stream, state) {\n var need = needFinish(state);\n if (need) {\n prefinish(stream, state);\n if (state.pendingcb === 0) {\n state.finished = true;\n stream.emit('finish');\n }\n }\n return need;\n}\n\nfunction endWritable(stream, state, cb) {\n state.ending = true;\n finishMaybe(stream, state);\n if (cb) {\n if (state.finished)\n process.nextTick(cb);\n else\n stream.once('finish', cb);\n }\n state.ended = true;\n stream.writable = false;\n}\n\nfunction onCorkedFinish(corkReq, state, err) {\n var entry = corkReq.entry;\n corkReq.entry = null;\n while (entry) {\n var cb = entry.callback;\n state.pendingcb--;\n cb(err);\n entry = entry.next;\n }\n\n // reuse the free corkReq.\n state.corkedRequestsFree.next = corkReq;\n}\n\nObject.defineProperty(Writable.prototype, 'destroyed', {\n // making it explicit this property is not enumerable\n // because otherwise some prototype manipulation in\n // userland will fail\n enumerable: false,\n get() {\n if (this._writableState === undefined) {\n return false;\n }\n return this._writableState.destroyed;\n },\n set(value) {\n // we ignore the value if the stream\n // has not been initialized yet\n if (!this._writableState) {\n return;\n }\n\n // backward compatibility, the user is explicitly\n // managing destroyed\n this._writableState.destroyed = value;\n }\n});\n\nWritable.prototype.destroy = destroyImpl.destroy;\nWritable.prototype._undestroy = destroyImpl.undestroy;\nWritable.prototype._destroy = function(err, cb) {\n cb(err);\n};\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 20386,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 1,
"endOffset": 20384,
"count": 1
},
{
"startOffset": 6918,
"endOffset": 7006,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "nop",
"ranges": [
{
"startOffset": 1980,
"endOffset": 1997,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "WritableState",
"ranges": [
{
"startOffset": 1999,
"endOffset": 5896,
"count": 2
},
{
"startOffset": 2071,
"endOffset": 2076,
"count": 0
},
{
"startOffset": 2426,
"endOffset": 2469,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "getBuffer",
"ranges": [
{
"startOffset": 5934,
"endOffset": 6101,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "writableStateBufferGetter",
"ranges": [
{
"startOffset": 6193,
"endOffset": 6264,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "value",
"ranges": [
{
"startOffset": 6696,
"endOffset": 6910,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "realHasInstance",
"ranges": [
{
"startOffset": 6946,
"endOffset": 7003,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Writable",
"ranges": [
{
"startOffset": 7008,
"endOffset": 8208,
"count": 2
},
{
"startOffset": 7648,
"endOffset": 7688,
"count": 0
},
{
"startOffset": 7694,
"endOffset": 7723,
"count": 0
},
{
"startOffset": 7900,
"endOffset": 7928,
"count": 0
},
{
"startOffset": 7982,
"endOffset": 8012,
"count": 0
},
{
"startOffset": 8067,
"endOffset": 8099,
"count": 0
},
{
"startOffset": 8152,
"endOffset": 8180,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "Writable.pipe",
"ranges": [
{
"startOffset": 8304,
"endOffset": 8370,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "writeAfterEnd",
"ranges": [
{
"startOffset": 8374,
"endOffset": 8584,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "validChunk",
"ranges": [
{
"startOffset": 8808,
"endOffset": 9180,
"count": 2
},
{
"startOffset": 8889,
"endOffset": 8933,
"count": 0
},
{
"startOffset": 8969,
"endOffset": 8989,
"count": 0
},
{
"startOffset": 8991,
"endOffset": 9069,
"count": 0
},
{
"startOffset": 9080,
"endOffset": 9163,
"count": 0
},
{
"startOffset": 9178,
"endOffset": 9179,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "Writable.write",
"ranges": [
{
"startOffset": 9209,
"endOffset": 9927,
"count": 2
},
{
"startOffset": 9372,
"endOffset": 9424,
"count": 0
},
{
"startOffset": 9426,
"endOffset": 9478,
"count": 0
},
{
"startOffset": 9582,
"endOffset": 9602,
"count": 0
},
{
"startOffset": 9700,
"endOffset": 9709,
"count": 0
},
{
"startOffset": 9735,
"endOffset": 9759,
"count": 0
},
{
"startOffset": 9925,
"endOffset": 9926,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "Writable.cork",
"ranges": [
{
"startOffset": 9956,
"endOffset": 10002,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Writable.uncork",
"ranges": [
{
"startOffset": 10033,
"endOffset": 10279,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "setDefaultEncoding",
"ranges": [
{
"startOffset": 10322,
"endOffset": 10633,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 10860,
"endOffset": 10943,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "decodeChunk",
"ranges": [
{
"startOffset": 10949,
"endOffset": 11160,
"count": 2
},
{
"startOffset": 11059,
"endOffset": 11093,
"count": 0
},
{
"startOffset": 11095,
"endOffset": 11142,
"count": 0
},
{
"startOffset": 11158,
"endOffset": 11159,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 11393,
"endOffset": 11455,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "writeOrBuffer",
"ranges": [
{
"startOffset": 11648,
"endOffset": 12601,
"count": 2
},
{
"startOffset": 11816,
"endOffset": 11894,
"count": 0
},
{
"startOffset": 11928,
"endOffset": 11931,
"count": 0
},
{
"startOffset": 12109,
"endOffset": 12132,
"count": 0
},
{
"startOffset": 12171,
"endOffset": 12512,
"count": 0
},
{
"startOffset": 12599,
"endOffset": 12600,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "doWrite",
"ranges": [
{
"startOffset": 12603,
"endOffset": 12981,
"count": 2
},
{
"startOffset": 12789,
"endOffset": 12838,
"count": 0
},
{
"startOffset": 12862,
"endOffset": 12899,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "onwriteError",
"ranges": [
{
"startOffset": 12983,
"endOffset": 13690,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "onwriteStateUpdate",
"ranges": [
{
"startOffset": 13692,
"endOffset": 13835,
"count": 2
}
],
"isBlockCoverage": true
},
{
"functionName": "onwrite",
"ranges": [
{
"startOffset": 13837,
"endOffset": 14538,
"count": 2
},
{
"startOffset": 13993,
"endOffset": 14027,
"count": 0
},
{
"startOffset": 14073,
"endOffset": 14115,
"count": 0
},
{
"startOffset": 14343,
"endOffset": 14384,
"count": 0
},
{
"startOffset": 14472,
"endOffset": 14532,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "afterWrite",
"ranges": [
{
"startOffset": 14540,
"endOffset": 14701,
"count": 2
}
],
"isBlockCoverage": true
},
{
"functionName": "onwriteDrain",
"ranges": [
{
"startOffset": 14894,
"endOffset": 15040,
"count": 2
},
{
"startOffset": 14978,
"endOffset": 15038,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "clearBuffer",
"ranges": [
{
"startOffset": 15105,
"endOffset": 17051,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Writable._write",
"ranges": [
{
"startOffset": 17081,
"endOffset": 17164,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Writable.end",
"ranges": [
{
"startOffset": 17228,
"endOffset": 17762,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 17984,
"endOffset": 18034,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "needFinish",
"ranges": [
{
"startOffset": 18040,
"endOffset": 18228,
"count": 4
},
{
"startOffset": 18092,
"endOffset": 18123,
"count": 0
},
{
"startOffset": 18124,
"endOffset": 18167,
"count": 0
},
{
"startOffset": 18168,
"endOffset": 18196,
"count": 0
},
{
"startOffset": 18197,
"endOffset": 18224,
"count": 0
},
{
"startOffset": 18226,
"endOffset": 18227,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "callFinal",
"ranges": [
{
"startOffset": 18229,
"endOffset": 18468,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "prefinish",
"ranges": [
{
"startOffset": 18469,
"endOffset": 18817,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "finishMaybe",
"ranges": [
{
"startOffset": 18819,
"endOffset": 19050,
"count": 2
},
{
"startOffset": 18901,
"endOffset": 19033,
"count": 0
},
{
"startOffset": 19048,
"endOffset": 19049,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "endWritable",
"ranges": [
{
"startOffset": 19052,
"endOffset": 19307,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "onCorkedFinish",
"ranges": [
{
"startOffset": 19309,
"endOffset": 19594,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 19810,
"endOffset": 19934,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "set",
"ranges": [
{
"startOffset": 19938,
"endOffset": 20207,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Writable._destroy",
"ranges": [
{
"startOffset": 20348,
"endOffset": 20380,
"count": 0
}
],
"isBlockCoverage": false
}
]
},
{
"url": "assert.js",
"source": "(function (exports, require, module, process) {// Originally from narwhal.js (http://narwhaljs.org)\n// Copyright (c) 2009 Thomas Robinson <280north.com>\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the 'Software'), to\n// deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n// sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nconst { Buffer } = require('buffer');\nconst { codes: {\n ERR_AMBIGUOUS_ARGUMENT,\n ERR_INVALID_ARG_TYPE,\n ERR_INVALID_RETURN_VALUE\n} } = require('internal/errors');\nconst { AssertionError, errorCache } = require('internal/assert');\nconst { openSync, closeSync, readSync } = require('fs');\nconst { inspect, types: { isPromise, isRegExp } } = require('util');\nconst { EOL } = require('internal/constants');\nconst { NativeModule } = require('internal/bootstrap/loaders');\n\nlet isDeepEqual;\nlet isDeepStrictEqual;\nlet parseExpressionAt;\nlet findNodeAround;\nlet columnOffset = 0;\nlet decoder;\n\nfunction lazyLoadComparison() {\n const comparison = require('internal/util/comparisons');\n isDeepEqual = comparison.isDeepEqual;\n isDeepStrictEqual = comparison.isDeepStrictEqual;\n}\n\n// Escape control characters but not \\n and \\t to keep the line breaks and\n// indentation intact.\n// eslint-disable-next-line no-control-regex\nconst escapeSequencesRegExp = /[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/g;\nconst meta = [\n '\\\\u0000', '\\\\u0001', '\\\\u0002', '\\\\u0003', '\\\\u0004',\n '\\\\u0005', '\\\\u0006', '\\\\u0007', '\\\\b', '',\n '', '\\\\u000b', '\\\\f', '', '\\\\u000e',\n '\\\\u000f', '\\\\u0010', '\\\\u0011', '\\\\u0012', '\\\\u0013',\n '\\\\u0014', '\\\\u0015', '\\\\u0016', '\\\\u0017', '\\\\u0018',\n '\\\\u0019', '\\\\u001a', '\\\\u001b', '\\\\u001c', '\\\\u001d',\n '\\\\u001e', '\\\\u001f'\n];\n\nconst escapeFn = (str) => meta[str.charCodeAt(0)];\n\nlet warned = false;\n\n// The assert module provides functions that throw\n// AssertionError's when particular conditions are not met. The\n// assert module must conform to the following interface.\n\nconst assert = module.exports = ok;\n\nconst NO_EXCEPTION_SENTINEL = {};\n\n// All of the following functions must throw an AssertionError\n// when a corresponding condition is not met, with a message that\n// may be undefined if not provided. All assertion methods provide\n// both the actual and expected values to the assertion error for\n// display purposes.\n\nfunction innerFail(obj) {\n if (obj.message instanceof Error) throw obj.message;\n\n throw new AssertionError(obj);\n}\n\nfunction fail(actual, expected, message, operator, stackStartFn) {\n const argsLen = arguments.length;\n\n if (argsLen === 0) {\n message = 'Failed';\n } else if (argsLen === 1) {\n message = actual;\n actual = undefined;\n } else {\n if (warned === false) {\n warned = true;\n process.emitWarning(\n 'assert.fail() with more than one argument is deprecated. ' +\n 'Please use assert.strictEqual() instead or only pass a message.',\n 'DeprecationWarning',\n 'DEP0094'\n );\n }\n if (argsLen === 2)\n operator = '!=';\n }\n\n innerFail({\n actual,\n expected,\n message,\n operator,\n stackStartFn: stackStartFn || fail\n });\n}\n\nassert.fail = fail;\n\n// The AssertionError is defined in internal/error.\nassert.AssertionError = AssertionError;\n\nfunction findColumn(fd, column, code) {\n if (code.length > column + 100) {\n try {\n return parseCode(code, column);\n } catch {\n // End recursion in case no code could be parsed. The expression should\n // have been found after 2500 characters, so stop trying.\n if (code.length - column > 2500) {\n // eslint-disable-next-line no-throw-literal\n throw null;\n }\n }\n }\n // Read up to 2500 bytes more than necessary in columns. That way we address\n // multi byte characters and read enough data to parse the code.\n const bytesToRead = column - code.length + 2500;\n const buffer = Buffer.allocUnsafe(bytesToRead);\n const bytesRead = readSync(fd, buffer, 0, bytesToRead);\n code += decoder.write(buffer.slice(0, bytesRead));\n // EOF: fast path.\n if (bytesRead < bytesToRead) {\n return parseCode(code, column);\n }\n // Read potentially missing code.\n return findColumn(fd, column, code);\n}\n\nfunction getCode(fd, line, column) {\n let bytesRead = 0;\n if (line === 0) {\n // Special handle line number one. This is more efficient and simplifies the\n // rest of the algorithm. Read more than the regular column number in bytes\n // to prevent multiple reads in case multi byte characters are used.\n return findColumn(fd, column, '');\n }\n let lines = 0;\n // Prevent blocking the event loop by limiting the maximum amount of\n // data that may be read.\n let maxReads = 64; // bytesPerRead * maxReads = 512 kb\n const bytesPerRead = 8192;\n // Use a single buffer up front that is reused until the call site is found.\n let buffer = Buffer.allocUnsafe(bytesPerRead);\n while (maxReads-- !== 0) {\n // Only allocate a new buffer in case the needed line is found. All data\n // before that can be discarded.\n buffer = lines < line ? buffer : Buffer.allocUnsafe(bytesPerRead);\n bytesRead = readSync(fd, buffer, 0, bytesPerRead);\n // Read the buffer until the required code line is found.\n for (var i = 0; i < bytesRead; i++) {\n if (buffer[i] === 10 && ++lines === line) {\n // If the end of file is reached, directly parse the code and return.\n if (bytesRead < bytesPerRead) {\n return parseCode(buffer.toString('utf8', i + 1, bytesRead), column);\n }\n // Check if the read code is sufficient or read more until the whole\n // expression is read. Make sure multi byte characters are preserved\n // properly by using the decoder.\n const code = decoder.write(buffer.slice(i + 1, bytesRead));\n return findColumn(fd, column, code);\n }\n }\n }\n}\n\nfunction parseCode(code, offset) {\n // Lazy load acorn.\n if (parseExpressionAt === undefined) {\n ({ parseExpressionAt } = require('internal/deps/acorn/dist/acorn'));\n ({ findNodeAround } = require('internal/deps/acorn/dist/walk'));\n }\n let node;\n let start = 0;\n // Parse the read code until the correct expression is found.\n do {\n try {\n node = parseExpressionAt(code, start);\n start = node.end + 1 || start;\n // Find the CallExpression in the tree.\n node = findNodeAround(node, offset, 'CallExpression');\n } catch (err) {\n // Unexpected token error and the like.\n start += err.raisedAt || 1;\n if (start > offset) {\n // No matching expression found. This could happen if the assert\n // expression is bigger than the provided buffer.\n // eslint-disable-next-line no-throw-literal\n throw null;\n }\n }\n } while (node === undefined || node.node.end < offset);\n\n return [\n node.node.start,\n code.slice(node.node.start, node.node.end)\n .replace(escapeSequencesRegExp, escapeFn)\n ];\n}\n\nfunction getErrMessage(message, fn) {\n const tmpLimit = Error.stackTraceLimit;\n // Make sure the limit is set to 1. Otherwise it could fail (<= 0) or it\n // does to much work.\n Error.stackTraceLimit = 1;\n // We only need the stack trace. To minimize the overhead use an object\n // instead of an error.\n const err = {};\n Error.captureStackTrace(err, fn);\n Error.stackTraceLimit = tmpLimit;\n\n const tmpPrepare = Error.prepareStackTrace;\n Error.prepareStackTrace = (_, stack) => stack;\n const call = err.stack[0];\n Error.prepareStackTrace = tmpPrepare;\n\n const filename = call.getFileName();\n\n if (!filename) {\n return message;\n }\n\n const line = call.getLineNumber() - 1;\n let column = call.getColumnNumber() - 1;\n\n // Line number one reports the wrong column due to being wrapped in a\n // function. Remove that offset to get the actual call.\n if (line === 0) {\n if (columnOffset === 0) {\n const { wrapper } = require('internal/modules/cjs/loader');\n columnOffset = wrapper[0].length;\n }\n column -= columnOffset;\n }\n\n const identifier = `${filename}${line}${column}`;\n\n if (errorCache.has(identifier)) {\n return errorCache.get(identifier);\n }\n\n // Skip Node.js modules!\n if (filename.endsWith('.js') && NativeModule.exists(filename.slice(0, -3))) {\n errorCache.set(identifier, undefined);\n return;\n }\n\n let fd;\n try {\n // Set the stack trace limit to zero. This makes sure unexpected token\n // errors are handled faster.\n Error.stackTraceLimit = 0;\n\n if (decoder === undefined) {\n const { StringDecoder } = require('string_decoder');\n decoder = new StringDecoder('utf8');\n }\n\n fd = openSync(filename, 'r', 0o666);\n // Reset column and message.\n [column, message] = getCode(fd, line, column);\n // Flush unfinished multi byte characters.\n decoder.end();\n // Always normalize indentation, otherwise the message could look weird.\n if (message.indexOf('\\n') !== -1) {\n if (EOL === '\\r\\n') {\n message = message.replace(/\\r\\n/g, '\\n');\n }\n const frames = message.split('\\n');\n message = frames.shift();\n for (const frame of frames) {\n let pos = 0;\n while (pos < column && (frame[pos] === ' ' || frame[pos] === '\\t')) {\n pos++;\n }\n message += `\\n ${frame.slice(pos)}`;\n }\n }\n message = `The expression evaluated to a falsy value:\\n\\n ${message}\\n`;\n // Make sure to always set the cache! No matter if the message is\n // undefined or not\n errorCache.set(identifier, message);\n\n return message;\n } catch (e) {\n // Invalidate cache to prevent trying to read this part again.\n errorCache.set(identifier, undefined);\n } finally {\n // Reset limit.\n Error.stackTraceLimit = tmpLimit;\n if (fd !== undefined)\n closeSync(fd);\n }\n}\n\nfunction innerOk(fn, argLen, value, message) {\n if (!value) {\n let generatedMessage = false;\n\n if (argLen === 0) {\n generatedMessage = true;\n message = 'No value argument passed to `assert.ok()`';\n } else if (message == null) {\n generatedMessage = true;\n message = getErrMessage(message, fn);\n } else if (message instanceof Error) {\n throw message;\n }\n\n const err = new AssertionError({\n actual: value,\n expected: true,\n message,\n operator: '==',\n stackStartFn: fn\n });\n err.generatedMessage = generatedMessage;\n throw err;\n }\n}\n\n// Pure assertion tests whether a value is truthy, as determined\n// by !!value.\nfunction ok(...args) {\n innerOk(ok, args.length, ...args);\n}\nassert.ok = ok;\n\n// The equality assertion tests shallow, coercive equality with ==.\n/* eslint-disable no-restricted-properties */\nassert.equal = function equal(actual, expected, message) {\n // eslint-disable-next-line eqeqeq\n if (actual != expected) {\n innerFail({\n actual,\n expected,\n message,\n operator: '==',\n stackStartFn: equal\n });\n }\n};\n\n// The non-equality assertion tests for whether two objects are not\n// equal with !=.\nassert.notEqual = function notEqual(actual, expected, message) {\n // eslint-disable-next-line eqeqeq\n if (actual == expected) {\n innerFail({\n actual,\n expected,\n message,\n operator: '!=',\n stackStartFn: notEqual\n });\n }\n};\n\n// The equivalence assertion tests a deep equality relation.\nassert.deepEqual = function deepEqual(actual, expected, message) {\n if (isDeepEqual === undefined) lazyLoadComparison();\n if (!isDeepEqual(actual, expected)) {\n innerFail({\n actual,\n expected,\n message,\n operator: 'deepEqual',\n stackStartFn: deepEqual\n });\n }\n};\n\n// The non-equivalence assertion tests for any deep inequality.\nassert.notDeepEqual = function notDeepEqual(actual, expected, message) {\n if (isDeepEqual === undefined) lazyLoadComparison();\n if (isDeepEqual(actual, expected)) {\n innerFail({\n actual,\n expected,\n message,\n operator: 'notDeepEqual',\n stackStartFn: notDeepEqual\n });\n }\n};\n/* eslint-enable */\n\nassert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {\n if (isDeepEqual === undefined) lazyLoadComparison();\n if (!isDeepStrictEqual(actual, expected)) {\n innerFail({\n actual,\n expected,\n message,\n operator: 'deepStrictEqual',\n stackStartFn: deepStrictEqual\n });\n }\n};\n\nassert.notDeepStrictEqual = notDeepStrictEqual;\nfunction notDeepStrictEqual(actual, expected, message) {\n if (isDeepEqual === undefined) lazyLoadComparison();\n if (isDeepStrictEqual(actual, expected)) {\n innerFail({\n actual,\n expected,\n message,\n operator: 'notDeepStrictEqual',\n stackStartFn: notDeepStrictEqual\n });\n }\n}\n\nassert.strictEqual = function strictEqual(actual, expected, message) {\n if (!Object.is(actual, expected)) {\n innerFail({\n actual,\n expected,\n message,\n operator: 'strictEqual',\n stackStartFn: strictEqual\n });\n }\n};\n\nassert.notStrictEqual = function notStrictEqual(actual, expected, message) {\n if (Object.is(actual, expected)) {\n innerFail({\n actual,\n expected,\n message,\n operator: 'notStrictEqual',\n stackStartFn: notStrictEqual\n });\n }\n};\n\nclass Comparison {\n constructor(obj, keys, actual) {\n for (const key of keys) {\n if (key in obj) {\n if (actual !== undefined &&\n typeof actual[key] === 'string' &&\n isRegExp(obj[key]) &&\n obj[key].test(actual[key])) {\n this[key] = actual[key];\n } else {\n this[key] = obj[key];\n }\n }\n }\n }\n}\n\nfunction compareExceptionKey(actual, expected, key, message, keys) {\n if (!(key in actual) || !isDeepStrictEqual(actual[key], expected[key])) {\n if (!message) {\n // Create placeholder objects to create a nice output.\n const a = new Comparison(actual, keys);\n const b = new Comparison(expected, keys, actual);\n\n const err = new AssertionError({\n actual: a,\n expected: b,\n operator: 'deepStrictEqual',\n stackStartFn: assert.throws\n });\n err.actual = actual;\n err.expected = expected;\n err.operator = 'throws';\n throw err;\n }\n innerFail({\n actual,\n expected,\n message,\n operator: 'throws',\n stackStartFn: assert.throws\n });\n }\n}\n\nfunction expectedException(actual, expected, msg) {\n if (typeof expected !== 'function') {\n if (isRegExp(expected))\n return expected.test(actual);\n // assert.doesNotThrow does not accept objects.\n if (arguments.length === 2) {\n throw new ERR_INVALID_ARG_TYPE(\n 'expected', ['Function', 'RegExp'], expected\n );\n }\n\n // TODO: Disallow primitives as error argument.\n // This is here to prevent a breaking change.\n if (typeof expected !== 'object') {\n return true;\n }\n\n // Handle primitives properly.\n if (typeof actual !== 'object' || actual === null) {\n const err = new AssertionError({\n actual,\n expected,\n message: msg,\n operator: 'deepStrictEqual',\n stackStartFn: assert.throws\n });\n err.operator = 'throws';\n throw err;\n }\n\n const keys = Object.keys(expected);\n // Special handle errors to make sure the name and the message are compared\n // as well.\n if (expected instanceof Error) {\n keys.push('name', 'message');\n }\n if (isDeepEqual === undefined) lazyLoadComparison();\n for (const key of keys) {\n if (typeof actual[key] === 'string' &&\n isRegExp(expected[key]) &&\n expected[key].test(actual[key])) {\n continue;\n }\n compareExceptionKey(actual, expected, key, msg, keys);\n }\n return true;\n }\n // Guard instanceof against arrow functions as they don't have a prototype.\n if (expected.prototype !== undefined && actual instanceof expected) {\n return true;\n }\n if (Error.isPrototypeOf(expected)) {\n return false;\n }\n return expected.call({}, actual) === true;\n}\n\nfunction getActual(block) {\n if (typeof block !== 'function') {\n throw new ERR_INVALID_ARG_TYPE('block', 'Function', block);\n }\n try {\n block();\n } catch (e) {\n return e;\n }\n return NO_EXCEPTION_SENTINEL;\n}\n\nfunction checkIsPromise(obj) {\n // Accept native ES6 promises and promises that are implemented in a similar\n // way. Do not accept thenables that use a function as `obj` and that have no\n // `catch` handler.\n return isPromise(obj) ||\n obj !== null && typeof obj === 'object' &&\n typeof obj.then === 'function' &&\n typeof obj.catch === 'function';\n}\n\nasync function waitForActual(block) {\n let resultPromise;\n if (typeof block === 'function') {\n // Return a rejected promise if `block` throws synchronously.\n resultPromise = block();\n // Fail in case no promise is returned.\n if (!checkIsPromise(resultPromise)) {\n throw new ERR_INVALID_RETURN_VALUE('instance of Promise',\n 'block', resultPromise);\n }\n } else if (checkIsPromise(block)) {\n resultPromise = block;\n } else {\n throw new ERR_INVALID_ARG_TYPE('block', ['Function', 'Promise'], block);\n }\n\n try {\n await resultPromise;\n } catch (e) {\n return e;\n }\n return NO_EXCEPTION_SENTINEL;\n}\n\nfunction expectsError(stackStartFn, actual, error, message) {\n if (typeof error === 'string') {\n if (arguments.length === 4) {\n throw new ERR_INVALID_ARG_TYPE('error',\n ['Object', 'Error', 'Function', 'RegExp'],\n error);\n }\n if (typeof actual === 'object' && actual !== null) {\n if (actual.message === error) {\n throw new ERR_AMBIGUOUS_ARGUMENT(\n 'error/message',\n `The error message \"${actual.message}\" is identical to the message.`\n );\n }\n } else if (actual === error) {\n throw new ERR_AMBIGUOUS_ARGUMENT(\n 'error/message',\n `The error \"${actual}\" is identical to the message.`\n );\n }\n message = error;\n error = undefined;\n }\n\n if (actual === NO_EXCEPTION_SENTINEL) {\n let details = '';\n if (error && error.name) {\n details += ` (${error.name})`;\n }\n details += message ? `: ${message}` : '.';\n const fnType = stackStartFn.name === 'rejects' ? 'rejection' : 'exception';\n innerFail({\n actual: undefined,\n expected: error,\n operator: stackStartFn.name,\n message: `Missing expected ${fnType}${details}`,\n stackStartFn\n });\n }\n if (error && expectedException(actual, error, message) === false) {\n throw actual;\n }\n}\n\nfunction expectsNoError(stackStartFn, actual, error, message) {\n if (actual === NO_EXCEPTION_SENTINEL)\n return;\n\n if (typeof error === 'string') {\n message = error;\n error = undefined;\n }\n\n if (!error || expectedException(actual, error)) {\n const details = message ? `: ${message}` : '.';\n const fnType = stackStartFn.name === 'doesNotReject' ?\n 'rejection' : 'exception';\n innerFail({\n actual,\n expected: error,\n operator: stackStartFn.name,\n message: `Got unwanted ${fnType}${details}\\n` +\n `Actual message: \"${actual && actual.message}\"`,\n stackStartFn\n });\n }\n throw actual;\n}\n\nassert.throws = function throws(block, ...args) {\n expectsError(throws, getActual(block), ...args);\n};\n\nassert.rejects = async function rejects(block, ...args) {\n expectsError(rejects, await waitForActual(block), ...args);\n};\n\nassert.doesNotThrow = function doesNotThrow(block, ...args) {\n expectsNoError(doesNotThrow, getActual(block), ...args);\n};\n\nassert.doesNotReject = async function doesNotReject(block, ...args) {\n expectsNoError(doesNotReject, await waitForActual(block), ...args);\n};\n\nassert.ifError = function ifError(err) {\n if (err !== null && err !== undefined) {\n let message = 'ifError got unwanted exception: ';\n if (typeof err === 'object' && typeof err.message === 'string') {\n if (err.message.length === 0 && err.constructor) {\n message += err.constructor.name;\n } else {\n message += err.message;\n }\n } else {\n message += inspect(err);\n }\n\n const newErr = new AssertionError({\n actual: err,\n expected: null,\n operator: 'ifError',\n message,\n stackStartFn: ifError\n });\n\n // Make sure we actually have a stack trace!\n const origStack = err.stack;\n\n if (typeof origStack === 'string') {\n // This will remove any duplicated frames from the error frames taken\n // from within `ifError` and add the original error frames to the newly\n // created ones.\n const tmp2 = origStack.split('\\n');\n tmp2.shift();\n // Filter all frames existing in err.stack.\n let tmp1 = newErr.stack.split('\\n');\n for (var i = 0; i < tmp2.length; i++) {\n // Find the first occurrence of the frame.\n const pos = tmp1.indexOf(tmp2[i]);\n if (pos !== -1) {\n // Only keep new frames.\n tmp1 = tmp1.slice(0, pos);\n break;\n }\n }\n newErr.stack = `${tmp1.join('\\n')}\\n${tmp2.join('\\n')}`;\n }\n\n throw newErr;\n }\n};\n\n// Expose a strict only variant of assert\nfunction strict(...args) {\n innerOk(strict, args.length, ...args);\n}\nassert.strict = Object.assign(strict, assert, {\n equal: assert.strictEqual,\n deepEqual: assert.deepStrictEqual,\n notEqual: assert.notStrictEqual,\n notDeepEqual: assert.notDeepStrictEqual\n});\nassert.strict.strict = assert.strict;\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 22292,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 1,
"endOffset": 22290,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "lazyLoadComparison",
"ranges": [
{
"startOffset": 1810,
"endOffset": 1994,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "escapeFn",
"ranges": [
{
"startOffset": 2574,
"endOffset": 2606,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "innerFail",
"ranges": [
{
"startOffset": 3160,
"endOffset": 3276,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "fail",
"ranges": [
{
"startOffset": 3278,
"endOffset": 3966,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "findColumn",
"ranges": [
{
"startOffset": 4082,
"endOffset": 5022,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "getCode",
"ranges": [
{
"startOffset": 5024,
"endOffset": 6667,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "parseCode",
"ranges": [
{
"startOffset": 6669,
"endOffset": 7752,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "getErrMessage",
"ranges": [
{
"startOffset": 7754,
"endOffset": 10585,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "innerOk",
"ranges": [
{
"startOffset": 10587,
"endOffset": 11194,
"count": 3
},
{
"startOffset": 10648,
"endOffset": 11192,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "ok",
"ranges": [
{
"startOffset": 11276,
"endOffset": 11337,
"count": 3
}
],
"isBlockCoverage": true
},
{
"functionName": "equal",
"ranges": [
{
"startOffset": 11484,
"endOffset": 11715,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "notEqual",
"ranges": [
{
"startOffset": 11822,
"endOffset": 12059,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "deepEqual",
"ranges": [
{
"startOffset": 12142,
"endOffset": 12418,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "notDeepEqual",
"ranges": [
{
"startOffset": 12507,
"endOffset": 12791,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "deepStrictEqual",
"ranges": [
{
"startOffset": 12839,
"endOffset": 13139,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "notDeepStrictEqual",
"ranges": [
{
"startOffset": 13190,
"endOffset": 13498,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "strictEqual",
"ranges": [
{
"startOffset": 13521,
"endOffset": 13746,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "notStrictEqual",
"ranges": [
{
"startOffset": 13773,
"endOffset": 14006,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Comparison",
"ranges": [
{
"startOffset": 14030,
"endOffset": 14387,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "compareExceptionKey",
"ranges": [
{
"startOffset": 14391,
"endOffset": 15128,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "expectedException",
"ranges": [
{
"startOffset": 15130,
"endOffset": 16793,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "getActual",
"ranges": [
{
"startOffset": 16795,
"endOffset": 17016,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "checkIsPromise",
"ranges": [
{
"startOffset": 17018,
"endOffset": 17380,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "waitForActual",
"ranges": [
{
"startOffset": 17382,
"endOffset": 18053,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "expectsError",
"ranges": [
{
"startOffset": 18055,
"endOffset": 19393,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "expectsNoError",
"ranges": [
{
"startOffset": 19395,
"endOffset": 20046,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "throws",
"ranges": [
{
"startOffset": 20064,
"endOffset": 20150,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "rejects",
"ranges": [
{
"startOffset": 20170,
"endOffset": 20274,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "doesNotThrow",
"ranges": [
{
"startOffset": 20299,
"endOffset": 20399,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "doesNotReject",
"ranges": [
{
"startOffset": 20425,
"endOffset": 20543,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "ifError",
"ranges": [
{
"startOffset": 20563,
"endOffset": 21940,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "strict",
"ranges": [
{
"startOffset": 21985,
"endOffset": 22054,
"count": 0
}
],
"isBlockCoverage": false
}
]
},
{
"url": "buffer.js",
"source": "(function (exports, require, module, process) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// 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 OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nconst {\n byteLengthUtf8,\n copy: _copy,\n compare: _compare,\n compareOffset,\n createFromString,\n fill: bindingFill,\n indexOfBuffer,\n indexOfNumber,\n indexOfString,\n swap16: _swap16,\n swap32: _swap32,\n swap64: _swap64,\n kMaxLength,\n kStringMaxLength\n} = process.binding('buffer');\n// We cannot use internalBinding unconditionally here because of the way\n// that test/parallel/test-buffer-bindingobj-no-zerofill.js is written.\nlet isAnyArrayBuffer;\ntry {\n const { internalBinding } = require('internal/bootstrap/loaders');\n isAnyArrayBuffer = internalBinding('types').isAnyArrayBuffer;\n} catch (e) {\n isAnyArrayBuffer = require('util').types.isAnyArrayBuffer;\n}\nconst {\n customInspectSymbol,\n isInsideNodeModules,\n normalizeEncoding,\n kIsEncodingSymbol\n} = require('internal/util');\nconst {\n isArrayBufferView,\n isUint8Array\n} = require('internal/util/types');\nconst {\n pendingDeprecation\n} = process.binding('config');\nconst {\n ERR_BUFFER_OUT_OF_BOUNDS,\n ERR_INDEX_OUT_OF_RANGE,\n ERR_INVALID_ARG_TYPE,\n ERR_INVALID_ARG_VALUE,\n ERR_INVALID_BUFFER_SIZE,\n ERR_INVALID_OPT_VALUE,\n ERR_NO_LONGER_SUPPORTED,\n ERR_UNKNOWN_ENCODING\n} = require('internal/errors').codes;\nconst { validateString } = require('internal/validators');\n\nconst internalBuffer = require('internal/buffer');\n\nconst { setupBufferJS } = internalBuffer;\n\nconst bindingObj = {};\n\nclass FastBuffer extends Uint8Array {}\nFastBuffer.prototype.constructor = Buffer;\ninternalBuffer.FastBuffer = FastBuffer;\n\nBuffer.prototype = FastBuffer.prototype;\n\nfor (const [name, method] of Object.entries(internalBuffer.readWrites)) {\n Buffer.prototype[name] = method;\n}\n\nconst constants = Object.defineProperties({}, {\n MAX_LENGTH: {\n value: kMaxLength,\n writable: false,\n enumerable: true\n },\n MAX_STRING_LENGTH: {\n value: kStringMaxLength,\n writable: false,\n enumerable: true\n }\n});\n\nBuffer.poolSize = 8 * 1024;\nvar poolSize, poolOffset, allocPool;\n\nsetupBufferJS(Buffer.prototype, bindingObj);\n\n// |zeroFill| can be undefined when running inside an isolate where we\n// do not own the ArrayBuffer allocator. Zero fill is always on in that case.\nconst zeroFill = bindingObj.zeroFill || [0];\n\nfunction createUnsafeBuffer(size) {\n return new FastBuffer(createUnsafeArrayBuffer(size));\n}\n\nfunction createUnsafeArrayBuffer(size) {\n zeroFill[0] = 0;\n try {\n return new ArrayBuffer(size);\n } finally {\n zeroFill[0] = 1;\n }\n}\n\nfunction createPool() {\n poolSize = Buffer.poolSize;\n allocPool = createUnsafeArrayBuffer(poolSize);\n poolOffset = 0;\n}\ncreatePool();\n\nfunction alignPool() {\n // Ensure aligned slices\n if (poolOffset & 0x7) {\n poolOffset |= 0x7;\n poolOffset++;\n }\n}\n\nlet bufferWarningAlreadyEmitted = false;\nlet nodeModulesCheckCounter = 0;\nconst bufferWarning = 'Buffer() is deprecated due to security and usability ' +\n 'issues. Please use the Buffer.alloc(), ' +\n 'Buffer.allocUnsafe(), or Buffer.from() methods instead.';\n\nfunction showFlaggedDeprecation() {\n if (bufferWarningAlreadyEmitted ||\n ++nodeModulesCheckCounter > 10000 ||\n (!pendingDeprecation &&\n isInsideNodeModules())) {\n // We don't emit a warning, because we either:\n // - Already did so, or\n // - Already checked too many times whether a call is coming\n // from node_modules and want to stop slowing down things, or\n // - We aren't running with `--pending-deprecation` enabled,\n // and the code is inside `node_modules`.\n return;\n }\n\n process.emitWarning(bufferWarning, 'DeprecationWarning', 'DEP0005');\n bufferWarningAlreadyEmitted = true;\n}\n\n/**\n * The Buffer() constructor is deprecated in documentation and should not be\n * used moving forward. Rather, developers should use one of the three new\n * factory APIs: Buffer.from(), Buffer.allocUnsafe() or Buffer.alloc() based on\n * their specific needs. There is no runtime deprecation because of the extent\n * to which the Buffer constructor is used in the ecosystem currently -- a\n * runtime deprecation would introduce too much breakage at this time. It's not\n * likely that the Buffer constructors would ever actually be removed.\n * Deprecation Code: DEP0005\n */\nfunction Buffer(arg, encodingOrOffset, length) {\n showFlaggedDeprecation();\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new ERR_INVALID_ARG_TYPE('string', 'string', arg);\n }\n return Buffer.alloc(arg);\n }\n return Buffer.from(arg, encodingOrOffset, length);\n}\n\nObject.defineProperty(Buffer, Symbol.species, {\n enumerable: false,\n configurable: true,\n get() { return FastBuffer; }\n});\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n */\nBuffer.from = function from(value, encodingOrOffset, length) {\n if (typeof value === 'string')\n return fromString(value, encodingOrOffset);\n\n if (isAnyArrayBuffer(value))\n return fromArrayBuffer(value, encodingOrOffset, length);\n\n if (value === null || value === undefined) {\n throw new ERR_INVALID_ARG_TYPE(\n 'first argument',\n ['string', 'Buffer', 'ArrayBuffer', 'Array', 'Array-like Object'],\n value\n );\n }\n\n if (typeof value === 'number') {\n throw new ERR_INVALID_ARG_TYPE('value', 'not number', value);\n }\n\n const valueOf = value.valueOf && value.valueOf();\n if (valueOf !== null && valueOf !== undefined && valueOf !== value)\n return Buffer.from(valueOf, encodingOrOffset, length);\n\n var b = fromObject(value);\n if (b)\n return b;\n\n if (typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(value[Symbol.toPrimitive]('string'),\n encodingOrOffset,\n length);\n }\n\n throw new ERR_INVALID_ARG_TYPE(\n 'first argument',\n ['string', 'Buffer', 'ArrayBuffer', 'Array', 'Array-like Object'],\n value\n );\n};\n\n// Identical to the built-in %TypedArray%.of(), but avoids using the deprecated\n// Buffer() constructor. Must use arrow function syntax to avoid automatically\n// adding a `prototype` property and making the function a constructor.\n//\n// Refs: https://tc39.github.io/ecma262/#sec-%typedarray%.of\n// Refs: https://esdiscuss.org/topic/isconstructor#content-11\nconst of = (...items) => {\n const newObj = createUnsafeBuffer(items.length);\n for (var k = 0; k < items.length; k++)\n newObj[k] = items[k];\n return newObj;\n};\nBuffer.of = of;\n\nObject.setPrototypeOf(Buffer, Uint8Array);\n\n// The 'assertSize' method will remove itself from the callstack when an error\n// occurs. This is done simply to keep the internal details of the\n// implementation from bleeding out to users.\nfunction assertSize(size) {\n let err = null;\n\n if (typeof size !== 'number') {\n err = new ERR_INVALID_ARG_TYPE('size', 'number', size);\n } else if (size < 0 || size > kMaxLength) {\n err = new ERR_INVALID_OPT_VALUE.RangeError('size', size);\n }\n\n if (err !== null) {\n Error.captureStackTrace(err, assertSize);\n throw err;\n }\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n */\nBuffer.alloc = function alloc(size, fill, encoding) {\n assertSize(size);\n if (fill !== undefined && fill !== 0 && size > 0) {\n const buf = createUnsafeBuffer(size);\n return _fill(buf, fill, 0, buf.length, encoding);\n }\n return new FastBuffer(size);\n};\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer\n * instance. If `--zero-fill-buffers` is set, will zero-fill the buffer.\n */\nBuffer.allocUnsafe = function allocUnsafe(size) {\n assertSize(size);\n return allocate(size);\n};\n\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled\n * Buffer instance that is not allocated off the pre-initialized pool.\n * If `--zero-fill-buffers` is set, will zero-fill the buffer.\n */\nBuffer.allocUnsafeSlow = function allocUnsafeSlow(size) {\n assertSize(size);\n return createUnsafeBuffer(size);\n};\n\n// If --zero-fill-buffers command line argument is set, a zero-filled\n// buffer is returned.\nfunction SlowBuffer(length) {\n // eslint-disable-next-line eqeqeq\n if (+length != length)\n length = 0;\n assertSize(+length);\n return createUnsafeBuffer(+length);\n}\n\nObject.setPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);\nObject.setPrototypeOf(SlowBuffer, Uint8Array);\n\nfunction allocate(size) {\n if (size <= 0) {\n return new FastBuffer();\n }\n if (size < (Buffer.poolSize >>> 1)) {\n if (size > (poolSize - poolOffset))\n createPool();\n var b = new FastBuffer(allocPool, poolOffset, size);\n poolOffset += size;\n alignPool();\n return b;\n } else {\n return createUnsafeBuffer(size);\n }\n}\n\nfunction fromString(string, encoding) {\n var length;\n if (typeof encoding !== 'string' || encoding.length === 0) {\n if (string.length === 0)\n return new FastBuffer();\n encoding = 'utf8';\n length = byteLengthUtf8(string);\n } else {\n length = byteLength(string, encoding, true);\n if (length === -1)\n throw new ERR_UNKNOWN_ENCODING(encoding);\n if (string.length === 0)\n return new FastBuffer();\n }\n\n if (length >= (Buffer.poolSize >>> 1))\n return createFromString(string, encoding);\n\n if (length > (poolSize - poolOffset))\n createPool();\n var b = new FastBuffer(allocPool, poolOffset, length);\n const actual = b.write(string, encoding);\n if (actual !== length) {\n // byteLength() may overestimate. That's a rare case, though.\n b = new FastBuffer(allocPool, poolOffset, actual);\n }\n poolOffset += actual;\n alignPool();\n return b;\n}\n\nfunction fromArrayLike(obj) {\n const length = obj.length;\n const b = allocate(length);\n for (var i = 0; i < length; i++)\n b[i] = obj[i];\n return b;\n}\n\nfunction fromArrayBuffer(obj, byteOffset, length) {\n // convert byteOffset to integer\n if (byteOffset === undefined) {\n byteOffset = 0;\n } else {\n byteOffset = +byteOffset;\n if (Number.isNaN(byteOffset))\n byteOffset = 0;\n }\n\n const maxLength = obj.byteLength - byteOffset;\n\n if (maxLength < 0)\n throw new ERR_BUFFER_OUT_OF_BOUNDS('offset');\n\n if (length === undefined) {\n length = maxLength;\n } else {\n // Convert length to non-negative integer.\n length = +length;\n if (length > 0) {\n if (length > maxLength)\n throw new ERR_BUFFER_OUT_OF_BOUNDS('length');\n } else {\n length = 0;\n }\n }\n\n return new FastBuffer(obj, byteOffset, length);\n}\n\nfunction fromObject(obj) {\n if (isUint8Array(obj)) {\n const b = allocate(obj.length);\n\n if (b.length === 0)\n return b;\n\n _copy(obj, b, 0, 0, obj.length);\n return b;\n }\n\n if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) {\n if (typeof obj.length !== 'number') {\n return new FastBuffer();\n }\n return fromArrayLike(obj);\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data);\n }\n}\n\n// Static methods\n\nBuffer.isBuffer = function isBuffer(b) {\n return b instanceof Buffer;\n};\n\nBuffer.compare = function compare(buf1, buf2) {\n if (!isUint8Array(buf1)) {\n throw new ERR_INVALID_ARG_TYPE('buf1', ['Buffer', 'Uint8Array'], buf1);\n }\n\n if (!isUint8Array(buf2)) {\n throw new ERR_INVALID_ARG_TYPE('buf2', ['Buffer', 'Uint8Array'], buf2);\n }\n\n if (buf1 === buf2) {\n return 0;\n }\n\n return _compare(buf1, buf2);\n};\n\nBuffer.isEncoding = function isEncoding(encoding) {\n return typeof encoding === 'string' && encoding.length !== 0 &&\n normalizeEncoding(encoding) !== undefined;\n};\nBuffer[kIsEncodingSymbol] = Buffer.isEncoding;\n\nBuffer.concat = function concat(list, length) {\n var i;\n if (!Array.isArray(list)) {\n throw new ERR_INVALID_ARG_TYPE(\n 'list', ['Array', 'Buffer', 'Uint8Array'], list);\n }\n\n if (list.length === 0)\n return new FastBuffer();\n\n if (length === undefined) {\n length = 0;\n for (i = 0; i < list.length; i++)\n length += list[i].length;\n } else {\n length = length >>> 0;\n }\n\n var buffer = Buffer.allocUnsafe(length);\n var pos = 0;\n for (i = 0; i < list.length; i++) {\n var buf = list[i];\n if (!isUint8Array(buf)) {\n // TODO(BridgeAR): This should not be of type ERR_INVALID_ARG_TYPE.\n // Instead, find the proper error code for this.\n throw new ERR_INVALID_ARG_TYPE(\n `list[${i}]`, ['Array', 'Buffer', 'Uint8Array'], list[i]);\n }\n _copy(buf, buffer, pos);\n pos += buf.length;\n }\n\n // Note: `length` is always equal to `buffer.length` at this point\n if (pos < length) {\n // Zero-fill the remaining bytes if the specified `length` was more than\n // the actual total length, i.e. if we have some remaining allocated bytes\n // there were not initialized.\n buffer.fill(0, pos, length);\n }\n\n return buffer;\n};\n\nfunction base64ByteLength(str, bytes) {\n // Handle padding\n if (str.charCodeAt(bytes - 1) === 0x3D)\n bytes--;\n if (bytes > 1 && str.charCodeAt(bytes - 1) === 0x3D)\n bytes--;\n\n // Base64 ratio: 3/4\n return (bytes * 3) >>> 2;\n}\n\nfunction byteLength(string, encoding) {\n if (typeof string !== 'string') {\n if (isArrayBufferView(string) || isAnyArrayBuffer(string)) {\n return string.byteLength;\n }\n\n throw new ERR_INVALID_ARG_TYPE(\n 'string', ['string', 'Buffer', 'ArrayBuffer'], string\n );\n }\n\n const len = string.length;\n const mustMatch = (arguments.length > 2 && arguments[2] === true);\n if (!mustMatch && len === 0)\n return 0;\n\n if (!encoding)\n return (mustMatch ? -1 : byteLengthUtf8(string));\n\n encoding += '';\n switch (encoding.length) {\n case 4:\n if (encoding === 'utf8') return byteLengthUtf8(string);\n if (encoding === 'ucs2') return len * 2;\n encoding = encoding.toLowerCase();\n if (encoding === 'utf8') return byteLengthUtf8(string);\n if (encoding === 'ucs2') return len * 2;\n break;\n case 5:\n if (encoding === 'utf-8') return byteLengthUtf8(string);\n if (encoding === 'ascii') return len;\n if (encoding === 'ucs-2') return len * 2;\n encoding = encoding.toLowerCase();\n if (encoding === 'utf-8') return byteLengthUtf8(string);\n if (encoding === 'ascii') return len;\n if (encoding === 'ucs-2') return len * 2;\n break;\n case 7:\n if (encoding === 'utf16le' || encoding.toLowerCase() === 'utf16le')\n return len * 2;\n break;\n case 8:\n if (encoding === 'utf-16le' || encoding.toLowerCase() === 'utf-16le')\n return len * 2;\n break;\n case 6:\n if (encoding === 'latin1' || encoding === 'binary') return len;\n if (encoding === 'base64') return base64ByteLength(string, len);\n encoding = encoding.toLowerCase();\n if (encoding === 'latin1' || encoding === 'binary') return len;\n if (encoding === 'base64') return base64ByteLength(string, len);\n break;\n case 3:\n if (encoding === 'hex' || encoding.toLowerCase() === 'hex')\n return len >>> 1;\n break;\n }\n return (mustMatch ? -1 : byteLengthUtf8(string));\n}\n\nBuffer.byteLength = byteLength;\n\n// For backwards compatibility.\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get() {\n if (!(this instanceof Buffer))\n return undefined;\n return this.buffer;\n }\n});\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get() {\n if (!(this instanceof Buffer))\n return undefined;\n return this.byteOffset;\n }\n});\n\nfunction stringSlice(buf, encoding, start, end) {\n if (encoding === undefined) return buf.utf8Slice(start, end);\n encoding += '';\n switch (encoding.length) {\n case 4:\n if (encoding === 'utf8') return buf.utf8Slice(start, end);\n if (encoding === 'ucs2') return buf.ucs2Slice(start, end);\n encoding = encoding.toLowerCase();\n if (encoding === 'utf8') return buf.utf8Slice(start, end);\n if (encoding === 'ucs2') return buf.ucs2Slice(start, end);\n break;\n case 5:\n if (encoding === 'utf-8') return buf.utf8Slice(start, end);\n if (encoding === 'ascii') return buf.asciiSlice(start, end);\n if (encoding === 'ucs-2') return buf.ucs2Slice(start, end);\n encoding = encoding.toLowerCase();\n if (encoding === 'utf-8') return buf.utf8Slice(start, end);\n if (encoding === 'ascii') return buf.asciiSlice(start, end);\n if (encoding === 'ucs-2') return buf.ucs2Slice(start, end);\n break;\n case 6:\n if (encoding === 'latin1' || encoding === 'binary')\n return buf.latin1Slice(start, end);\n if (encoding === 'base64') return buf.base64Slice(start, end);\n encoding = encoding.toLowerCase();\n if (encoding === 'latin1' || encoding === 'binary')\n return buf.latin1Slice(start, end);\n if (encoding === 'base64') return buf.base64Slice(start, end);\n break;\n case 3:\n if (encoding === 'hex' || encoding.toLowerCase() === 'hex')\n return buf.hexSlice(start, end);\n break;\n case 7:\n if (encoding === 'utf16le' || encoding.toLowerCase() === 'utf16le')\n return buf.ucs2Slice(start, end);\n break;\n case 8:\n if (encoding === 'utf-16le' || encoding.toLowerCase() === 'utf-16le')\n return buf.ucs2Slice(start, end);\n break;\n }\n throw new ERR_UNKNOWN_ENCODING(encoding);\n}\n\nBuffer.prototype.copy =\n function copy(target, targetStart, sourceStart, sourceEnd) {\n return _copy(this, target, targetStart, sourceStart, sourceEnd);\n };\n\n// No need to verify that \"buf.length <= MAX_UINT32\" since it's a read-only\n// property of a typed array.\n// This behaves neither like String nor Uint8Array in that we set start/end\n// to their upper/lower bounds if the value passed is out of range.\nBuffer.prototype.toString = function toString(encoding, start, end) {\n if (arguments.length === 0) {\n return this.utf8Slice(0, this.length);\n }\n\n const len = this.length;\n if (len === 0)\n return '';\n\n if (!start || start < 0)\n start = 0;\n else if (start >= len)\n return '';\n\n if (end === undefined || end > len)\n end = len;\n else if (end <= 0)\n return '';\n\n start |= 0;\n end |= 0;\n\n if (end <= start)\n return '';\n return stringSlice(this, encoding, start, end);\n};\n\nBuffer.prototype.equals = function equals(otherBuffer) {\n if (!isUint8Array(otherBuffer)) {\n throw new ERR_INVALID_ARG_TYPE(\n 'otherBuffer', ['Buffer', 'Uint8Array'], otherBuffer);\n }\n if (this === otherBuffer)\n return true;\n\n return _compare(this, otherBuffer) === 0;\n};\n\n// Override how buffers are presented by util.inspect().\nBuffer.prototype[customInspectSymbol] = function inspect() {\n var str = '';\n var max = exports.INSPECT_MAX_BYTES;\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();\n if (this.length > max)\n str += ' ... ';\n return `<${this.constructor.name} ${str}>`;\n};\nBuffer.prototype.inspect = Buffer.prototype[customInspectSymbol];\n\nBuffer.prototype.compare = function compare(target,\n start,\n end,\n thisStart,\n thisEnd) {\n if (!isUint8Array(target)) {\n throw new ERR_INVALID_ARG_TYPE('target', ['Buffer', 'Uint8Array'], target);\n }\n if (arguments.length === 1)\n return _compare(this, target);\n\n if (start === undefined)\n start = 0;\n else if (start < 0)\n throw new ERR_INDEX_OUT_OF_RANGE();\n else\n start >>>= 0;\n\n if (end === undefined)\n end = target.length;\n else if (end > target.length)\n throw new ERR_INDEX_OUT_OF_RANGE();\n else\n end >>>= 0;\n\n if (thisStart === undefined)\n thisStart = 0;\n else if (thisStart < 0)\n throw new ERR_INDEX_OUT_OF_RANGE();\n else\n thisStart >>>= 0;\n\n if (thisEnd === undefined)\n thisEnd = this.length;\n else if (thisEnd > this.length)\n throw new ERR_INDEX_OUT_OF_RANGE();\n else\n thisEnd >>>= 0;\n\n if (thisStart >= thisEnd)\n return (start >= end ? 0 : -1);\n else if (start >= end)\n return 1;\n\n return compareOffset(this, target, start, thisStart, end, thisEnd);\n};\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant if val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {\n if (typeof byteOffset === 'string') {\n encoding = byteOffset;\n byteOffset = undefined;\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff;\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000;\n }\n // Coerce to Number. Values like null and [] become 0.\n byteOffset = +byteOffset;\n // If the offset is undefined, \"foo\", {}, coerces to NaN, search whole buffer.\n if (Number.isNaN(byteOffset)) {\n byteOffset = dir ? 0 : buffer.length;\n }\n dir = !!dir; // Cast to bool.\n\n if (typeof val === 'string') {\n if (encoding === undefined) {\n return indexOfString(buffer, val, byteOffset, encoding, dir);\n }\n return slowIndexOf(buffer, val, byteOffset, encoding, dir);\n } else if (isUint8Array(val)) {\n return indexOfBuffer(buffer, val, byteOffset, encoding, dir);\n } else if (typeof val === 'number') {\n return indexOfNumber(buffer, val, byteOffset, dir);\n }\n\n throw new ERR_INVALID_ARG_TYPE(\n 'value', ['string', 'Buffer', 'Uint8Array'], val\n );\n}\n\nfunction slowIndexOf(buffer, val, byteOffset, encoding, dir) {\n var loweredCase = false;\n for (;;) {\n switch (encoding) {\n case 'utf8':\n case 'utf-8':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n case 'latin1':\n case 'binary':\n return indexOfString(buffer, val, byteOffset, encoding, dir);\n\n case 'base64':\n case 'ascii':\n case 'hex':\n return indexOfBuffer(\n buffer, Buffer.from(val, encoding), byteOffset, encoding, dir);\n\n default:\n if (loweredCase) {\n throw new ERR_UNKNOWN_ENCODING(encoding);\n }\n\n encoding = ('' + encoding).toLowerCase();\n loweredCase = true;\n }\n }\n}\n\nBuffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true);\n};\n\nBuffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false);\n};\n\nBuffer.prototype.includes = function includes(val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1;\n};\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill(val, start, end, encoding) {\n return _fill(this, val, start, end, encoding);\n};\n\nfunction _fill(buf, val, start, end, encoding) {\n if (typeof val === 'string') {\n if (start === undefined || typeof start === 'string') {\n encoding = start;\n start = 0;\n end = buf.length;\n } else if (typeof end === 'string') {\n encoding = end;\n end = buf.length;\n }\n\n const normalizedEncoding = normalizeEncoding(encoding);\n if (normalizedEncoding === undefined) {\n validateString(encoding, 'encoding');\n throw new ERR_UNKNOWN_ENCODING(encoding);\n }\n\n if (val.length === 0) {\n // If val === '' default to zero.\n val = 0;\n } else if (val.length === 1) {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n if (normalizedEncoding === 'utf8') {\n const code = val.charCodeAt(0);\n if (code < 128) {\n val = code;\n }\n } else if (normalizedEncoding === 'latin1') {\n val = val.charCodeAt(0);\n }\n }\n } else {\n encoding = undefined;\n }\n\n if (start === undefined) {\n start = 0;\n end = buf.length;\n } else {\n // Invalid ranges are not set to a default, so can range check early.\n if (end === undefined) {\n if (start < 0)\n throw new ERR_INDEX_OUT_OF_RANGE();\n end = buf.length;\n } else {\n if (start < 0 || end > buf.length || end < 0)\n throw new ERR_INDEX_OUT_OF_RANGE();\n end = end >>> 0;\n }\n start = start >>> 0;\n if (start >= end)\n return buf;\n }\n\n const res = bindingFill(buf, val, start, end, encoding);\n if (res < 0) {\n if (res === -1)\n throw new ERR_INVALID_ARG_VALUE('value', val);\n throw new ERR_INDEX_OUT_OF_RANGE();\n }\n\n return buf;\n}\n\nBuffer.prototype.write = function write(string, offset, length, encoding) {\n // Buffer#write(string);\n if (offset === undefined) {\n return this.utf8Write(string, 0, this.length);\n\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset;\n length = this.length;\n offset = 0;\n\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0;\n if (isFinite(length)) {\n length = length >>> 0;\n } else {\n encoding = length;\n length = undefined;\n }\n\n var remaining = this.length - offset;\n if (length === undefined || length > remaining)\n length = remaining;\n\n if (string.length > 0 && (length < 0 || offset < 0))\n throw new ERR_BUFFER_OUT_OF_BOUNDS();\n } else {\n // if someone is still calling the obsolete form of write(), tell them.\n // we don't want eg buf.write(\"foo\", \"utf8\", 10) to silently turn into\n // buf.write(\"foo\", \"utf8\"), so we can't ignore extra args\n throw new ERR_NO_LONGER_SUPPORTED(\n 'Buffer.write(string, encoding, offset[, length])'\n );\n }\n\n if (!encoding) return this.utf8Write(string, offset, length);\n\n encoding += '';\n switch (encoding.length) {\n case 4:\n if (encoding === 'utf8') return this.utf8Write(string, offset, length);\n if (encoding === 'ucs2') return this.ucs2Write(string, offset, length);\n encoding = encoding.toLowerCase();\n if (encoding === 'utf8') return this.utf8Write(string, offset, length);\n if (encoding === 'ucs2') return this.ucs2Write(string, offset, length);\n break;\n case 5:\n if (encoding === 'utf-8') return this.utf8Write(string, offset, length);\n if (encoding === 'ascii') return this.asciiWrite(string, offset, length);\n if (encoding === 'ucs-2') return this.ucs2Write(string, offset, length);\n encoding = encoding.toLowerCase();\n if (encoding === 'utf-8') return this.utf8Write(string, offset, length);\n if (encoding === 'ascii') return this.asciiWrite(string, offset, length);\n if (encoding === 'ucs-2') return this.ucs2Write(string, offset, length);\n break;\n case 7:\n if (encoding === 'utf16le' || encoding.toLowerCase() === 'utf16le')\n return this.ucs2Write(string, offset, length);\n break;\n case 8:\n if (encoding === 'utf-16le' || encoding.toLowerCase() === 'utf-16le')\n return this.ucs2Write(string, offset, length);\n break;\n case 6:\n if (encoding === 'latin1' || encoding === 'binary')\n return this.latin1Write(string, offset, length);\n if (encoding === 'base64')\n return this.base64Write(string, offset, length);\n encoding = encoding.toLowerCase();\n if (encoding === 'latin1' || encoding === 'binary')\n return this.latin1Write(string, offset, length);\n if (encoding === 'base64')\n return this.base64Write(string, offset, length);\n break;\n case 3:\n if (encoding === 'hex' || encoding.toLowerCase() === 'hex')\n return this.hexWrite(string, offset, length);\n break;\n }\n throw new ERR_UNKNOWN_ENCODING(encoding);\n};\n\nBuffer.prototype.toJSON = function toJSON() {\n if (this.length > 0) {\n const data = new Array(this.length);\n for (var i = 0; i < this.length; ++i)\n data[i] = this[i];\n return { type: 'Buffer', data };\n } else {\n return { type: 'Buffer', data: [] };\n }\n};\n\nfunction adjustOffset(offset, length) {\n // Use Math.trunc() to convert offset to an integer value that can be larger\n // than an Int32. Hence, don't use offset | 0 or similar techniques.\n offset = Math.trunc(offset);\n if (offset === 0) {\n return 0;\n }\n if (offset < 0) {\n offset += length;\n return offset > 0 ? offset : 0;\n }\n if (offset < length) {\n return offset;\n }\n return Number.isNaN(offset) ? 0 : length;\n}\n\nBuffer.prototype.slice = function slice(start, end) {\n const srcLength = this.length;\n start = adjustOffset(start, srcLength);\n end = end !== undefined ? adjustOffset(end, srcLength) : srcLength;\n const newLength = end > start ? end - start : 0;\n return new FastBuffer(this.buffer, this.byteOffset + start, newLength);\n};\n\nfunction swap(b, n, m) {\n const i = b[n];\n b[n] = b[m];\n b[m] = i;\n}\n\nBuffer.prototype.swap16 = function swap16() {\n // For Buffer.length < 128, it's generally faster to\n // do the swap in javascript. For larger buffers,\n // dropping down to the native code is faster.\n const len = this.length;\n if (len % 2 !== 0)\n throw new ERR_INVALID_BUFFER_SIZE('16-bits');\n if (len < 128) {\n for (var i = 0; i < len; i += 2)\n swap(this, i, i + 1);\n return this;\n }\n return _swap16(this);\n};\n\nBuffer.prototype.swap32 = function swap32() {\n // For Buffer.length < 192, it's generally faster to\n // do the swap in javascript. For larger buffers,\n // dropping down to the native code is faster.\n const len = this.length;\n if (len % 4 !== 0)\n throw new ERR_INVALID_BUFFER_SIZE('32-bits');\n if (len < 192) {\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3);\n swap(this, i + 1, i + 2);\n }\n return this;\n }\n return _swap32(this);\n};\n\nBuffer.prototype.swap64 = function swap64() {\n // For Buffer.length < 192, it's generally faster to\n // do the swap in javascript. For larger buffers,\n // dropping down to the native code is faster.\n const len = this.length;\n if (len % 8 !== 0)\n throw new ERR_INVALID_BUFFER_SIZE('64-bits');\n if (len < 192) {\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7);\n swap(this, i + 1, i + 6);\n swap(this, i + 2, i + 5);\n swap(this, i + 3, i + 4);\n }\n return this;\n }\n return _swap64(this);\n};\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString;\n\nlet transcode;\nif (process.binding('config').hasIntl) {\n const {\n icuErrName,\n transcode: _transcode\n } = process.binding('icu');\n\n // Transcodes the Buffer from one encoding to another, returning a new\n // Buffer instance.\n transcode = function transcode(source, fromEncoding, toEncoding) {\n if (!isUint8Array(source)) {\n throw new ERR_INVALID_ARG_TYPE('source',\n ['Buffer', 'Uint8Array'], source);\n }\n if (source.length === 0) return Buffer.alloc(0);\n\n fromEncoding = normalizeEncoding(fromEncoding) || fromEncoding;\n toEncoding = normalizeEncoding(toEncoding) || toEncoding;\n const result = _transcode(source, fromEncoding, toEncoding);\n if (typeof result !== 'number')\n return result;\n\n const code = icuErrName(result);\n // eslint-disable-next-line no-restricted-syntax\n const err = new Error(`Unable to transcode Buffer [${code}]`);\n err.code = code;\n err.errno = result;\n throw err;\n };\n}\n\nmodule.exports = exports = {\n Buffer,\n SlowBuffer,\n transcode,\n INSPECT_MAX_BYTES: 50,\n\n // Legacy\n kMaxLength,\n kStringMaxLength\n};\n\nObject.defineProperty(exports, 'constants', {\n configurable: false,\n enumerable: true,\n value: constants\n});\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 32983,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 1,
"endOffset": 32981,
"count": 1
},
{
"startOffset": 1796,
"endOffset": 1870,
"count": 0
},
{
"startOffset": 2803,
"endOffset": 2841,
"count": 36
},
{
"startOffset": 3379,
"endOffset": 3385,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "FastBuffer",
"ranges": [
{
"startOffset": 2566,
"endOffset": 2566,
"count": 2
}
],
"isBlockCoverage": true
},
{
"functionName": "createUnsafeBuffer",
"ranges": [
{
"startOffset": 3388,
"endOffset": 3481,
"count": 1
},
{
"startOffset": 3479,
"endOffset": 3480,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "createUnsafeArrayBuffer",
"ranges": [
{
"startOffset": 3483,
"endOffset": 3625,
"count": 2
},
{
"startOffset": 3584,
"endOffset": 3589,
"count": 0
},
{
"startOffset": 3623,
"endOffset": 3624,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "createPool",
"ranges": [
{
"startOffset": 3627,
"endOffset": 3749,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "alignPool",
"ranges": [
{
"startOffset": 3765,
"endOffset": 3887,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "showFlaggedDeprecation",
"ranges": [
{
"startOffset": 4191,
"endOffset": 4822,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "Buffer",
"ranges": [
{
"startOffset": 5398,
"endOffset": 5731,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 5826,
"endOffset": 5854,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "from",
"ranges": [
{
"startOffset": 6111,
"endOffset": 7218,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "of",
"ranges": [
{
"startOffset": 7589,
"endOffset": 7741,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "assertSize",
"ranges": [
{
"startOffset": 7996,
"endOffset": 8338,
"count": 2
},
{
"startOffset": 8075,
"endOffset": 8140,
"count": 0
},
{
"startOffset": 8181,
"endOffset": 8248,
"count": 0
},
{
"startOffset": 8270,
"endOffset": 8336,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "alloc",
"ranges": [
{
"startOffset": 8439,
"endOffset": 8684,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "allocUnsafe",
"ranges": [
{
"startOffset": 8863,
"endOffset": 8938,
"count": 1
},
{
"startOffset": 8936,
"endOffset": 8937,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "allocUnsafeSlow",
"ranges": [
{
"startOffset": 9179,
"endOffset": 9268,
"count": 1
},
{
"startOffset": 9266,
"endOffset": 9267,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "SlowBuffer",
"ranges": [
{
"startOffset": 9364,
"endOffset": 9534,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "allocate",
"ranges": [
{
"startOffset": 9651,
"endOffset": 9994,
"count": 1
},
{
"startOffset": 9694,
"endOffset": 9728,
"count": 0
},
{
"startOffset": 9815,
"endOffset": 9828,
"count": 0
},
{
"startOffset": 9940,
"endOffset": 9993,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "fromString",
"ranges": [
{
"startOffset": 9996,
"endOffset": 10881,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "fromArrayLike",
"ranges": [
{
"startOffset": 10883,
"endOffset": 11039,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "fromArrayBuffer",
"ranges": [
{
"startOffset": 11041,
"endOffset": 11739,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "fromObject",
"ranges": [
{
"startOffset": 11741,
"endOffset": 12209,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "isBuffer",
"ranges": [
{
"startOffset": 12248,
"endOffset": 12302,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "compare",
"ranges": [
{
"startOffset": 12322,
"endOffset": 12647,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "isEncoding",
"ranges": [
{
"startOffset": 12670,
"endOffset": 12821,
"count": 1
},
{
"startOffset": 12819,
"endOffset": 12820,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "concat",
"ranges": [
{
"startOffset": 12887,
"endOffset": 14053,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "base64ByteLength",
"ranges": [
{
"startOffset": 14056,
"endOffset": 14292,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "byteLength",
"ranges": [
{
"startOffset": 14294,
"endOffset": 16275,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 16416,
"endOffset": 16510,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 16589,
"endOffset": 16687,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "stringSlice",
"ranges": [
{
"startOffset": 16693,
"endOffset": 18517,
"count": 1
},
{
"startOffset": 16773,
"endOffset": 16806,
"count": 0
},
{
"startOffset": 16930,
"endOffset": 18516,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "copy",
"ranges": [
{
"startOffset": 18545,
"endOffset": 18678,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "toString",
"ranges": [
{
"startOffset": 18959,
"endOffset": 19427,
"count": 2
},
{
"startOffset": 19031,
"endOffset": 19079,
"count": 1
},
{
"startOffset": 19075,
"endOffset": 19079,
"count": 0
},
{
"startOffset": 19079,
"endOffset": 19129,
"count": 1
},
{
"startOffset": 19129,
"endOffset": 19139,
"count": 0
},
{
"startOffset": 19139,
"endOffset": 19154,
"count": 1
},
{
"startOffset": 19154,
"endOffset": 19166,
"count": 0
},
{
"startOffset": 19172,
"endOffset": 19182,
"count": 1
},
{
"startOffset": 19182,
"endOffset": 19222,
"count": 0
},
{
"startOffset": 19222,
"endOffset": 19248,
"count": 1
},
{
"startOffset": 19248,
"endOffset": 19260,
"count": 0
},
{
"startOffset": 19266,
"endOffset": 19276,
"count": 1
},
{
"startOffset": 19276,
"endOffset": 19312,
"count": 0
},
{
"startOffset": 19312,
"endOffset": 19365,
"count": 1
},
{
"startOffset": 19365,
"endOffset": 19375,
"count": 0
},
{
"startOffset": 19375,
"endOffset": 19425,
"count": 1
},
{
"startOffset": 19425,
"endOffset": 19426,
"count": 0
}
],
"isBlockCoverage": true
},
{
"functionName": "equals",
"ranges": [
{
"startOffset": 19456,
"endOffset": 19715,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "inspect",
"ranges": [
{
"startOffset": 19815,
"endOffset": 20054,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "compare",
"ranges": [
{
"startOffset": 20150,
"endOffset": 21321,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "bidirectionalIndexOf",
"ranges": [
{
"startOffset": 21749,
"endOffset": 22839,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "slowIndexOf",
"ranges": [
{
"startOffset": 22841,
"endOffset": 23562,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "indexOf",
"ranges": [
{
"startOffset": 23591,
"endOffset": 23708,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "lastIndexOf",
"ranges": [
{
"startOffset": 23742,
"endOffset": 23864,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "includes",
"ranges": [
{
"startOffset": 23895,
"endOffset": 24000,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "fill",
"ranges": [
{
"startOffset": 24178,
"endOffset": 24271,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "_fill",
"ranges": [
{
"startOffset": 24274,
"endOffset": 25943,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "write",
"ranges": [
{
"startOffset": 25970,
"endOffset": 29110,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "toJSON",
"ranges": [
{
"startOffset": 29139,
"endOffset": 29386,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "adjustOffset",
"ranges": [
{
"startOffset": 29389,
"endOffset": 29825,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "slice",
"ranges": [
{
"startOffset": 29852,
"endOffset": 30152,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "swap",
"ranges": [
{
"startOffset": 30155,
"endOffset": 30226,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "swap16",
"ranges": [
{
"startOffset": 30254,
"endOffset": 30658,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "swap32",
"ranges": [
{
"startOffset": 30687,
"endOffset": 31131,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "swap64",
"ranges": [
{
"startOffset": 31160,
"endOffset": 31668,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "transcode",
"ranges": [
{
"startOffset": 31981,
"endOffset": 32721,
"count": 0
}
],
"isBlockCoverage": false
}
]
},
{
"url": "cjs-facade:file:///data/projects/web/v8-to-istanbul/src/test/fixtures/esm-hello-world/main.js",
"source": "\n export let executor;\n export let $default;\n /* This function is implicitly returned as the module's completion value */\n (() => ({\n setExecutor: fn => executor = fn,\n reflect: {\n exports: { \n default: {\n get: () => $default,\n set: v => $default = v\n }\n }\n }\n }));",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 321,
"count": 2
}
],
"isBlockCoverage": true
},
{
"functionName": "",
"ranges": [
{
"startOffset": 128,
"endOffset": 319,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "setExecutor",
"ranges": [
{
"startOffset": 154,
"endOffset": 173,
"count": 1
}
],
"isBlockCoverage": true
},
{
"functionName": "get",
"ranges": [
{
"startOffset": 242,
"endOffset": 256,
"count": 0
}
],
"isBlockCoverage": false
},
{
"functionName": "set",
"ranges": [
{
"startOffset": 273,
"endOffset": 290,
"count": 1
}
],
"isBlockCoverage": true
}
]
},
{
"url": "console.js",
"source": "(function (exports, require, module, process) {// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// 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 OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nconst {\n isStackOverflowError,\n codes: {\n ERR_CONSOLE_WRITABLE_STREAM,\n ERR_INVALID_ARG_TYPE,\n ERR_INVALID_ARG_VALUE,\n },\n} = require('internal/errors');\nconst { previewEntries } = process.binding('util');\nconst { Buffer: { isBuffer } } = require('buffer');\nconst util = require('util');\nconst {\n isTypedArray, isSet, isMap, isSetIterator, isMapIterator,\n} = util.types;\nconst kCounts = Symbol('counts');\n\nconst {\n keys: ObjectKeys,\n values: ObjectValues,\n} = Object;\nconst hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);\n\nconst {\n isArray: ArrayIsArray,\n from: ArrayFrom,\n} = Array;\n\n// Lazy loaded for startup performance.\nlet cliTable;\n\n// Track amount of indentation required via `console.group()`.\nconst kGroupIndent = Symbol('kGroupIndent');\n\nconst kFormatForStderr = Symbol('kFormatForStderr');\nconst kFormatForStdout = Symbol('kFormatForStdout');\nconst kGetInspectOptions = Symbol('kGetInspectOptions');\nconst kColorMode = Symbol('kColorMode');\n\nfunction Console(options /* or: stdout, stderr, ignoreErrors = true */) {\n if (!(this instanceof Console)) {\n return new Console(...arguments);\n }\n\n if (!options || typeof options.write === 'function') {\n options = {\n stdout: options,\n stderr: arguments[1],\n ignoreErrors: arguments[2]\n };\n }\n\n const {\n stdout,\n stderr = stdout,\n ignoreErrors = true,\n colorMode = 'auto'\n } = options;\n\n if (!stdout || typeof stdout.write !== 'function') {\n throw new ERR_CONSOLE_WRITABLE_STREAM('stdout');\n }\n if (!stderr || typeof stderr.write !== 'function') {\n throw new ERR_CONSOLE_WRITABLE_STREAM('stderr');\n }\n\n var prop = {\n writable: true,\n enumerable: false,\n configurable: true\n };\n prop.value = stdout;\n Object.defineProperty(this, '_stdout', prop);\n prop.value = stderr;\n Object.defineProperty(this, '_stderr', prop);\n prop.value = Boolean(ignoreErrors);\n Object.defineProperty(this, '_ignoreErrors', prop);\n prop.value = new Map();\n Object.defineProperty(this, '_times', prop);\n prop.value = createWriteErrorHandler(stdout);\n Object.defineProperty(this, '_stdoutErrorHandler', prop);\n prop.value = createWriteErrorHandler(stderr);\n Object.defineProperty(this, '_stderrErrorHandler', prop);\n\n if (typeof colorMode !== 'boolean' && colorMode !== 'auto')\n throw new ERR_INVALID_ARG_VALUE('colorMode', colorMode);\n\n this[kCounts] = new Map();\n this[kColorMode] = colorMode;\n\n Object.defineProperty(this, kGroupIndent, { writable: true });\n this[kGroupIndent] = '';\n\n // bind the prototype functions to this Console instance\n var keys = Object.keys(Console.prototype);\n for (var v = 0; v < keys.length; v++) {\n var k = keys[v];\n this[k] = this[k].bind(this);\n }\n}\n\n// Make a function that can serve as the callback passed to `stream.write()`.\nfunction createWriteErrorHandler(stream) {\n return (err) => {\n // This conditional evaluates to true if and only if there was an error\n // that was not already emitted (which happens when the _write callback\n // is invoked asynchronously).\n if (err !== null && !stream._writableState.errorEmitted) {\n // If there was an error, it will be emitted on `stream` as\n // an `error` event. Adding a `once` listener will keep that error\n // from becoming an uncaught exception, but since the handler is\n // removed after the event, non-console.* writes won't be affected.\n // we are only adding noop if there is no one else listening for 'error'\n if (stream.listenerCount('error') === 0) {\n stream.on('error', noop);\n }\n }\n };\n}\n\nfunction write(ignoreErrors, stream, string, errorhandler, groupIndent) {\n if (groupIndent.length !== 0) {\n if (string.indexOf('\\n') !== -1) {\n string = string.replace(/\\n/g, `\\n${groupIndent}`);\n }\n string = groupIndent + string;\n }\n string += '\\n';\n\n if (ignoreErrors === false) return stream.write(string);\n\n // There may be an error occurring synchronously (e.g. for files or TTYs\n // on POSIX systems) or asynchronously (e.g. pipes on POSIX systems), so\n // handle both situations.\n try {\n // Add and later remove a noop error handler to catch synchronous errors.\n stream.once('error', noop);\n\n stream.write(string, errorhandler);\n } catch (e) {\n // console is a debugging utility, so it swallowing errors is not desirable\n // even in edge cases such as low stack space.\n if (isStackOverflowError(e))\n throw e;\n // Sorry, there's no proper way to pass along the error here.\n } finally {\n stream.removeListener('error', noop);\n }\n}\n\nconst kColorInspectOptions = { colors: true };\nconst kNoColorInspectOptions = {};\nConsole.prototype[kGetInspectOptions] = function(stream) {\n let color = this[kColorMode];\n if (color === 'auto') {\n color = stream.isTTY && (\n typeof stream.getColorDepth === 'function' ?\n stream.getColorDepth() > 2 : true);\n }\n\n return color ? kColorInspectOptions : kNoColorInspectOptions;\n};\n\nConsole.prototype[kFormatForStdout] = function(args) {\n const opts = this[kGetInspectOptions](this._stdout);\n return util.formatWithOptions(opts, ...args);\n};\n\nConsole.prototype[kFormatForStderr] = function(args) {\n const opts = this[kGetInspectOptions](this._stderr);\n return util.formatWithOptions(opts, ...args);\n};\n\nConsole.prototype.log = function log(...args) {\n write(this._ignoreErrors,\n this._stdout,\n this[kFormatForStdout](args),\n this._stdoutErrorHandler,\n this[kGroupIndent]);\n};\nConsole.prototype.debug = Console.prototype.log;\nConsole.prototype.info = Console.prototype.log;\nConsole.prototype.dirxml = Console.prototype.log;\n\nConsole.prototype.warn = function warn(...args) {\n write(this._ignoreErrors,\n this._stderr,\n this[kFormatForStderr](args),\n this._stderrErrorHandler,\n this[kGroupIndent]);\n};\nConsole.prototype.error = Console.prototype.warn;\n\nConsole.prototype.dir = function dir(object, options) {\n options = Object.assign({\n customInspect: false\n }, this[kGetInspectOptions](this._stdout), options);\n write(this._ignoreErrors,\n this._stdout,\n util.inspect(object, options),\n this._stdoutErrorHandler,\n this[kGroupIndent]);\n};\n\nConsole.prototype.time = function time(label = 'default') {\n // Coerces everything other than Symbol to a string\n label = `${label}`;\n this._times.set(label, process.hrtime());\n};\n\nConsole.prototype.timeEnd = function timeEnd(label = 'default') {\n // Coerces everything other than Symbol to a string\n label = `${label}`;\n const hasWarned = timeLogImpl(this, 'timeEnd', label);\n if (!hasWarned) {\n this._times.delete(label);\n }\n};\n\nConsole.prototype.timeLog = function timeLog(label, ...data) {\n // Coerces everything other than Symbol to a string\n label = `${label}`;\n timeLogImpl(this, 'timeLog', label, data);\n};\n\n// Returns true if label was not found\nfunction timeLogImpl(self, name, label = 'default', data) {\n const time = self._times.get(label);\n if (!time) {\n process.emitWarning(`No such label '${label}' for console.${name}()`);\n return true;\n }\n const duration = process.hrtime(time);\n const ms = duration[0] * 1000 + duration[1] / 1e6;\n if (data === undefined) {\n self.log('%s: %sms', label, ms.toFixed(3));\n } else {\n self.log('%s: %sms', label, ms.toFixed(3), ...data);\n }\n return false;\n}\n\nConsole.prototype.trace = function trace(...args) {\n const err = {\n name: 'Trace',\n message: this[kFormatForStderr](args)\n };\n Error.captureStackTrace(err, trace);\n this.error(err.stack);\n};\n\nConsole.prototype.assert = function assert(expression, ...args) {\n if (!expression) {\n args[0] = `Assertion failed${args.length === 0 ? '' : `: ${args[0]}`}`;\n this.warn(this[kFormatForStderr](args));\n }\n};\n\n// Defined by: https://console.spec.whatwg.org/#clear\nConsole.prototype.clear = function clear() {\n // It only makes sense to clear if _stdout is a TTY.\n // Otherwise, do nothing.\n if (this._stdout.isTTY) {\n // The require is here intentionally to avoid readline being\n // required too early when console is first loaded.\n const { cursorTo, clearScreenDown } = require('readline');\n cursorTo(this._stdout, 0, 0);\n clearScreenDown(this._stdout);\n }\n};\n\n// Defined by: https://console.spec.whatwg.org/#count\nConsole.prototype.count = function count(label = 'default') {\n // Ensures that label is a string, and only things that can be\n // coerced to strings. e.g. Symbol is not allowed\n label = `${label}`;\n const counts = this[kCounts];\n let count = counts.get(label);\n if (count === undefined)\n count = 1;\n else\n count++;\n counts.set(label, count);\n this.log(`${label}: ${count}`);\n};\n\n// Not yet defined by the https://console.spec.whatwg.org, but\n// proposed to be added and currently implemented by Edge. Having\n// the ability to reset counters is important to help prevent\n// the counter from being a memory leak.\nConsole.prototype.countReset = function countReset(label = 'default') {\n const counts = this[kCounts];\n counts.delete(`${label}`);\n};\n\nConsole.prototype.group = function group(...data) {\n if (data.length > 0) {\n this.log(...data);\n }\n this[kGroupIndent] += ' ';\n};\nConsole.prototype.groupCollapsed = Console.prototype.group;\n\nConsole.prototype.groupEnd = function groupEnd() {\n this[kGroupIndent] =\n this[kGroupIndent].slice(0, this[kGroupIndent].length - 2);\n};\n\nconst keyKey = 'Key';\nconst valuesKey = 'Values';\nconst indexKey = '(index)';\nconst iterKey = '(iteration index)';\n\n\nconst isArray = (v) => ArrayIsArray(v) || isTypedArray(v) || isBuffer(v);\n\n// https://console.spec.whatwg.org/#table\nConsole.prototype.table = function(tabularData, properties) {\n if (properties !== undefined && !ArrayIsArray(properties))\n throw new ERR_INVALID_ARG_TYPE('properties', 'Array', properties);\n\n if (tabularData == null || typeof tabularData !== 'object')\n return this.log(tabularData);\n\n if (cliTable === undefined) cliTable = require('internal/cli_table');\n const final = (k, v) => this.log(cliTable(k, v));\n\n const inspect = (v) => {\n const opt = { depth: 0, maxArrayLength: 3 };\n if (v !== null && typeof v === 'object' &&\n !isArray(v) && ObjectKeys(v).length > 2)\n opt.depth = -1;\n Object.assign(opt, this[kGetInspectOptions](this._stdout));\n return util.inspect(v, opt);\n };\n const getIndexArray = (length) => ArrayFrom({ length }, (_, i) => inspect(i));\n\n const mapIter = isMapIterator(tabularData);\n let isKeyValue = false;\n let i = 0;\n if (mapIter) {\n const res = previewEntries(tabularData, true);\n tabularData = res[0];\n isKeyValue = res[1];\n }\n\n if (isKeyValue || isMap(tabularData)) {\n const keys = [];\n const values = [];\n let length = 0;\n if (mapIter) {\n for (; i < tabularData.length / 2; ++i) {\n keys.push(inspect(tabularData[i * 2]));\n values.push(inspect(tabularData[i * 2 + 1]));\n length++;\n }\n } else {\n for (const [k, v] of tabularData) {\n keys.push(inspect(k));\n values.push(inspect(v));\n length++;\n }\n }\n return final([\n iterKey, keyKey, valuesKey\n ], [\n getIndexArray(length),\n keys,\n values,\n ]);\n }\n\n const setIter = isSetIterator(tabularData);\n if (setIter)\n tabularData = previewEntries(tabularData);\n\n const setlike = setIter || (mapIter && !isKeyValue) || isSet(tabularData);\n if (setlike) {\n const values = [];\n let length = 0;\n for (const v of tabularData) {\n values.push(inspect(v));\n length++;\n }\n return final([setlike ? iterKey : indexKey, valuesKey], [\n getIndexArray(length),\n values,\n ]);\n }\n\n const map = {};\n let hasPrimitives = false;\n const valuesKeyArray = [];\n const indexKeyArray = ObjectKeys(tabularData);\n\n for (; i < indexKeyArray.length; i++) {\n const item = tabularData[indexKeyArray[i]];\n const primitive = item === null ||\n (typeof item !== 'function' && typeof item !== 'object');\n if (properties === undefined && primitive) {\n hasPrimitives = true;\n valuesKeyArray[i] = inspect(item);\n } else {\n const keys = properties || ObjectKeys(item);\n for (const key of keys) {\n if (map[key] === undefined)\n map[key] = [];\n if ((primitive && properties) || !hasOwnProperty(item, key))\n map[key][i] = '';\n else\n map[key][i] = item == null ? item : inspect(item[key]);\n }\n }\n }\n\n const keys = ObjectKeys(map);\n const values = ObjectValues(map);\n if (hasPrimitives) {\n keys.push(valuesKey);\n values.push(valuesKeyArray);\n }\n keys.unshift(indexKey);\n values.unshift(indexKeyArray);\n\n return final(keys, values);\n};\n\nmodule.exports = new Console({\n stdout: process.stdout,\n stderr: process.stderr\n});\nmodule.exports.Console = Console;\n\nfunction noop() {}\n\n});",
"functions": [
{
"functionName": "",
"ranges": [
{
"startOffset": 0,
"endOffset": 14074,
"count": 1
}