diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index c2b41286b400c..5e66d51c3f047 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -261,20 +261,15 @@ graph LR; ## all dependencies ```mermaid graph LR; - abort-controller-->event-target-shim; agent-base-->debug; aggregate-error-->clean-stack; aggregate-error-->indent-string; ansi-styles-->color-convert; - are-we-there-yet-->delegates; - are-we-there-yet-->readable-stream; bin-links-->cmd-shim; bin-links-->npm-normalize-package-bin; bin-links-->read-cmd-shim; bin-links-->write-file-atomic; brace-expansion-->balanced-match; - buffer-->base64-js; - buffer-->ieee754; builtins-->semver; cacache-->fs-minipass; cacache-->glob; @@ -759,11 +754,6 @@ graph LR; read-package-json-->npm-normalize-package-bin; read-package-json-fast-->json-parse-even-better-errors; read-package-json-fast-->npm-normalize-package-bin; - readable-stream-->abort-controller; - readable-stream-->buffer; - readable-stream-->events; - readable-stream-->process; - readable-stream-->string_decoder; semver-->lru-cache; shebang-command-->shebang-regex; sigstore-->sigstore-bundle["@sigstore/bundle"]; @@ -790,7 +780,6 @@ graph LR; string-width-->emoji-regex; string-width-->is-fullwidth-code-point; string-width-->strip-ansi; - string_decoder-->safe-buffer; strip-ansi-->ansi-regex; tar-->chownr; tar-->fs-minipass; diff --git a/node_modules/.gitignore b/node_modules/.gitignore index 6e1e05a97179e..ccc6cde538c77 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -46,7 +46,6 @@ !/@tufjs/canonical-json !/@tufjs/models !/abbrev -!/abort-controller !/agent-base !/aggregate-error !/ansi-regex @@ -55,11 +54,9 @@ !/archy !/are-we-there-yet !/balanced-match -!/base64-js !/bin-links !/binary-extensions !/brace-expansion -!/buffer !/builtins !/cacache !/chalk @@ -95,15 +92,12 @@ /debug/node_modules/* !/debug/node_modules/ms !/defaults -!/delegates !/diff !/eastasianwidth !/emoji-regex !/encoding !/env-paths !/err-code -!/event-target-shim -!/events !/exponential-backoff !/fastest-levenshtein !/foreground-child @@ -123,7 +117,6 @@ !/http-proxy-agent !/https-proxy-agent !/iconv-lite -!/ieee754 !/ignore-walk !/imurmurhash !/indent-string @@ -193,7 +186,6 @@ !/path-scurry !/postcss-selector-parser !/proc-log -!/process !/promise-all-reject-late !/promise-call-limit !/promise-inflight @@ -204,9 +196,7 @@ !/read-package-json-fast !/read-package-json !/read -!/readable-stream !/retry -!/safe-buffer !/safer-buffer !/semver !/semver/node_modules/ @@ -225,7 +215,6 @@ !/spdx-expression-parse !/spdx-license-ids !/ssri -!/string_decoder !/string-width-cjs !/string-width-cjs/node_modules/ /string-width-cjs/node_modules/* diff --git a/node_modules/abort-controller/LICENSE b/node_modules/abort-controller/LICENSE deleted file mode 100644 index c914149a6f845..0000000000000 --- a/node_modules/abort-controller/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Toru Nagashima - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/abort-controller/browser.js b/node_modules/abort-controller/browser.js deleted file mode 100644 index b0c5ec37d9b76..0000000000000 --- a/node_modules/abort-controller/browser.js +++ /dev/null @@ -1,13 +0,0 @@ -/*globals self, window */ -"use strict" - -/*eslint-disable @mysticatea/prettier */ -const { AbortController, AbortSignal } = - typeof self !== "undefined" ? self : - typeof window !== "undefined" ? window : - /* otherwise */ undefined -/*eslint-enable @mysticatea/prettier */ - -module.exports = AbortController -module.exports.AbortSignal = AbortSignal -module.exports.default = AbortController diff --git a/node_modules/abort-controller/browser.mjs b/node_modules/abort-controller/browser.mjs deleted file mode 100644 index a8f321afed675..0000000000000 --- a/node_modules/abort-controller/browser.mjs +++ /dev/null @@ -1,11 +0,0 @@ -/*globals self, window */ - -/*eslint-disable @mysticatea/prettier */ -const { AbortController, AbortSignal } = - typeof self !== "undefined" ? self : - typeof window !== "undefined" ? window : - /* otherwise */ undefined -/*eslint-enable @mysticatea/prettier */ - -export default AbortController -export { AbortController, AbortSignal } diff --git a/node_modules/abort-controller/dist/abort-controller.js b/node_modules/abort-controller/dist/abort-controller.js deleted file mode 100644 index 49af73955859f..0000000000000 --- a/node_modules/abort-controller/dist/abort-controller.js +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -var eventTargetShim = require('event-target-shim'); - -/** - * The signal class. - * @see https://dom.spec.whatwg.org/#abortsignal - */ -class AbortSignal extends eventTargetShim.EventTarget { - /** - * AbortSignal cannot be constructed directly. - */ - constructor() { - super(); - throw new TypeError("AbortSignal cannot be constructed directly"); - } - /** - * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise. - */ - get aborted() { - const aborted = abortedFlags.get(this); - if (typeof aborted !== "boolean") { - throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`); - } - return aborted; - } -} -eventTargetShim.defineEventAttribute(AbortSignal.prototype, "abort"); -/** - * Create an AbortSignal object. - */ -function createAbortSignal() { - const signal = Object.create(AbortSignal.prototype); - eventTargetShim.EventTarget.call(signal); - abortedFlags.set(signal, false); - return signal; -} -/** - * Abort a given signal. - */ -function abortSignal(signal) { - if (abortedFlags.get(signal) !== false) { - return; - } - abortedFlags.set(signal, true); - signal.dispatchEvent({ type: "abort" }); -} -/** - * Aborted flag for each instances. - */ -const abortedFlags = new WeakMap(); -// Properties should be enumerable. -Object.defineProperties(AbortSignal.prototype, { - aborted: { enumerable: true }, -}); -// `toString()` should return `"[object AbortSignal]"` -if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") { - Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, { - configurable: true, - value: "AbortSignal", - }); -} - -/** - * The AbortController. - * @see https://dom.spec.whatwg.org/#abortcontroller - */ -class AbortController { - /** - * Initialize this controller. - */ - constructor() { - signals.set(this, createAbortSignal()); - } - /** - * Returns the `AbortSignal` object associated with this object. - */ - get signal() { - return getSignal(this); - } - /** - * Abort and signal to any observers that the associated activity is to be aborted. - */ - abort() { - abortSignal(getSignal(this)); - } -} -/** - * Associated signals. - */ -const signals = new WeakMap(); -/** - * Get the associated signal of a given controller. - */ -function getSignal(controller) { - const signal = signals.get(controller); - if (signal == null) { - throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`); - } - return signal; -} -// Properties should be enumerable. -Object.defineProperties(AbortController.prototype, { - signal: { enumerable: true }, - abort: { enumerable: true }, -}); -if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") { - Object.defineProperty(AbortController.prototype, Symbol.toStringTag, { - configurable: true, - value: "AbortController", - }); -} - -exports.AbortController = AbortController; -exports.AbortSignal = AbortSignal; -exports.default = AbortController; - -module.exports = AbortController -module.exports.AbortController = module.exports["default"] = AbortController -module.exports.AbortSignal = AbortSignal -//# sourceMappingURL=abort-controller.js.map diff --git a/node_modules/abort-controller/dist/abort-controller.mjs b/node_modules/abort-controller/dist/abort-controller.mjs deleted file mode 100644 index 88ba22d5574ed..0000000000000 --- a/node_modules/abort-controller/dist/abort-controller.mjs +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -import { EventTarget, defineEventAttribute } from 'event-target-shim'; - -/** - * The signal class. - * @see https://dom.spec.whatwg.org/#abortsignal - */ -class AbortSignal extends EventTarget { - /** - * AbortSignal cannot be constructed directly. - */ - constructor() { - super(); - throw new TypeError("AbortSignal cannot be constructed directly"); - } - /** - * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise. - */ - get aborted() { - const aborted = abortedFlags.get(this); - if (typeof aborted !== "boolean") { - throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`); - } - return aborted; - } -} -defineEventAttribute(AbortSignal.prototype, "abort"); -/** - * Create an AbortSignal object. - */ -function createAbortSignal() { - const signal = Object.create(AbortSignal.prototype); - EventTarget.call(signal); - abortedFlags.set(signal, false); - return signal; -} -/** - * Abort a given signal. - */ -function abortSignal(signal) { - if (abortedFlags.get(signal) !== false) { - return; - } - abortedFlags.set(signal, true); - signal.dispatchEvent({ type: "abort" }); -} -/** - * Aborted flag for each instances. - */ -const abortedFlags = new WeakMap(); -// Properties should be enumerable. -Object.defineProperties(AbortSignal.prototype, { - aborted: { enumerable: true }, -}); -// `toString()` should return `"[object AbortSignal]"` -if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") { - Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, { - configurable: true, - value: "AbortSignal", - }); -} - -/** - * The AbortController. - * @see https://dom.spec.whatwg.org/#abortcontroller - */ -class AbortController { - /** - * Initialize this controller. - */ - constructor() { - signals.set(this, createAbortSignal()); - } - /** - * Returns the `AbortSignal` object associated with this object. - */ - get signal() { - return getSignal(this); - } - /** - * Abort and signal to any observers that the associated activity is to be aborted. - */ - abort() { - abortSignal(getSignal(this)); - } -} -/** - * Associated signals. - */ -const signals = new WeakMap(); -/** - * Get the associated signal of a given controller. - */ -function getSignal(controller) { - const signal = signals.get(controller); - if (signal == null) { - throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`); - } - return signal; -} -// Properties should be enumerable. -Object.defineProperties(AbortController.prototype, { - signal: { enumerable: true }, - abort: { enumerable: true }, -}); -if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") { - Object.defineProperty(AbortController.prototype, Symbol.toStringTag, { - configurable: true, - value: "AbortController", - }); -} - -export default AbortController; -export { AbortController, AbortSignal }; -//# sourceMappingURL=abort-controller.mjs.map diff --git a/node_modules/abort-controller/dist/abort-controller.umd.js b/node_modules/abort-controller/dist/abort-controller.umd.js deleted file mode 100644 index f643cfd6b6711..0000000000000 --- a/node_modules/abort-controller/dist/abort-controller.umd.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.AbortControllerShim={}))})(this,function(a){'use strict';function b(a){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},b(a)}function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function d(a,b){for(var c,d=0;d=6.5" - }, - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "browser": "./browser.js", - "devDependencies": { - "@babel/core": "^7.2.2", - "@babel/plugin-transform-modules-commonjs": "^7.2.0", - "@babel/preset-env": "^7.3.0", - "@babel/register": "^7.0.0", - "@mysticatea/eslint-plugin": "^8.0.1", - "@mysticatea/spy": "^0.1.2", - "@types/mocha": "^5.2.5", - "@types/node": "^10.12.18", - "assert": "^1.4.1", - "codecov": "^3.1.0", - "dts-bundle-generator": "^2.0.0", - "eslint": "^5.12.1", - "karma": "^3.1.4", - "karma-chrome-launcher": "^2.2.0", - "karma-coverage": "^1.1.2", - "karma-firefox-launcher": "^1.1.0", - "karma-growl-reporter": "^1.0.0", - "karma-ie-launcher": "^1.0.0", - "karma-mocha": "^1.3.0", - "karma-rollup-preprocessor": "^7.0.0-rc.2", - "mocha": "^5.2.0", - "npm-run-all": "^4.1.5", - "nyc": "^13.1.0", - "opener": "^1.5.1", - "rimraf": "^2.6.3", - "rollup": "^1.1.2", - "rollup-plugin-babel": "^4.3.2", - "rollup-plugin-babel-minify": "^7.0.0", - "rollup-plugin-commonjs": "^9.2.0", - "rollup-plugin-node-resolve": "^4.0.0", - "rollup-plugin-sourcemaps": "^0.4.2", - "rollup-plugin-typescript": "^1.0.0", - "rollup-watch": "^4.3.1", - "ts-node": "^8.0.1", - "type-tester": "^1.0.0", - "typescript": "^3.2.4" - }, - "scripts": { - "preversion": "npm test", - "version": "npm run -s build && git add dist/*", - "postversion": "git push && git push --tags", - "clean": "rimraf .nyc_output coverage", - "coverage": "opener coverage/lcov-report/index.html", - "lint": "eslint . --ext .ts", - "build": "run-s -s build:*", - "build:rollup": "rollup -c", - "build:dts": "dts-bundle-generator -o dist/abort-controller.d.ts src/abort-controller.ts && ts-node scripts/fix-dts", - "test": "run-s -s lint test:*", - "test:mocha": "nyc mocha test/*.ts", - "test:karma": "karma start --single-run", - "watch": "run-p -s watch:*", - "watch:mocha": "mocha test/*.ts --require ts-node/register --watch-extensions ts --watch --growl", - "watch:karma": "karma start --watch", - "codecov": "codecov" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/mysticatea/abort-controller.git" - }, - "keywords": [ - "w3c", - "whatwg", - "event", - "events", - "abort", - "cancel", - "abortcontroller", - "abortsignal", - "controller", - "signal", - "shim" - ], - "author": "Toru Nagashima (https://github.com/mysticatea)", - "license": "MIT", - "bugs": { - "url": "https://github.com/mysticatea/abort-controller/issues" - }, - "homepage": "https://github.com/mysticatea/abort-controller#readme" -} diff --git a/node_modules/abort-controller/polyfill.js b/node_modules/abort-controller/polyfill.js deleted file mode 100644 index 3ca892330b1e5..0000000000000 --- a/node_modules/abort-controller/polyfill.js +++ /dev/null @@ -1,21 +0,0 @@ -/*globals require, self, window */ -"use strict" - -const ac = require("./dist/abort-controller") - -/*eslint-disable @mysticatea/prettier */ -const g = - typeof self !== "undefined" ? self : - typeof window !== "undefined" ? window : - typeof global !== "undefined" ? global : - /* otherwise */ undefined -/*eslint-enable @mysticatea/prettier */ - -if (g) { - if (typeof g.AbortController === "undefined") { - g.AbortController = ac.AbortController - } - if (typeof g.AbortSignal === "undefined") { - g.AbortSignal = ac.AbortSignal - } -} diff --git a/node_modules/abort-controller/polyfill.mjs b/node_modules/abort-controller/polyfill.mjs deleted file mode 100644 index 0602a64dddfd2..0000000000000 --- a/node_modules/abort-controller/polyfill.mjs +++ /dev/null @@ -1,19 +0,0 @@ -/*globals self, window */ -import * as ac from "./dist/abort-controller" - -/*eslint-disable @mysticatea/prettier */ -const g = - typeof self !== "undefined" ? self : - typeof window !== "undefined" ? window : - typeof global !== "undefined" ? global : - /* otherwise */ undefined -/*eslint-enable @mysticatea/prettier */ - -if (g) { - if (typeof g.AbortController === "undefined") { - g.AbortController = ac.AbortController - } - if (typeof g.AbortSignal === "undefined") { - g.AbortSignal = ac.AbortSignal - } -} diff --git a/node_modules/are-we-there-yet/lib/tracker-stream.js b/node_modules/are-we-there-yet/lib/tracker-stream.js index 4b111b6bae8a8..75e44df309150 100644 --- a/node_modules/are-we-there-yet/lib/tracker-stream.js +++ b/node_modules/are-we-there-yet/lib/tracker-stream.js @@ -1,6 +1,5 @@ 'use strict' -const stream = require('readable-stream') -const delegate = require('delegates') +const stream = require('stream') const Tracker = require('./tracker.js') class TrackerStream extends stream.Transform { @@ -9,7 +8,11 @@ class TrackerStream extends stream.Transform { this.tracker = new Tracker(name, size) this.name = name this.id = this.tracker.id - this.tracker.on('change', delegateChange(this)) + this.tracker.on('change', this.trackerChange.bind(this)) + } + + trackerChange (name, completion) { + this.emit('change', name, completion, this) } _transform (data, encoding, cb) { @@ -22,17 +25,18 @@ class TrackerStream extends stream.Transform { this.tracker.finish() cb() } -} -function delegateChange (trackerStream) { - return function (name, completion, tracker) { - trackerStream.emit('change', name, completion, trackerStream) + completed () { + return this.tracker.completed() } -} -delegate(TrackerStream.prototype, 'tracker') - .method('completed') - .method('addWork') - .method('finish') + addWork (work) { + return this.tracker.addWork(work) + } + + finish () { + return this.tracker.finish() + } +} module.exports = TrackerStream diff --git a/node_modules/are-we-there-yet/package.json b/node_modules/are-we-there-yet/package.json index e238c6581df66..f072a21abb444 100644 --- a/node_modules/are-we-there-yet/package.json +++ b/node_modules/are-we-there-yet/package.json @@ -1,11 +1,11 @@ { "name": "are-we-there-yet", - "version": "4.0.1", + "version": "4.0.2", "description": "Keep track of the overall completion of many disparate processes", "main": "lib/index.js", "scripts": { "test": "tap", - "lint": "eslint \"**/*.js\"", + "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"", "lintfix": "npm run lint -- --fix", "posttest": "npm run lint", "postsnap": "npm run lintfix --", @@ -25,13 +25,9 @@ "homepage": "https://github.com/npm/are-we-there-yet", "devDependencies": { "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.17.0", + "@npmcli/template-oss": "4.21.3", "tap": "^16.0.1" }, - "dependencies": { - "delegates": "^1.0.0", - "readable-stream": "^4.1.0" - }, "files": [ "bin/", "lib/" @@ -51,7 +47,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.17.0", + "version": "4.21.3", "publish": true } } diff --git a/node_modules/base64-js/LICENSE b/node_modules/base64-js/LICENSE deleted file mode 100644 index 6d52b8acfbe77..0000000000000 --- a/node_modules/base64-js/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Jameson Little - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/base64-js/base64js.min.js b/node_modules/base64-js/base64js.min.js deleted file mode 100644 index 908ac83fd1240..0000000000000 --- a/node_modules/base64-js/base64js.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.base64js=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c>16,j[k++]=255&b>>8,j[k++]=255&b;return 2===h&&(b=l[a.charCodeAt(c)]<<2|l[a.charCodeAt(c+1)]>>4,j[k++]=255&b),1===h&&(b=l[a.charCodeAt(c)]<<10|l[a.charCodeAt(c+1)]<<4|l[a.charCodeAt(c+2)]>>2,j[k++]=255&b>>8,j[k++]=255&b),j}function g(a){return k[63&a>>18]+k[63&a>>12]+k[63&a>>6]+k[63&a]}function h(a,b,c){for(var d,e=[],f=b;fj?j:g+f));return 1===d?(b=a[c-1],e.push(k[b>>2]+k[63&b<<4]+"==")):2===d&&(b=(a[c-2]<<8)+a[c-1],e.push(k[b>>10]+k[63&b>>4]+k[63&b<<2]+"=")),e.join("")}c.byteLength=function(a){var b=d(a),c=b[0],e=b[1];return 3*(c+e)/4-e},c.toByteArray=f,c.fromByteArray=j;for(var k=[],l=[],m="undefined"==typeof Uint8Array?Array:Uint8Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,p=n.length;o 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // Trim off extra bytes after placeholder bytes are found - // See: https://github.com/beatgammit/base64-js/issues/42 - var validLen = b64.indexOf('=') - if (validLen === -1) validLen = len - - var placeHoldersLen = validLen === len - ? 0 - : 4 - (validLen % 4) - - return [validLen, placeHoldersLen] -} - -// base64 is 4/3 + up to two characters of the original data -function byteLength (b64) { - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function _byteLength (b64, validLen, placeHoldersLen) { - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function toByteArray (b64) { - var tmp - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - - var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) - - var curByte = 0 - - // if there are placeholders, only get up to the last complete 4 chars - var len = placeHoldersLen > 0 - ? validLen - 4 - : validLen - - var i - for (i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | - (revLookup[b64.charCodeAt(i + 1)] << 12) | - (revLookup[b64.charCodeAt(i + 2)] << 6) | - revLookup[b64.charCodeAt(i + 3)] - arr[curByte++] = (tmp >> 16) & 0xFF - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | - (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | - (revLookup[b64.charCodeAt(i + 1)] << 4) | - (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + - lookup[num >> 12 & 0x3F] + - lookup[num >> 6 & 0x3F] + - lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xFF0000) + - ((uint8[i + 1] << 8) & 0xFF00) + - (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - parts.push( - lookup[tmp >> 2] + - lookup[(tmp << 4) & 0x3F] + - '==' - ) - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + uint8[len - 1] - parts.push( - lookup[tmp >> 10] + - lookup[(tmp >> 4) & 0x3F] + - lookup[(tmp << 2) & 0x3F] + - '=' - ) - } - - return parts.join('') -} diff --git a/node_modules/base64-js/package.json b/node_modules/base64-js/package.json deleted file mode 100644 index c3972e39f2be5..0000000000000 --- a/node_modules/base64-js/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "base64-js", - "description": "Base64 encoding/decoding in pure JS", - "version": "1.5.1", - "author": "T. Jameson Little ", - "typings": "index.d.ts", - "bugs": { - "url": "https://github.com/beatgammit/base64-js/issues" - }, - "devDependencies": { - "babel-minify": "^0.5.1", - "benchmark": "^2.1.4", - "browserify": "^16.3.0", - "standard": "*", - "tape": "4.x" - }, - "homepage": "https://github.com/beatgammit/base64-js", - "keywords": [ - "base64" - ], - "license": "MIT", - "main": "index.js", - "repository": { - "type": "git", - "url": "git://github.com/beatgammit/base64-js.git" - }, - "scripts": { - "build": "browserify -s base64js -r ./ | minify > base64js.min.js", - "lint": "standard", - "test": "npm run lint && npm run unit", - "unit": "tape test/*.js" - }, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] -} diff --git a/node_modules/buffer/AUTHORS.md b/node_modules/buffer/AUTHORS.md deleted file mode 100644 index 468aa1908c379..0000000000000 --- a/node_modules/buffer/AUTHORS.md +++ /dev/null @@ -1,73 +0,0 @@ -# Authors - -#### Ordered by first contribution. - -- Romain Beauxis (toots@rastageeks.org) -- Tobias Koppers (tobias.koppers@googlemail.com) -- Janus (ysangkok@gmail.com) -- Rainer Dreyer (rdrey1@gmail.com) -- Tõnis Tiigi (tonistiigi@gmail.com) -- James Halliday (mail@substack.net) -- Michael Williamson (mike@zwobble.org) -- elliottcable (github@elliottcable.name) -- rafael (rvalle@livelens.net) -- Andrew Kelley (superjoe30@gmail.com) -- Andreas Madsen (amwebdk@gmail.com) -- Mike Brevoort (mike.brevoort@pearson.com) -- Brian White (mscdex@mscdex.net) -- Feross Aboukhadijeh (feross@feross.org) -- Ruben Verborgh (ruben@verborgh.org) -- eliang (eliang.cs@gmail.com) -- Jesse Tane (jesse.tane@gmail.com) -- Alfonso Boza (alfonso@cloud.com) -- Mathias Buus (mathiasbuus@gmail.com) -- Devon Govett (devongovett@gmail.com) -- Daniel Cousens (github@dcousens.com) -- Joseph Dykstra (josephdykstra@gmail.com) -- Parsha Pourkhomami (parshap+git@gmail.com) -- Damjan Košir (damjan.kosir@gmail.com) -- daverayment (dave.rayment@gmail.com) -- kawanet (u-suke@kawa.net) -- Linus Unnebäck (linus@folkdatorn.se) -- Nolan Lawson (nolan.lawson@gmail.com) -- Calvin Metcalf (calvin.metcalf@gmail.com) -- Koki Takahashi (hakatasiloving@gmail.com) -- Guy Bedford (guybedford@gmail.com) -- Jan Schär (jscissr@gmail.com) -- RaulTsc (tomescu.raul@gmail.com) -- Matthieu Monsch (monsch@alum.mit.edu) -- Dan Ehrenberg (littledan@chromium.org) -- Kirill Fomichev (fanatid@ya.ru) -- Yusuke Kawasaki (u-suke@kawa.net) -- DC (dcposch@dcpos.ch) -- John-David Dalton (john.david.dalton@gmail.com) -- adventure-yunfei (adventure030@gmail.com) -- Emil Bay (github@tixz.dk) -- Sam Sudar (sudar.sam@gmail.com) -- Volker Mische (volker.mische@gmail.com) -- David Walton (support@geekstocks.com) -- Сковорода Никита Андреевич (chalkerx@gmail.com) -- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com) -- ukstv (sergey.ukustov@machinomy.com) -- Renée Kooi (renee@kooi.me) -- ranbochen (ranbochen@qq.com) -- Vladimir Borovik (bobahbdb@gmail.com) -- greenkeeper[bot] (23040076+greenkeeper[bot]@users.noreply.github.com) -- kumavis (aaron@kumavis.me) -- Sergey Ukustov (sergey.ukustov@machinomy.com) -- Fei Liu (liu.feiwood@gmail.com) -- Blaine Bublitz (blaine.bublitz@gmail.com) -- clement (clement@seald.io) -- Koushik Dutta (koushd@gmail.com) -- Jordan Harband (ljharb@gmail.com) -- Niklas Mischkulnig (mischnic@users.noreply.github.com) -- Nikolai Vavilov (vvnicholas@gmail.com) -- Fedor Nezhivoi (gyzerok@users.noreply.github.com) -- shuse2 (shus.toda@gmail.com) -- Peter Newman (peternewman@users.noreply.github.com) -- mathmakgakpak (44949126+mathmakgakpak@users.noreply.github.com) -- jkkang (jkkang@smartauth.kr) -- Deklan Webster (deklanw@gmail.com) -- Martin Heidegger (martin.heidegger@gmail.com) - -#### Generated by bin/update-authors.sh. diff --git a/node_modules/buffer/LICENSE b/node_modules/buffer/LICENSE deleted file mode 100644 index d6bf75dcf1f6f..0000000000000 --- a/node_modules/buffer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Feross Aboukhadijeh, and other contributors. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/buffer/index.js b/node_modules/buffer/index.js deleted file mode 100644 index 7a0e9c2a123bc..0000000000000 --- a/node_modules/buffer/index.js +++ /dev/null @@ -1,2106 +0,0 @@ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -const base64 = require('base64-js') -const ieee754 = require('ieee754') -const customInspectSymbol = - (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation - ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation - : null - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -const K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} - -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - const arr = new Uint8Array(1) - const proto = { foo: function () { return 42 } } - Object.setPrototypeOf(proto, Uint8Array.prototype) - Object.setPrototypeOf(arr, proto) - return arr.foo() === 42 - } catch (e) { - return false - } -} - -Object.defineProperty(Buffer.prototype, 'parent', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.buffer - } -}) - -Object.defineProperty(Buffer.prototype, 'offset', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.byteOffset - } -}) - -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('The value "' + length + '" is invalid for option "size"') - } - // Return an augmented `Uint8Array` instance - const buf = new Uint8Array(length) - Object.setPrototypeOf(buf, Buffer.prototype) - return buf -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new TypeError( - 'The "string" argument must be of type string. Received type number' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) -} - -Buffer.poolSize = 8192 // not used by this implementation - -function from (value, encodingOrOffset, length) { - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - if (ArrayBuffer.isView(value)) { - return fromArrayView(value) - } - - if (value == null) { - throw new TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) - } - - if (isInstance(value, ArrayBuffer) || - (value && isInstance(value.buffer, ArrayBuffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof SharedArrayBuffer !== 'undefined' && - (isInstance(value, SharedArrayBuffer) || - (value && isInstance(value.buffer, SharedArrayBuffer)))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof value === 'number') { - throw new TypeError( - 'The "value" argument must not be of type number. Received type number' - ) - } - - const valueOf = value.valueOf && value.valueOf() - if (valueOf != null && valueOf !== value) { - return Buffer.from(valueOf, encodingOrOffset, length) - } - - const b = fromObject(value) - if (b) return b - - if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && - typeof value[Symbol.toPrimitive] === 'function') { - return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length) - } - - throw new TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} - -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype) -Object.setPrototypeOf(Buffer, Uint8Array) - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('The value "' + size + '" is invalid for option "size"') - } -} - -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpreted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} - -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} - -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - - const length = byteLength(string, encoding) | 0 - let buf = createBuffer(length) - - const actual = buf.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } - - return buf -} - -function fromArrayLike (array) { - const length = array.length < 0 ? 0 : checked(array.length) | 0 - const buf = createBuffer(length) - for (let i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf -} - -function fromArrayView (arrayView) { - if (isInstance(arrayView, Uint8Array)) { - const copy = new Uint8Array(arrayView) - return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength) - } - return fromArrayLike(arrayView) -} - -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } - - let buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } - - // Return an augmented `Uint8Array` instance - Object.setPrototypeOf(buf, Buffer.prototype) - - return buf -} - -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - const len = checked(obj.length) | 0 - const buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } - - obj.copy(buf, 0, 0, len) - return buf - } - - if (obj.length !== undefined) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } -} - -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true && - b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false -} - -Buffer.compare = function compare (a, b) { - if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) - if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError( - 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' - ) - } - - if (a === b) return 0 - - let x = a.length - let y = b.length - - for (let i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - let i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - const buffer = Buffer.allocUnsafe(length) - let pos = 0 - for (i = 0; i < list.length; ++i) { - let buf = list[i] - if (isInstance(buf, Uint8Array)) { - if (pos + buf.length > buffer.length) { - if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf) - buf.copy(buffer, pos) - } else { - Uint8Array.prototype.set.call( - buffer, - buf, - pos - ) - } - } else if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } else { - buf.copy(buffer, pos) - } - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - throw new TypeError( - 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + - 'Received type ' + typeof string - ) - } - - const len = string.length - const mustMatch = (arguments.length > 2 && arguments[2] === true) - if (!mustMatch && len === 0) return 0 - - // Use a for loop to avoid recursion - let loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) { - return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 - } - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - let loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coercion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - const i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - const len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (let i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - const len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (let i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - const len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (let i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - const length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.toLocaleString = Buffer.prototype.toString - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - let str = '' - const max = exports.INSPECT_MAX_BYTES - str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() - if (this.length > max) str += ' ... ' - return '' -} -if (customInspectSymbol) { - Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (isInstance(target, Uint8Array)) { - target = Buffer.from(target, target.offset, target.byteLength) - } - if (!Buffer.isBuffer(target)) { - throw new TypeError( - 'The "target" argument must be one of type Buffer or Uint8Array. ' + - 'Received type ' + (typeof target) - ) - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - let x = thisEnd - thisStart - let y = end - start - const len = Math.min(x, y) - - const thisCopy = this.slice(thisStart, thisEnd) - const targetCopy = target.slice(start, end) - - for (let i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [val], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - let indexSize = 1 - let arrLength = arr.length - let valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - let i - if (dir) { - let foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - let found = true - for (let j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - const remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - const strLen = string.length - - if (length > strLen / 2) { - length = strLen / 2 - } - let i - for (i = 0; i < length; ++i) { - const parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - const remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - let loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - case 'latin1': - case 'binary': - return asciiWrite(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - const res = [] - - let i = start - while (i < end) { - const firstByte = buf[i] - let codePoint = null - let bytesPerSequence = (firstByte > 0xEF) - ? 4 - : (firstByte > 0xDF) - ? 3 - : (firstByte > 0xBF) - ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - let secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -const MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - const len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - let res = '' - let i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - let ret = '' - end = Math.min(buf.length, end) - - for (let i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - let ret = '' - end = Math.min(buf.length, end) - - for (let i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - const len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - let out = '' - for (let i = start; i < end; ++i) { - out += hexSliceLookupTable[buf[i]] - } - return out -} - -function utf16leSlice (buf, start, end) { - const bytes = buf.slice(start, end) - let res = '' - // If bytes.length is odd, the last 8 bits must be ignored (same as node.js) - for (let i = 0; i < bytes.length - 1; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - const len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - const newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - Object.setPrototypeOf(newBuf, Buffer.prototype) - - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUintLE = -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - let val = this[offset] - let mul = 1 - let i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUintBE = -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - let val = this[offset + --byteLength] - let mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUint8 = -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUint16LE = -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUint16BE = -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUint32LE = -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUint32BE = -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) { - offset = offset >>> 0 - validateNumber(offset, 'offset') - const first = this[offset] - const last = this[offset + 7] - if (first === undefined || last === undefined) { - boundsError(offset, this.length - 8) - } - - const lo = first + - this[++offset] * 2 ** 8 + - this[++offset] * 2 ** 16 + - this[++offset] * 2 ** 24 - - const hi = this[++offset] + - this[++offset] * 2 ** 8 + - this[++offset] * 2 ** 16 + - last * 2 ** 24 - - return BigInt(lo) + (BigInt(hi) << BigInt(32)) -}) - -Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) { - offset = offset >>> 0 - validateNumber(offset, 'offset') - const first = this[offset] - const last = this[offset + 7] - if (first === undefined || last === undefined) { - boundsError(offset, this.length - 8) - } - - const hi = first * 2 ** 24 + - this[++offset] * 2 ** 16 + - this[++offset] * 2 ** 8 + - this[++offset] - - const lo = this[++offset] * 2 ** 24 + - this[++offset] * 2 ** 16 + - this[++offset] * 2 ** 8 + - last - - return (BigInt(hi) << BigInt(32)) + BigInt(lo) -}) - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - let val = this[offset] - let mul = 1 - let i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - let i = byteLength - let mul = 1 - let val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - const val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - const val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) { - offset = offset >>> 0 - validateNumber(offset, 'offset') - const first = this[offset] - const last = this[offset + 7] - if (first === undefined || last === undefined) { - boundsError(offset, this.length - 8) - } - - const val = this[offset + 4] + - this[offset + 5] * 2 ** 8 + - this[offset + 6] * 2 ** 16 + - (last << 24) // Overflow - - return (BigInt(val) << BigInt(32)) + - BigInt(first + - this[++offset] * 2 ** 8 + - this[++offset] * 2 ** 16 + - this[++offset] * 2 ** 24) -}) - -Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) { - offset = offset >>> 0 - validateNumber(offset, 'offset') - const first = this[offset] - const last = this[offset + 7] - if (first === undefined || last === undefined) { - boundsError(offset, this.length - 8) - } - - const val = (first << 24) + // Overflow - this[++offset] * 2 ** 16 + - this[++offset] * 2 ** 8 + - this[++offset] - - return (BigInt(val) << BigInt(32)) + - BigInt(this[++offset] * 2 ** 24 + - this[++offset] * 2 ** 16 + - this[++offset] * 2 ** 8 + - last) -}) - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUintLE = -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - const maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - let mul = 1 - let i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUintBE = -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - const maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - let i = byteLength - 1 - let mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUint8 = -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeUint16LE = -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeUint16BE = -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeUint32LE = -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeUint32BE = -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -function wrtBigUInt64LE (buf, value, offset, min, max) { - checkIntBI(value, min, max, buf, offset, 7) - - let lo = Number(value & BigInt(0xffffffff)) - buf[offset++] = lo - lo = lo >> 8 - buf[offset++] = lo - lo = lo >> 8 - buf[offset++] = lo - lo = lo >> 8 - buf[offset++] = lo - let hi = Number(value >> BigInt(32) & BigInt(0xffffffff)) - buf[offset++] = hi - hi = hi >> 8 - buf[offset++] = hi - hi = hi >> 8 - buf[offset++] = hi - hi = hi >> 8 - buf[offset++] = hi - return offset -} - -function wrtBigUInt64BE (buf, value, offset, min, max) { - checkIntBI(value, min, max, buf, offset, 7) - - let lo = Number(value & BigInt(0xffffffff)) - buf[offset + 7] = lo - lo = lo >> 8 - buf[offset + 6] = lo - lo = lo >> 8 - buf[offset + 5] = lo - lo = lo >> 8 - buf[offset + 4] = lo - let hi = Number(value >> BigInt(32) & BigInt(0xffffffff)) - buf[offset + 3] = hi - hi = hi >> 8 - buf[offset + 2] = hi - hi = hi >> 8 - buf[offset + 1] = hi - hi = hi >> 8 - buf[offset] = hi - return offset + 8 -} - -Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) { - return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff')) -}) - -Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) { - return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff')) -}) - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - const limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - let i = 0 - let mul = 1 - let sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - const limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - let i = byteLength - 1 - let mul = 1 - let sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) { - return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff')) -}) - -Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) { - return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff')) -}) - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - const len = end - start - - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - if (val.length === 1) { - const code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } - } - } else if (typeof val === 'number') { - val = val & 255 - } else if (typeof val === 'boolean') { - val = Number(val) - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - let i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - const bytes = Buffer.isBuffer(val) - ? val - : Buffer.from(val, encoding) - const len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// CUSTOM ERRORS -// ============= - -// Simplified versions from Node, changed for Buffer-only usage -const errors = {} -function E (sym, getMessage, Base) { - errors[sym] = class NodeError extends Base { - constructor () { - super() - - Object.defineProperty(this, 'message', { - value: getMessage.apply(this, arguments), - writable: true, - configurable: true - }) - - // Add the error code to the name to include it in the stack trace. - this.name = `${this.name} [${sym}]` - // Access the stack to generate the error message including the error code - // from the name. - this.stack // eslint-disable-line no-unused-expressions - // Reset the name to the actual name. - delete this.name - } - - get code () { - return sym - } - - set code (value) { - Object.defineProperty(this, 'code', { - configurable: true, - enumerable: true, - value, - writable: true - }) - } - - toString () { - return `${this.name} [${sym}]: ${this.message}` - } - } -} - -E('ERR_BUFFER_OUT_OF_BOUNDS', - function (name) { - if (name) { - return `${name} is outside of buffer bounds` - } - - return 'Attempt to access memory outside buffer bounds' - }, RangeError) -E('ERR_INVALID_ARG_TYPE', - function (name, actual) { - return `The "${name}" argument must be of type number. Received type ${typeof actual}` - }, TypeError) -E('ERR_OUT_OF_RANGE', - function (str, range, input) { - let msg = `The value of "${str}" is out of range.` - let received = input - if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { - received = addNumericalSeparator(String(input)) - } else if (typeof input === 'bigint') { - received = String(input) - if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) { - received = addNumericalSeparator(received) - } - received += 'n' - } - msg += ` It must be ${range}. Received ${received}` - return msg - }, RangeError) - -function addNumericalSeparator (val) { - let res = '' - let i = val.length - const start = val[0] === '-' ? 1 : 0 - for (; i >= start + 4; i -= 3) { - res = `_${val.slice(i - 3, i)}${res}` - } - return `${val.slice(0, i)}${res}` -} - -// CHECK FUNCTIONS -// =============== - -function checkBounds (buf, offset, byteLength) { - validateNumber(offset, 'offset') - if (buf[offset] === undefined || buf[offset + byteLength] === undefined) { - boundsError(offset, buf.length - (byteLength + 1)) - } -} - -function checkIntBI (value, min, max, buf, offset, byteLength) { - if (value > max || value < min) { - const n = typeof min === 'bigint' ? 'n' : '' - let range - if (byteLength > 3) { - if (min === 0 || min === BigInt(0)) { - range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}` - } else { - range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` + - `${(byteLength + 1) * 8 - 1}${n}` - } - } else { - range = `>= ${min}${n} and <= ${max}${n}` - } - throw new errors.ERR_OUT_OF_RANGE('value', range, value) - } - checkBounds(buf, offset, byteLength) -} - -function validateNumber (value, name) { - if (typeof value !== 'number') { - throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value) - } -} - -function boundsError (value, length, type) { - if (Math.floor(value) !== value) { - validateNumber(value, type) - throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value) - } - - if (length < 0) { - throw new errors.ERR_BUFFER_OUT_OF_BOUNDS() - } - - throw new errors.ERR_OUT_OF_RANGE(type || 'offset', - `>= ${type ? 1 : 0} and <= ${length}`, - value) -} - -// HELPER FUNCTIONS -// ================ - -const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function utf8ToBytes (string, units) { - units = units || Infinity - let codePoint - const length = string.length - let leadSurrogate = null - const bytes = [] - - for (let i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - const byteArray = [] - for (let i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - let c, hi, lo - const byteArray = [] - for (let i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - let i - for (i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass -// the `instanceof` check but they should be treated as of that type. -// See: https://github.com/feross/buffer/issues/166 -function isInstance (obj, type) { - return obj instanceof type || - (obj != null && obj.constructor != null && obj.constructor.name != null && - obj.constructor.name === type.name) -} -function numberIsNaN (obj) { - // For IE11 support - return obj !== obj // eslint-disable-line no-self-compare -} - -// Create lookup table for `toString('hex')` -// See: https://github.com/feross/buffer/issues/219 -const hexSliceLookupTable = (function () { - const alphabet = '0123456789abcdef' - const table = new Array(256) - for (let i = 0; i < 16; ++i) { - const i16 = i * 16 - for (let j = 0; j < 16; ++j) { - table[i16 + j] = alphabet[i] + alphabet[j] - } - } - return table -})() - -// Return not function with Error if BigInt not supported -function defineBigIntMethod (fn) { - return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn -} - -function BufferBigIntNotDefined () { - throw new Error('BigInt not supported') -} diff --git a/node_modules/buffer/package.json b/node_modules/buffer/package.json deleted file mode 100644 index ca1ad9a707884..0000000000000 --- a/node_modules/buffer/package.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "name": "buffer", - "description": "Node.js Buffer API, for the browser", - "version": "6.0.3", - "author": { - "name": "Feross Aboukhadijeh", - "email": "feross@feross.org", - "url": "https://feross.org" - }, - "bugs": { - "url": "https://github.com/feross/buffer/issues" - }, - "contributors": [ - "Romain Beauxis ", - "James Halliday " - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - }, - "devDependencies": { - "airtap": "^3.0.0", - "benchmark": "^2.1.4", - "browserify": "^17.0.0", - "concat-stream": "^2.0.0", - "hyperquest": "^2.1.3", - "is-buffer": "^2.0.5", - "is-nan": "^1.3.0", - "split": "^1.0.1", - "standard": "*", - "tape": "^5.0.1", - "through2": "^4.0.2", - "uglify-js": "^3.11.5" - }, - "homepage": "https://github.com/feross/buffer", - "jspm": { - "map": { - "./index.js": { - "node": "@node/buffer" - } - } - }, - "keywords": [ - "arraybuffer", - "browser", - "browserify", - "buffer", - "compatible", - "dataview", - "uint8array" - ], - "license": "MIT", - "main": "index.js", - "types": "index.d.ts", - "repository": { - "type": "git", - "url": "git://github.com/feross/buffer.git" - }, - "scripts": { - "perf": "browserify --debug perf/bracket-notation.js > perf/bundle.js && open perf/index.html", - "perf-node": "node perf/bracket-notation.js && node perf/concat.js && node perf/copy-big.js && node perf/copy.js && node perf/new-big.js && node perf/new.js && node perf/readDoubleBE.js && node perf/readFloatBE.js && node perf/readUInt32LE.js && node perf/slice.js && node perf/writeFloatBE.js", - "size": "browserify -r ./ | uglifyjs -c -m | gzip | wc -c", - "test": "standard && node ./bin/test.js", - "test-browser-old": "airtap -- test/*.js", - "test-browser-old-local": "airtap --local -- test/*.js", - "test-browser-new": "airtap -- test/*.js test/node/*.js", - "test-browser-new-local": "airtap --local -- test/*.js test/node/*.js", - "test-node": "tape test/*.js test/node/*.js", - "update-authors": "./bin/update-authors.sh" - }, - "standard": { - "ignore": [ - "test/node/**/*.js", - "test/common.js", - "test/_polyfill.js", - "perf/**/*.js" - ] - }, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] -} diff --git a/node_modules/delegates/History.md b/node_modules/delegates/History.md deleted file mode 100644 index 25959eab67b84..0000000000000 --- a/node_modules/delegates/History.md +++ /dev/null @@ -1,22 +0,0 @@ - -1.0.0 / 2015-12-14 -================== - - * Merge pull request #12 from kasicka/master - * Add license text - -0.1.0 / 2014-10-17 -================== - - * adds `.fluent()` to api - -0.0.3 / 2014-01-13 -================== - - * fix receiver for .method() - -0.0.2 / 2014-01-13 -================== - - * Object.defineProperty() sucks - * Initial commit diff --git a/node_modules/delegates/License b/node_modules/delegates/License deleted file mode 100644 index 60de60addbe7e..0000000000000 --- a/node_modules/delegates/License +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2015 TJ Holowaychuk - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/delegates/Makefile b/node_modules/delegates/Makefile deleted file mode 100644 index a9dcfd50dbdb2..0000000000000 --- a/node_modules/delegates/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -test: - @./node_modules/.bin/mocha \ - --require should \ - --reporter spec \ - --bail - -.PHONY: test \ No newline at end of file diff --git a/node_modules/delegates/index.js b/node_modules/delegates/index.js deleted file mode 100644 index 17c222d52935c..0000000000000 --- a/node_modules/delegates/index.js +++ /dev/null @@ -1,121 +0,0 @@ - -/** - * Expose `Delegator`. - */ - -module.exports = Delegator; - -/** - * Initialize a delegator. - * - * @param {Object} proto - * @param {String} target - * @api public - */ - -function Delegator(proto, target) { - if (!(this instanceof Delegator)) return new Delegator(proto, target); - this.proto = proto; - this.target = target; - this.methods = []; - this.getters = []; - this.setters = []; - this.fluents = []; -} - -/** - * Delegate method `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.method = function(name){ - var proto = this.proto; - var target = this.target; - this.methods.push(name); - - proto[name] = function(){ - return this[target][name].apply(this[target], arguments); - }; - - return this; -}; - -/** - * Delegator accessor `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.access = function(name){ - return this.getter(name).setter(name); -}; - -/** - * Delegator getter `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.getter = function(name){ - var proto = this.proto; - var target = this.target; - this.getters.push(name); - - proto.__defineGetter__(name, function(){ - return this[target][name]; - }); - - return this; -}; - -/** - * Delegator setter `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.setter = function(name){ - var proto = this.proto; - var target = this.target; - this.setters.push(name); - - proto.__defineSetter__(name, function(val){ - return this[target][name] = val; - }); - - return this; -}; - -/** - * Delegator fluent accessor - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.fluent = function (name) { - var proto = this.proto; - var target = this.target; - this.fluents.push(name); - - proto[name] = function(val){ - if ('undefined' != typeof val) { - this[target][name] = val; - return this; - } else { - return this[target][name]; - } - }; - - return this; -}; diff --git a/node_modules/delegates/package.json b/node_modules/delegates/package.json deleted file mode 100644 index 17240384fd43b..0000000000000 --- a/node_modules/delegates/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "delegates", - "version": "1.0.0", - "repository": "visionmedia/node-delegates", - "description": "delegate methods and accessors to another property", - "keywords": ["delegate", "delegation"], - "dependencies": {}, - "devDependencies": { - "mocha": "*", - "should": "*" - }, - "license": "MIT" -} diff --git a/node_modules/delegates/test/index.js b/node_modules/delegates/test/index.js deleted file mode 100644 index 7b6e3d4df19d9..0000000000000 --- a/node_modules/delegates/test/index.js +++ /dev/null @@ -1,94 +0,0 @@ - -var assert = require('assert'); -var delegate = require('..'); - -describe('.method(name)', function(){ - it('should delegate methods', function(){ - var obj = {}; - - obj.request = { - foo: function(bar){ - assert(this == obj.request); - return bar; - } - }; - - delegate(obj, 'request').method('foo'); - - obj.foo('something').should.equal('something'); - }) -}) - -describe('.getter(name)', function(){ - it('should delegate getters', function(){ - var obj = {}; - - obj.request = { - get type() { - return 'text/html'; - } - } - - delegate(obj, 'request').getter('type'); - - obj.type.should.equal('text/html'); - }) -}) - -describe('.setter(name)', function(){ - it('should delegate setters', function(){ - var obj = {}; - - obj.request = { - get type() { - return this._type.toUpperCase(); - }, - - set type(val) { - this._type = val; - } - } - - delegate(obj, 'request').setter('type'); - - obj.type = 'hey'; - obj.request.type.should.equal('HEY'); - }) -}) - -describe('.access(name)', function(){ - it('should delegate getters and setters', function(){ - var obj = {}; - - obj.request = { - get type() { - return this._type.toUpperCase(); - }, - - set type(val) { - this._type = val; - } - } - - delegate(obj, 'request').access('type'); - - obj.type = 'hey'; - obj.type.should.equal('HEY'); - }) -}) - -describe('.fluent(name)', function () { - it('should delegate in a fluent fashion', function () { - var obj = { - settings: { - env: 'development' - } - }; - - delegate(obj, 'settings').fluent('env'); - - obj.env().should.equal('development'); - obj.env('production').should.equal(obj); - obj.settings.env.should.equal('production'); - }) -}) diff --git a/node_modules/event-target-shim/LICENSE b/node_modules/event-target-shim/LICENSE deleted file mode 100644 index c39e6949ed2dc..0000000000000 --- a/node_modules/event-target-shim/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Toru Nagashima - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/node_modules/event-target-shim/dist/event-target-shim.js b/node_modules/event-target-shim/dist/event-target-shim.js deleted file mode 100644 index 53ce22036e35e..0000000000000 --- a/node_modules/event-target-shim/dist/event-target-shim.js +++ /dev/null @@ -1,871 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2015 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -/** - * @typedef {object} PrivateData - * @property {EventTarget} eventTarget The event target. - * @property {{type:string}} event The original event object. - * @property {number} eventPhase The current event phase. - * @property {EventTarget|null} currentTarget The current event target. - * @property {boolean} canceled The flag to prevent default. - * @property {boolean} stopped The flag to stop propagation. - * @property {boolean} immediateStopped The flag to stop propagation immediately. - * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null. - * @property {number} timeStamp The unix time. - * @private - */ - -/** - * Private data for event wrappers. - * @type {WeakMap} - * @private - */ -const privateData = new WeakMap(); - -/** - * Cache for wrapper classes. - * @type {WeakMap} - * @private - */ -const wrappers = new WeakMap(); - -/** - * Get private data. - * @param {Event} event The event object to get private data. - * @returns {PrivateData} The private data of the event. - * @private - */ -function pd(event) { - const retv = privateData.get(event); - console.assert( - retv != null, - "'this' is expected an Event object, but got", - event - ); - return retv -} - -/** - * https://dom.spec.whatwg.org/#set-the-canceled-flag - * @param data {PrivateData} private data. - */ -function setCancelFlag(data) { - if (data.passiveListener != null) { - if ( - typeof console !== "undefined" && - typeof console.error === "function" - ) { - console.error( - "Unable to preventDefault inside passive event listener invocation.", - data.passiveListener - ); - } - return - } - if (!data.event.cancelable) { - return - } - - data.canceled = true; - if (typeof data.event.preventDefault === "function") { - data.event.preventDefault(); - } -} - -/** - * @see https://dom.spec.whatwg.org/#interface-event - * @private - */ -/** - * The event wrapper. - * @constructor - * @param {EventTarget} eventTarget The event target of this dispatching. - * @param {Event|{type:string}} event The original event to wrap. - */ -function Event(eventTarget, event) { - privateData.set(this, { - eventTarget, - event, - eventPhase: 2, - currentTarget: eventTarget, - canceled: false, - stopped: false, - immediateStopped: false, - passiveListener: null, - timeStamp: event.timeStamp || Date.now(), - }); - - // https://heycam.github.io/webidl/#Unforgeable - Object.defineProperty(this, "isTrusted", { value: false, enumerable: true }); - - // Define accessors - const keys = Object.keys(event); - for (let i = 0; i < keys.length; ++i) { - const key = keys[i]; - if (!(key in this)) { - Object.defineProperty(this, key, defineRedirectDescriptor(key)); - } - } -} - -// Should be enumerable, but class methods are not enumerable. -Event.prototype = { - /** - * The type of this event. - * @type {string} - */ - get type() { - return pd(this).event.type - }, - - /** - * The target of this event. - * @type {EventTarget} - */ - get target() { - return pd(this).eventTarget - }, - - /** - * The target of this event. - * @type {EventTarget} - */ - get currentTarget() { - return pd(this).currentTarget - }, - - /** - * @returns {EventTarget[]} The composed path of this event. - */ - composedPath() { - const currentTarget = pd(this).currentTarget; - if (currentTarget == null) { - return [] - } - return [currentTarget] - }, - - /** - * Constant of NONE. - * @type {number} - */ - get NONE() { - return 0 - }, - - /** - * Constant of CAPTURING_PHASE. - * @type {number} - */ - get CAPTURING_PHASE() { - return 1 - }, - - /** - * Constant of AT_TARGET. - * @type {number} - */ - get AT_TARGET() { - return 2 - }, - - /** - * Constant of BUBBLING_PHASE. - * @type {number} - */ - get BUBBLING_PHASE() { - return 3 - }, - - /** - * The target of this event. - * @type {number} - */ - get eventPhase() { - return pd(this).eventPhase - }, - - /** - * Stop event bubbling. - * @returns {void} - */ - stopPropagation() { - const data = pd(this); - - data.stopped = true; - if (typeof data.event.stopPropagation === "function") { - data.event.stopPropagation(); - } - }, - - /** - * Stop event bubbling. - * @returns {void} - */ - stopImmediatePropagation() { - const data = pd(this); - - data.stopped = true; - data.immediateStopped = true; - if (typeof data.event.stopImmediatePropagation === "function") { - data.event.stopImmediatePropagation(); - } - }, - - /** - * The flag to be bubbling. - * @type {boolean} - */ - get bubbles() { - return Boolean(pd(this).event.bubbles) - }, - - /** - * The flag to be cancelable. - * @type {boolean} - */ - get cancelable() { - return Boolean(pd(this).event.cancelable) - }, - - /** - * Cancel this event. - * @returns {void} - */ - preventDefault() { - setCancelFlag(pd(this)); - }, - - /** - * The flag to indicate cancellation state. - * @type {boolean} - */ - get defaultPrevented() { - return pd(this).canceled - }, - - /** - * The flag to be composed. - * @type {boolean} - */ - get composed() { - return Boolean(pd(this).event.composed) - }, - - /** - * The unix time of this event. - * @type {number} - */ - get timeStamp() { - return pd(this).timeStamp - }, - - /** - * The target of this event. - * @type {EventTarget} - * @deprecated - */ - get srcElement() { - return pd(this).eventTarget - }, - - /** - * The flag to stop event bubbling. - * @type {boolean} - * @deprecated - */ - get cancelBubble() { - return pd(this).stopped - }, - set cancelBubble(value) { - if (!value) { - return - } - const data = pd(this); - - data.stopped = true; - if (typeof data.event.cancelBubble === "boolean") { - data.event.cancelBubble = true; - } - }, - - /** - * The flag to indicate cancellation state. - * @type {boolean} - * @deprecated - */ - get returnValue() { - return !pd(this).canceled - }, - set returnValue(value) { - if (!value) { - setCancelFlag(pd(this)); - } - }, - - /** - * Initialize this event object. But do nothing under event dispatching. - * @param {string} type The event type. - * @param {boolean} [bubbles=false] The flag to be possible to bubble up. - * @param {boolean} [cancelable=false] The flag to be possible to cancel. - * @deprecated - */ - initEvent() { - // Do nothing. - }, -}; - -// `constructor` is not enumerable. -Object.defineProperty(Event.prototype, "constructor", { - value: Event, - configurable: true, - writable: true, -}); - -// Ensure `event instanceof window.Event` is `true`. -if (typeof window !== "undefined" && typeof window.Event !== "undefined") { - Object.setPrototypeOf(Event.prototype, window.Event.prototype); - - // Make association for wrappers. - wrappers.set(window.Event.prototype, Event); -} - -/** - * Get the property descriptor to redirect a given property. - * @param {string} key Property name to define property descriptor. - * @returns {PropertyDescriptor} The property descriptor to redirect the property. - * @private - */ -function defineRedirectDescriptor(key) { - return { - get() { - return pd(this).event[key] - }, - set(value) { - pd(this).event[key] = value; - }, - configurable: true, - enumerable: true, - } -} - -/** - * Get the property descriptor to call a given method property. - * @param {string} key Property name to define property descriptor. - * @returns {PropertyDescriptor} The property descriptor to call the method property. - * @private - */ -function defineCallDescriptor(key) { - return { - value() { - const event = pd(this).event; - return event[key].apply(event, arguments) - }, - configurable: true, - enumerable: true, - } -} - -/** - * Define new wrapper class. - * @param {Function} BaseEvent The base wrapper class. - * @param {Object} proto The prototype of the original event. - * @returns {Function} The defined wrapper class. - * @private - */ -function defineWrapper(BaseEvent, proto) { - const keys = Object.keys(proto); - if (keys.length === 0) { - return BaseEvent - } - - /** CustomEvent */ - function CustomEvent(eventTarget, event) { - BaseEvent.call(this, eventTarget, event); - } - - CustomEvent.prototype = Object.create(BaseEvent.prototype, { - constructor: { value: CustomEvent, configurable: true, writable: true }, - }); - - // Define accessors. - for (let i = 0; i < keys.length; ++i) { - const key = keys[i]; - if (!(key in BaseEvent.prototype)) { - const descriptor = Object.getOwnPropertyDescriptor(proto, key); - const isFunc = typeof descriptor.value === "function"; - Object.defineProperty( - CustomEvent.prototype, - key, - isFunc - ? defineCallDescriptor(key) - : defineRedirectDescriptor(key) - ); - } - } - - return CustomEvent -} - -/** - * Get the wrapper class of a given prototype. - * @param {Object} proto The prototype of the original event to get its wrapper. - * @returns {Function} The wrapper class. - * @private - */ -function getWrapper(proto) { - if (proto == null || proto === Object.prototype) { - return Event - } - - let wrapper = wrappers.get(proto); - if (wrapper == null) { - wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto); - wrappers.set(proto, wrapper); - } - return wrapper -} - -/** - * Wrap a given event to management a dispatching. - * @param {EventTarget} eventTarget The event target of this dispatching. - * @param {Object} event The event to wrap. - * @returns {Event} The wrapper instance. - * @private - */ -function wrapEvent(eventTarget, event) { - const Wrapper = getWrapper(Object.getPrototypeOf(event)); - return new Wrapper(eventTarget, event) -} - -/** - * Get the immediateStopped flag of a given event. - * @param {Event} event The event to get. - * @returns {boolean} The flag to stop propagation immediately. - * @private - */ -function isStopped(event) { - return pd(event).immediateStopped -} - -/** - * Set the current event phase of a given event. - * @param {Event} event The event to set current target. - * @param {number} eventPhase New event phase. - * @returns {void} - * @private - */ -function setEventPhase(event, eventPhase) { - pd(event).eventPhase = eventPhase; -} - -/** - * Set the current target of a given event. - * @param {Event} event The event to set current target. - * @param {EventTarget|null} currentTarget New current target. - * @returns {void} - * @private - */ -function setCurrentTarget(event, currentTarget) { - pd(event).currentTarget = currentTarget; -} - -/** - * Set a passive listener of a given event. - * @param {Event} event The event to set current target. - * @param {Function|null} passiveListener New passive listener. - * @returns {void} - * @private - */ -function setPassiveListener(event, passiveListener) { - pd(event).passiveListener = passiveListener; -} - -/** - * @typedef {object} ListenerNode - * @property {Function} listener - * @property {1|2|3} listenerType - * @property {boolean} passive - * @property {boolean} once - * @property {ListenerNode|null} next - * @private - */ - -/** - * @type {WeakMap>} - * @private - */ -const listenersMap = new WeakMap(); - -// Listener types -const CAPTURE = 1; -const BUBBLE = 2; -const ATTRIBUTE = 3; - -/** - * Check whether a given value is an object or not. - * @param {any} x The value to check. - * @returns {boolean} `true` if the value is an object. - */ -function isObject(x) { - return x !== null && typeof x === "object" //eslint-disable-line no-restricted-syntax -} - -/** - * Get listeners. - * @param {EventTarget} eventTarget The event target to get. - * @returns {Map} The listeners. - * @private - */ -function getListeners(eventTarget) { - const listeners = listenersMap.get(eventTarget); - if (listeners == null) { - throw new TypeError( - "'this' is expected an EventTarget object, but got another value." - ) - } - return listeners -} - -/** - * Get the property descriptor for the event attribute of a given event. - * @param {string} eventName The event name to get property descriptor. - * @returns {PropertyDescriptor} The property descriptor. - * @private - */ -function defineEventAttributeDescriptor(eventName) { - return { - get() { - const listeners = getListeners(this); - let node = listeners.get(eventName); - while (node != null) { - if (node.listenerType === ATTRIBUTE) { - return node.listener - } - node = node.next; - } - return null - }, - - set(listener) { - if (typeof listener !== "function" && !isObject(listener)) { - listener = null; // eslint-disable-line no-param-reassign - } - const listeners = getListeners(this); - - // Traverse to the tail while removing old value. - let prev = null; - let node = listeners.get(eventName); - while (node != null) { - if (node.listenerType === ATTRIBUTE) { - // Remove old value. - if (prev !== null) { - prev.next = node.next; - } else if (node.next !== null) { - listeners.set(eventName, node.next); - } else { - listeners.delete(eventName); - } - } else { - prev = node; - } - - node = node.next; - } - - // Add new value. - if (listener !== null) { - const newNode = { - listener, - listenerType: ATTRIBUTE, - passive: false, - once: false, - next: null, - }; - if (prev === null) { - listeners.set(eventName, newNode); - } else { - prev.next = newNode; - } - } - }, - configurable: true, - enumerable: true, - } -} - -/** - * Define an event attribute (e.g. `eventTarget.onclick`). - * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite. - * @param {string} eventName The event name to define. - * @returns {void} - */ -function defineEventAttribute(eventTargetPrototype, eventName) { - Object.defineProperty( - eventTargetPrototype, - `on${eventName}`, - defineEventAttributeDescriptor(eventName) - ); -} - -/** - * Define a custom EventTarget with event attributes. - * @param {string[]} eventNames Event names for event attributes. - * @returns {EventTarget} The custom EventTarget. - * @private - */ -function defineCustomEventTarget(eventNames) { - /** CustomEventTarget */ - function CustomEventTarget() { - EventTarget.call(this); - } - - CustomEventTarget.prototype = Object.create(EventTarget.prototype, { - constructor: { - value: CustomEventTarget, - configurable: true, - writable: true, - }, - }); - - for (let i = 0; i < eventNames.length; ++i) { - defineEventAttribute(CustomEventTarget.prototype, eventNames[i]); - } - - return CustomEventTarget -} - -/** - * EventTarget. - * - * - This is constructor if no arguments. - * - This is a function which returns a CustomEventTarget constructor if there are arguments. - * - * For example: - * - * class A extends EventTarget {} - * class B extends EventTarget("message") {} - * class C extends EventTarget("message", "error") {} - * class D extends EventTarget(["message", "error"]) {} - */ -function EventTarget() { - /*eslint-disable consistent-return */ - if (this instanceof EventTarget) { - listenersMap.set(this, new Map()); - return - } - if (arguments.length === 1 && Array.isArray(arguments[0])) { - return defineCustomEventTarget(arguments[0]) - } - if (arguments.length > 0) { - const types = new Array(arguments.length); - for (let i = 0; i < arguments.length; ++i) { - types[i] = arguments[i]; - } - return defineCustomEventTarget(types) - } - throw new TypeError("Cannot call a class as a function") - /*eslint-enable consistent-return */ -} - -// Should be enumerable, but class methods are not enumerable. -EventTarget.prototype = { - /** - * Add a given listener to this event target. - * @param {string} eventName The event name to add. - * @param {Function} listener The listener to add. - * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. - * @returns {void} - */ - addEventListener(eventName, listener, options) { - if (listener == null) { - return - } - if (typeof listener !== "function" && !isObject(listener)) { - throw new TypeError("'listener' should be a function or an object.") - } - - const listeners = getListeners(this); - const optionsIsObj = isObject(options); - const capture = optionsIsObj - ? Boolean(options.capture) - : Boolean(options); - const listenerType = capture ? CAPTURE : BUBBLE; - const newNode = { - listener, - listenerType, - passive: optionsIsObj && Boolean(options.passive), - once: optionsIsObj && Boolean(options.once), - next: null, - }; - - // Set it as the first node if the first node is null. - let node = listeners.get(eventName); - if (node === undefined) { - listeners.set(eventName, newNode); - return - } - - // Traverse to the tail while checking duplication.. - let prev = null; - while (node != null) { - if ( - node.listener === listener && - node.listenerType === listenerType - ) { - // Should ignore duplication. - return - } - prev = node; - node = node.next; - } - - // Add it. - prev.next = newNode; - }, - - /** - * Remove a given listener from this event target. - * @param {string} eventName The event name to remove. - * @param {Function} listener The listener to remove. - * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. - * @returns {void} - */ - removeEventListener(eventName, listener, options) { - if (listener == null) { - return - } - - const listeners = getListeners(this); - const capture = isObject(options) - ? Boolean(options.capture) - : Boolean(options); - const listenerType = capture ? CAPTURE : BUBBLE; - - let prev = null; - let node = listeners.get(eventName); - while (node != null) { - if ( - node.listener === listener && - node.listenerType === listenerType - ) { - if (prev !== null) { - prev.next = node.next; - } else if (node.next !== null) { - listeners.set(eventName, node.next); - } else { - listeners.delete(eventName); - } - return - } - - prev = node; - node = node.next; - } - }, - - /** - * Dispatch a given event. - * @param {Event|{type:string}} event The event to dispatch. - * @returns {boolean} `false` if canceled. - */ - dispatchEvent(event) { - if (event == null || typeof event.type !== "string") { - throw new TypeError('"event.type" should be a string.') - } - - // If listeners aren't registered, terminate. - const listeners = getListeners(this); - const eventName = event.type; - let node = listeners.get(eventName); - if (node == null) { - return true - } - - // Since we cannot rewrite several properties, so wrap object. - const wrappedEvent = wrapEvent(this, event); - - // This doesn't process capturing phase and bubbling phase. - // This isn't participating in a tree. - let prev = null; - while (node != null) { - // Remove this listener if it's once - if (node.once) { - if (prev !== null) { - prev.next = node.next; - } else if (node.next !== null) { - listeners.set(eventName, node.next); - } else { - listeners.delete(eventName); - } - } else { - prev = node; - } - - // Call this listener - setPassiveListener( - wrappedEvent, - node.passive ? node.listener : null - ); - if (typeof node.listener === "function") { - try { - node.listener.call(this, wrappedEvent); - } catch (err) { - if ( - typeof console !== "undefined" && - typeof console.error === "function" - ) { - console.error(err); - } - } - } else if ( - node.listenerType !== ATTRIBUTE && - typeof node.listener.handleEvent === "function" - ) { - node.listener.handleEvent(wrappedEvent); - } - - // Break if `event.stopImmediatePropagation` was called. - if (isStopped(wrappedEvent)) { - break - } - - node = node.next; - } - setPassiveListener(wrappedEvent, null); - setEventPhase(wrappedEvent, 0); - setCurrentTarget(wrappedEvent, null); - - return !wrappedEvent.defaultPrevented - }, -}; - -// `constructor` is not enumerable. -Object.defineProperty(EventTarget.prototype, "constructor", { - value: EventTarget, - configurable: true, - writable: true, -}); - -// Ensure `eventTarget instanceof window.EventTarget` is `true`. -if ( - typeof window !== "undefined" && - typeof window.EventTarget !== "undefined" -) { - Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype); -} - -exports.defineEventAttribute = defineEventAttribute; -exports.EventTarget = EventTarget; -exports.default = EventTarget; - -module.exports = EventTarget -module.exports.EventTarget = module.exports["default"] = EventTarget -module.exports.defineEventAttribute = defineEventAttribute -//# sourceMappingURL=event-target-shim.js.map diff --git a/node_modules/event-target-shim/dist/event-target-shim.mjs b/node_modules/event-target-shim/dist/event-target-shim.mjs deleted file mode 100644 index 114f3a1711059..0000000000000 --- a/node_modules/event-target-shim/dist/event-target-shim.mjs +++ /dev/null @@ -1,862 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2015 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */ -/** - * @typedef {object} PrivateData - * @property {EventTarget} eventTarget The event target. - * @property {{type:string}} event The original event object. - * @property {number} eventPhase The current event phase. - * @property {EventTarget|null} currentTarget The current event target. - * @property {boolean} canceled The flag to prevent default. - * @property {boolean} stopped The flag to stop propagation. - * @property {boolean} immediateStopped The flag to stop propagation immediately. - * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null. - * @property {number} timeStamp The unix time. - * @private - */ - -/** - * Private data for event wrappers. - * @type {WeakMap} - * @private - */ -const privateData = new WeakMap(); - -/** - * Cache for wrapper classes. - * @type {WeakMap} - * @private - */ -const wrappers = new WeakMap(); - -/** - * Get private data. - * @param {Event} event The event object to get private data. - * @returns {PrivateData} The private data of the event. - * @private - */ -function pd(event) { - const retv = privateData.get(event); - console.assert( - retv != null, - "'this' is expected an Event object, but got", - event - ); - return retv -} - -/** - * https://dom.spec.whatwg.org/#set-the-canceled-flag - * @param data {PrivateData} private data. - */ -function setCancelFlag(data) { - if (data.passiveListener != null) { - if ( - typeof console !== "undefined" && - typeof console.error === "function" - ) { - console.error( - "Unable to preventDefault inside passive event listener invocation.", - data.passiveListener - ); - } - return - } - if (!data.event.cancelable) { - return - } - - data.canceled = true; - if (typeof data.event.preventDefault === "function") { - data.event.preventDefault(); - } -} - -/** - * @see https://dom.spec.whatwg.org/#interface-event - * @private - */ -/** - * The event wrapper. - * @constructor - * @param {EventTarget} eventTarget The event target of this dispatching. - * @param {Event|{type:string}} event The original event to wrap. - */ -function Event(eventTarget, event) { - privateData.set(this, { - eventTarget, - event, - eventPhase: 2, - currentTarget: eventTarget, - canceled: false, - stopped: false, - immediateStopped: false, - passiveListener: null, - timeStamp: event.timeStamp || Date.now(), - }); - - // https://heycam.github.io/webidl/#Unforgeable - Object.defineProperty(this, "isTrusted", { value: false, enumerable: true }); - - // Define accessors - const keys = Object.keys(event); - for (let i = 0; i < keys.length; ++i) { - const key = keys[i]; - if (!(key in this)) { - Object.defineProperty(this, key, defineRedirectDescriptor(key)); - } - } -} - -// Should be enumerable, but class methods are not enumerable. -Event.prototype = { - /** - * The type of this event. - * @type {string} - */ - get type() { - return pd(this).event.type - }, - - /** - * The target of this event. - * @type {EventTarget} - */ - get target() { - return pd(this).eventTarget - }, - - /** - * The target of this event. - * @type {EventTarget} - */ - get currentTarget() { - return pd(this).currentTarget - }, - - /** - * @returns {EventTarget[]} The composed path of this event. - */ - composedPath() { - const currentTarget = pd(this).currentTarget; - if (currentTarget == null) { - return [] - } - return [currentTarget] - }, - - /** - * Constant of NONE. - * @type {number} - */ - get NONE() { - return 0 - }, - - /** - * Constant of CAPTURING_PHASE. - * @type {number} - */ - get CAPTURING_PHASE() { - return 1 - }, - - /** - * Constant of AT_TARGET. - * @type {number} - */ - get AT_TARGET() { - return 2 - }, - - /** - * Constant of BUBBLING_PHASE. - * @type {number} - */ - get BUBBLING_PHASE() { - return 3 - }, - - /** - * The target of this event. - * @type {number} - */ - get eventPhase() { - return pd(this).eventPhase - }, - - /** - * Stop event bubbling. - * @returns {void} - */ - stopPropagation() { - const data = pd(this); - - data.stopped = true; - if (typeof data.event.stopPropagation === "function") { - data.event.stopPropagation(); - } - }, - - /** - * Stop event bubbling. - * @returns {void} - */ - stopImmediatePropagation() { - const data = pd(this); - - data.stopped = true; - data.immediateStopped = true; - if (typeof data.event.stopImmediatePropagation === "function") { - data.event.stopImmediatePropagation(); - } - }, - - /** - * The flag to be bubbling. - * @type {boolean} - */ - get bubbles() { - return Boolean(pd(this).event.bubbles) - }, - - /** - * The flag to be cancelable. - * @type {boolean} - */ - get cancelable() { - return Boolean(pd(this).event.cancelable) - }, - - /** - * Cancel this event. - * @returns {void} - */ - preventDefault() { - setCancelFlag(pd(this)); - }, - - /** - * The flag to indicate cancellation state. - * @type {boolean} - */ - get defaultPrevented() { - return pd(this).canceled - }, - - /** - * The flag to be composed. - * @type {boolean} - */ - get composed() { - return Boolean(pd(this).event.composed) - }, - - /** - * The unix time of this event. - * @type {number} - */ - get timeStamp() { - return pd(this).timeStamp - }, - - /** - * The target of this event. - * @type {EventTarget} - * @deprecated - */ - get srcElement() { - return pd(this).eventTarget - }, - - /** - * The flag to stop event bubbling. - * @type {boolean} - * @deprecated - */ - get cancelBubble() { - return pd(this).stopped - }, - set cancelBubble(value) { - if (!value) { - return - } - const data = pd(this); - - data.stopped = true; - if (typeof data.event.cancelBubble === "boolean") { - data.event.cancelBubble = true; - } - }, - - /** - * The flag to indicate cancellation state. - * @type {boolean} - * @deprecated - */ - get returnValue() { - return !pd(this).canceled - }, - set returnValue(value) { - if (!value) { - setCancelFlag(pd(this)); - } - }, - - /** - * Initialize this event object. But do nothing under event dispatching. - * @param {string} type The event type. - * @param {boolean} [bubbles=false] The flag to be possible to bubble up. - * @param {boolean} [cancelable=false] The flag to be possible to cancel. - * @deprecated - */ - initEvent() { - // Do nothing. - }, -}; - -// `constructor` is not enumerable. -Object.defineProperty(Event.prototype, "constructor", { - value: Event, - configurable: true, - writable: true, -}); - -// Ensure `event instanceof window.Event` is `true`. -if (typeof window !== "undefined" && typeof window.Event !== "undefined") { - Object.setPrototypeOf(Event.prototype, window.Event.prototype); - - // Make association for wrappers. - wrappers.set(window.Event.prototype, Event); -} - -/** - * Get the property descriptor to redirect a given property. - * @param {string} key Property name to define property descriptor. - * @returns {PropertyDescriptor} The property descriptor to redirect the property. - * @private - */ -function defineRedirectDescriptor(key) { - return { - get() { - return pd(this).event[key] - }, - set(value) { - pd(this).event[key] = value; - }, - configurable: true, - enumerable: true, - } -} - -/** - * Get the property descriptor to call a given method property. - * @param {string} key Property name to define property descriptor. - * @returns {PropertyDescriptor} The property descriptor to call the method property. - * @private - */ -function defineCallDescriptor(key) { - return { - value() { - const event = pd(this).event; - return event[key].apply(event, arguments) - }, - configurable: true, - enumerable: true, - } -} - -/** - * Define new wrapper class. - * @param {Function} BaseEvent The base wrapper class. - * @param {Object} proto The prototype of the original event. - * @returns {Function} The defined wrapper class. - * @private - */ -function defineWrapper(BaseEvent, proto) { - const keys = Object.keys(proto); - if (keys.length === 0) { - return BaseEvent - } - - /** CustomEvent */ - function CustomEvent(eventTarget, event) { - BaseEvent.call(this, eventTarget, event); - } - - CustomEvent.prototype = Object.create(BaseEvent.prototype, { - constructor: { value: CustomEvent, configurable: true, writable: true }, - }); - - // Define accessors. - for (let i = 0; i < keys.length; ++i) { - const key = keys[i]; - if (!(key in BaseEvent.prototype)) { - const descriptor = Object.getOwnPropertyDescriptor(proto, key); - const isFunc = typeof descriptor.value === "function"; - Object.defineProperty( - CustomEvent.prototype, - key, - isFunc - ? defineCallDescriptor(key) - : defineRedirectDescriptor(key) - ); - } - } - - return CustomEvent -} - -/** - * Get the wrapper class of a given prototype. - * @param {Object} proto The prototype of the original event to get its wrapper. - * @returns {Function} The wrapper class. - * @private - */ -function getWrapper(proto) { - if (proto == null || proto === Object.prototype) { - return Event - } - - let wrapper = wrappers.get(proto); - if (wrapper == null) { - wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto); - wrappers.set(proto, wrapper); - } - return wrapper -} - -/** - * Wrap a given event to management a dispatching. - * @param {EventTarget} eventTarget The event target of this dispatching. - * @param {Object} event The event to wrap. - * @returns {Event} The wrapper instance. - * @private - */ -function wrapEvent(eventTarget, event) { - const Wrapper = getWrapper(Object.getPrototypeOf(event)); - return new Wrapper(eventTarget, event) -} - -/** - * Get the immediateStopped flag of a given event. - * @param {Event} event The event to get. - * @returns {boolean} The flag to stop propagation immediately. - * @private - */ -function isStopped(event) { - return pd(event).immediateStopped -} - -/** - * Set the current event phase of a given event. - * @param {Event} event The event to set current target. - * @param {number} eventPhase New event phase. - * @returns {void} - * @private - */ -function setEventPhase(event, eventPhase) { - pd(event).eventPhase = eventPhase; -} - -/** - * Set the current target of a given event. - * @param {Event} event The event to set current target. - * @param {EventTarget|null} currentTarget New current target. - * @returns {void} - * @private - */ -function setCurrentTarget(event, currentTarget) { - pd(event).currentTarget = currentTarget; -} - -/** - * Set a passive listener of a given event. - * @param {Event} event The event to set current target. - * @param {Function|null} passiveListener New passive listener. - * @returns {void} - * @private - */ -function setPassiveListener(event, passiveListener) { - pd(event).passiveListener = passiveListener; -} - -/** - * @typedef {object} ListenerNode - * @property {Function} listener - * @property {1|2|3} listenerType - * @property {boolean} passive - * @property {boolean} once - * @property {ListenerNode|null} next - * @private - */ - -/** - * @type {WeakMap>} - * @private - */ -const listenersMap = new WeakMap(); - -// Listener types -const CAPTURE = 1; -const BUBBLE = 2; -const ATTRIBUTE = 3; - -/** - * Check whether a given value is an object or not. - * @param {any} x The value to check. - * @returns {boolean} `true` if the value is an object. - */ -function isObject(x) { - return x !== null && typeof x === "object" //eslint-disable-line no-restricted-syntax -} - -/** - * Get listeners. - * @param {EventTarget} eventTarget The event target to get. - * @returns {Map} The listeners. - * @private - */ -function getListeners(eventTarget) { - const listeners = listenersMap.get(eventTarget); - if (listeners == null) { - throw new TypeError( - "'this' is expected an EventTarget object, but got another value." - ) - } - return listeners -} - -/** - * Get the property descriptor for the event attribute of a given event. - * @param {string} eventName The event name to get property descriptor. - * @returns {PropertyDescriptor} The property descriptor. - * @private - */ -function defineEventAttributeDescriptor(eventName) { - return { - get() { - const listeners = getListeners(this); - let node = listeners.get(eventName); - while (node != null) { - if (node.listenerType === ATTRIBUTE) { - return node.listener - } - node = node.next; - } - return null - }, - - set(listener) { - if (typeof listener !== "function" && !isObject(listener)) { - listener = null; // eslint-disable-line no-param-reassign - } - const listeners = getListeners(this); - - // Traverse to the tail while removing old value. - let prev = null; - let node = listeners.get(eventName); - while (node != null) { - if (node.listenerType === ATTRIBUTE) { - // Remove old value. - if (prev !== null) { - prev.next = node.next; - } else if (node.next !== null) { - listeners.set(eventName, node.next); - } else { - listeners.delete(eventName); - } - } else { - prev = node; - } - - node = node.next; - } - - // Add new value. - if (listener !== null) { - const newNode = { - listener, - listenerType: ATTRIBUTE, - passive: false, - once: false, - next: null, - }; - if (prev === null) { - listeners.set(eventName, newNode); - } else { - prev.next = newNode; - } - } - }, - configurable: true, - enumerable: true, - } -} - -/** - * Define an event attribute (e.g. `eventTarget.onclick`). - * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite. - * @param {string} eventName The event name to define. - * @returns {void} - */ -function defineEventAttribute(eventTargetPrototype, eventName) { - Object.defineProperty( - eventTargetPrototype, - `on${eventName}`, - defineEventAttributeDescriptor(eventName) - ); -} - -/** - * Define a custom EventTarget with event attributes. - * @param {string[]} eventNames Event names for event attributes. - * @returns {EventTarget} The custom EventTarget. - * @private - */ -function defineCustomEventTarget(eventNames) { - /** CustomEventTarget */ - function CustomEventTarget() { - EventTarget.call(this); - } - - CustomEventTarget.prototype = Object.create(EventTarget.prototype, { - constructor: { - value: CustomEventTarget, - configurable: true, - writable: true, - }, - }); - - for (let i = 0; i < eventNames.length; ++i) { - defineEventAttribute(CustomEventTarget.prototype, eventNames[i]); - } - - return CustomEventTarget -} - -/** - * EventTarget. - * - * - This is constructor if no arguments. - * - This is a function which returns a CustomEventTarget constructor if there are arguments. - * - * For example: - * - * class A extends EventTarget {} - * class B extends EventTarget("message") {} - * class C extends EventTarget("message", "error") {} - * class D extends EventTarget(["message", "error"]) {} - */ -function EventTarget() { - /*eslint-disable consistent-return */ - if (this instanceof EventTarget) { - listenersMap.set(this, new Map()); - return - } - if (arguments.length === 1 && Array.isArray(arguments[0])) { - return defineCustomEventTarget(arguments[0]) - } - if (arguments.length > 0) { - const types = new Array(arguments.length); - for (let i = 0; i < arguments.length; ++i) { - types[i] = arguments[i]; - } - return defineCustomEventTarget(types) - } - throw new TypeError("Cannot call a class as a function") - /*eslint-enable consistent-return */ -} - -// Should be enumerable, but class methods are not enumerable. -EventTarget.prototype = { - /** - * Add a given listener to this event target. - * @param {string} eventName The event name to add. - * @param {Function} listener The listener to add. - * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. - * @returns {void} - */ - addEventListener(eventName, listener, options) { - if (listener == null) { - return - } - if (typeof listener !== "function" && !isObject(listener)) { - throw new TypeError("'listener' should be a function or an object.") - } - - const listeners = getListeners(this); - const optionsIsObj = isObject(options); - const capture = optionsIsObj - ? Boolean(options.capture) - : Boolean(options); - const listenerType = capture ? CAPTURE : BUBBLE; - const newNode = { - listener, - listenerType, - passive: optionsIsObj && Boolean(options.passive), - once: optionsIsObj && Boolean(options.once), - next: null, - }; - - // Set it as the first node if the first node is null. - let node = listeners.get(eventName); - if (node === undefined) { - listeners.set(eventName, newNode); - return - } - - // Traverse to the tail while checking duplication.. - let prev = null; - while (node != null) { - if ( - node.listener === listener && - node.listenerType === listenerType - ) { - // Should ignore duplication. - return - } - prev = node; - node = node.next; - } - - // Add it. - prev.next = newNode; - }, - - /** - * Remove a given listener from this event target. - * @param {string} eventName The event name to remove. - * @param {Function} listener The listener to remove. - * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. - * @returns {void} - */ - removeEventListener(eventName, listener, options) { - if (listener == null) { - return - } - - const listeners = getListeners(this); - const capture = isObject(options) - ? Boolean(options.capture) - : Boolean(options); - const listenerType = capture ? CAPTURE : BUBBLE; - - let prev = null; - let node = listeners.get(eventName); - while (node != null) { - if ( - node.listener === listener && - node.listenerType === listenerType - ) { - if (prev !== null) { - prev.next = node.next; - } else if (node.next !== null) { - listeners.set(eventName, node.next); - } else { - listeners.delete(eventName); - } - return - } - - prev = node; - node = node.next; - } - }, - - /** - * Dispatch a given event. - * @param {Event|{type:string}} event The event to dispatch. - * @returns {boolean} `false` if canceled. - */ - dispatchEvent(event) { - if (event == null || typeof event.type !== "string") { - throw new TypeError('"event.type" should be a string.') - } - - // If listeners aren't registered, terminate. - const listeners = getListeners(this); - const eventName = event.type; - let node = listeners.get(eventName); - if (node == null) { - return true - } - - // Since we cannot rewrite several properties, so wrap object. - const wrappedEvent = wrapEvent(this, event); - - // This doesn't process capturing phase and bubbling phase. - // This isn't participating in a tree. - let prev = null; - while (node != null) { - // Remove this listener if it's once - if (node.once) { - if (prev !== null) { - prev.next = node.next; - } else if (node.next !== null) { - listeners.set(eventName, node.next); - } else { - listeners.delete(eventName); - } - } else { - prev = node; - } - - // Call this listener - setPassiveListener( - wrappedEvent, - node.passive ? node.listener : null - ); - if (typeof node.listener === "function") { - try { - node.listener.call(this, wrappedEvent); - } catch (err) { - if ( - typeof console !== "undefined" && - typeof console.error === "function" - ) { - console.error(err); - } - } - } else if ( - node.listenerType !== ATTRIBUTE && - typeof node.listener.handleEvent === "function" - ) { - node.listener.handleEvent(wrappedEvent); - } - - // Break if `event.stopImmediatePropagation` was called. - if (isStopped(wrappedEvent)) { - break - } - - node = node.next; - } - setPassiveListener(wrappedEvent, null); - setEventPhase(wrappedEvent, 0); - setCurrentTarget(wrappedEvent, null); - - return !wrappedEvent.defaultPrevented - }, -}; - -// `constructor` is not enumerable. -Object.defineProperty(EventTarget.prototype, "constructor", { - value: EventTarget, - configurable: true, - writable: true, -}); - -// Ensure `eventTarget instanceof window.EventTarget` is `true`. -if ( - typeof window !== "undefined" && - typeof window.EventTarget !== "undefined" -) { - Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype); -} - -export default EventTarget; -export { defineEventAttribute, EventTarget }; -//# sourceMappingURL=event-target-shim.mjs.map diff --git a/node_modules/event-target-shim/dist/event-target-shim.umd.js b/node_modules/event-target-shim/dist/event-target-shim.umd.js deleted file mode 100644 index e7cf5d4d5885f..0000000000000 --- a/node_modules/event-target-shim/dist/event-target-shim.umd.js +++ /dev/null @@ -1,6 +0,0 @@ -/** - * @author Toru Nagashima - * @copyright 2015 Toru Nagashima. All rights reserved. - * See LICENSE file in root directory for full license. - */(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.EventTargetShim={}))})(this,function(a){"use strict";function b(a){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},b(a)}function c(a){var b=u.get(a);return console.assert(null!=b,"'this' is expected an Event object, but got",a),b}function d(a){return null==a.passiveListener?void(!a.event.cancelable||(a.canceled=!0,"function"==typeof a.event.preventDefault&&a.event.preventDefault())):void("undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",a.passiveListener))}function e(a,b){u.set(this,{eventTarget:a,event:b,eventPhase:2,currentTarget:a,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:b.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});for(var c,d=Object.keys(b),e=0;e=6" - }, - "scripts": { - "preversion": "npm test", - "version": "npm run build && git add dist/*", - "postversion": "git push && git push --tags", - "clean": "rimraf .nyc_output coverage", - "coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html", - "lint": "eslint src test scripts --ext .js,.mjs", - "build": "rollup -c scripts/rollup.config.js", - "pretest": "npm run lint", - "test": "run-s test:*", - "test:mocha": "nyc --require ./scripts/babel-register mocha test/*.mjs", - "test:karma": "karma start scripts/karma.conf.js --single-run", - "watch": "run-p watch:*", - "watch:mocha": "mocha test/*.mjs --require ./scripts/babel-register --watch --watch-extensions js,mjs --growl", - "watch:karma": "karma start scripts/karma.conf.js --watch", - "codecov": "codecov" - }, - "devDependencies": { - "@babel/core": "^7.2.2", - "@babel/plugin-transform-modules-commonjs": "^7.2.0", - "@babel/preset-env": "^7.2.3", - "@babel/register": "^7.0.0", - "@mysticatea/eslint-plugin": "^8.0.1", - "@mysticatea/spy": "^0.1.2", - "assert": "^1.4.1", - "codecov": "^3.1.0", - "eslint": "^5.12.1", - "karma": "^3.1.4", - "karma-chrome-launcher": "^2.2.0", - "karma-coverage": "^1.1.2", - "karma-firefox-launcher": "^1.0.0", - "karma-growl-reporter": "^1.0.0", - "karma-ie-launcher": "^1.0.0", - "karma-mocha": "^1.3.0", - "karma-rollup-preprocessor": "^7.0.0-rc.2", - "mocha": "^5.2.0", - "npm-run-all": "^4.1.5", - "nyc": "^13.1.0", - "opener": "^1.5.1", - "rimraf": "^2.6.3", - "rollup": "^1.1.1", - "rollup-plugin-babel": "^4.3.2", - "rollup-plugin-babel-minify": "^7.0.0", - "rollup-plugin-commonjs": "^9.2.0", - "rollup-plugin-json": "^3.1.0", - "rollup-plugin-node-resolve": "^4.0.0", - "rollup-watch": "^4.3.1", - "type-tester": "^1.0.0", - "typescript": "^3.2.4" - }, - "repository": { - "type": "git", - "url": "https://github.com/mysticatea/event-target-shim.git" - }, - "keywords": [ - "w3c", - "whatwg", - "eventtarget", - "event", - "events", - "shim" - ], - "author": "Toru Nagashima", - "license": "MIT", - "bugs": { - "url": "https://github.com/mysticatea/event-target-shim/issues" - }, - "homepage": "https://github.com/mysticatea/event-target-shim" -} diff --git a/node_modules/events/.airtap.yml b/node_modules/events/.airtap.yml deleted file mode 100644 index c7a8a87d5e99d..0000000000000 --- a/node_modules/events/.airtap.yml +++ /dev/null @@ -1,15 +0,0 @@ -sauce_connect: true -loopback: airtap.local -browsers: - - name: chrome - version: latest - - name: firefox - version: latest - - name: safari - version: 9..latest - - name: iphone - version: latest - - name: ie - version: 9..latest - - name: microsoftedge - version: 13..latest diff --git a/node_modules/events/History.md b/node_modules/events/History.md deleted file mode 100644 index f48bf210da3ea..0000000000000 --- a/node_modules/events/History.md +++ /dev/null @@ -1,118 +0,0 @@ -# 3.3.0 - - - Support EventTarget emitters in `events.once` from Node.js 12.11.0. - - Now you can use the `events.once` function with objects that implement the EventTarget interface. This interface is used widely in - the DOM and other web APIs. - - ```js - var events = require('events'); - var assert = require('assert'); - - async function connect() { - var ws = new WebSocket('wss://example.com'); - await events.once(ws, 'open'); - assert(ws.readyState === WebSocket.OPEN); - } - - async function onClick() { - await events.once(document.body, 'click'); - alert('you clicked the page!'); - } - ``` - -# 3.2.0 - - - Add `events.once` from Node.js 11.13.0. - - To use this function, Promises must be supported in the environment. Use a polyfill like `es6-promise` if you support older browsers. - -# 3.1.0 (2020-01-08) - -`events` now matches the Node.js 11.12.0 API. - - - pass through return value in wrapped `emitter.once()` listeners - - Now, this works: - ```js - emitter.once('myevent', function () { return 1; }); - var listener = emitter.rawListeners('myevent')[0] - assert(listener() === 1); - ``` - Previously, `listener()` would return undefined regardless of the implementation. - - Ported from https://github.com/nodejs/node/commit/acc506c2d2771dab8d7bba6d3452bc5180dff7cf - - - Reduce code duplication in listener type check ([#67](https://github.com/Gozala/events/pull/67) by [@friederbluemle](https://github.com/friederbluemle)). - - Improve `emitter.once()` performance in some engines - -# 3.0.0 (2018-05-25) - -**This version drops support for IE8.** `events` no longer includes polyfills -for ES5 features. If you need to support older environments, use an ES5 shim -like [es5-shim](https://npmjs.com/package/es5-shim). Both the shim and sham -versions of es5-shim are necessary. - - - Update to events code from Node.js 10.x - - (semver major) Adds `off()` method - - Port more tests from Node.js - - Switch browser tests to airtap, making things more reliable - -# 2.1.0 (2018-05-25) - - - add Emitter#rawListeners from Node.js v9.4 - -# 2.0.0 (2018-02-02) - - - Update to events code from node.js 8.x - - Adds `prependListener()` and `prependOnceListener()` - - Adds `eventNames()` method - - (semver major) Unwrap `once()` listeners in `listeners()` - - copy tests from node.js - -Note that this version doubles the gzipped size, jumping from 1.1KB to 2.1KB, -due to new methods and runtime performance improvements. Be aware of that when -upgrading. - -# 1.1.1 (2016-06-22) - - - add more context to errors if they are not instanceof Error - -# 1.1.0 (2015-09-29) - - - add Emitter#listerCount (to match node v4 api) - -# 1.0.2 (2014-08-28) - - - remove un-reachable code - - update devDeps - -## 1.0.1 / 2014-05-11 - - - check for console.trace before using it - -## 1.0.0 / 2013-12-10 - - - Update to latest events code from node.js 0.10 - - copy tests from node.js - -## 0.4.0 / 2011-07-03 ## - - - Switching to graphquire@0.8.0 - -## 0.3.0 / 2011-07-03 ## - - - Switching to URL based module require. - -## 0.2.0 / 2011-06-10 ## - - - Simplified package structure. - - Graphquire for dependency management. - -## 0.1.1 / 2011-05-16 ## - - - Unhandled errors are logged via console.error - -## 0.1.0 / 2011-04-22 ## - - - Initial release diff --git a/node_modules/events/LICENSE b/node_modules/events/LICENSE deleted file mode 100644 index 52ed3b0a63274..0000000000000 --- a/node_modules/events/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT - -Copyright Joyent, Inc. and other Node contributors. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to permit -persons to whom the Software is furnished to do so, subject to the -following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/events/events.js b/node_modules/events/events.js deleted file mode 100644 index 34b69a0b4a6e1..0000000000000 --- a/node_modules/events/events.js +++ /dev/null @@ -1,497 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var R = typeof Reflect === 'object' ? Reflect : null -var ReflectApply = R && typeof R.apply === 'function' - ? R.apply - : function ReflectApply(target, receiver, args) { - return Function.prototype.apply.call(target, receiver, args); - } - -var ReflectOwnKeys -if (R && typeof R.ownKeys === 'function') { - ReflectOwnKeys = R.ownKeys -} else if (Object.getOwnPropertySymbols) { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target) - .concat(Object.getOwnPropertySymbols(target)); - }; -} else { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target); - }; -} - -function ProcessEmitWarning(warning) { - if (console && console.warn) console.warn(warning); -} - -var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { - return value !== value; -} - -function EventEmitter() { - EventEmitter.init.call(this); -} -module.exports = EventEmitter; -module.exports.once = once; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._eventsCount = 0; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -var defaultMaxListeners = 10; - -function checkListener(listener) { - if (typeof listener !== 'function') { - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); - } -} - -Object.defineProperty(EventEmitter, 'defaultMaxListeners', { - enumerable: true, - get: function() { - return defaultMaxListeners; - }, - set: function(arg) { - if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { - throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); - } - defaultMaxListeners = arg; - } -}); - -EventEmitter.init = function() { - - if (this._events === undefined || - this._events === Object.getPrototypeOf(this)._events) { - this._events = Object.create(null); - this._eventsCount = 0; - } - - this._maxListeners = this._maxListeners || undefined; -}; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { - if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); - } - this._maxListeners = n; - return this; -}; - -function _getMaxListeners(that) { - if (that._maxListeners === undefined) - return EventEmitter.defaultMaxListeners; - return that._maxListeners; -} - -EventEmitter.prototype.getMaxListeners = function getMaxListeners() { - return _getMaxListeners(this); -}; - -EventEmitter.prototype.emit = function emit(type) { - var args = []; - for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); - var doError = (type === 'error'); - - var events = this._events; - if (events !== undefined) - doError = (doError && events.error === undefined); - else if (!doError) - return false; - - // If there is no 'error' event listener then throw. - if (doError) { - var er; - if (args.length > 0) - er = args[0]; - if (er instanceof Error) { - // Note: The comments on the `throw` lines are intentional, they show - // up in Node's output if this results in an unhandled exception. - throw er; // Unhandled 'error' event - } - // At least give some kind of context to the user - var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); - err.context = er; - throw err; // Unhandled 'error' event - } - - var handler = events[type]; - - if (handler === undefined) - return false; - - if (typeof handler === 'function') { - ReflectApply(handler, this, args); - } else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - ReflectApply(listeners[i], this, args); - } - - return true; -}; - -function _addListener(target, type, listener, prepend) { - var m; - var events; - var existing; - - checkListener(listener); - - events = target._events; - if (events === undefined) { - events = target._events = Object.create(null); - target._eventsCount = 0; - } else { - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (events.newListener !== undefined) { - target.emit('newListener', type, - listener.listener ? listener.listener : listener); - - // Re-assign `events` because a newListener handler could have caused the - // this._events to be assigned to a new object - events = target._events; - } - existing = events[type]; - } - - if (existing === undefined) { - // Optimize the case of one listener. Don't need the extra array object. - existing = events[type] = listener; - ++target._eventsCount; - } else { - if (typeof existing === 'function') { - // Adding the second element, need to change to array. - existing = events[type] = - prepend ? [listener, existing] : [existing, listener]; - // If we've already got an array, just append. - } else if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } - - // Check for listener leak - m = _getMaxListeners(target); - if (m > 0 && existing.length > m && !existing.warned) { - existing.warned = true; - // No error code for this since it is a Warning - // eslint-disable-next-line no-restricted-syntax - var w = new Error('Possible EventEmitter memory leak detected. ' + - existing.length + ' ' + String(type) + ' listeners ' + - 'added. Use emitter.setMaxListeners() to ' + - 'increase limit'); - w.name = 'MaxListenersExceededWarning'; - w.emitter = target; - w.type = type; - w.count = existing.length; - ProcessEmitWarning(w); - } - } - - return target; -} - -EventEmitter.prototype.addListener = function addListener(type, listener) { - return _addListener(this, type, listener, false); -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.prependListener = - function prependListener(type, listener) { - return _addListener(this, type, listener, true); - }; - -function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - if (arguments.length === 0) - return this.listener.call(this.target); - return this.listener.apply(this.target, arguments); - } -} - -function _onceWrap(target, type, listener) { - var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; - var wrapped = onceWrapper.bind(state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; -} - -EventEmitter.prototype.once = function once(type, listener) { - checkListener(listener); - this.on(type, _onceWrap(this, type, listener)); - return this; -}; - -EventEmitter.prototype.prependOnceListener = - function prependOnceListener(type, listener) { - checkListener(listener); - this.prependListener(type, _onceWrap(this, type, listener)); - return this; - }; - -// Emits a 'removeListener' event if and only if the listener was removed. -EventEmitter.prototype.removeListener = - function removeListener(type, listener) { - var list, events, position, i, originalListener; - - checkListener(listener); - - events = this._events; - if (events === undefined) - return this; - - list = events[type]; - if (list === undefined) - return this; - - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) - this._events = Object.create(null); - else { - delete events[type]; - if (events.removeListener) - this.emit('removeListener', type, list.listener || listener); - } - } else if (typeof list !== 'function') { - position = -1; - - for (i = list.length - 1; i >= 0; i--) { - if (list[i] === listener || list[i].listener === listener) { - originalListener = list[i].listener; - position = i; - break; - } - } - - if (position < 0) - return this; - - if (position === 0) - list.shift(); - else { - spliceOne(list, position); - } - - if (list.length === 1) - events[type] = list[0]; - - if (events.removeListener !== undefined) - this.emit('removeListener', type, originalListener || listener); - } - - return this; - }; - -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - -EventEmitter.prototype.removeAllListeners = - function removeAllListeners(type) { - var listeners, events, i; - - events = this._events; - if (events === undefined) - return this; - - // not listening for removeListener, no need to emit - if (events.removeListener === undefined) { - if (arguments.length === 0) { - this._events = Object.create(null); - this._eventsCount = 0; - } else if (events[type] !== undefined) { - if (--this._eventsCount === 0) - this._events = Object.create(null); - else - delete events[type]; - } - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - var keys = Object.keys(events); - var key; - for (i = 0; i < keys.length; ++i) { - key = keys[i]; - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = Object.create(null); - this._eventsCount = 0; - return this; - } - - listeners = events[type]; - - if (typeof listeners === 'function') { - this.removeListener(type, listeners); - } else if (listeners !== undefined) { - // LIFO order - for (i = listeners.length - 1; i >= 0; i--) { - this.removeListener(type, listeners[i]); - } - } - - return this; - }; - -function _listeners(target, type, unwrap) { - var events = target._events; - - if (events === undefined) - return []; - - var evlistener = events[type]; - if (evlistener === undefined) - return []; - - if (typeof evlistener === 'function') - return unwrap ? [evlistener.listener || evlistener] : [evlistener]; - - return unwrap ? - unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); -} - -EventEmitter.prototype.listeners = function listeners(type) { - return _listeners(this, type, true); -}; - -EventEmitter.prototype.rawListeners = function rawListeners(type) { - return _listeners(this, type, false); -}; - -EventEmitter.listenerCount = function(emitter, type) { - if (typeof emitter.listenerCount === 'function') { - return emitter.listenerCount(type); - } else { - return listenerCount.call(emitter, type); - } -}; - -EventEmitter.prototype.listenerCount = listenerCount; -function listenerCount(type) { - var events = this._events; - - if (events !== undefined) { - var evlistener = events[type]; - - if (typeof evlistener === 'function') { - return 1; - } else if (evlistener !== undefined) { - return evlistener.length; - } - } - - return 0; -} - -EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; -}; - -function arrayClone(arr, n) { - var copy = new Array(n); - for (var i = 0; i < n; ++i) - copy[i] = arr[i]; - return copy; -} - -function spliceOne(list, index) { - for (; index + 1 < list.length; index++) - list[index] = list[index + 1]; - list.pop(); -} - -function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i = 0; i < ret.length; ++i) { - ret[i] = arr[i].listener || arr[i]; - } - return ret; -} - -function once(emitter, name) { - return new Promise(function (resolve, reject) { - function errorListener(err) { - emitter.removeListener(name, resolver); - reject(err); - } - - function resolver() { - if (typeof emitter.removeListener === 'function') { - emitter.removeListener('error', errorListener); - } - resolve([].slice.call(arguments)); - }; - - eventTargetAgnosticAddListener(emitter, name, resolver, { once: true }); - if (name !== 'error') { - addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true }); - } - }); -} - -function addErrorHandlerIfEventEmitter(emitter, handler, flags) { - if (typeof emitter.on === 'function') { - eventTargetAgnosticAddListener(emitter, 'error', handler, flags); - } -} - -function eventTargetAgnosticAddListener(emitter, name, listener, flags) { - if (typeof emitter.on === 'function') { - if (flags.once) { - emitter.once(name, listener); - } else { - emitter.on(name, listener); - } - } else if (typeof emitter.addEventListener === 'function') { - // EventTarget does not have `error` event semantics like Node - // EventEmitters, we do not listen for `error` events here. - emitter.addEventListener(name, function wrapListener(arg) { - // IE does not have builtin `{ once: true }` support so we - // have to do it manually. - if (flags.once) { - emitter.removeEventListener(name, wrapListener); - } - listener(arg); - }); - } else { - throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter); - } -} diff --git a/node_modules/events/package.json b/node_modules/events/package.json deleted file mode 100644 index b9580d88142d2..0000000000000 --- a/node_modules/events/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "events", - "version": "3.3.0", - "description": "Node's event emitter for all engines.", - "keywords": [ - "events", - "eventEmitter", - "eventDispatcher", - "listeners" - ], - "author": "Irakli Gozalishvili (http://jeditoolkit.com)", - "repository": { - "type": "git", - "url": "git://github.com/Gozala/events.git", - "web": "https://github.com/Gozala/events" - }, - "bugs": { - "url": "http://github.com/Gozala/events/issues/" - }, - "main": "./events.js", - "engines": { - "node": ">=0.8.x" - }, - "devDependencies": { - "airtap": "^1.0.0", - "functions-have-names": "^1.2.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "isarray": "^2.0.5", - "tape": "^5.0.0" - }, - "scripts": { - "test": "node tests/index.js", - "test:browsers": "airtap -- tests/index.js" - }, - "license": "MIT" -} diff --git a/node_modules/events/security.md b/node_modules/events/security.md deleted file mode 100644 index a14ace6a57db7..0000000000000 --- a/node_modules/events/security.md +++ /dev/null @@ -1,10 +0,0 @@ -# Security Policy - -## Supported Versions -Only the latest major version is supported at any given time. - -## Reporting a Vulnerability - -To report a security vulnerability, please use the -[Tidelift security contact](https://tidelift.com/security). -Tidelift will coordinate the fix and disclosure. diff --git a/node_modules/events/tests/add-listeners.js b/node_modules/events/tests/add-listeners.js deleted file mode 100644 index 9b578272ba889..0000000000000 --- a/node_modules/events/tests/add-listeners.js +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var common = require('./common'); -var assert = require('assert'); -var EventEmitter = require('../'); - -{ - var ee = new EventEmitter(); - var events_new_listener_emitted = []; - var listeners_new_listener_emitted = []; - - // Sanity check - assert.strictEqual(ee.addListener, ee.on); - - ee.on('newListener', function(event, listener) { - // Don't track newListener listeners. - if (event === 'newListener') - return; - - events_new_listener_emitted.push(event); - listeners_new_listener_emitted.push(listener); - }); - - var hello = common.mustCall(function(a, b) { - assert.strictEqual('a', a); - assert.strictEqual('b', b); - }); - - ee.once('newListener', function(name, listener) { - assert.strictEqual(name, 'hello'); - assert.strictEqual(listener, hello); - - var listeners = this.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - }); - - ee.on('hello', hello); - ee.once('foo', assert.fail); - - assert.ok(Array.isArray(events_new_listener_emitted)); - assert.strictEqual(events_new_listener_emitted.length, 2); - assert.strictEqual(events_new_listener_emitted[0], 'hello'); - assert.strictEqual(events_new_listener_emitted[1], 'foo'); - - assert.ok(Array.isArray(listeners_new_listener_emitted)); - assert.strictEqual(listeners_new_listener_emitted.length, 2); - assert.strictEqual(listeners_new_listener_emitted[0], hello); - assert.strictEqual(listeners_new_listener_emitted[1], assert.fail); - - ee.emit('hello', 'a', 'b'); -} - -// just make sure that this doesn't throw: -{ - var f = new EventEmitter(); - - f.setMaxListeners(0); -} - -{ - var listen1 = function() {}; - var listen2 = function() {}; - var ee = new EventEmitter(); - - ee.once('newListener', function() { - var listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - ee.once('newListener', function() { - var listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - }); - ee.on('hello', listen2); - }); - ee.on('hello', listen1); - // The order of listeners on an event is not always the order in which the - // listeners were added. - var listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 2); - assert.strictEqual(listeners[0], listen2); - assert.strictEqual(listeners[1], listen1); -} - -// Verify that the listener must be a function -assert.throws(function() { - var ee = new EventEmitter(); - - ee.on('foo', null); -}, /^TypeError: The "listener" argument must be of type Function. Received type object$/); diff --git a/node_modules/events/tests/check-listener-leaks.js b/node_modules/events/tests/check-listener-leaks.js deleted file mode 100644 index 7fce48f37bf24..0000000000000 --- a/node_modules/events/tests/check-listener-leaks.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var common = require('./common'); -var assert = require('assert'); -var events = require('../'); - -// Redirect warning output to tape. -var consoleWarn = console.warn; -console.warn = common.test.comment; - -common.test.on('end', function () { - console.warn = consoleWarn; -}); - -// default -{ - var e = new events.EventEmitter(); - - for (var i = 0; i < 10; i++) { - e.on('default', common.mustNotCall()); - } - assert.ok(!e._events['default'].hasOwnProperty('warned')); - e.on('default', common.mustNotCall()); - assert.ok(e._events['default'].warned); - - // specific - e.setMaxListeners(5); - for (var i = 0; i < 5; i++) { - e.on('specific', common.mustNotCall()); - } - assert.ok(!e._events['specific'].hasOwnProperty('warned')); - e.on('specific', common.mustNotCall()); - assert.ok(e._events['specific'].warned); - - // only one - e.setMaxListeners(1); - e.on('only one', common.mustNotCall()); - assert.ok(!e._events['only one'].hasOwnProperty('warned')); - e.on('only one', common.mustNotCall()); - assert.ok(e._events['only one'].hasOwnProperty('warned')); - - // unlimited - e.setMaxListeners(0); - for (var i = 0; i < 1000; i++) { - e.on('unlimited', common.mustNotCall()); - } - assert.ok(!e._events['unlimited'].hasOwnProperty('warned')); -} - -// process-wide -{ - events.EventEmitter.defaultMaxListeners = 42; - var e = new events.EventEmitter(); - - for (var i = 0; i < 42; ++i) { - e.on('fortytwo', common.mustNotCall()); - } - assert.ok(!e._events['fortytwo'].hasOwnProperty('warned')); - e.on('fortytwo', common.mustNotCall()); - assert.ok(e._events['fortytwo'].hasOwnProperty('warned')); - delete e._events['fortytwo'].warned; - - events.EventEmitter.defaultMaxListeners = 44; - e.on('fortytwo', common.mustNotCall()); - assert.ok(!e._events['fortytwo'].hasOwnProperty('warned')); - e.on('fortytwo', common.mustNotCall()); - assert.ok(e._events['fortytwo'].hasOwnProperty('warned')); -} - -// but _maxListeners still has precedence over defaultMaxListeners -{ - events.EventEmitter.defaultMaxListeners = 42; - var e = new events.EventEmitter(); - e.setMaxListeners(1); - e.on('uno', common.mustNotCall()); - assert.ok(!e._events['uno'].hasOwnProperty('warned')); - e.on('uno', common.mustNotCall()); - assert.ok(e._events['uno'].hasOwnProperty('warned')); - - // chainable - assert.strictEqual(e, e.setMaxListeners(1)); -} diff --git a/node_modules/events/tests/common.js b/node_modules/events/tests/common.js deleted file mode 100644 index 49569b05f59d5..0000000000000 --- a/node_modules/events/tests/common.js +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var test = require('tape'); -var assert = require('assert'); - -var noop = function() {}; - -var mustCallChecks = []; - -function runCallChecks(exitCode) { - if (exitCode !== 0) return; - - var failed = filter(mustCallChecks, function(context) { - if ('minimum' in context) { - context.messageSegment = 'at least ' + context.minimum; - return context.actual < context.minimum; - } else { - context.messageSegment = 'exactly ' + context.exact; - return context.actual !== context.exact; - } - }); - - for (var i = 0; i < failed.length; i++) { - var context = failed[i]; - console.log('Mismatched %s function calls. Expected %s, actual %d.', - context.name, - context.messageSegment, - context.actual); - // IE8 has no .stack - if (context.stack) console.log(context.stack.split('\n').slice(2).join('\n')); - } - - assert.strictEqual(failed.length, 0); -} - -exports.mustCall = function(fn, exact) { - return _mustCallInner(fn, exact, 'exact'); -}; - -function _mustCallInner(fn, criteria, field) { - if (typeof criteria == 'undefined') criteria = 1; - - if (typeof fn === 'number') { - criteria = fn; - fn = noop; - } else if (fn === undefined) { - fn = noop; - } - - if (typeof criteria !== 'number') - throw new TypeError('Invalid ' + field + ' value: ' + criteria); - - var context = { - actual: 0, - stack: (new Error()).stack, - name: fn.name || '' - }; - - context[field] = criteria; - - // add the exit listener only once to avoid listener leak warnings - if (mustCallChecks.length === 0) test.onFinish(function() { runCallChecks(0); }); - - mustCallChecks.push(context); - - return function() { - context.actual++; - return fn.apply(this, arguments); - }; -} - -exports.mustNotCall = function(msg) { - return function mustNotCall() { - assert.fail(msg || 'function should not have been called'); - }; -}; - -function filter(arr, fn) { - if (arr.filter) return arr.filter(fn); - var filtered = []; - for (var i = 0; i < arr.length; i++) { - if (fn(arr[i], i, arr)) filtered.push(arr[i]); - } - return filtered -} diff --git a/node_modules/events/tests/errors.js b/node_modules/events/tests/errors.js deleted file mode 100644 index a23df437f05d3..0000000000000 --- a/node_modules/events/tests/errors.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; -var assert = require('assert'); -var EventEmitter = require('../'); - -var EE = new EventEmitter(); - -assert.throws(function () { - EE.emit('error', 'Accepts a string'); -}, 'Error: Unhandled error. (Accepts a string)'); - -assert.throws(function () { - EE.emit('error', { message: 'Error!' }); -}, 'Unhandled error. ([object Object])'); diff --git a/node_modules/events/tests/events-list.js b/node_modules/events/tests/events-list.js deleted file mode 100644 index 08aa62177e2c2..0000000000000 --- a/node_modules/events/tests/events-list.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -var EventEmitter = require('../'); -var assert = require('assert'); - -var EE = new EventEmitter(); -var m = function() {}; -EE.on('foo', function() {}); -assert.equal(1, EE.eventNames().length); -assert.equal('foo', EE.eventNames()[0]); -EE.on('bar', m); -assert.equal(2, EE.eventNames().length); -assert.equal('foo', EE.eventNames()[0]); -assert.equal('bar', EE.eventNames()[1]); -EE.removeListener('bar', m); -assert.equal(1, EE.eventNames().length); -assert.equal('foo', EE.eventNames()[0]); - -if (typeof Symbol !== 'undefined') { - var s = Symbol('s'); - EE.on(s, m); - assert.equal(2, EE.eventNames().length); - assert.equal('foo', EE.eventNames()[0]); - assert.equal(s, EE.eventNames()[1]); - EE.removeListener(s, m); - assert.equal(1, EE.eventNames().length); - assert.equal('foo', EE.eventNames()[0]); -} diff --git a/node_modules/events/tests/events-once.js b/node_modules/events/tests/events-once.js deleted file mode 100644 index dae864963daae..0000000000000 --- a/node_modules/events/tests/events-once.js +++ /dev/null @@ -1,234 +0,0 @@ -'use strict'; - -var common = require('./common'); -var EventEmitter = require('../').EventEmitter; -var once = require('../').once; -var has = require('has'); -var assert = require('assert'); - -function Event(type) { - this.type = type; -} - -function EventTargetMock() { - this.events = {}; - - this.addEventListener = common.mustCall(this.addEventListener); - this.removeEventListener = common.mustCall(this.removeEventListener); -} - -EventTargetMock.prototype.addEventListener = function addEventListener(name, listener, options) { - if (!(name in this.events)) { - this.events[name] = { listeners: [], options: options || {} } - } - this.events[name].listeners.push(listener); -}; - -EventTargetMock.prototype.removeEventListener = function removeEventListener(name, callback) { - if (!(name in this.events)) { - return; - } - var event = this.events[name]; - var stack = event.listeners; - - for (var i = 0, l = stack.length; i < l; i++) { - if (stack[i] === callback) { - stack.splice(i, 1); - if (stack.length === 0) { - delete this.events[name]; - } - return; - } - } -}; - -EventTargetMock.prototype.dispatchEvent = function dispatchEvent(arg) { - if (!(arg.type in this.events)) { - return true; - } - - var event = this.events[arg.type]; - var stack = event.listeners.slice(); - - for (var i = 0, l = stack.length; i < l; i++) { - stack[i].call(null, arg); - if (event.options.once) { - this.removeEventListener(arg.type, stack[i]); - } - } - return !arg.defaultPrevented; -}; - -function onceAnEvent() { - var ee = new EventEmitter(); - - process.nextTick(function () { - ee.emit('myevent', 42); - }); - - return once(ee, 'myevent').then(function (args) { - var value = args[0] - assert.strictEqual(value, 42); - assert.strictEqual(ee.listenerCount('error'), 0); - assert.strictEqual(ee.listenerCount('myevent'), 0); - }); -} - -function onceAnEventWithTwoArgs() { - var ee = new EventEmitter(); - - process.nextTick(function () { - ee.emit('myevent', 42, 24); - }); - - return once(ee, 'myevent').then(function (value) { - assert.strictEqual(value.length, 2); - assert.strictEqual(value[0], 42); - assert.strictEqual(value[1], 24); - }); -} - -function catchesErrors() { - var ee = new EventEmitter(); - - var expected = new Error('kaboom'); - var err; - process.nextTick(function () { - ee.emit('error', expected); - }); - - return once(ee, 'myevent').then(function () { - throw new Error('should reject') - }, function (err) { - assert.strictEqual(err, expected); - assert.strictEqual(ee.listenerCount('error'), 0); - assert.strictEqual(ee.listenerCount('myevent'), 0); - }); -} - -function stopListeningAfterCatchingError() { - var ee = new EventEmitter(); - - var expected = new Error('kaboom'); - var err; - process.nextTick(function () { - ee.emit('error', expected); - ee.emit('myevent', 42, 24); - }); - - // process.on('multipleResolves', common.mustNotCall()); - - return once(ee, 'myevent').then(common.mustNotCall, function (err) { - // process.removeAllListeners('multipleResolves'); - assert.strictEqual(err, expected); - assert.strictEqual(ee.listenerCount('error'), 0); - assert.strictEqual(ee.listenerCount('myevent'), 0); - }); -} - -function onceError() { - var ee = new EventEmitter(); - - var expected = new Error('kaboom'); - process.nextTick(function () { - ee.emit('error', expected); - }); - - var promise = once(ee, 'error'); - assert.strictEqual(ee.listenerCount('error'), 1); - return promise.then(function (args) { - var err = args[0] - assert.strictEqual(err, expected); - assert.strictEqual(ee.listenerCount('error'), 0); - assert.strictEqual(ee.listenerCount('myevent'), 0); - }); -} - -function onceWithEventTarget() { - var et = new EventTargetMock(); - var event = new Event('myevent'); - process.nextTick(function () { - et.dispatchEvent(event); - }); - return once(et, 'myevent').then(function (args) { - var value = args[0]; - assert.strictEqual(value, event); - assert.strictEqual(has(et.events, 'myevent'), false); - }); -} - -function onceWithEventTargetError() { - var et = new EventTargetMock(); - var error = new Event('error'); - process.nextTick(function () { - et.dispatchEvent(error); - }); - return once(et, 'error').then(function (args) { - var err = args[0]; - assert.strictEqual(err, error); - assert.strictEqual(has(et.events, 'error'), false); - }); -} - -function prioritizesEventEmitter() { - var ee = new EventEmitter(); - ee.addEventListener = assert.fail; - ee.removeAllListeners = assert.fail; - process.nextTick(function () { - ee.emit('foo'); - }); - return once(ee, 'foo'); -} - -var allTests = [ - onceAnEvent(), - onceAnEventWithTwoArgs(), - catchesErrors(), - stopListeningAfterCatchingError(), - onceError(), - onceWithEventTarget(), - onceWithEventTargetError(), - prioritizesEventEmitter() -]; - -var hasBrowserEventTarget = false; -try { - hasBrowserEventTarget = typeof (new window.EventTarget().addEventListener) === 'function' && - new window.Event('xyz').type === 'xyz'; -} catch (err) {} - -if (hasBrowserEventTarget) { - var onceWithBrowserEventTarget = function onceWithBrowserEventTarget() { - var et = new window.EventTarget(); - var event = new window.Event('myevent'); - process.nextTick(function () { - et.dispatchEvent(event); - }); - return once(et, 'myevent').then(function (args) { - var value = args[0]; - assert.strictEqual(value, event); - assert.strictEqual(has(et.events, 'myevent'), false); - }); - } - - var onceWithBrowserEventTargetError = function onceWithBrowserEventTargetError() { - var et = new window.EventTarget(); - var error = new window.Event('error'); - process.nextTick(function () { - et.dispatchEvent(error); - }); - return once(et, 'error').then(function (args) { - var err = args[0]; - assert.strictEqual(err, error); - assert.strictEqual(has(et.events, 'error'), false); - }); - } - - common.test.comment('Testing with browser built-in EventTarget'); - allTests.push([ - onceWithBrowserEventTarget(), - onceWithBrowserEventTargetError() - ]); -} - -module.exports = Promise.all(allTests); diff --git a/node_modules/events/tests/index.js b/node_modules/events/tests/index.js deleted file mode 100644 index 2d739e670ca02..0000000000000 --- a/node_modules/events/tests/index.js +++ /dev/null @@ -1,64 +0,0 @@ -var test = require('tape'); -var functionsHaveNames = require('functions-have-names'); -var hasSymbols = require('has-symbols'); - -require('./legacy-compat'); -var common = require('./common'); - -// we do this to easily wrap each file in a mocha test -// and also have browserify be able to statically analyze this file -var orig_require = require; -var require = function(file) { - test(file, function(t) { - // Store the tape object so tests can access it. - t.on('end', function () { delete common.test; }); - common.test = t; - - try { - var exp = orig_require(file); - if (exp && exp.then) { - exp.then(function () { t.end(); }, t.fail); - return; - } - } catch (err) { - t.fail(err); - } - t.end(); - }); -}; - -require('./add-listeners.js'); -require('./check-listener-leaks.js'); -require('./errors.js'); -require('./events-list.js'); -if (typeof Promise === 'function') { - require('./events-once.js'); -} else { - // Promise support is not available. - test('./events-once.js', { skip: true }, function () {}); -} -require('./listener-count.js'); -require('./listeners-side-effects.js'); -require('./listeners.js'); -require('./max-listeners.js'); -if (functionsHaveNames()) { - require('./method-names.js'); -} else { - // Function.name is not supported in IE - test('./method-names.js', { skip: true }, function () {}); -} -require('./modify-in-emit.js'); -require('./num-args.js'); -require('./once.js'); -require('./prepend.js'); -require('./set-max-listeners-side-effects.js'); -require('./special-event-names.js'); -require('./subclass.js'); -if (hasSymbols()) { - require('./symbols.js'); -} else { - // Symbol is not available. - test('./symbols.js', { skip: true }, function () {}); -} -require('./remove-all-listeners.js'); -require('./remove-listeners.js'); diff --git a/node_modules/events/tests/legacy-compat.js b/node_modules/events/tests/legacy-compat.js deleted file mode 100644 index a402be6e2f42d..0000000000000 --- a/node_modules/events/tests/legacy-compat.js +++ /dev/null @@ -1,16 +0,0 @@ -// sigh... life is hard -if (!global.console) { - console = {} -} - -var fns = ['log', 'error', 'trace']; -for (var i=0 ; ifoo should not be emitted'); -} - -e.once('foo', remove); -e.removeListener('foo', remove); -e.emit('foo'); - -e.once('e', common.mustCall(function() { - e.emit('e'); -})); - -e.once('e', common.mustCall()); - -e.emit('e'); - -// Verify that the listener must be a function -assert.throws(function() { - var ee = new EventEmitter(); - - ee.once('foo', null); -}, /^TypeError: The "listener" argument must be of type Function. Received type object$/); - -{ - // once() has different code paths based on the number of arguments being - // emitted. Verify that all of the cases are covered. - var maxArgs = 4; - - for (var i = 0; i <= maxArgs; ++i) { - var ee = new EventEmitter(); - var args = ['foo']; - - for (var j = 0; j < i; ++j) - args.push(j); - - ee.once('foo', common.mustCall(function() { - var params = Array.prototype.slice.call(arguments); - var restArgs = args.slice(1); - assert.ok(Array.isArray(params)); - assert.strictEqual(params.length, restArgs.length); - for (var index = 0; index < params.length; index++) { - var param = params[index]; - assert.strictEqual(param, restArgs[index]); - } - })); - - EventEmitter.prototype.emit.apply(ee, args); - } -} diff --git a/node_modules/events/tests/prepend.js b/node_modules/events/tests/prepend.js deleted file mode 100644 index 79afde0bf3971..0000000000000 --- a/node_modules/events/tests/prepend.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -var common = require('./common'); -var EventEmitter = require('../'); -var assert = require('assert'); - -var myEE = new EventEmitter(); -var m = 0; -// This one comes last. -myEE.on('foo', common.mustCall(function () { - assert.strictEqual(m, 2); -})); - -// This one comes second. -myEE.prependListener('foo', common.mustCall(function () { - assert.strictEqual(m++, 1); -})); - -// This one comes first. -myEE.prependOnceListener('foo', - common.mustCall(function () { - assert.strictEqual(m++, 0); - })); - -myEE.emit('foo'); - -// Verify that the listener must be a function -assert.throws(function () { - var ee = new EventEmitter(); - ee.prependOnceListener('foo', null); -}, 'TypeError: The "listener" argument must be of type Function. Received type object'); diff --git a/node_modules/events/tests/remove-all-listeners.js b/node_modules/events/tests/remove-all-listeners.js deleted file mode 100644 index 622941cfa604c..0000000000000 --- a/node_modules/events/tests/remove-all-listeners.js +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var common = require('./common'); -var assert = require('assert'); -var events = require('../'); -var test = require('tape'); - -function expect(expected) { - var actual = []; - test.onFinish(function() { - var sortedActual = actual.sort(); - var sortedExpected = expected.sort(); - assert.strictEqual(sortedActual.length, sortedExpected.length); - for (var index = 0; index < sortedActual.length; index++) { - var value = sortedActual[index]; - assert.strictEqual(value, sortedExpected[index]); - } - }); - function listener(name) { - actual.push(name); - } - return common.mustCall(listener, expected.length); -} - -{ - var ee = new events.EventEmitter(); - var noop = common.mustNotCall(); - ee.on('foo', noop); - ee.on('bar', noop); - ee.on('baz', noop); - ee.on('baz', noop); - var fooListeners = ee.listeners('foo'); - var barListeners = ee.listeners('bar'); - var bazListeners = ee.listeners('baz'); - ee.on('removeListener', expect(['bar', 'baz', 'baz'])); - ee.removeAllListeners('bar'); - ee.removeAllListeners('baz'); - - var listeners = ee.listeners('foo'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 1); - assert.strictEqual(listeners[0], noop); - - listeners = ee.listeners('bar'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - listeners = ee.listeners('baz'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - // After calling removeAllListeners(), - // the old listeners array should stay unchanged. - assert.strictEqual(fooListeners.length, 1); - assert.strictEqual(fooListeners[0], noop); - assert.strictEqual(barListeners.length, 1); - assert.strictEqual(barListeners[0], noop); - assert.strictEqual(bazListeners.length, 2); - assert.strictEqual(bazListeners[0], noop); - assert.strictEqual(bazListeners[1], noop); - // After calling removeAllListeners(), - // new listeners arrays is different from the old. - assert.notStrictEqual(ee.listeners('bar'), barListeners); - assert.notStrictEqual(ee.listeners('baz'), bazListeners); -} - -{ - var ee = new events.EventEmitter(); - ee.on('foo', common.mustNotCall()); - ee.on('bar', common.mustNotCall()); - // Expect LIFO order - ee.on('removeListener', expect(['foo', 'bar', 'removeListener'])); - ee.on('removeListener', expect(['foo', 'bar'])); - ee.removeAllListeners(); - - var listeners = ee.listeners('foo'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - listeners = ee.listeners('bar'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); -} - -{ - var ee = new events.EventEmitter(); - ee.on('removeListener', common.mustNotCall()); - // Check for regression where removeAllListeners() throws when - // there exists a 'removeListener' listener, but there exists - // no listeners for the provided event type. - assert.doesNotThrow(function () { ee.removeAllListeners(ee, 'foo') }); -} - -{ - var ee = new events.EventEmitter(); - var expectLength = 2; - ee.on('removeListener', function() { - assert.strictEqual(expectLength--, this.listeners('baz').length); - }); - ee.on('baz', common.mustNotCall()); - ee.on('baz', common.mustNotCall()); - ee.on('baz', common.mustNotCall()); - assert.strictEqual(ee.listeners('baz').length, expectLength + 1); - ee.removeAllListeners('baz'); - assert.strictEqual(ee.listeners('baz').length, 0); -} - -{ - var ee = new events.EventEmitter(); - assert.strictEqual(ee, ee.removeAllListeners()); -} - -{ - var ee = new events.EventEmitter(); - ee._events = undefined; - assert.strictEqual(ee, ee.removeAllListeners()); -} diff --git a/node_modules/events/tests/remove-listeners.js b/node_modules/events/tests/remove-listeners.js deleted file mode 100644 index 18e4d1651fa25..0000000000000 --- a/node_modules/events/tests/remove-listeners.js +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var common = require('./common'); -var assert = require('assert'); -var EventEmitter = require('../'); - -var listener1 = function listener1() {}; -var listener2 = function listener2() {}; - -{ - var ee = new EventEmitter(); - ee.on('hello', listener1); - ee.on('removeListener', common.mustCall(function(name, cb) { - assert.strictEqual(name, 'hello'); - assert.strictEqual(cb, listener1); - })); - ee.removeListener('hello', listener1); - var listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); -} - -{ - var ee = new EventEmitter(); - ee.on('hello', listener1); - ee.on('removeListener', common.mustNotCall()); - ee.removeListener('hello', listener2); - - var listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 1); - assert.strictEqual(listeners[0], listener1); -} - -{ - var ee = new EventEmitter(); - ee.on('hello', listener1); - ee.on('hello', listener2); - - var listeners; - ee.once('removeListener', common.mustCall(function(name, cb) { - assert.strictEqual(name, 'hello'); - assert.strictEqual(cb, listener1); - listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 1); - assert.strictEqual(listeners[0], listener2); - })); - ee.removeListener('hello', listener1); - listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 1); - assert.strictEqual(listeners[0], listener2); - ee.once('removeListener', common.mustCall(function(name, cb) { - assert.strictEqual(name, 'hello'); - assert.strictEqual(cb, listener2); - listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - })); - ee.removeListener('hello', listener2); - listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); -} - -{ - var ee = new EventEmitter(); - - function remove1() { - assert.fail('remove1 should not have been called'); - } - - function remove2() { - assert.fail('remove2 should not have been called'); - } - - ee.on('removeListener', common.mustCall(function(name, cb) { - if (cb !== remove1) return; - this.removeListener('quux', remove2); - this.emit('quux'); - }, 2)); - ee.on('quux', remove1); - ee.on('quux', remove2); - ee.removeListener('quux', remove1); -} - -{ - var ee = new EventEmitter(); - ee.on('hello', listener1); - ee.on('hello', listener2); - - var listeners; - ee.once('removeListener', common.mustCall(function(name, cb) { - assert.strictEqual(name, 'hello'); - assert.strictEqual(cb, listener1); - listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 1); - assert.strictEqual(listeners[0], listener2); - ee.once('removeListener', common.mustCall(function(name, cb) { - assert.strictEqual(name, 'hello'); - assert.strictEqual(cb, listener2); - listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - })); - ee.removeListener('hello', listener2); - listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); - })); - ee.removeListener('hello', listener1); - listeners = ee.listeners('hello'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 0); -} - -{ - var ee = new EventEmitter(); - var listener3 = common.mustCall(function() { - ee.removeListener('hello', listener4); - }, 2); - var listener4 = common.mustCall(); - - ee.on('hello', listener3); - ee.on('hello', listener4); - - // listener4 will still be called although it is removed by listener 3. - ee.emit('hello'); - // This is so because the interal listener array at time of emit - // was [listener3,listener4] - - // Interal listener array [listener3] - ee.emit('hello'); -} - -{ - var ee = new EventEmitter(); - - ee.once('hello', listener1); - ee.on('removeListener', common.mustCall(function(eventName, listener) { - assert.strictEqual(eventName, 'hello'); - assert.strictEqual(listener, listener1); - })); - ee.emit('hello'); -} - -{ - var ee = new EventEmitter(); - - assert.strictEqual(ee, ee.removeListener('foo', function() {})); -} - -// Verify that the removed listener must be a function -assert.throws(function() { - var ee = new EventEmitter(); - - ee.removeListener('foo', null); -}, /^TypeError: The "listener" argument must be of type Function\. Received type object$/); - -{ - var ee = new EventEmitter(); - var listener = function() {}; - ee._events = undefined; - var e = ee.removeListener('foo', listener); - assert.strictEqual(e, ee); -} - -{ - var ee = new EventEmitter(); - - ee.on('foo', listener1); - ee.on('foo', listener2); - var listeners = ee.listeners('foo'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 2); - assert.strictEqual(listeners[0], listener1); - assert.strictEqual(listeners[1], listener2); - - ee.removeListener('foo', listener1); - assert.strictEqual(ee._events.foo, listener2); - - ee.on('foo', listener1); - listeners = ee.listeners('foo'); - assert.ok(Array.isArray(listeners)); - assert.strictEqual(listeners.length, 2); - assert.strictEqual(listeners[0], listener2); - assert.strictEqual(listeners[1], listener1); - - ee.removeListener('foo', listener1); - assert.strictEqual(ee._events.foo, listener2); -} diff --git a/node_modules/events/tests/set-max-listeners-side-effects.js b/node_modules/events/tests/set-max-listeners-side-effects.js deleted file mode 100644 index 13dbb671e9024..0000000000000 --- a/node_modules/events/tests/set-max-listeners-side-effects.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -require('./common'); -var assert = require('assert'); -var events = require('../'); - -var e = new events.EventEmitter(); - -if (Object.create) assert.ok(!(e._events instanceof Object)); -assert.strictEqual(Object.keys(e._events).length, 0); -e.setMaxListeners(5); -assert.strictEqual(Object.keys(e._events).length, 0); diff --git a/node_modules/events/tests/special-event-names.js b/node_modules/events/tests/special-event-names.js deleted file mode 100644 index a2f0b744a706c..0000000000000 --- a/node_modules/events/tests/special-event-names.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -var common = require('./common'); -var EventEmitter = require('../'); -var assert = require('assert'); - -var ee = new EventEmitter(); -var handler = function() {}; - -assert.strictEqual(ee.eventNames().length, 0); - -assert.strictEqual(ee._events.hasOwnProperty, undefined); -assert.strictEqual(ee._events.toString, undefined); - -ee.on('__defineGetter__', handler); -ee.on('toString', handler); -ee.on('__proto__', handler); - -assert.strictEqual(ee.eventNames()[0], '__defineGetter__'); -assert.strictEqual(ee.eventNames()[1], 'toString'); - -assert.strictEqual(ee.listeners('__defineGetter__').length, 1); -assert.strictEqual(ee.listeners('__defineGetter__')[0], handler); -assert.strictEqual(ee.listeners('toString').length, 1); -assert.strictEqual(ee.listeners('toString')[0], handler); - -// Only run __proto__ tests if that property can actually be set -if ({ __proto__: 'ok' }.__proto__ === 'ok') { - assert.strictEqual(ee.eventNames().length, 3); - assert.strictEqual(ee.eventNames()[2], '__proto__'); - assert.strictEqual(ee.listeners('__proto__').length, 1); - assert.strictEqual(ee.listeners('__proto__')[0], handler); - - ee.on('__proto__', common.mustCall(function(val) { - assert.strictEqual(val, 1); - })); - ee.emit('__proto__', 1); - - process.on('__proto__', common.mustCall(function(val) { - assert.strictEqual(val, 1); - })); - process.emit('__proto__', 1); -} else { - console.log('# skipped __proto__') -} diff --git a/node_modules/events/tests/subclass.js b/node_modules/events/tests/subclass.js deleted file mode 100644 index bd033fff4d266..0000000000000 --- a/node_modules/events/tests/subclass.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -var common = require('./common'); -var test = require('tape'); -var assert = require('assert'); -var EventEmitter = require('../').EventEmitter; -var util = require('util'); - -util.inherits(MyEE, EventEmitter); - -function MyEE(cb) { - this.once(1, cb); - this.emit(1); - this.removeAllListeners(); - EventEmitter.call(this); -} - -var myee = new MyEE(common.mustCall()); - - -util.inherits(ErrorEE, EventEmitter); -function ErrorEE() { - this.emit('error', new Error('blerg')); -} - -assert.throws(function() { - new ErrorEE(); -}, /blerg/); - -test.onFinish(function() { - assert.ok(!(myee._events instanceof Object)); - assert.strictEqual(Object.keys(myee._events).length, 0); -}); - - -function MyEE2() { - EventEmitter.call(this); -} - -MyEE2.prototype = new EventEmitter(); - -var ee1 = new MyEE2(); -var ee2 = new MyEE2(); - -ee1.on('x', function() {}); - -assert.strictEqual(ee2.listenerCount('x'), 0); diff --git a/node_modules/events/tests/symbols.js b/node_modules/events/tests/symbols.js deleted file mode 100644 index 0721f0ec0b5d6..0000000000000 --- a/node_modules/events/tests/symbols.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -var common = require('./common'); -var EventEmitter = require('../'); -var assert = require('assert'); - -var ee = new EventEmitter(); -var foo = Symbol('foo'); -var listener = common.mustCall(); - -ee.on(foo, listener); -assert.strictEqual(ee.listeners(foo).length, 1); -assert.strictEqual(ee.listeners(foo)[0], listener); - -ee.emit(foo); - -ee.removeAllListeners(); -assert.strictEqual(ee.listeners(foo).length, 0); - -ee.on(foo, listener); -assert.strictEqual(ee.listeners(foo).length, 1); -assert.strictEqual(ee.listeners(foo)[0], listener); - -ee.removeListener(foo, listener); -assert.strictEqual(ee.listeners(foo).length, 0); diff --git a/node_modules/ieee754/LICENSE b/node_modules/ieee754/LICENSE deleted file mode 100644 index 5aac82c78c2d9..0000000000000 --- a/node_modules/ieee754/LICENSE +++ /dev/null @@ -1,11 +0,0 @@ -Copyright 2008 Fair Oaks Labs, Inc. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/ieee754/index.js b/node_modules/ieee754/index.js deleted file mode 100644 index 81d26c343c93d..0000000000000 --- a/node_modules/ieee754/index.js +++ /dev/null @@ -1,85 +0,0 @@ -/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d - - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} - - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) -} - -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } - - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 - } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} diff --git a/node_modules/ieee754/package.json b/node_modules/ieee754/package.json deleted file mode 100644 index 7b23851384185..0000000000000 --- a/node_modules/ieee754/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "ieee754", - "description": "Read/write IEEE754 floating point numbers from/to a Buffer or array-like object", - "version": "1.2.1", - "author": { - "name": "Feross Aboukhadijeh", - "email": "feross@feross.org", - "url": "https://feross.org" - }, - "contributors": [ - "Romain Beauxis " - ], - "devDependencies": { - "airtap": "^3.0.0", - "standard": "*", - "tape": "^5.0.1" - }, - "keywords": [ - "IEEE 754", - "buffer", - "convert", - "floating point", - "ieee754" - ], - "license": "BSD-3-Clause", - "main": "index.js", - "types": "index.d.ts", - "repository": { - "type": "git", - "url": "git://github.com/feross/ieee754.git" - }, - "scripts": { - "test": "standard && npm run test-node && npm run test-browser", - "test-browser": "airtap -- test/*.js", - "test-browser-local": "airtap --local -- test/*.js", - "test-node": "tape test/*.js" - }, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] -} diff --git a/node_modules/process/LICENSE b/node_modules/process/LICENSE deleted file mode 100644 index b8c1246cf49cb..0000000000000 --- a/node_modules/process/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -(The MIT License) - -Copyright (c) 2013 Roman Shtylman - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/process/browser.js b/node_modules/process/browser.js deleted file mode 100644 index d059362306586..0000000000000 --- a/node_modules/process/browser.js +++ /dev/null @@ -1,184 +0,0 @@ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; diff --git a/node_modules/process/index.js b/node_modules/process/index.js deleted file mode 100644 index 8d8ed7df45bb8..0000000000000 --- a/node_modules/process/index.js +++ /dev/null @@ -1,2 +0,0 @@ -// for now just expose the builtin process global from node.js -module.exports = global.process; diff --git a/node_modules/process/package.json b/node_modules/process/package.json deleted file mode 100644 index d2cfaade44177..0000000000000 --- a/node_modules/process/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "author": "Roman Shtylman ", - "name": "process", - "description": "process information for node.js and browsers", - "keywords": [ - "process" - ], - "scripts": { - "test": "mocha test.js", - "browser": "zuul --no-coverage --ui mocha-bdd --local 8080 -- test.js" - }, - "version": "0.11.10", - "repository": { - "type": "git", - "url": "git://github.com/shtylman/node-process.git" - }, - "license": "MIT", - "browser": "./browser.js", - "main": "./index.js", - "engines": { - "node": ">= 0.6.0" - }, - "devDependencies": { - "mocha": "2.2.1", - "zuul": "^3.10.3" - } -} diff --git a/node_modules/process/test.js b/node_modules/process/test.js deleted file mode 100644 index 8ba579c0a2026..0000000000000 --- a/node_modules/process/test.js +++ /dev/null @@ -1,199 +0,0 @@ -var assert = require('assert'); -var ourProcess = require('./browser'); -describe('test against our process', function () { - test(ourProcess); -}); -if (!process.browser) { - describe('test against node', function () { - test(process); - }); - vmtest(); -} -function test (ourProcess) { - describe('test arguments', function () { - it ('works', function (done) { - var order = 0; - - - ourProcess.nextTick(function (num) { - assert.equal(num, order++, 'first one works'); - ourProcess.nextTick(function (num) { - assert.equal(num, order++, 'recursive one is 4th'); - }, 3); - }, 0); - ourProcess.nextTick(function (num) { - assert.equal(num, order++, 'second one starts'); - ourProcess.nextTick(function (num) { - assert.equal(num, order++, 'this is third'); - ourProcess.nextTick(function (num) { - assert.equal(num, order++, 'this is last'); - done(); - }, 5); - }, 4); - }, 1); - ourProcess.nextTick(function (num) { - - assert.equal(num, order++, '3rd schedualed happens after the error'); - }, 2); - }); - }); -if (!process.browser) { - describe('test errors', function (t) { - it ('works', function (done) { - var order = 0; - process.removeAllListeners('uncaughtException'); - process.once('uncaughtException', function(err) { - assert.equal(2, order++, 'error is third'); - ourProcess.nextTick(function () { - assert.equal(5, order++, 'schedualed in error is last'); - done(); - }); - }); - ourProcess.nextTick(function () { - assert.equal(0, order++, 'first one works'); - ourProcess.nextTick(function () { - assert.equal(4, order++, 'recursive one is 4th'); - }); - }); - ourProcess.nextTick(function () { - assert.equal(1, order++, 'second one starts'); - throw(new Error('an error is thrown')); - }); - ourProcess.nextTick(function () { - assert.equal(3, order++, '3rd schedualed happens after the error'); - }); - }); - }); -} - describe('rename globals', function (t) { - var oldTimeout = setTimeout; - var oldClear = clearTimeout; - - it('clearTimeout', function (done){ - - var ok = true; - clearTimeout = function () { - ok = false; - } - var ran = false; - function cleanup() { - clearTimeout = oldClear; - var err; - try { - assert.ok(ok, 'fake clearTimeout ran'); - assert.ok(ran, 'should have run'); - } catch (e) { - err = e; - } - done(err); - } - setTimeout(cleanup, 1000); - ourProcess.nextTick(function () { - ran = true; - }); - }); - it('just setTimeout', function (done){ - - - setTimeout = function () { - setTimeout = oldTimeout; - try { - assert.ok(false, 'fake setTimeout called') - } catch (e) { - done(e); - } - - } - - ourProcess.nextTick(function () { - setTimeout = oldTimeout; - done(); - }); - }); - }); -} -function vmtest() { - var vm = require('vm'); - var fs = require('fs'); - var process = fs.readFileSync('./browser.js', {encoding: 'utf8'}); - - - describe('should work in vm in strict mode with no globals', function () { - it('should parse', function (done) { - var str = '"use strict";var module = {exports:{}};'; - str += process; - str += 'this.works = process.browser;'; - var script = new vm.Script(str); - var context = { - works: false - }; - script.runInNewContext(context); - assert.ok(context.works); - done(); - }); - it('setTimeout throws error', function (done) { - var str = '"use strict";var module = {exports:{}};'; - str += process; - str += 'try {process.nextTick(function () {})} catch (e){this.works = e;}'; - var script = new vm.Script(str); - var context = { - works: false - }; - script.runInNewContext(context); - assert.ok(context.works); - done(); - }); - it('should generally work', function (done) { - var str = '"use strict";var module = {exports:{}};'; - str += process; - str += 'process.nextTick(function () {assert.ok(true);done();})'; - var script = new vm.Script(str); - var context = { - clearTimeout: clearTimeout, - setTimeout: setTimeout, - done: done, - assert: assert - }; - script.runInNewContext(context); - }); - it('late defs setTimeout', function (done) { - var str = '"use strict";var module = {exports:{}};'; - str += process; - str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {assert.ok(true);done();})'; - var script = new vm.Script(str); - var context = { - clearTimeout: clearTimeout, - hiddenSetTimeout: setTimeout, - done: done, - assert: assert - }; - script.runInNewContext(context); - }); - it('late defs clearTimeout', function (done) { - var str = '"use strict";var module = {exports:{}};'; - str += process; - str += 'var clearTimeout = hiddenClearTimeout;process.nextTick(function () {assert.ok(true);done();})'; - var script = new vm.Script(str); - var context = { - hiddenClearTimeout: clearTimeout, - setTimeout: setTimeout, - done: done, - assert: assert - }; - script.runInNewContext(context); - }); - it('late defs setTimeout and then redefine', function (done) { - var str = '"use strict";var module = {exports:{}};'; - str += process; - str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {setTimeout = function (){throw new Error("foo")};hiddenSetTimeout(function(){process.nextTick(function (){assert.ok(true);done();});});});'; - var script = new vm.Script(str); - var context = { - clearTimeout: clearTimeout, - hiddenSetTimeout: setTimeout, - done: done, - assert: assert - }; - script.runInNewContext(context); - }); - }); -} diff --git a/node_modules/readable-stream/LICENSE b/node_modules/readable-stream/LICENSE deleted file mode 100644 index 2873b3b2e5950..0000000000000 --- a/node_modules/readable-stream/LICENSE +++ /dev/null @@ -1,47 +0,0 @@ -Node.js is licensed for use as follows: - -""" -Copyright Node.js contributors. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" - -This license applies to parts of Node.js originating from the -https://github.com/joyent/node repository: - -""" -Copyright Joyent, Inc. and other Node contributors. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" diff --git a/node_modules/readable-stream/lib/_stream_duplex.js b/node_modules/readable-stream/lib/_stream_duplex.js deleted file mode 100644 index e03c6bf5ff87a..0000000000000 --- a/node_modules/readable-stream/lib/_stream_duplex.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' - -// Keep this file as an alias for the full stream module. -module.exports = require('./stream').Duplex diff --git a/node_modules/readable-stream/lib/_stream_passthrough.js b/node_modules/readable-stream/lib/_stream_passthrough.js deleted file mode 100644 index 1206dc4555fe2..0000000000000 --- a/node_modules/readable-stream/lib/_stream_passthrough.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' - -// Keep this file as an alias for the full stream module. -module.exports = require('./stream').PassThrough diff --git a/node_modules/readable-stream/lib/_stream_readable.js b/node_modules/readable-stream/lib/_stream_readable.js deleted file mode 100644 index 49416586f2098..0000000000000 --- a/node_modules/readable-stream/lib/_stream_readable.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' - -// Keep this file as an alias for the full stream module. -module.exports = require('./stream').Readable diff --git a/node_modules/readable-stream/lib/_stream_transform.js b/node_modules/readable-stream/lib/_stream_transform.js deleted file mode 100644 index ef227b12c57c3..0000000000000 --- a/node_modules/readable-stream/lib/_stream_transform.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' - -// Keep this file as an alias for the full stream module. -module.exports = require('./stream').Transform diff --git a/node_modules/readable-stream/lib/_stream_writable.js b/node_modules/readable-stream/lib/_stream_writable.js deleted file mode 100644 index 00c7b037ce7bf..0000000000000 --- a/node_modules/readable-stream/lib/_stream_writable.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' - -// Keep this file as an alias for the full stream module. -module.exports = require('./stream').Writable diff --git a/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js b/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js deleted file mode 100644 index 3a26a1d3e6d76..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/add-abort-signal.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict' - -const { AbortError, codes } = require('../../ours/errors') -const { isNodeStream, isWebStream, kControllerErrorFunction } = require('./utils') -const eos = require('./end-of-stream') -const { ERR_INVALID_ARG_TYPE } = codes - -// This method is inlined here for readable-stream -// It also does not allow for signal to not exist on the stream -// https://github.com/nodejs/node/pull/36061#discussion_r533718029 -const validateAbortSignal = (signal, name) => { - if (typeof signal !== 'object' || !('aborted' in signal)) { - throw new ERR_INVALID_ARG_TYPE(name, 'AbortSignal', signal) - } -} -module.exports.addAbortSignal = function addAbortSignal(signal, stream) { - validateAbortSignal(signal, 'signal') - if (!isNodeStream(stream) && !isWebStream(stream)) { - throw new ERR_INVALID_ARG_TYPE('stream', ['ReadableStream', 'WritableStream', 'Stream'], stream) - } - return module.exports.addAbortSignalNoValidate(signal, stream) -} -module.exports.addAbortSignalNoValidate = function (signal, stream) { - if (typeof signal !== 'object' || !('aborted' in signal)) { - return stream - } - const onAbort = isNodeStream(stream) - ? () => { - stream.destroy( - new AbortError(undefined, { - cause: signal.reason - }) - ) - } - : () => { - stream[kControllerErrorFunction]( - new AbortError(undefined, { - cause: signal.reason - }) - ) - } - if (signal.aborted) { - onAbort() - } else { - signal.addEventListener('abort', onAbort) - eos(stream, () => signal.removeEventListener('abort', onAbort)) - } - return stream -} diff --git a/node_modules/readable-stream/lib/internal/streams/buffer_list.js b/node_modules/readable-stream/lib/internal/streams/buffer_list.js deleted file mode 100644 index b55e35cf9a0f8..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/buffer_list.js +++ /dev/null @@ -1,157 +0,0 @@ -'use strict' - -const { StringPrototypeSlice, SymbolIterator, TypedArrayPrototypeSet, Uint8Array } = require('../../ours/primordials') -const { Buffer } = require('buffer') -const { inspect } = require('../../ours/util') -module.exports = class BufferList { - constructor() { - this.head = null - this.tail = null - this.length = 0 - } - push(v) { - const entry = { - data: v, - next: null - } - if (this.length > 0) this.tail.next = entry - else this.head = entry - this.tail = entry - ++this.length - } - unshift(v) { - const entry = { - data: v, - next: this.head - } - if (this.length === 0) this.tail = entry - this.head = entry - ++this.length - } - shift() { - if (this.length === 0) return - const ret = this.head.data - if (this.length === 1) this.head = this.tail = null - else this.head = this.head.next - --this.length - return ret - } - clear() { - this.head = this.tail = null - this.length = 0 - } - join(s) { - if (this.length === 0) return '' - let p = this.head - let ret = '' + p.data - while ((p = p.next) !== null) ret += s + p.data - return ret - } - concat(n) { - if (this.length === 0) return Buffer.alloc(0) - const ret = Buffer.allocUnsafe(n >>> 0) - let p = this.head - let i = 0 - while (p) { - TypedArrayPrototypeSet(ret, p.data, i) - i += p.data.length - p = p.next - } - return ret - } - - // Consumes a specified amount of bytes or characters from the buffered data. - consume(n, hasStrings) { - const data = this.head.data - if (n < data.length) { - // `slice` is the same for buffers and strings. - const slice = data.slice(0, n) - this.head.data = data.slice(n) - return slice - } - if (n === data.length) { - // First chunk is a perfect match. - return this.shift() - } - // Result spans more than one buffer. - return hasStrings ? this._getString(n) : this._getBuffer(n) - } - first() { - return this.head.data - } - *[SymbolIterator]() { - for (let p = this.head; p; p = p.next) { - yield p.data - } - } - - // Consumes a specified amount of characters from the buffered data. - _getString(n) { - let ret = '' - let p = this.head - let c = 0 - do { - const str = p.data - if (n > str.length) { - ret += str - n -= str.length - } else { - if (n === str.length) { - ret += str - ++c - if (p.next) this.head = p.next - else this.head = this.tail = null - } else { - ret += StringPrototypeSlice(str, 0, n) - this.head = p - p.data = StringPrototypeSlice(str, n) - } - break - } - ++c - } while ((p = p.next) !== null) - this.length -= c - return ret - } - - // Consumes a specified amount of bytes from the buffered data. - _getBuffer(n) { - const ret = Buffer.allocUnsafe(n) - const retLen = n - let p = this.head - let c = 0 - do { - const buf = p.data - if (n > buf.length) { - TypedArrayPrototypeSet(ret, buf, retLen - n) - n -= buf.length - } else { - if (n === buf.length) { - TypedArrayPrototypeSet(ret, buf, retLen - n) - ++c - if (p.next) this.head = p.next - else this.head = this.tail = null - } else { - TypedArrayPrototypeSet(ret, new Uint8Array(buf.buffer, buf.byteOffset, n), retLen - n) - this.head = p - p.data = buf.slice(n) - } - break - } - ++c - } while ((p = p.next) !== null) - this.length -= c - return ret - } - - // Make sure the linked list only shows the minimal necessary information. - [Symbol.for('nodejs.util.inspect.custom')](_, options) { - return inspect(this, { - ...options, - // Only inspect one level. - depth: 0, - // It should not recurse. - customInspect: false - }) - } -} diff --git a/node_modules/readable-stream/lib/internal/streams/compose.js b/node_modules/readable-stream/lib/internal/streams/compose.js deleted file mode 100644 index f565c12ef3620..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/compose.js +++ /dev/null @@ -1,194 +0,0 @@ -'use strict' - -const { pipeline } = require('./pipeline') -const Duplex = require('./duplex') -const { destroyer } = require('./destroy') -const { - isNodeStream, - isReadable, - isWritable, - isWebStream, - isTransformStream, - isWritableStream, - isReadableStream -} = require('./utils') -const { - AbortError, - codes: { ERR_INVALID_ARG_VALUE, ERR_MISSING_ARGS } -} = require('../../ours/errors') -const eos = require('./end-of-stream') -module.exports = function compose(...streams) { - if (streams.length === 0) { - throw new ERR_MISSING_ARGS('streams') - } - if (streams.length === 1) { - return Duplex.from(streams[0]) - } - const orgStreams = [...streams] - if (typeof streams[0] === 'function') { - streams[0] = Duplex.from(streams[0]) - } - if (typeof streams[streams.length - 1] === 'function') { - const idx = streams.length - 1 - streams[idx] = Duplex.from(streams[idx]) - } - for (let n = 0; n < streams.length; ++n) { - if (!isNodeStream(streams[n]) && !isWebStream(streams[n])) { - // TODO(ronag): Add checks for non streams. - continue - } - if ( - n < streams.length - 1 && - !(isReadable(streams[n]) || isReadableStream(streams[n]) || isTransformStream(streams[n])) - ) { - throw new ERR_INVALID_ARG_VALUE(`streams[${n}]`, orgStreams[n], 'must be readable') - } - if (n > 0 && !(isWritable(streams[n]) || isWritableStream(streams[n]) || isTransformStream(streams[n]))) { - throw new ERR_INVALID_ARG_VALUE(`streams[${n}]`, orgStreams[n], 'must be writable') - } - } - let ondrain - let onfinish - let onreadable - let onclose - let d - function onfinished(err) { - const cb = onclose - onclose = null - if (cb) { - cb(err) - } else if (err) { - d.destroy(err) - } else if (!readable && !writable) { - d.destroy() - } - } - const head = streams[0] - const tail = pipeline(streams, onfinished) - const writable = !!(isWritable(head) || isWritableStream(head) || isTransformStream(head)) - const readable = !!(isReadable(tail) || isReadableStream(tail) || isTransformStream(tail)) - - // TODO(ronag): Avoid double buffering. - // Implement Writable/Readable/Duplex traits. - // See, https://github.com/nodejs/node/pull/33515. - d = new Duplex({ - // TODO (ronag): highWaterMark? - writableObjectMode: !!(head !== null && head !== undefined && head.writableObjectMode), - readableObjectMode: !!(tail !== null && tail !== undefined && tail.writableObjectMode), - writable, - readable - }) - if (writable) { - if (isNodeStream(head)) { - d._write = function (chunk, encoding, callback) { - if (head.write(chunk, encoding)) { - callback() - } else { - ondrain = callback - } - } - d._final = function (callback) { - head.end() - onfinish = callback - } - head.on('drain', function () { - if (ondrain) { - const cb = ondrain - ondrain = null - cb() - } - }) - } else if (isWebStream(head)) { - const writable = isTransformStream(head) ? head.writable : head - const writer = writable.getWriter() - d._write = async function (chunk, encoding, callback) { - try { - await writer.ready - writer.write(chunk).catch(() => {}) - callback() - } catch (err) { - callback(err) - } - } - d._final = async function (callback) { - try { - await writer.ready - writer.close().catch(() => {}) - onfinish = callback - } catch (err) { - callback(err) - } - } - } - const toRead = isTransformStream(tail) ? tail.readable : tail - eos(toRead, () => { - if (onfinish) { - const cb = onfinish - onfinish = null - cb() - } - }) - } - if (readable) { - if (isNodeStream(tail)) { - tail.on('readable', function () { - if (onreadable) { - const cb = onreadable - onreadable = null - cb() - } - }) - tail.on('end', function () { - d.push(null) - }) - d._read = function () { - while (true) { - const buf = tail.read() - if (buf === null) { - onreadable = d._read - return - } - if (!d.push(buf)) { - return - } - } - } - } else if (isWebStream(tail)) { - const readable = isTransformStream(tail) ? tail.readable : tail - const reader = readable.getReader() - d._read = async function () { - while (true) { - try { - const { value, done } = await reader.read() - if (!d.push(value)) { - return - } - if (done) { - d.push(null) - return - } - } catch { - return - } - } - } - } - } - d._destroy = function (err, callback) { - if (!err && onclose !== null) { - err = new AbortError() - } - onreadable = null - ondrain = null - onfinish = null - if (onclose === null) { - callback(err) - } else { - onclose = callback - if (isNodeStream(tail)) { - destroyer(tail, err) - } - } - } - return d -} diff --git a/node_modules/readable-stream/lib/internal/streams/destroy.js b/node_modules/readable-stream/lib/internal/streams/destroy.js deleted file mode 100644 index db76c29f94bab..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/destroy.js +++ /dev/null @@ -1,290 +0,0 @@ -'use strict' - -/* replacement start */ - -const process = require('process/') - -/* replacement end */ - -const { - aggregateTwoErrors, - codes: { ERR_MULTIPLE_CALLBACK }, - AbortError -} = require('../../ours/errors') -const { Symbol } = require('../../ours/primordials') -const { kDestroyed, isDestroyed, isFinished, isServerRequest } = require('./utils') -const kDestroy = Symbol('kDestroy') -const kConstruct = Symbol('kConstruct') -function checkError(err, w, r) { - if (err) { - // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364 - err.stack // eslint-disable-line no-unused-expressions - - if (w && !w.errored) { - w.errored = err - } - if (r && !r.errored) { - r.errored = err - } - } -} - -// Backwards compat. cb() is undocumented and unused in core but -// unfortunately might be used by modules. -function destroy(err, cb) { - const r = this._readableState - const w = this._writableState - // With duplex streams we use the writable side for state. - const s = w || r - if ((w !== null && w !== undefined && w.destroyed) || (r !== null && r !== undefined && r.destroyed)) { - if (typeof cb === 'function') { - cb() - } - return this - } - - // We set destroyed to true before firing error callbacks in order - // to make it re-entrance safe in case destroy() is called within callbacks - checkError(err, w, r) - if (w) { - w.destroyed = true - } - if (r) { - r.destroyed = true - } - - // If still constructing then defer calling _destroy. - if (!s.constructed) { - this.once(kDestroy, function (er) { - _destroy(this, aggregateTwoErrors(er, err), cb) - }) - } else { - _destroy(this, err, cb) - } - return this -} -function _destroy(self, err, cb) { - let called = false - function onDestroy(err) { - if (called) { - return - } - called = true - const r = self._readableState - const w = self._writableState - checkError(err, w, r) - if (w) { - w.closed = true - } - if (r) { - r.closed = true - } - if (typeof cb === 'function') { - cb(err) - } - if (err) { - process.nextTick(emitErrorCloseNT, self, err) - } else { - process.nextTick(emitCloseNT, self) - } - } - try { - self._destroy(err || null, onDestroy) - } catch (err) { - onDestroy(err) - } -} -function emitErrorCloseNT(self, err) { - emitErrorNT(self, err) - emitCloseNT(self) -} -function emitCloseNT(self) { - const r = self._readableState - const w = self._writableState - if (w) { - w.closeEmitted = true - } - if (r) { - r.closeEmitted = true - } - if ((w !== null && w !== undefined && w.emitClose) || (r !== null && r !== undefined && r.emitClose)) { - self.emit('close') - } -} -function emitErrorNT(self, err) { - const r = self._readableState - const w = self._writableState - if ((w !== null && w !== undefined && w.errorEmitted) || (r !== null && r !== undefined && r.errorEmitted)) { - return - } - if (w) { - w.errorEmitted = true - } - if (r) { - r.errorEmitted = true - } - self.emit('error', err) -} -function undestroy() { - const r = this._readableState - const w = this._writableState - if (r) { - r.constructed = true - r.closed = false - r.closeEmitted = false - r.destroyed = false - r.errored = null - r.errorEmitted = false - r.reading = false - r.ended = r.readable === false - r.endEmitted = r.readable === false - } - if (w) { - w.constructed = true - w.destroyed = false - w.closed = false - w.closeEmitted = false - w.errored = null - w.errorEmitted = false - w.finalCalled = false - w.prefinished = false - w.ended = w.writable === false - w.ending = w.writable === false - w.finished = w.writable === false - } -} -function errorOrDestroy(stream, err, sync) { - // We have tests that rely on errors being emitted - // in the same tick, so changing this is semver major. - // For now when you opt-in to autoDestroy we allow - // the error to be emitted nextTick. In a future - // semver major update we should change the default to this. - - const r = stream._readableState - const w = stream._writableState - if ((w !== null && w !== undefined && w.destroyed) || (r !== null && r !== undefined && r.destroyed)) { - return this - } - if ((r !== null && r !== undefined && r.autoDestroy) || (w !== null && w !== undefined && w.autoDestroy)) - stream.destroy(err) - else if (err) { - // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364 - err.stack // eslint-disable-line no-unused-expressions - - if (w && !w.errored) { - w.errored = err - } - if (r && !r.errored) { - r.errored = err - } - if (sync) { - process.nextTick(emitErrorNT, stream, err) - } else { - emitErrorNT(stream, err) - } - } -} -function construct(stream, cb) { - if (typeof stream._construct !== 'function') { - return - } - const r = stream._readableState - const w = stream._writableState - if (r) { - r.constructed = false - } - if (w) { - w.constructed = false - } - stream.once(kConstruct, cb) - if (stream.listenerCount(kConstruct) > 1) { - // Duplex - return - } - process.nextTick(constructNT, stream) -} -function constructNT(stream) { - let called = false - function onConstruct(err) { - if (called) { - errorOrDestroy(stream, err !== null && err !== undefined ? err : new ERR_MULTIPLE_CALLBACK()) - return - } - called = true - const r = stream._readableState - const w = stream._writableState - const s = w || r - if (r) { - r.constructed = true - } - if (w) { - w.constructed = true - } - if (s.destroyed) { - stream.emit(kDestroy, err) - } else if (err) { - errorOrDestroy(stream, err, true) - } else { - process.nextTick(emitConstructNT, stream) - } - } - try { - stream._construct((err) => { - process.nextTick(onConstruct, err) - }) - } catch (err) { - process.nextTick(onConstruct, err) - } -} -function emitConstructNT(stream) { - stream.emit(kConstruct) -} -function isRequest(stream) { - return (stream === null || stream === undefined ? undefined : stream.setHeader) && typeof stream.abort === 'function' -} -function emitCloseLegacy(stream) { - stream.emit('close') -} -function emitErrorCloseLegacy(stream, err) { - stream.emit('error', err) - process.nextTick(emitCloseLegacy, stream) -} - -// Normalize destroy for legacy. -function destroyer(stream, err) { - if (!stream || isDestroyed(stream)) { - return - } - if (!err && !isFinished(stream)) { - err = new AbortError() - } - - // TODO: Remove isRequest branches. - if (isServerRequest(stream)) { - stream.socket = null - stream.destroy(err) - } else if (isRequest(stream)) { - stream.abort() - } else if (isRequest(stream.req)) { - stream.req.abort() - } else if (typeof stream.destroy === 'function') { - stream.destroy(err) - } else if (typeof stream.close === 'function') { - // TODO: Don't lose err? - stream.close() - } else if (err) { - process.nextTick(emitErrorCloseLegacy, stream, err) - } else { - process.nextTick(emitCloseLegacy, stream) - } - if (!stream.destroyed) { - stream[kDestroyed] = true - } -} -module.exports = { - construct, - destroyer, - destroy, - undestroy, - errorOrDestroy -} diff --git a/node_modules/readable-stream/lib/internal/streams/duplex.js b/node_modules/readable-stream/lib/internal/streams/duplex.js deleted file mode 100644 index dd08396738baa..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/duplex.js +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototype inheritance, this class -// prototypically inherits from Readable, and then parasitically from -// Writable. - -'use strict' - -const { - ObjectDefineProperties, - ObjectGetOwnPropertyDescriptor, - ObjectKeys, - ObjectSetPrototypeOf -} = require('../../ours/primordials') -module.exports = Duplex -const Readable = require('./readable') -const Writable = require('./writable') -ObjectSetPrototypeOf(Duplex.prototype, Readable.prototype) -ObjectSetPrototypeOf(Duplex, Readable) -{ - const keys = ObjectKeys(Writable.prototype) - // Allow the keys array to be GC'ed. - for (let i = 0; i < keys.length; i++) { - const method = keys[i] - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method] - } -} -function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options) - Readable.call(this, options) - Writable.call(this, options) - if (options) { - this.allowHalfOpen = options.allowHalfOpen !== false - if (options.readable === false) { - this._readableState.readable = false - this._readableState.ended = true - this._readableState.endEmitted = true - } - if (options.writable === false) { - this._writableState.writable = false - this._writableState.ending = true - this._writableState.ended = true - this._writableState.finished = true - } - } else { - this.allowHalfOpen = true - } -} -ObjectDefineProperties(Duplex.prototype, { - writable: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable') - }, - writableHighWaterMark: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableHighWaterMark') - }, - writableObjectMode: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableObjectMode') - }, - writableBuffer: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableBuffer') - }, - writableLength: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableLength') - }, - writableFinished: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableFinished') - }, - writableCorked: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableCorked') - }, - writableEnded: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableEnded') - }, - writableNeedDrain: { - __proto__: null, - ...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableNeedDrain') - }, - destroyed: { - __proto__: null, - get() { - if (this._readableState === undefined || this._writableState === undefined) { - return false - } - return this._readableState.destroyed && this._writableState.destroyed - }, - set(value) { - // Backward compatibility, the user is explicitly - // managing destroyed. - if (this._readableState && this._writableState) { - this._readableState.destroyed = value - this._writableState.destroyed = value - } - } - } -}) -let webStreamsAdapters - -// Lazy to avoid circular references -function lazyWebStreams() { - if (webStreamsAdapters === undefined) webStreamsAdapters = {} - return webStreamsAdapters -} -Duplex.fromWeb = function (pair, options) { - return lazyWebStreams().newStreamDuplexFromReadableWritablePair(pair, options) -} -Duplex.toWeb = function (duplex) { - return lazyWebStreams().newReadableWritablePairFromDuplex(duplex) -} -let duplexify -Duplex.from = function (body) { - if (!duplexify) { - duplexify = require('./duplexify') - } - return duplexify(body, 'body') -} diff --git a/node_modules/readable-stream/lib/internal/streams/duplexify.js b/node_modules/readable-stream/lib/internal/streams/duplexify.js deleted file mode 100644 index 599fb47ab53c2..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/duplexify.js +++ /dev/null @@ -1,379 +0,0 @@ -/* replacement start */ - -const process = require('process/') - -/* replacement end */ - -;('use strict') -const bufferModule = require('buffer') -const { - isReadable, - isWritable, - isIterable, - isNodeStream, - isReadableNodeStream, - isWritableNodeStream, - isDuplexNodeStream -} = require('./utils') -const eos = require('./end-of-stream') -const { - AbortError, - codes: { ERR_INVALID_ARG_TYPE, ERR_INVALID_RETURN_VALUE } -} = require('../../ours/errors') -const { destroyer } = require('./destroy') -const Duplex = require('./duplex') -const Readable = require('./readable') -const { createDeferredPromise } = require('../../ours/util') -const from = require('./from') -const Blob = globalThis.Blob || bufferModule.Blob -const isBlob = - typeof Blob !== 'undefined' - ? function isBlob(b) { - return b instanceof Blob - } - : function isBlob(b) { - return false - } -const AbortController = globalThis.AbortController || require('abort-controller').AbortController -const { FunctionPrototypeCall } = require('../../ours/primordials') - -// This is needed for pre node 17. -class Duplexify extends Duplex { - constructor(options) { - super(options) - - // https://github.com/nodejs/node/pull/34385 - - if ((options === null || options === undefined ? undefined : options.readable) === false) { - this._readableState.readable = false - this._readableState.ended = true - this._readableState.endEmitted = true - } - if ((options === null || options === undefined ? undefined : options.writable) === false) { - this._writableState.writable = false - this._writableState.ending = true - this._writableState.ended = true - this._writableState.finished = true - } - } -} -module.exports = function duplexify(body, name) { - if (isDuplexNodeStream(body)) { - return body - } - if (isReadableNodeStream(body)) { - return _duplexify({ - readable: body - }) - } - if (isWritableNodeStream(body)) { - return _duplexify({ - writable: body - }) - } - if (isNodeStream(body)) { - return _duplexify({ - writable: false, - readable: false - }) - } - - // TODO: Webstreams - // if (isReadableStream(body)) { - // return _duplexify({ readable: Readable.fromWeb(body) }); - // } - - // TODO: Webstreams - // if (isWritableStream(body)) { - // return _duplexify({ writable: Writable.fromWeb(body) }); - // } - - if (typeof body === 'function') { - const { value, write, final, destroy } = fromAsyncGen(body) - if (isIterable(value)) { - return from(Duplexify, value, { - // TODO (ronag): highWaterMark? - objectMode: true, - write, - final, - destroy - }) - } - const then = value === null || value === undefined ? undefined : value.then - if (typeof then === 'function') { - let d - const promise = FunctionPrototypeCall( - then, - value, - (val) => { - if (val != null) { - throw new ERR_INVALID_RETURN_VALUE('nully', 'body', val) - } - }, - (err) => { - destroyer(d, err) - } - ) - return (d = new Duplexify({ - // TODO (ronag): highWaterMark? - objectMode: true, - readable: false, - write, - final(cb) { - final(async () => { - try { - await promise - process.nextTick(cb, null) - } catch (err) { - process.nextTick(cb, err) - } - }) - }, - destroy - })) - } - throw new ERR_INVALID_RETURN_VALUE('Iterable, AsyncIterable or AsyncFunction', name, value) - } - if (isBlob(body)) { - return duplexify(body.arrayBuffer()) - } - if (isIterable(body)) { - return from(Duplexify, body, { - // TODO (ronag): highWaterMark? - objectMode: true, - writable: false - }) - } - - // TODO: Webstreams. - // if ( - // isReadableStream(body?.readable) && - // isWritableStream(body?.writable) - // ) { - // return Duplexify.fromWeb(body); - // } - - if ( - typeof (body === null || body === undefined ? undefined : body.writable) === 'object' || - typeof (body === null || body === undefined ? undefined : body.readable) === 'object' - ) { - const readable = - body !== null && body !== undefined && body.readable - ? isReadableNodeStream(body === null || body === undefined ? undefined : body.readable) - ? body === null || body === undefined - ? undefined - : body.readable - : duplexify(body.readable) - : undefined - const writable = - body !== null && body !== undefined && body.writable - ? isWritableNodeStream(body === null || body === undefined ? undefined : body.writable) - ? body === null || body === undefined - ? undefined - : body.writable - : duplexify(body.writable) - : undefined - return _duplexify({ - readable, - writable - }) - } - const then = body === null || body === undefined ? undefined : body.then - if (typeof then === 'function') { - let d - FunctionPrototypeCall( - then, - body, - (val) => { - if (val != null) { - d.push(val) - } - d.push(null) - }, - (err) => { - destroyer(d, err) - } - ) - return (d = new Duplexify({ - objectMode: true, - writable: false, - read() {} - })) - } - throw new ERR_INVALID_ARG_TYPE( - name, - [ - 'Blob', - 'ReadableStream', - 'WritableStream', - 'Stream', - 'Iterable', - 'AsyncIterable', - 'Function', - '{ readable, writable } pair', - 'Promise' - ], - body - ) -} -function fromAsyncGen(fn) { - let { promise, resolve } = createDeferredPromise() - const ac = new AbortController() - const signal = ac.signal - const value = fn( - (async function* () { - while (true) { - const _promise = promise - promise = null - const { chunk, done, cb } = await _promise - process.nextTick(cb) - if (done) return - if (signal.aborted) - throw new AbortError(undefined, { - cause: signal.reason - }) - ;({ promise, resolve } = createDeferredPromise()) - yield chunk - } - })(), - { - signal - } - ) - return { - value, - write(chunk, encoding, cb) { - const _resolve = resolve - resolve = null - _resolve({ - chunk, - done: false, - cb - }) - }, - final(cb) { - const _resolve = resolve - resolve = null - _resolve({ - done: true, - cb - }) - }, - destroy(err, cb) { - ac.abort() - cb(err) - } - } -} -function _duplexify(pair) { - const r = pair.readable && typeof pair.readable.read !== 'function' ? Readable.wrap(pair.readable) : pair.readable - const w = pair.writable - let readable = !!isReadable(r) - let writable = !!isWritable(w) - let ondrain - let onfinish - let onreadable - let onclose - let d - function onfinished(err) { - const cb = onclose - onclose = null - if (cb) { - cb(err) - } else if (err) { - d.destroy(err) - } - } - - // TODO(ronag): Avoid double buffering. - // Implement Writable/Readable/Duplex traits. - // See, https://github.com/nodejs/node/pull/33515. - d = new Duplexify({ - // TODO (ronag): highWaterMark? - readableObjectMode: !!(r !== null && r !== undefined && r.readableObjectMode), - writableObjectMode: !!(w !== null && w !== undefined && w.writableObjectMode), - readable, - writable - }) - if (writable) { - eos(w, (err) => { - writable = false - if (err) { - destroyer(r, err) - } - onfinished(err) - }) - d._write = function (chunk, encoding, callback) { - if (w.write(chunk, encoding)) { - callback() - } else { - ondrain = callback - } - } - d._final = function (callback) { - w.end() - onfinish = callback - } - w.on('drain', function () { - if (ondrain) { - const cb = ondrain - ondrain = null - cb() - } - }) - w.on('finish', function () { - if (onfinish) { - const cb = onfinish - onfinish = null - cb() - } - }) - } - if (readable) { - eos(r, (err) => { - readable = false - if (err) { - destroyer(r, err) - } - onfinished(err) - }) - r.on('readable', function () { - if (onreadable) { - const cb = onreadable - onreadable = null - cb() - } - }) - r.on('end', function () { - d.push(null) - }) - d._read = function () { - while (true) { - const buf = r.read() - if (buf === null) { - onreadable = d._read - return - } - if (!d.push(buf)) { - return - } - } - } - } - d._destroy = function (err, callback) { - if (!err && onclose !== null) { - err = new AbortError() - } - onreadable = null - ondrain = null - onfinish = null - if (onclose === null) { - callback(err) - } else { - onclose = callback - destroyer(w, err) - destroyer(r, err) - } - } - return d -} diff --git a/node_modules/readable-stream/lib/internal/streams/end-of-stream.js b/node_modules/readable-stream/lib/internal/streams/end-of-stream.js deleted file mode 100644 index 043c9c4bdac51..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +++ /dev/null @@ -1,281 +0,0 @@ -/* replacement start */ - -const process = require('process/') - -/* replacement end */ -// Ported from https://github.com/mafintosh/end-of-stream with -// permission from the author, Mathias Buus (@mafintosh). - -;('use strict') -const { AbortError, codes } = require('../../ours/errors') -const { ERR_INVALID_ARG_TYPE, ERR_STREAM_PREMATURE_CLOSE } = codes -const { kEmptyObject, once } = require('../../ours/util') -const { validateAbortSignal, validateFunction, validateObject, validateBoolean } = require('../validators') -const { Promise, PromisePrototypeThen } = require('../../ours/primordials') -const { - isClosed, - isReadable, - isReadableNodeStream, - isReadableStream, - isReadableFinished, - isReadableErrored, - isWritable, - isWritableNodeStream, - isWritableStream, - isWritableFinished, - isWritableErrored, - isNodeStream, - willEmitClose: _willEmitClose, - kIsClosedPromise -} = require('./utils') -function isRequest(stream) { - return stream.setHeader && typeof stream.abort === 'function' -} -const nop = () => {} -function eos(stream, options, callback) { - var _options$readable, _options$writable - if (arguments.length === 2) { - callback = options - options = kEmptyObject - } else if (options == null) { - options = kEmptyObject - } else { - validateObject(options, 'options') - } - validateFunction(callback, 'callback') - validateAbortSignal(options.signal, 'options.signal') - callback = once(callback) - if (isReadableStream(stream) || isWritableStream(stream)) { - return eosWeb(stream, options, callback) - } - if (!isNodeStream(stream)) { - throw new ERR_INVALID_ARG_TYPE('stream', ['ReadableStream', 'WritableStream', 'Stream'], stream) - } - const readable = - (_options$readable = options.readable) !== null && _options$readable !== undefined - ? _options$readable - : isReadableNodeStream(stream) - const writable = - (_options$writable = options.writable) !== null && _options$writable !== undefined - ? _options$writable - : isWritableNodeStream(stream) - const wState = stream._writableState - const rState = stream._readableState - const onlegacyfinish = () => { - if (!stream.writable) { - onfinish() - } - } - - // TODO (ronag): Improve soft detection to include core modules and - // common ecosystem modules that do properly emit 'close' but fail - // this generic check. - let willEmitClose = - _willEmitClose(stream) && isReadableNodeStream(stream) === readable && isWritableNodeStream(stream) === writable - let writableFinished = isWritableFinished(stream, false) - const onfinish = () => { - writableFinished = true - // Stream should not be destroyed here. If it is that - // means that user space is doing something differently and - // we cannot trust willEmitClose. - if (stream.destroyed) { - willEmitClose = false - } - if (willEmitClose && (!stream.readable || readable)) { - return - } - if (!readable || readableFinished) { - callback.call(stream) - } - } - let readableFinished = isReadableFinished(stream, false) - const onend = () => { - readableFinished = true - // Stream should not be destroyed here. If it is that - // means that user space is doing something differently and - // we cannot trust willEmitClose. - if (stream.destroyed) { - willEmitClose = false - } - if (willEmitClose && (!stream.writable || writable)) { - return - } - if (!writable || writableFinished) { - callback.call(stream) - } - } - const onerror = (err) => { - callback.call(stream, err) - } - let closed = isClosed(stream) - const onclose = () => { - closed = true - const errored = isWritableErrored(stream) || isReadableErrored(stream) - if (errored && typeof errored !== 'boolean') { - return callback.call(stream, errored) - } - if (readable && !readableFinished && isReadableNodeStream(stream, true)) { - if (!isReadableFinished(stream, false)) return callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE()) - } - if (writable && !writableFinished) { - if (!isWritableFinished(stream, false)) return callback.call(stream, new ERR_STREAM_PREMATURE_CLOSE()) - } - callback.call(stream) - } - const onclosed = () => { - closed = true - const errored = isWritableErrored(stream) || isReadableErrored(stream) - if (errored && typeof errored !== 'boolean') { - return callback.call(stream, errored) - } - callback.call(stream) - } - const onrequest = () => { - stream.req.on('finish', onfinish) - } - if (isRequest(stream)) { - stream.on('complete', onfinish) - if (!willEmitClose) { - stream.on('abort', onclose) - } - if (stream.req) { - onrequest() - } else { - stream.on('request', onrequest) - } - } else if (writable && !wState) { - // legacy streams - stream.on('end', onlegacyfinish) - stream.on('close', onlegacyfinish) - } - - // Not all streams will emit 'close' after 'aborted'. - if (!willEmitClose && typeof stream.aborted === 'boolean') { - stream.on('aborted', onclose) - } - stream.on('end', onend) - stream.on('finish', onfinish) - if (options.error !== false) { - stream.on('error', onerror) - } - stream.on('close', onclose) - if (closed) { - process.nextTick(onclose) - } else if ( - (wState !== null && wState !== undefined && wState.errorEmitted) || - (rState !== null && rState !== undefined && rState.errorEmitted) - ) { - if (!willEmitClose) { - process.nextTick(onclosed) - } - } else if ( - !readable && - (!willEmitClose || isReadable(stream)) && - (writableFinished || isWritable(stream) === false) - ) { - process.nextTick(onclosed) - } else if ( - !writable && - (!willEmitClose || isWritable(stream)) && - (readableFinished || isReadable(stream) === false) - ) { - process.nextTick(onclosed) - } else if (rState && stream.req && stream.aborted) { - process.nextTick(onclosed) - } - const cleanup = () => { - callback = nop - stream.removeListener('aborted', onclose) - stream.removeListener('complete', onfinish) - stream.removeListener('abort', onclose) - stream.removeListener('request', onrequest) - if (stream.req) stream.req.removeListener('finish', onfinish) - stream.removeListener('end', onlegacyfinish) - stream.removeListener('close', onlegacyfinish) - stream.removeListener('finish', onfinish) - stream.removeListener('end', onend) - stream.removeListener('error', onerror) - stream.removeListener('close', onclose) - } - if (options.signal && !closed) { - const abort = () => { - // Keep it because cleanup removes it. - const endCallback = callback - cleanup() - endCallback.call( - stream, - new AbortError(undefined, { - cause: options.signal.reason - }) - ) - } - if (options.signal.aborted) { - process.nextTick(abort) - } else { - const originalCallback = callback - callback = once((...args) => { - options.signal.removeEventListener('abort', abort) - originalCallback.apply(stream, args) - }) - options.signal.addEventListener('abort', abort) - } - } - return cleanup -} -function eosWeb(stream, options, callback) { - let isAborted = false - let abort = nop - if (options.signal) { - abort = () => { - isAborted = true - callback.call( - stream, - new AbortError(undefined, { - cause: options.signal.reason - }) - ) - } - if (options.signal.aborted) { - process.nextTick(abort) - } else { - const originalCallback = callback - callback = once((...args) => { - options.signal.removeEventListener('abort', abort) - originalCallback.apply(stream, args) - }) - options.signal.addEventListener('abort', abort) - } - } - const resolverFn = (...args) => { - if (!isAborted) { - process.nextTick(() => callback.apply(stream, args)) - } - } - PromisePrototypeThen(stream[kIsClosedPromise].promise, resolverFn, resolverFn) - return nop -} -function finished(stream, opts) { - var _opts - let autoCleanup = false - if (opts === null) { - opts = kEmptyObject - } - if ((_opts = opts) !== null && _opts !== undefined && _opts.cleanup) { - validateBoolean(opts.cleanup, 'cleanup') - autoCleanup = opts.cleanup - } - return new Promise((resolve, reject) => { - const cleanup = eos(stream, opts, (err) => { - if (autoCleanup) { - cleanup() - } - if (err) { - reject(err) - } else { - resolve() - } - }) - }) -} -module.exports = eos -module.exports.finished = finished diff --git a/node_modules/readable-stream/lib/internal/streams/from.js b/node_modules/readable-stream/lib/internal/streams/from.js deleted file mode 100644 index c7e7531402879..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/from.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict' - -/* replacement start */ - -const process = require('process/') - -/* replacement end */ - -const { PromisePrototypeThen, SymbolAsyncIterator, SymbolIterator } = require('../../ours/primordials') -const { Buffer } = require('buffer') -const { ERR_INVALID_ARG_TYPE, ERR_STREAM_NULL_VALUES } = require('../../ours/errors').codes -function from(Readable, iterable, opts) { - let iterator - if (typeof iterable === 'string' || iterable instanceof Buffer) { - return new Readable({ - objectMode: true, - ...opts, - read() { - this.push(iterable) - this.push(null) - } - }) - } - let isAsync - if (iterable && iterable[SymbolAsyncIterator]) { - isAsync = true - iterator = iterable[SymbolAsyncIterator]() - } else if (iterable && iterable[SymbolIterator]) { - isAsync = false - iterator = iterable[SymbolIterator]() - } else { - throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable) - } - const readable = new Readable({ - objectMode: true, - highWaterMark: 1, - // TODO(ronag): What options should be allowed? - ...opts - }) - - // Flag to protect against _read - // being called before last iteration completion. - let reading = false - readable._read = function () { - if (!reading) { - reading = true - next() - } - } - readable._destroy = function (error, cb) { - PromisePrototypeThen( - close(error), - () => process.nextTick(cb, error), - // nextTick is here in case cb throws - (e) => process.nextTick(cb, e || error) - ) - } - async function close(error) { - const hadError = error !== undefined && error !== null - const hasThrow = typeof iterator.throw === 'function' - if (hadError && hasThrow) { - const { value, done } = await iterator.throw(error) - await value - if (done) { - return - } - } - if (typeof iterator.return === 'function') { - const { value } = await iterator.return() - await value - } - } - async function next() { - for (;;) { - try { - const { value, done } = isAsync ? await iterator.next() : iterator.next() - if (done) { - readable.push(null) - } else { - const res = value && typeof value.then === 'function' ? await value : value - if (res === null) { - reading = false - throw new ERR_STREAM_NULL_VALUES() - } else if (readable.push(res)) { - continue - } else { - reading = false - } - } - } catch (err) { - readable.destroy(err) - } - break - } - } - return readable -} -module.exports = from diff --git a/node_modules/readable-stream/lib/internal/streams/lazy_transform.js b/node_modules/readable-stream/lib/internal/streams/lazy_transform.js deleted file mode 100644 index 439461a127839..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/lazy_transform.js +++ /dev/null @@ -1,51 +0,0 @@ -// LazyTransform is a special type of Transform stream that is lazily loaded. -// This is used for performance with bi-API-ship: when two APIs are available -// for the stream, one conventional and one non-conventional. -'use strict' - -const { ObjectDefineProperties, ObjectDefineProperty, ObjectSetPrototypeOf } = require('../../ours/primordials') -const stream = require('../../stream') -const { getDefaultEncoding } = require('../crypto/util') -module.exports = LazyTransform -function LazyTransform(options) { - this._options = options -} -ObjectSetPrototypeOf(LazyTransform.prototype, stream.Transform.prototype) -ObjectSetPrototypeOf(LazyTransform, stream.Transform) -function makeGetter(name) { - return function () { - stream.Transform.call(this, this._options) - this._writableState.decodeStrings = false - if (!this._options || !this._options.defaultEncoding) { - this._writableState.defaultEncoding = getDefaultEncoding() - } - return this[name] - } -} -function makeSetter(name) { - return function (val) { - ObjectDefineProperty(this, name, { - __proto__: null, - value: val, - enumerable: true, - configurable: true, - writable: true - }) - } -} -ObjectDefineProperties(LazyTransform.prototype, { - _readableState: { - __proto__: null, - get: makeGetter('_readableState'), - set: makeSetter('_readableState'), - configurable: true, - enumerable: true - }, - _writableState: { - __proto__: null, - get: makeGetter('_writableState'), - set: makeSetter('_writableState'), - configurable: true, - enumerable: true - } -}) diff --git a/node_modules/readable-stream/lib/internal/streams/legacy.js b/node_modules/readable-stream/lib/internal/streams/legacy.js deleted file mode 100644 index d492f7ff4e6b6..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/legacy.js +++ /dev/null @@ -1,89 +0,0 @@ -'use strict' - -const { ArrayIsArray, ObjectSetPrototypeOf } = require('../../ours/primordials') -const { EventEmitter: EE } = require('events') -function Stream(opts) { - EE.call(this, opts) -} -ObjectSetPrototypeOf(Stream.prototype, EE.prototype) -ObjectSetPrototypeOf(Stream, EE) -Stream.prototype.pipe = function (dest, options) { - const source = this - function ondata(chunk) { - if (dest.writable && dest.write(chunk) === false && source.pause) { - source.pause() - } - } - source.on('data', ondata) - function ondrain() { - if (source.readable && source.resume) { - source.resume() - } - } - dest.on('drain', ondrain) - - // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once. - if (!dest._isStdio && (!options || options.end !== false)) { - source.on('end', onend) - source.on('close', onclose) - } - let didOnEnd = false - function onend() { - if (didOnEnd) return - didOnEnd = true - dest.end() - } - function onclose() { - if (didOnEnd) return - didOnEnd = true - if (typeof dest.destroy === 'function') dest.destroy() - } - - // Don't leave dangling pipes when there are errors. - function onerror(er) { - cleanup() - if (EE.listenerCount(this, 'error') === 0) { - this.emit('error', er) - } - } - prependListener(source, 'error', onerror) - prependListener(dest, 'error', onerror) - - // Remove all the event listeners that were added. - function cleanup() { - source.removeListener('data', ondata) - dest.removeListener('drain', ondrain) - source.removeListener('end', onend) - source.removeListener('close', onclose) - source.removeListener('error', onerror) - dest.removeListener('error', onerror) - source.removeListener('end', cleanup) - source.removeListener('close', cleanup) - dest.removeListener('close', cleanup) - } - source.on('end', cleanup) - source.on('close', cleanup) - dest.on('close', cleanup) - dest.emit('pipe', source) - - // Allow for unix-like usage: A.pipe(B).pipe(C) - return dest -} -function prependListener(emitter, event, fn) { - // Sadly this is not cacheable as some libraries bundle their own - // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn) - - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn) - else if (ArrayIsArray(emitter._events[event])) emitter._events[event].unshift(fn) - else emitter._events[event] = [fn, emitter._events[event]] -} -module.exports = { - Stream, - prependListener -} diff --git a/node_modules/readable-stream/lib/internal/streams/operators.js b/node_modules/readable-stream/lib/internal/streams/operators.js deleted file mode 100644 index 869cacb39faca..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/operators.js +++ /dev/null @@ -1,457 +0,0 @@ -'use strict' - -const AbortController = globalThis.AbortController || require('abort-controller').AbortController -const { - codes: { ERR_INVALID_ARG_VALUE, ERR_INVALID_ARG_TYPE, ERR_MISSING_ARGS, ERR_OUT_OF_RANGE }, - AbortError -} = require('../../ours/errors') -const { validateAbortSignal, validateInteger, validateObject } = require('../validators') -const kWeakHandler = require('../../ours/primordials').Symbol('kWeak') -const { finished } = require('./end-of-stream') -const staticCompose = require('./compose') -const { addAbortSignalNoValidate } = require('./add-abort-signal') -const { isWritable, isNodeStream } = require('./utils') -const { - ArrayPrototypePush, - MathFloor, - Number, - NumberIsNaN, - Promise, - PromiseReject, - PromisePrototypeThen, - Symbol -} = require('../../ours/primordials') -const kEmpty = Symbol('kEmpty') -const kEof = Symbol('kEof') -function compose(stream, options) { - if (options != null) { - validateObject(options, 'options') - } - if ((options === null || options === undefined ? undefined : options.signal) != null) { - validateAbortSignal(options.signal, 'options.signal') - } - if (isNodeStream(stream) && !isWritable(stream)) { - throw new ERR_INVALID_ARG_VALUE('stream', stream, 'must be writable') - } - const composedStream = staticCompose(this, stream) - if (options !== null && options !== undefined && options.signal) { - // Not validating as we already validated before - addAbortSignalNoValidate(options.signal, composedStream) - } - return composedStream -} -function map(fn, options) { - if (typeof fn !== 'function') { - throw new ERR_INVALID_ARG_TYPE('fn', ['Function', 'AsyncFunction'], fn) - } - if (options != null) { - validateObject(options, 'options') - } - if ((options === null || options === undefined ? undefined : options.signal) != null) { - validateAbortSignal(options.signal, 'options.signal') - } - let concurrency = 1 - if ((options === null || options === undefined ? undefined : options.concurrency) != null) { - concurrency = MathFloor(options.concurrency) - } - validateInteger(concurrency, 'concurrency', 1) - return async function* map() { - var _options$signal, _options$signal2 - const ac = new AbortController() - const stream = this - const queue = [] - const signal = ac.signal - const signalOpt = { - signal - } - const abort = () => ac.abort() - if ( - options !== null && - options !== undefined && - (_options$signal = options.signal) !== null && - _options$signal !== undefined && - _options$signal.aborted - ) { - abort() - } - options === null || options === undefined - ? undefined - : (_options$signal2 = options.signal) === null || _options$signal2 === undefined - ? undefined - : _options$signal2.addEventListener('abort', abort) - let next - let resume - let done = false - function onDone() { - done = true - } - async function pump() { - try { - for await (let val of stream) { - var _val - if (done) { - return - } - if (signal.aborted) { - throw new AbortError() - } - try { - val = fn(val, signalOpt) - } catch (err) { - val = PromiseReject(err) - } - if (val === kEmpty) { - continue - } - if (typeof ((_val = val) === null || _val === undefined ? undefined : _val.catch) === 'function') { - val.catch(onDone) - } - queue.push(val) - if (next) { - next() - next = null - } - if (!done && queue.length && queue.length >= concurrency) { - await new Promise((resolve) => { - resume = resolve - }) - } - } - queue.push(kEof) - } catch (err) { - const val = PromiseReject(err) - PromisePrototypeThen(val, undefined, onDone) - queue.push(val) - } finally { - var _options$signal3 - done = true - if (next) { - next() - next = null - } - options === null || options === undefined - ? undefined - : (_options$signal3 = options.signal) === null || _options$signal3 === undefined - ? undefined - : _options$signal3.removeEventListener('abort', abort) - } - } - pump() - try { - while (true) { - while (queue.length > 0) { - const val = await queue[0] - if (val === kEof) { - return - } - if (signal.aborted) { - throw new AbortError() - } - if (val !== kEmpty) { - yield val - } - queue.shift() - if (resume) { - resume() - resume = null - } - } - await new Promise((resolve) => { - next = resolve - }) - } - } finally { - ac.abort() - done = true - if (resume) { - resume() - resume = null - } - } - }.call(this) -} -function asIndexedPairs(options = undefined) { - if (options != null) { - validateObject(options, 'options') - } - if ((options === null || options === undefined ? undefined : options.signal) != null) { - validateAbortSignal(options.signal, 'options.signal') - } - return async function* asIndexedPairs() { - let index = 0 - for await (const val of this) { - var _options$signal4 - if ( - options !== null && - options !== undefined && - (_options$signal4 = options.signal) !== null && - _options$signal4 !== undefined && - _options$signal4.aborted - ) { - throw new AbortError({ - cause: options.signal.reason - }) - } - yield [index++, val] - } - }.call(this) -} -async function some(fn, options = undefined) { - for await (const unused of filter.call(this, fn, options)) { - return true - } - return false -} -async function every(fn, options = undefined) { - if (typeof fn !== 'function') { - throw new ERR_INVALID_ARG_TYPE('fn', ['Function', 'AsyncFunction'], fn) - } - // https://en.wikipedia.org/wiki/De_Morgan%27s_laws - return !(await some.call( - this, - async (...args) => { - return !(await fn(...args)) - }, - options - )) -} -async function find(fn, options) { - for await (const result of filter.call(this, fn, options)) { - return result - } - return undefined -} -async function forEach(fn, options) { - if (typeof fn !== 'function') { - throw new ERR_INVALID_ARG_TYPE('fn', ['Function', 'AsyncFunction'], fn) - } - async function forEachFn(value, options) { - await fn(value, options) - return kEmpty - } - // eslint-disable-next-line no-unused-vars - for await (const unused of map.call(this, forEachFn, options)); -} -function filter(fn, options) { - if (typeof fn !== 'function') { - throw new ERR_INVALID_ARG_TYPE('fn', ['Function', 'AsyncFunction'], fn) - } - async function filterFn(value, options) { - if (await fn(value, options)) { - return value - } - return kEmpty - } - return map.call(this, filterFn, options) -} - -// Specific to provide better error to reduce since the argument is only -// missing if the stream has no items in it - but the code is still appropriate -class ReduceAwareErrMissingArgs extends ERR_MISSING_ARGS { - constructor() { - super('reduce') - this.message = 'Reduce of an empty stream requires an initial value' - } -} -async function reduce(reducer, initialValue, options) { - var _options$signal5 - if (typeof reducer !== 'function') { - throw new ERR_INVALID_ARG_TYPE('reducer', ['Function', 'AsyncFunction'], reducer) - } - if (options != null) { - validateObject(options, 'options') - } - if ((options === null || options === undefined ? undefined : options.signal) != null) { - validateAbortSignal(options.signal, 'options.signal') - } - let hasInitialValue = arguments.length > 1 - if ( - options !== null && - options !== undefined && - (_options$signal5 = options.signal) !== null && - _options$signal5 !== undefined && - _options$signal5.aborted - ) { - const err = new AbortError(undefined, { - cause: options.signal.reason - }) - this.once('error', () => {}) // The error is already propagated - await finished(this.destroy(err)) - throw err - } - const ac = new AbortController() - const signal = ac.signal - if (options !== null && options !== undefined && options.signal) { - const opts = { - once: true, - [kWeakHandler]: this - } - options.signal.addEventListener('abort', () => ac.abort(), opts) - } - let gotAnyItemFromStream = false - try { - for await (const value of this) { - var _options$signal6 - gotAnyItemFromStream = true - if ( - options !== null && - options !== undefined && - (_options$signal6 = options.signal) !== null && - _options$signal6 !== undefined && - _options$signal6.aborted - ) { - throw new AbortError() - } - if (!hasInitialValue) { - initialValue = value - hasInitialValue = true - } else { - initialValue = await reducer(initialValue, value, { - signal - }) - } - } - if (!gotAnyItemFromStream && !hasInitialValue) { - throw new ReduceAwareErrMissingArgs() - } - } finally { - ac.abort() - } - return initialValue -} -async function toArray(options) { - if (options != null) { - validateObject(options, 'options') - } - if ((options === null || options === undefined ? undefined : options.signal) != null) { - validateAbortSignal(options.signal, 'options.signal') - } - const result = [] - for await (const val of this) { - var _options$signal7 - if ( - options !== null && - options !== undefined && - (_options$signal7 = options.signal) !== null && - _options$signal7 !== undefined && - _options$signal7.aborted - ) { - throw new AbortError(undefined, { - cause: options.signal.reason - }) - } - ArrayPrototypePush(result, val) - } - return result -} -function flatMap(fn, options) { - const values = map.call(this, fn, options) - return async function* flatMap() { - for await (const val of values) { - yield* val - } - }.call(this) -} -function toIntegerOrInfinity(number) { - // We coerce here to align with the spec - // https://github.com/tc39/proposal-iterator-helpers/issues/169 - number = Number(number) - if (NumberIsNaN(number)) { - return 0 - } - if (number < 0) { - throw new ERR_OUT_OF_RANGE('number', '>= 0', number) - } - return number -} -function drop(number, options = undefined) { - if (options != null) { - validateObject(options, 'options') - } - if ((options === null || options === undefined ? undefined : options.signal) != null) { - validateAbortSignal(options.signal, 'options.signal') - } - number = toIntegerOrInfinity(number) - return async function* drop() { - var _options$signal8 - if ( - options !== null && - options !== undefined && - (_options$signal8 = options.signal) !== null && - _options$signal8 !== undefined && - _options$signal8.aborted - ) { - throw new AbortError() - } - for await (const val of this) { - var _options$signal9 - if ( - options !== null && - options !== undefined && - (_options$signal9 = options.signal) !== null && - _options$signal9 !== undefined && - _options$signal9.aborted - ) { - throw new AbortError() - } - if (number-- <= 0) { - yield val - } - } - }.call(this) -} -function take(number, options = undefined) { - if (options != null) { - validateObject(options, 'options') - } - if ((options === null || options === undefined ? undefined : options.signal) != null) { - validateAbortSignal(options.signal, 'options.signal') - } - number = toIntegerOrInfinity(number) - return async function* take() { - var _options$signal10 - if ( - options !== null && - options !== undefined && - (_options$signal10 = options.signal) !== null && - _options$signal10 !== undefined && - _options$signal10.aborted - ) { - throw new AbortError() - } - for await (const val of this) { - var _options$signal11 - if ( - options !== null && - options !== undefined && - (_options$signal11 = options.signal) !== null && - _options$signal11 !== undefined && - _options$signal11.aborted - ) { - throw new AbortError() - } - if (number-- > 0) { - yield val - } else { - return - } - } - }.call(this) -} -module.exports.streamReturningOperators = { - asIndexedPairs, - drop, - filter, - flatMap, - map, - take, - compose -} -module.exports.promiseReturningOperators = { - every, - forEach, - reduce, - toArray, - some, - find -} diff --git a/node_modules/readable-stream/lib/internal/streams/passthrough.js b/node_modules/readable-stream/lib/internal/streams/passthrough.js deleted file mode 100644 index ed4f486c3baa4..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/passthrough.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// a passthrough stream. -// basically just the most minimal sort of Transform stream. -// Every written chunk gets output as-is. - -'use strict' - -const { ObjectSetPrototypeOf } = require('../../ours/primordials') -module.exports = PassThrough -const Transform = require('./transform') -ObjectSetPrototypeOf(PassThrough.prototype, Transform.prototype) -ObjectSetPrototypeOf(PassThrough, Transform) -function PassThrough(options) { - if (!(this instanceof PassThrough)) return new PassThrough(options) - Transform.call(this, options) -} -PassThrough.prototype._transform = function (chunk, encoding, cb) { - cb(null, chunk) -} diff --git a/node_modules/readable-stream/lib/internal/streams/pipeline.js b/node_modules/readable-stream/lib/internal/streams/pipeline.js deleted file mode 100644 index 8393ba5146991..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/pipeline.js +++ /dev/null @@ -1,465 +0,0 @@ -/* replacement start */ - -const process = require('process/') - -/* replacement end */ -// Ported from https://github.com/mafintosh/pump with -// permission from the author, Mathias Buus (@mafintosh). - -;('use strict') -const { ArrayIsArray, Promise, SymbolAsyncIterator } = require('../../ours/primordials') -const eos = require('./end-of-stream') -const { once } = require('../../ours/util') -const destroyImpl = require('./destroy') -const Duplex = require('./duplex') -const { - aggregateTwoErrors, - codes: { - ERR_INVALID_ARG_TYPE, - ERR_INVALID_RETURN_VALUE, - ERR_MISSING_ARGS, - ERR_STREAM_DESTROYED, - ERR_STREAM_PREMATURE_CLOSE - }, - AbortError -} = require('../../ours/errors') -const { validateFunction, validateAbortSignal } = require('../validators') -const { - isIterable, - isReadable, - isReadableNodeStream, - isNodeStream, - isTransformStream, - isWebStream, - isReadableStream, - isReadableEnded -} = require('./utils') -const AbortController = globalThis.AbortController || require('abort-controller').AbortController -let PassThrough -let Readable -function destroyer(stream, reading, writing) { - let finished = false - stream.on('close', () => { - finished = true - }) - const cleanup = eos( - stream, - { - readable: reading, - writable: writing - }, - (err) => { - finished = !err - } - ) - return { - destroy: (err) => { - if (finished) return - finished = true - destroyImpl.destroyer(stream, err || new ERR_STREAM_DESTROYED('pipe')) - }, - cleanup - } -} -function popCallback(streams) { - // Streams should never be an empty array. It should always contain at least - // a single stream. Therefore optimize for the average case instead of - // checking for length === 0 as well. - validateFunction(streams[streams.length - 1], 'streams[stream.length - 1]') - return streams.pop() -} -function makeAsyncIterable(val) { - if (isIterable(val)) { - return val - } else if (isReadableNodeStream(val)) { - // Legacy streams are not Iterable. - return fromReadable(val) - } - throw new ERR_INVALID_ARG_TYPE('val', ['Readable', 'Iterable', 'AsyncIterable'], val) -} -async function* fromReadable(val) { - if (!Readable) { - Readable = require('./readable') - } - yield* Readable.prototype[SymbolAsyncIterator].call(val) -} -async function pumpToNode(iterable, writable, finish, { end }) { - let error - let onresolve = null - const resume = (err) => { - if (err) { - error = err - } - if (onresolve) { - const callback = onresolve - onresolve = null - callback() - } - } - const wait = () => - new Promise((resolve, reject) => { - if (error) { - reject(error) - } else { - onresolve = () => { - if (error) { - reject(error) - } else { - resolve() - } - } - } - }) - writable.on('drain', resume) - const cleanup = eos( - writable, - { - readable: false - }, - resume - ) - try { - if (writable.writableNeedDrain) { - await wait() - } - for await (const chunk of iterable) { - if (!writable.write(chunk)) { - await wait() - } - } - if (end) { - writable.end() - } - await wait() - finish() - } catch (err) { - finish(error !== err ? aggregateTwoErrors(error, err) : err) - } finally { - cleanup() - writable.off('drain', resume) - } -} -async function pumpToWeb(readable, writable, finish, { end }) { - if (isTransformStream(writable)) { - writable = writable.writable - } - // https://streams.spec.whatwg.org/#example-manual-write-with-backpressure - const writer = writable.getWriter() - try { - for await (const chunk of readable) { - await writer.ready - writer.write(chunk).catch(() => {}) - } - await writer.ready - if (end) { - await writer.close() - } - finish() - } catch (err) { - try { - await writer.abort(err) - finish(err) - } catch (err) { - finish(err) - } - } -} -function pipeline(...streams) { - return pipelineImpl(streams, once(popCallback(streams))) -} -function pipelineImpl(streams, callback, opts) { - if (streams.length === 1 && ArrayIsArray(streams[0])) { - streams = streams[0] - } - if (streams.length < 2) { - throw new ERR_MISSING_ARGS('streams') - } - const ac = new AbortController() - const signal = ac.signal - const outerSignal = opts === null || opts === undefined ? undefined : opts.signal - - // Need to cleanup event listeners if last stream is readable - // https://github.com/nodejs/node/issues/35452 - const lastStreamCleanup = [] - validateAbortSignal(outerSignal, 'options.signal') - function abort() { - finishImpl(new AbortError()) - } - outerSignal === null || outerSignal === undefined ? undefined : outerSignal.addEventListener('abort', abort) - let error - let value - const destroys = [] - let finishCount = 0 - function finish(err) { - finishImpl(err, --finishCount === 0) - } - function finishImpl(err, final) { - if (err && (!error || error.code === 'ERR_STREAM_PREMATURE_CLOSE')) { - error = err - } - if (!error && !final) { - return - } - while (destroys.length) { - destroys.shift()(error) - } - outerSignal === null || outerSignal === undefined ? undefined : outerSignal.removeEventListener('abort', abort) - ac.abort() - if (final) { - if (!error) { - lastStreamCleanup.forEach((fn) => fn()) - } - process.nextTick(callback, error, value) - } - } - let ret - for (let i = 0; i < streams.length; i++) { - const stream = streams[i] - const reading = i < streams.length - 1 - const writing = i > 0 - const end = reading || (opts === null || opts === undefined ? undefined : opts.end) !== false - const isLastStream = i === streams.length - 1 - if (isNodeStream(stream)) { - if (end) { - const { destroy, cleanup } = destroyer(stream, reading, writing) - destroys.push(destroy) - if (isReadable(stream) && isLastStream) { - lastStreamCleanup.push(cleanup) - } - } - - // Catch stream errors that occur after pipe/pump has completed. - function onError(err) { - if (err && err.name !== 'AbortError' && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { - finish(err) - } - } - stream.on('error', onError) - if (isReadable(stream) && isLastStream) { - lastStreamCleanup.push(() => { - stream.removeListener('error', onError) - }) - } - } - if (i === 0) { - if (typeof stream === 'function') { - ret = stream({ - signal - }) - if (!isIterable(ret)) { - throw new ERR_INVALID_RETURN_VALUE('Iterable, AsyncIterable or Stream', 'source', ret) - } - } else if (isIterable(stream) || isReadableNodeStream(stream) || isTransformStream(stream)) { - ret = stream - } else { - ret = Duplex.from(stream) - } - } else if (typeof stream === 'function') { - if (isTransformStream(ret)) { - var _ret - ret = makeAsyncIterable((_ret = ret) === null || _ret === undefined ? undefined : _ret.readable) - } else { - ret = makeAsyncIterable(ret) - } - ret = stream(ret, { - signal - }) - if (reading) { - if (!isIterable(ret, true)) { - throw new ERR_INVALID_RETURN_VALUE('AsyncIterable', `transform[${i - 1}]`, ret) - } - } else { - var _ret2 - if (!PassThrough) { - PassThrough = require('./passthrough') - } - - // If the last argument to pipeline is not a stream - // we must create a proxy stream so that pipeline(...) - // always returns a stream which can be further - // composed through `.pipe(stream)`. - - const pt = new PassThrough({ - objectMode: true - }) - - // Handle Promises/A+ spec, `then` could be a getter that throws on - // second use. - const then = (_ret2 = ret) === null || _ret2 === undefined ? undefined : _ret2.then - if (typeof then === 'function') { - finishCount++ - then.call( - ret, - (val) => { - value = val - if (val != null) { - pt.write(val) - } - if (end) { - pt.end() - } - process.nextTick(finish) - }, - (err) => { - pt.destroy(err) - process.nextTick(finish, err) - } - ) - } else if (isIterable(ret, true)) { - finishCount++ - pumpToNode(ret, pt, finish, { - end - }) - } else if (isReadableStream(ret) || isTransformStream(ret)) { - const toRead = ret.readable || ret - finishCount++ - pumpToNode(toRead, pt, finish, { - end - }) - } else { - throw new ERR_INVALID_RETURN_VALUE('AsyncIterable or Promise', 'destination', ret) - } - ret = pt - const { destroy, cleanup } = destroyer(ret, false, true) - destroys.push(destroy) - if (isLastStream) { - lastStreamCleanup.push(cleanup) - } - } - } else if (isNodeStream(stream)) { - if (isReadableNodeStream(ret)) { - finishCount += 2 - const cleanup = pipe(ret, stream, finish, { - end - }) - if (isReadable(stream) && isLastStream) { - lastStreamCleanup.push(cleanup) - } - } else if (isTransformStream(ret) || isReadableStream(ret)) { - const toRead = ret.readable || ret - finishCount++ - pumpToNode(toRead, stream, finish, { - end - }) - } else if (isIterable(ret)) { - finishCount++ - pumpToNode(ret, stream, finish, { - end - }) - } else { - throw new ERR_INVALID_ARG_TYPE( - 'val', - ['Readable', 'Iterable', 'AsyncIterable', 'ReadableStream', 'TransformStream'], - ret - ) - } - ret = stream - } else if (isWebStream(stream)) { - if (isReadableNodeStream(ret)) { - finishCount++ - pumpToWeb(makeAsyncIterable(ret), stream, finish, { - end - }) - } else if (isReadableStream(ret) || isIterable(ret)) { - finishCount++ - pumpToWeb(ret, stream, finish, { - end - }) - } else if (isTransformStream(ret)) { - finishCount++ - pumpToWeb(ret.readable, stream, finish, { - end - }) - } else { - throw new ERR_INVALID_ARG_TYPE( - 'val', - ['Readable', 'Iterable', 'AsyncIterable', 'ReadableStream', 'TransformStream'], - ret - ) - } - ret = stream - } else { - ret = Duplex.from(stream) - } - } - if ( - (signal !== null && signal !== undefined && signal.aborted) || - (outerSignal !== null && outerSignal !== undefined && outerSignal.aborted) - ) { - process.nextTick(abort) - } - return ret -} -function pipe(src, dst, finish, { end }) { - let ended = false - dst.on('close', () => { - if (!ended) { - // Finish if the destination closes before the source has completed. - finish(new ERR_STREAM_PREMATURE_CLOSE()) - } - }) - src.pipe(dst, { - end: false - }) // If end is true we already will have a listener to end dst. - - if (end) { - // Compat. Before node v10.12.0 stdio used to throw an error so - // pipe() did/does not end() stdio destinations. - // Now they allow it but "secretly" don't close the underlying fd. - - function endFn() { - ended = true - dst.end() - } - if (isReadableEnded(src)) { - // End the destination if the source has already ended. - process.nextTick(endFn) - } else { - src.once('end', endFn) - } - } else { - finish() - } - eos( - src, - { - readable: true, - writable: false - }, - (err) => { - const rState = src._readableState - if ( - err && - err.code === 'ERR_STREAM_PREMATURE_CLOSE' && - rState && - rState.ended && - !rState.errored && - !rState.errorEmitted - ) { - // Some readable streams will emit 'close' before 'end'. However, since - // this is on the readable side 'end' should still be emitted if the - // stream has been ended and no error emitted. This should be allowed in - // favor of backwards compatibility. Since the stream is piped to a - // destination this should not result in any observable difference. - // We don't need to check if this is a writable premature close since - // eos will only fail with premature close on the reading side for - // duplex streams. - src.once('end', finish).once('error', finish) - } else { - finish(err) - } - } - ) - return eos( - dst, - { - readable: false, - writable: true - }, - finish - ) -} -module.exports = { - pipelineImpl, - pipeline -} diff --git a/node_modules/readable-stream/lib/internal/streams/readable.js b/node_modules/readable-stream/lib/internal/streams/readable.js deleted file mode 100644 index 3fc01d1f88093..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/readable.js +++ /dev/null @@ -1,1247 +0,0 @@ -/* replacement start */ - -const process = require('process/') - -/* replacement end */ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -;('use strict') -const { - ArrayPrototypeIndexOf, - NumberIsInteger, - NumberIsNaN, - NumberParseInt, - ObjectDefineProperties, - ObjectKeys, - ObjectSetPrototypeOf, - Promise, - SafeSet, - SymbolAsyncIterator, - Symbol -} = require('../../ours/primordials') -module.exports = Readable -Readable.ReadableState = ReadableState -const { EventEmitter: EE } = require('events') -const { Stream, prependListener } = require('./legacy') -const { Buffer } = require('buffer') -const { addAbortSignal } = require('./add-abort-signal') -const eos = require('./end-of-stream') -let debug = require('../../ours/util').debuglog('stream', (fn) => { - debug = fn -}) -const BufferList = require('./buffer_list') -const destroyImpl = require('./destroy') -const { getHighWaterMark, getDefaultHighWaterMark } = require('./state') -const { - aggregateTwoErrors, - codes: { - ERR_INVALID_ARG_TYPE, - ERR_METHOD_NOT_IMPLEMENTED, - ERR_OUT_OF_RANGE, - ERR_STREAM_PUSH_AFTER_EOF, - ERR_STREAM_UNSHIFT_AFTER_END_EVENT - } -} = require('../../ours/errors') -const { validateObject } = require('../validators') -const kPaused = Symbol('kPaused') -const { StringDecoder } = require('string_decoder') -const from = require('./from') -ObjectSetPrototypeOf(Readable.prototype, Stream.prototype) -ObjectSetPrototypeOf(Readable, Stream) -const nop = () => {} -const { errorOrDestroy } = destroyImpl -function ReadableState(options, stream, isDuplex) { - // Duplex streams are both readable and writable, but share - // the same options object. - // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof require('./duplex') - - // Object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away. - this.objectMode = !!(options && options.objectMode) - if (isDuplex) this.objectMode = this.objectMode || !!(options && options.readableObjectMode) - - // The point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - this.highWaterMark = options - ? getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex) - : getDefaultHighWaterMark(false) - - // A linked list is used to store data chunks instead of an array because the - // linked list can remove elements from the beginning faster than - // array.shift(). - this.buffer = new BufferList() - this.length = 0 - this.pipes = [] - this.flowing = null - this.ended = false - this.endEmitted = false - this.reading = false - - // Stream is still being constructed and cannot be - // destroyed until construction finished or failed. - // Async construction is opt in, therefore we start as - // constructed. - this.constructed = true - - // A flag to be able to tell if the event 'readable'/'data' is emitted - // immediately, or on a later tick. We set this to true at first, because - // any actions that shouldn't happen until "later" should generally also - // not happen before the first read call. - this.sync = true - - // Whenever we return null, then we set a flag to say - // that we're awaiting a 'readable' event emission. - this.needReadable = false - this.emittedReadable = false - this.readableListening = false - this.resumeScheduled = false - this[kPaused] = null - - // True if the error was already emitted and should not be thrown again. - this.errorEmitted = false - - // Should close be emitted on destroy. Defaults to true. - this.emitClose = !options || options.emitClose !== false - - // Should .destroy() be called after 'end' (and potentially 'finish'). - this.autoDestroy = !options || options.autoDestroy !== false - - // Has it been destroyed. - this.destroyed = false - - // Indicates whether the stream has errored. When true no further - // _read calls, 'data' or 'readable' events should occur. This is needed - // since when autoDestroy is disabled we need a way to tell whether the - // stream has failed. - this.errored = null - - // Indicates whether the stream has finished destroying. - this.closed = false - - // True if close has been emitted or would have been emitted - // depending on emitClose. - this.closeEmitted = false - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = (options && options.defaultEncoding) || 'utf8' - - // Ref the piped dest which we need a drain event on it - // type: null | Writable | Set. - this.awaitDrainWriters = null - this.multiAwaitDrain = false - - // If true, a maybeReadMore has been scheduled. - this.readingMore = false - this.dataEmitted = false - this.decoder = null - this.encoding = null - if (options && options.encoding) { - this.decoder = new StringDecoder(options.encoding) - this.encoding = options.encoding - } -} -function Readable(options) { - if (!(this instanceof Readable)) return new Readable(options) - - // Checking for a Stream.Duplex instance is faster here instead of inside - // the ReadableState constructor, at least with V8 6.5. - const isDuplex = this instanceof require('./duplex') - this._readableState = new ReadableState(options, this, isDuplex) - if (options) { - if (typeof options.read === 'function') this._read = options.read - if (typeof options.destroy === 'function') this._destroy = options.destroy - if (typeof options.construct === 'function') this._construct = options.construct - if (options.signal && !isDuplex) addAbortSignal(options.signal, this) - } - Stream.call(this, options) - destroyImpl.construct(this, () => { - if (this._readableState.needReadable) { - maybeReadMore(this, this._readableState) - } - }) -} -Readable.prototype.destroy = destroyImpl.destroy -Readable.prototype._undestroy = destroyImpl.undestroy -Readable.prototype._destroy = function (err, cb) { - cb(err) -} -Readable.prototype[EE.captureRejectionSymbol] = function (err) { - this.destroy(err) -} - -// Manually shove something into the read() buffer. -// This returns true if the highWaterMark has not been hit yet, -// similar to how Writable.write() returns true if you should -// write() some more. -Readable.prototype.push = function (chunk, encoding) { - return readableAddChunk(this, chunk, encoding, false) -} - -// Unshift should *always* be something directly out of read(). -Readable.prototype.unshift = function (chunk, encoding) { - return readableAddChunk(this, chunk, encoding, true) -} -function readableAddChunk(stream, chunk, encoding, addToFront) { - debug('readableAddChunk', chunk) - const state = stream._readableState - let err - if (!state.objectMode) { - if (typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding - if (state.encoding !== encoding) { - if (addToFront && state.encoding) { - // When unshifting, if state.encoding is set, we have to save - // the string in the BufferList with the state encoding. - chunk = Buffer.from(chunk, encoding).toString(state.encoding) - } else { - chunk = Buffer.from(chunk, encoding) - encoding = '' - } - } - } else if (chunk instanceof Buffer) { - encoding = '' - } else if (Stream._isUint8Array(chunk)) { - chunk = Stream._uint8ArrayToBuffer(chunk) - encoding = '' - } else if (chunk != null) { - err = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk) - } - } - if (err) { - errorOrDestroy(stream, err) - } else if (chunk === null) { - state.reading = false - onEofChunk(stream, state) - } else if (state.objectMode || (chunk && chunk.length > 0)) { - if (addToFront) { - if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT()) - else if (state.destroyed || state.errored) return false - else addChunk(stream, state, chunk, true) - } else if (state.ended) { - errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()) - } else if (state.destroyed || state.errored) { - return false - } else { - state.reading = false - if (state.decoder && !encoding) { - chunk = state.decoder.write(chunk) - if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false) - else maybeReadMore(stream, state) - } else { - addChunk(stream, state, chunk, false) - } - } - } else if (!addToFront) { - state.reading = false - maybeReadMore(stream, state) - } - - // We can push more data if we are below the highWaterMark. - // Also, if we have no data yet, we can stand some more bytes. - // This is to work around cases where hwm=0, such as the repl. - return !state.ended && (state.length < state.highWaterMark || state.length === 0) -} -function addChunk(stream, state, chunk, addToFront) { - if (state.flowing && state.length === 0 && !state.sync && stream.listenerCount('data') > 0) { - // Use the guard to avoid creating `Set()` repeatedly - // when we have multiple pipes. - if (state.multiAwaitDrain) { - state.awaitDrainWriters.clear() - } else { - state.awaitDrainWriters = null - } - state.dataEmitted = true - stream.emit('data', chunk) - } else { - // Update the buffer info. - state.length += state.objectMode ? 1 : chunk.length - if (addToFront) state.buffer.unshift(chunk) - else state.buffer.push(chunk) - if (state.needReadable) emitReadable(stream) - } - maybeReadMore(stream, state) -} -Readable.prototype.isPaused = function () { - const state = this._readableState - return state[kPaused] === true || state.flowing === false -} - -// Backwards compatibility. -Readable.prototype.setEncoding = function (enc) { - const decoder = new StringDecoder(enc) - this._readableState.decoder = decoder - // If setEncoding(null), decoder.encoding equals utf8. - this._readableState.encoding = this._readableState.decoder.encoding - const buffer = this._readableState.buffer - // Iterate over current buffer to convert already stored Buffers: - let content = '' - for (const data of buffer) { - content += decoder.write(data) - } - buffer.clear() - if (content !== '') buffer.push(content) - this._readableState.length = content.length - return this -} - -// Don't raise the hwm > 1GB. -const MAX_HWM = 0x40000000 -function computeNewHighWaterMark(n) { - if (n > MAX_HWM) { - throw new ERR_OUT_OF_RANGE('size', '<= 1GiB', n) - } else { - // Get the next highest power of 2 to prevent increasing hwm excessively in - // tiny amounts. - n-- - n |= n >>> 1 - n |= n >>> 2 - n |= n >>> 4 - n |= n >>> 8 - n |= n >>> 16 - n++ - } - return n -} - -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function howMuchToRead(n, state) { - if (n <= 0 || (state.length === 0 && state.ended)) return 0 - if (state.objectMode) return 1 - if (NumberIsNaN(n)) { - // Only flow one buffer at a time. - if (state.flowing && state.length) return state.buffer.first().length - return state.length - } - if (n <= state.length) return n - return state.ended ? state.length : 0 -} - -// You can override either this method, or the async _read(n) below. -Readable.prototype.read = function (n) { - debug('read', n) - // Same as parseInt(undefined, 10), however V8 7.3 performance regressed - // in this scenario, so we are doing it manually. - if (n === undefined) { - n = NaN - } else if (!NumberIsInteger(n)) { - n = NumberParseInt(n, 10) - } - const state = this._readableState - const nOrig = n - - // If we're asking for more than the current hwm, then raise the hwm. - if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n) - if (n !== 0) state.emittedReadable = false - - // If we're doing read(0) to trigger a readable event, but we - // already have a bunch of data in the buffer, then just trigger - // the 'readable' event and move on. - if ( - n === 0 && - state.needReadable && - ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended) - ) { - debug('read: emitReadable', state.length, state.ended) - if (state.length === 0 && state.ended) endReadable(this) - else emitReadable(this) - return null - } - n = howMuchToRead(n, state) - - // If we've ended, and we're now clear, then finish it up. - if (n === 0 && state.ended) { - if (state.length === 0) endReadable(this) - return null - } - - // All the actual chunk generation logic needs to be - // *below* the call to _read. The reason is that in certain - // synthetic stream cases, such as passthrough streams, _read - // may be a completely synchronous operation which may change - // the state of the read buffer, providing enough data when - // before there was *not* enough. - // - // So, the steps are: - // 1. Figure out what the state of things will be after we do - // a read from the buffer. - // - // 2. If that resulting state will trigger a _read, then call _read. - // Note that this may be asynchronous, or synchronous. Yes, it is - // deeply ugly to write APIs this way, but that still doesn't mean - // that the Readable class should behave improperly, as streams are - // designed to be sync/async agnostic. - // Take note if the _read call is sync or async (ie, if the read call - // has returned yet), so that we know whether or not it's safe to emit - // 'readable' etc. - // - // 3. Actually pull the requested chunks out of the buffer and return. - - // if we need a readable event, then we need to do some reading. - let doRead = state.needReadable - debug('need readable', doRead) - - // If we currently have less than the highWaterMark, then also read some. - if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true - debug('length less than watermark', doRead) - } - - // However, if we've ended, then there's no point, if we're already - // reading, then it's unnecessary, if we're constructing we have to wait, - // and if we're destroyed or errored, then it's not allowed, - if (state.ended || state.reading || state.destroyed || state.errored || !state.constructed) { - doRead = false - debug('reading, ended or constructing', doRead) - } else if (doRead) { - debug('do read') - state.reading = true - state.sync = true - // If the length is currently zero, then we *need* a readable event. - if (state.length === 0) state.needReadable = true - - // Call internal read method - try { - this._read(state.highWaterMark) - } catch (err) { - errorOrDestroy(this, err) - } - state.sync = false - // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - if (!state.reading) n = howMuchToRead(nOrig, state) - } - let ret - if (n > 0) ret = fromList(n, state) - else ret = null - if (ret === null) { - state.needReadable = state.length <= state.highWaterMark - n = 0 - } else { - state.length -= n - if (state.multiAwaitDrain) { - state.awaitDrainWriters.clear() - } else { - state.awaitDrainWriters = null - } - } - if (state.length === 0) { - // If we have nothing in the buffer, then we want to know - // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true - - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended) endReadable(this) - } - if (ret !== null && !state.errorEmitted && !state.closeEmitted) { - state.dataEmitted = true - this.emit('data', ret) - } - return ret -} -function onEofChunk(stream, state) { - debug('onEofChunk') - if (state.ended) return - if (state.decoder) { - const chunk = state.decoder.end() - if (chunk && chunk.length) { - state.buffer.push(chunk) - state.length += state.objectMode ? 1 : chunk.length - } - } - state.ended = true - if (state.sync) { - // If we are sync, wait until next tick to emit the data. - // Otherwise we risk emitting data in the flow() - // the readable code triggers during a read() call. - emitReadable(stream) - } else { - // Emit 'readable' now to make sure it gets picked up. - state.needReadable = false - state.emittedReadable = true - // We have to emit readable now that we are EOF. Modules - // in the ecosystem (e.g. dicer) rely on this event being sync. - emitReadable_(stream) - } -} - -// Don't emit readable right away in sync mode, because this can trigger -// another read() call => stack overflow. This way, it might trigger -// a nextTick recursion warning, but that's not so bad. -function emitReadable(stream) { - const state = stream._readableState - debug('emitReadable', state.needReadable, state.emittedReadable) - state.needReadable = false - if (!state.emittedReadable) { - debug('emitReadable', state.flowing) - state.emittedReadable = true - process.nextTick(emitReadable_, stream) - } -} -function emitReadable_(stream) { - const state = stream._readableState - debug('emitReadable_', state.destroyed, state.length, state.ended) - if (!state.destroyed && !state.errored && (state.length || state.ended)) { - stream.emit('readable') - state.emittedReadable = false - } - - // The stream needs another readable event if: - // 1. It is not flowing, as the flow mechanism will take - // care of it. - // 2. It is not ended. - // 3. It is below the highWaterMark, so we can schedule - // another readable later. - state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark - flow(stream) -} - -// At this point, the user has presumably seen the 'readable' event, -// and called read() to consume some data. that may have triggered -// in turn another _read(n) call, in which case reading = true if -// it's in progress. -// However, if we're not ended, or reading, and the length < hwm, -// then go ahead and try to read some more preemptively. -function maybeReadMore(stream, state) { - if (!state.readingMore && state.constructed) { - state.readingMore = true - process.nextTick(maybeReadMore_, stream, state) - } -} -function maybeReadMore_(stream, state) { - // Attempt to read more data if we should. - // - // The conditions for reading more data are (one of): - // - Not enough data buffered (state.length < state.highWaterMark). The loop - // is responsible for filling the buffer with enough data if such data - // is available. If highWaterMark is 0 and we are not in the flowing mode - // we should _not_ attempt to buffer any extra data. We'll get more data - // when the stream consumer calls read() instead. - // - No data in the buffer, and the stream is in flowing mode. In this mode - // the loop below is responsible for ensuring read() is called. Failing to - // call read here would abort the flow and there's no other mechanism for - // continuing the flow if the stream consumer has just subscribed to the - // 'data' event. - // - // In addition to the above conditions to keep reading data, the following - // conditions prevent the data from being read: - // - The stream has ended (state.ended). - // - There is already a pending 'read' operation (state.reading). This is a - // case where the stream has called the implementation defined _read() - // method, but they are processing the call asynchronously and have _not_ - // called push() with new data. In this case we skip performing more - // read()s. The execution ends in this method again after the _read() ends - // up calling push() with more data. - while ( - !state.reading && - !state.ended && - (state.length < state.highWaterMark || (state.flowing && state.length === 0)) - ) { - const len = state.length - debug('maybeReadMore read 0') - stream.read(0) - if (len === state.length) - // Didn't get any data, stop spinning. - break - } - state.readingMore = false -} - -// Abstract method. to be overridden in specific implementation classes. -// call cb(er, data) where data is <= n in length. -// for virtual (non-string, non-buffer) streams, "length" is somewhat -// arbitrary, and perhaps not very meaningful. -Readable.prototype._read = function (n) { - throw new ERR_METHOD_NOT_IMPLEMENTED('_read()') -} -Readable.prototype.pipe = function (dest, pipeOpts) { - const src = this - const state = this._readableState - if (state.pipes.length === 1) { - if (!state.multiAwaitDrain) { - state.multiAwaitDrain = true - state.awaitDrainWriters = new SafeSet(state.awaitDrainWriters ? [state.awaitDrainWriters] : []) - } - } - state.pipes.push(dest) - debug('pipe count=%d opts=%j', state.pipes.length, pipeOpts) - const doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr - const endFn = doEnd ? onend : unpipe - if (state.endEmitted) process.nextTick(endFn) - else src.once('end', endFn) - dest.on('unpipe', onunpipe) - function onunpipe(readable, unpipeInfo) { - debug('onunpipe') - if (readable === src) { - if (unpipeInfo && unpipeInfo.hasUnpiped === false) { - unpipeInfo.hasUnpiped = true - cleanup() - } - } - } - function onend() { - debug('onend') - dest.end() - } - let ondrain - let cleanedUp = false - function cleanup() { - debug('cleanup') - // Cleanup event handlers once the pipe is broken. - dest.removeListener('close', onclose) - dest.removeListener('finish', onfinish) - if (ondrain) { - dest.removeListener('drain', ondrain) - } - dest.removeListener('error', onerror) - dest.removeListener('unpipe', onunpipe) - src.removeListener('end', onend) - src.removeListener('end', unpipe) - src.removeListener('data', ondata) - cleanedUp = true - - // If the reader is waiting for a drain event from this - // specific writer, then it would cause it to never start - // flowing again. - // So, if this is awaiting a drain, then we just call it now. - // If we don't know, then assume that we are waiting for one. - if (ondrain && state.awaitDrainWriters && (!dest._writableState || dest._writableState.needDrain)) ondrain() - } - function pause() { - // If the user unpiped during `dest.write()`, it is possible - // to get stuck in a permanently paused state if that write - // also returned false. - // => Check whether `dest` is still a piping destination. - if (!cleanedUp) { - if (state.pipes.length === 1 && state.pipes[0] === dest) { - debug('false write response, pause', 0) - state.awaitDrainWriters = dest - state.multiAwaitDrain = false - } else if (state.pipes.length > 1 && state.pipes.includes(dest)) { - debug('false write response, pause', state.awaitDrainWriters.size) - state.awaitDrainWriters.add(dest) - } - src.pause() - } - if (!ondrain) { - // When the dest drains, it reduces the awaitDrain counter - // on the source. This would be more elegant with a .once() - // handler in flow(), but adding and removing repeatedly is - // too slow. - ondrain = pipeOnDrain(src, dest) - dest.on('drain', ondrain) - } - } - src.on('data', ondata) - function ondata(chunk) { - debug('ondata') - const ret = dest.write(chunk) - debug('dest.write', ret) - if (ret === false) { - pause() - } - } - - // If the dest has an error, then stop piping into it. - // However, don't suppress the throwing behavior for this. - function onerror(er) { - debug('onerror', er) - unpipe() - dest.removeListener('error', onerror) - if (dest.listenerCount('error') === 0) { - const s = dest._writableState || dest._readableState - if (s && !s.errorEmitted) { - // User incorrectly emitted 'error' directly on the stream. - errorOrDestroy(dest, er) - } else { - dest.emit('error', er) - } - } - } - - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror) - - // Both close and finish should trigger unpipe, but only once. - function onclose() { - dest.removeListener('finish', onfinish) - unpipe() - } - dest.once('close', onclose) - function onfinish() { - debug('onfinish') - dest.removeListener('close', onclose) - unpipe() - } - dest.once('finish', onfinish) - function unpipe() { - debug('unpipe') - src.unpipe(dest) - } - - // Tell the dest that it's being piped to. - dest.emit('pipe', src) - - // Start the flow if it hasn't been started already. - - if (dest.writableNeedDrain === true) { - if (state.flowing) { - pause() - } - } else if (!state.flowing) { - debug('pipe resume') - src.resume() - } - return dest -} -function pipeOnDrain(src, dest) { - return function pipeOnDrainFunctionResult() { - const state = src._readableState - - // `ondrain` will call directly, - // `this` maybe not a reference to dest, - // so we use the real dest here. - if (state.awaitDrainWriters === dest) { - debug('pipeOnDrain', 1) - state.awaitDrainWriters = null - } else if (state.multiAwaitDrain) { - debug('pipeOnDrain', state.awaitDrainWriters.size) - state.awaitDrainWriters.delete(dest) - } - if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) && src.listenerCount('data')) { - src.resume() - } - } -} -Readable.prototype.unpipe = function (dest) { - const state = this._readableState - const unpipeInfo = { - hasUnpiped: false - } - - // If we're not piping anywhere, then do nothing. - if (state.pipes.length === 0) return this - if (!dest) { - // remove all. - const dests = state.pipes - state.pipes = [] - this.pause() - for (let i = 0; i < dests.length; i++) - dests[i].emit('unpipe', this, { - hasUnpiped: false - }) - return this - } - - // Try to find the right one. - const index = ArrayPrototypeIndexOf(state.pipes, dest) - if (index === -1) return this - state.pipes.splice(index, 1) - if (state.pipes.length === 0) this.pause() - dest.emit('unpipe', this, unpipeInfo) - return this -} - -// Set up data events if they are asked for -// Ensure readable listeners eventually get something. -Readable.prototype.on = function (ev, fn) { - const res = Stream.prototype.on.call(this, ev, fn) - const state = this._readableState - if (ev === 'data') { - // Update readableListening so that resume() may be a no-op - // a few lines down. This is needed to support once('readable'). - state.readableListening = this.listenerCount('readable') > 0 - - // Try start flowing on next tick if stream isn't explicitly paused. - if (state.flowing !== false) this.resume() - } else if (ev === 'readable') { - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true - state.flowing = false - state.emittedReadable = false - debug('on readable', state.length, state.reading) - if (state.length) { - emitReadable(this) - } else if (!state.reading) { - process.nextTick(nReadingNextTick, this) - } - } - } - return res -} -Readable.prototype.addListener = Readable.prototype.on -Readable.prototype.removeListener = function (ev, fn) { - const res = Stream.prototype.removeListener.call(this, ev, fn) - if (ev === 'readable') { - // We need to check if there is someone still listening to - // readable and reset the state. However this needs to happen - // after readable has been emitted but before I/O (nextTick) to - // support once('readable', fn) cycles. This means that calling - // resume within the same tick will have no - // effect. - process.nextTick(updateReadableListening, this) - } - return res -} -Readable.prototype.off = Readable.prototype.removeListener -Readable.prototype.removeAllListeners = function (ev) { - const res = Stream.prototype.removeAllListeners.apply(this, arguments) - if (ev === 'readable' || ev === undefined) { - // We need to check if there is someone still listening to - // readable and reset the state. However this needs to happen - // after readable has been emitted but before I/O (nextTick) to - // support once('readable', fn) cycles. This means that calling - // resume within the same tick will have no - // effect. - process.nextTick(updateReadableListening, this) - } - return res -} -function updateReadableListening(self) { - const state = self._readableState - state.readableListening = self.listenerCount('readable') > 0 - if (state.resumeScheduled && state[kPaused] === false) { - // Flowing needs to be set to true now, otherwise - // the upcoming resume will not flow. - state.flowing = true - - // Crude way to check if we should resume. - } else if (self.listenerCount('data') > 0) { - self.resume() - } else if (!state.readableListening) { - state.flowing = null - } -} -function nReadingNextTick(self) { - debug('readable nexttick read 0') - self.read(0) -} - -// pause() and resume() are remnants of the legacy readable stream API -// If the user uses them, then switch into old mode. -Readable.prototype.resume = function () { - const state = this._readableState - if (!state.flowing) { - debug('resume') - // We flow only if there is no one listening - // for readable, but we still have to call - // resume(). - state.flowing = !state.readableListening - resume(this, state) - } - state[kPaused] = false - return this -} -function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true - process.nextTick(resume_, stream, state) - } -} -function resume_(stream, state) { - debug('resume', state.reading) - if (!state.reading) { - stream.read(0) - } - state.resumeScheduled = false - stream.emit('resume') - flow(stream) - if (state.flowing && !state.reading) stream.read(0) -} -Readable.prototype.pause = function () { - debug('call pause flowing=%j', this._readableState.flowing) - if (this._readableState.flowing !== false) { - debug('pause') - this._readableState.flowing = false - this.emit('pause') - } - this._readableState[kPaused] = true - return this -} -function flow(stream) { - const state = stream._readableState - debug('flow', state.flowing) - while (state.flowing && stream.read() !== null); -} - -// Wrap an old-style stream as the async data source. -// This is *not* part of the readable stream interface. -// It is an ugly unfortunate mess of history. -Readable.prototype.wrap = function (stream) { - let paused = false - - // TODO (ronag): Should this.destroy(err) emit - // 'error' on the wrapped stream? Would require - // a static factory method, e.g. Readable.wrap(stream). - - stream.on('data', (chunk) => { - if (!this.push(chunk) && stream.pause) { - paused = true - stream.pause() - } - }) - stream.on('end', () => { - this.push(null) - }) - stream.on('error', (err) => { - errorOrDestroy(this, err) - }) - stream.on('close', () => { - this.destroy() - }) - stream.on('destroy', () => { - this.destroy() - }) - this._read = () => { - if (paused && stream.resume) { - paused = false - stream.resume() - } - } - - // Proxy all the other methods. Important when wrapping filters and duplexes. - const streamKeys = ObjectKeys(stream) - for (let j = 1; j < streamKeys.length; j++) { - const i = streamKeys[j] - if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = stream[i].bind(stream) - } - } - return this -} -Readable.prototype[SymbolAsyncIterator] = function () { - return streamToAsyncIterator(this) -} -Readable.prototype.iterator = function (options) { - if (options !== undefined) { - validateObject(options, 'options') - } - return streamToAsyncIterator(this, options) -} -function streamToAsyncIterator(stream, options) { - if (typeof stream.read !== 'function') { - stream = Readable.wrap(stream, { - objectMode: true - }) - } - const iter = createAsyncIterator(stream, options) - iter.stream = stream - return iter -} -async function* createAsyncIterator(stream, options) { - let callback = nop - function next(resolve) { - if (this === stream) { - callback() - callback = nop - } else { - callback = resolve - } - } - stream.on('readable', next) - let error - const cleanup = eos( - stream, - { - writable: false - }, - (err) => { - error = err ? aggregateTwoErrors(error, err) : null - callback() - callback = nop - } - ) - try { - while (true) { - const chunk = stream.destroyed ? null : stream.read() - if (chunk !== null) { - yield chunk - } else if (error) { - throw error - } else if (error === null) { - return - } else { - await new Promise(next) - } - } - } catch (err) { - error = aggregateTwoErrors(error, err) - throw error - } finally { - if ( - (error || (options === null || options === undefined ? undefined : options.destroyOnReturn) !== false) && - (error === undefined || stream._readableState.autoDestroy) - ) { - destroyImpl.destroyer(stream, null) - } else { - stream.off('readable', next) - cleanup() - } - } -} - -// Making it explicit these properties are not enumerable -// because otherwise some prototype manipulation in -// userland will fail. -ObjectDefineProperties(Readable.prototype, { - readable: { - __proto__: null, - get() { - const r = this._readableState - // r.readable === false means that this is part of a Duplex stream - // where the readable side was disabled upon construction. - // Compat. The user might manually disable readable side through - // deprecated setter. - return !!r && r.readable !== false && !r.destroyed && !r.errorEmitted && !r.endEmitted - }, - set(val) { - // Backwards compat. - if (this._readableState) { - this._readableState.readable = !!val - } - } - }, - readableDidRead: { - __proto__: null, - enumerable: false, - get: function () { - return this._readableState.dataEmitted - } - }, - readableAborted: { - __proto__: null, - enumerable: false, - get: function () { - return !!( - this._readableState.readable !== false && - (this._readableState.destroyed || this._readableState.errored) && - !this._readableState.endEmitted - ) - } - }, - readableHighWaterMark: { - __proto__: null, - enumerable: false, - get: function () { - return this._readableState.highWaterMark - } - }, - readableBuffer: { - __proto__: null, - enumerable: false, - get: function () { - return this._readableState && this._readableState.buffer - } - }, - readableFlowing: { - __proto__: null, - enumerable: false, - get: function () { - return this._readableState.flowing - }, - set: function (state) { - if (this._readableState) { - this._readableState.flowing = state - } - } - }, - readableLength: { - __proto__: null, - enumerable: false, - get() { - return this._readableState.length - } - }, - readableObjectMode: { - __proto__: null, - enumerable: false, - get() { - return this._readableState ? this._readableState.objectMode : false - } - }, - readableEncoding: { - __proto__: null, - enumerable: false, - get() { - return this._readableState ? this._readableState.encoding : null - } - }, - errored: { - __proto__: null, - enumerable: false, - get() { - return this._readableState ? this._readableState.errored : null - } - }, - closed: { - __proto__: null, - get() { - return this._readableState ? this._readableState.closed : false - } - }, - destroyed: { - __proto__: null, - enumerable: false, - get() { - return this._readableState ? this._readableState.destroyed : false - }, - set(value) { - // We ignore the value if the stream - // has not been initialized yet. - if (!this._readableState) { - return - } - - // Backward compatibility, the user is explicitly - // managing destroyed. - this._readableState.destroyed = value - } - }, - readableEnded: { - __proto__: null, - enumerable: false, - get() { - return this._readableState ? this._readableState.endEmitted : false - } - } -}) -ObjectDefineProperties(ReadableState.prototype, { - // Legacy getter for `pipesCount`. - pipesCount: { - __proto__: null, - get() { - return this.pipes.length - } - }, - // Legacy property for `paused`. - paused: { - __proto__: null, - get() { - return this[kPaused] !== false - }, - set(value) { - this[kPaused] = !!value - } - } -}) - -// Exposed for testing purposes only. -Readable._fromList = fromList - -// Pluck off n bytes from an array of buffers. -// Length is the combined lengths of all the buffers in the list. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromList(n, state) { - // nothing buffered. - if (state.length === 0) return null - let ret - if (state.objectMode) ret = state.buffer.shift() - else if (!n || n >= state.length) { - // Read it all, truncate the list. - if (state.decoder) ret = state.buffer.join('') - else if (state.buffer.length === 1) ret = state.buffer.first() - else ret = state.buffer.concat(state.length) - state.buffer.clear() - } else { - // read part of list. - ret = state.buffer.consume(n, state.decoder) - } - return ret -} -function endReadable(stream) { - const state = stream._readableState - debug('endReadable', state.endEmitted) - if (!state.endEmitted) { - state.ended = true - process.nextTick(endReadableNT, state, stream) - } -} -function endReadableNT(state, stream) { - debug('endReadableNT', state.endEmitted, state.length) - - // Check that we didn't get one last unshift. - if (!state.errored && !state.closeEmitted && !state.endEmitted && state.length === 0) { - state.endEmitted = true - stream.emit('end') - if (stream.writable && stream.allowHalfOpen === false) { - process.nextTick(endWritableNT, stream) - } else if (state.autoDestroy) { - // In case of duplex streams we need a way to detect - // if the writable side is ready for autoDestroy as well. - const wState = stream._writableState - const autoDestroy = - !wState || - (wState.autoDestroy && - // We don't expect the writable to ever 'finish' - // if writable is explicitly set to false. - (wState.finished || wState.writable === false)) - if (autoDestroy) { - stream.destroy() - } - } - } -} -function endWritableNT(stream) { - const writable = stream.writable && !stream.writableEnded && !stream.destroyed - if (writable) { - stream.end() - } -} -Readable.from = function (iterable, opts) { - return from(Readable, iterable, opts) -} -let webStreamsAdapters - -// Lazy to avoid circular references -function lazyWebStreams() { - if (webStreamsAdapters === undefined) webStreamsAdapters = {} - return webStreamsAdapters -} -Readable.fromWeb = function (readableStream, options) { - return lazyWebStreams().newStreamReadableFromReadableStream(readableStream, options) -} -Readable.toWeb = function (streamReadable, options) { - return lazyWebStreams().newReadableStreamFromStreamReadable(streamReadable, options) -} -Readable.wrap = function (src, options) { - var _ref, _src$readableObjectMo - return new Readable({ - objectMode: - (_ref = - (_src$readableObjectMo = src.readableObjectMode) !== null && _src$readableObjectMo !== undefined - ? _src$readableObjectMo - : src.objectMode) !== null && _ref !== undefined - ? _ref - : true, - ...options, - destroy(err, callback) { - destroyImpl.destroyer(src, err) - callback(err) - } - }).wrap(src) -} diff --git a/node_modules/readable-stream/lib/internal/streams/state.js b/node_modules/readable-stream/lib/internal/streams/state.js deleted file mode 100644 index 18c2d845ff018..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/state.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict' - -const { MathFloor, NumberIsInteger } = require('../../ours/primordials') -const { ERR_INVALID_ARG_VALUE } = require('../../ours/errors').codes -function highWaterMarkFrom(options, isDuplex, duplexKey) { - return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null -} -function getDefaultHighWaterMark(objectMode) { - return objectMode ? 16 : 16 * 1024 -} -function getHighWaterMark(state, options, duplexKey, isDuplex) { - const hwm = highWaterMarkFrom(options, isDuplex, duplexKey) - if (hwm != null) { - if (!NumberIsInteger(hwm) || hwm < 0) { - const name = isDuplex ? `options.${duplexKey}` : 'options.highWaterMark' - throw new ERR_INVALID_ARG_VALUE(name, hwm) - } - return MathFloor(hwm) - } - - // Default value - return getDefaultHighWaterMark(state.objectMode) -} -module.exports = { - getHighWaterMark, - getDefaultHighWaterMark -} diff --git a/node_modules/readable-stream/lib/internal/streams/transform.js b/node_modules/readable-stream/lib/internal/streams/transform.js deleted file mode 100644 index fa9413a447463..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/transform.js +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// a transform stream is a readable/writable stream where you do -// something with the data. Sometimes it's called a "filter", -// but that's not a great name for it, since that implies a thing where -// some bits pass through, and others are simply ignored. (That would -// be a valid example of a transform, of course.) -// -// While the output is causally related to the input, it's not a -// necessarily symmetric or synchronous transformation. For example, -// a zlib stream might take multiple plain-text writes(), and then -// emit a single compressed chunk some time in the future. -// -// Here's how this works: -// -// The Transform stream has all the aspects of the readable and writable -// stream classes. When you write(chunk), that calls _write(chunk,cb) -// internally, and returns false if there's a lot of pending writes -// buffered up. When you call read(), that calls _read(n) until -// there's enough pending readable data buffered up. -// -// In a transform stream, the written data is placed in a buffer. When -// _read(n) is called, it transforms the queued up data, calling the -// buffered _write cb's as it consumes chunks. If consuming a single -// written chunk would result in multiple output chunks, then the first -// outputted bit calls the readcb, and subsequent chunks just go into -// the read buffer, and will cause it to emit 'readable' if necessary. -// -// This way, back-pressure is actually determined by the reading side, -// since _read has to be called to start processing a new chunk. However, -// a pathological inflate type of transform can cause excessive buffering -// here. For example, imagine a stream where every byte of input is -// interpreted as an integer from 0-255, and then results in that many -// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in -// 1kb of data being output. In this case, you could write a very small -// amount of input, and end up with a very large amount of output. In -// such a pathological inflating mechanism, there'd be no way to tell -// the system to stop doing the transform. A single 4MB write could -// cause the system to run out of memory. -// -// However, even in such a pathological case, only a single written chunk -// would be consumed, and then the rest would wait (un-transformed) until -// the results of the previous transformed chunk were consumed. - -'use strict' - -const { ObjectSetPrototypeOf, Symbol } = require('../../ours/primordials') -module.exports = Transform -const { ERR_METHOD_NOT_IMPLEMENTED } = require('../../ours/errors').codes -const Duplex = require('./duplex') -const { getHighWaterMark } = require('./state') -ObjectSetPrototypeOf(Transform.prototype, Duplex.prototype) -ObjectSetPrototypeOf(Transform, Duplex) -const kCallback = Symbol('kCallback') -function Transform(options) { - if (!(this instanceof Transform)) return new Transform(options) - - // TODO (ronag): This should preferably always be - // applied but would be semver-major. Or even better; - // make Transform a Readable with the Writable interface. - const readableHighWaterMark = options ? getHighWaterMark(this, options, 'readableHighWaterMark', true) : null - if (readableHighWaterMark === 0) { - // A Duplex will buffer both on the writable and readable side while - // a Transform just wants to buffer hwm number of elements. To avoid - // buffering twice we disable buffering on the writable side. - options = { - ...options, - highWaterMark: null, - readableHighWaterMark, - // TODO (ronag): 0 is not optimal since we have - // a "bug" where we check needDrain before calling _write and not after. - // Refs: https://github.com/nodejs/node/pull/32887 - // Refs: https://github.com/nodejs/node/pull/35941 - writableHighWaterMark: options.writableHighWaterMark || 0 - } - } - Duplex.call(this, options) - - // We have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - this._readableState.sync = false - this[kCallback] = null - if (options) { - if (typeof options.transform === 'function') this._transform = options.transform - if (typeof options.flush === 'function') this._flush = options.flush - } - - // When the writable side finishes, then flush out anything remaining. - // Backwards compat. Some Transform streams incorrectly implement _final - // instead of or in addition to _flush. By using 'prefinish' instead of - // implementing _final we continue supporting this unfortunate use case. - this.on('prefinish', prefinish) -} -function final(cb) { - if (typeof this._flush === 'function' && !this.destroyed) { - this._flush((er, data) => { - if (er) { - if (cb) { - cb(er) - } else { - this.destroy(er) - } - return - } - if (data != null) { - this.push(data) - } - this.push(null) - if (cb) { - cb() - } - }) - } else { - this.push(null) - if (cb) { - cb() - } - } -} -function prefinish() { - if (this._final !== final) { - final.call(this) - } -} -Transform.prototype._final = final -Transform.prototype._transform = function (chunk, encoding, callback) { - throw new ERR_METHOD_NOT_IMPLEMENTED('_transform()') -} -Transform.prototype._write = function (chunk, encoding, callback) { - const rState = this._readableState - const wState = this._writableState - const length = rState.length - this._transform(chunk, encoding, (err, val) => { - if (err) { - callback(err) - return - } - if (val != null) { - this.push(val) - } - if ( - wState.ended || - // Backwards compat. - length === rState.length || - // Backwards compat. - rState.length < rState.highWaterMark - ) { - callback() - } else { - this[kCallback] = callback - } - }) -} -Transform.prototype._read = function () { - if (this[kCallback]) { - const callback = this[kCallback] - this[kCallback] = null - callback() - } -} diff --git a/node_modules/readable-stream/lib/internal/streams/utils.js b/node_modules/readable-stream/lib/internal/streams/utils.js deleted file mode 100644 index e589ad96c6924..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/utils.js +++ /dev/null @@ -1,321 +0,0 @@ -'use strict' - -const { Symbol, SymbolAsyncIterator, SymbolIterator, SymbolFor } = require('../../ours/primordials') -const kDestroyed = Symbol('kDestroyed') -const kIsErrored = Symbol('kIsErrored') -const kIsReadable = Symbol('kIsReadable') -const kIsDisturbed = Symbol('kIsDisturbed') -const kIsClosedPromise = SymbolFor('nodejs.webstream.isClosedPromise') -const kControllerErrorFunction = SymbolFor('nodejs.webstream.controllerErrorFunction') -function isReadableNodeStream(obj, strict = false) { - var _obj$_readableState - return !!( - ( - obj && - typeof obj.pipe === 'function' && - typeof obj.on === 'function' && - (!strict || (typeof obj.pause === 'function' && typeof obj.resume === 'function')) && - (!obj._writableState || - ((_obj$_readableState = obj._readableState) === null || _obj$_readableState === undefined - ? undefined - : _obj$_readableState.readable) !== false) && - // Duplex - (!obj._writableState || obj._readableState) - ) // Writable has .pipe. - ) -} - -function isWritableNodeStream(obj) { - var _obj$_writableState - return !!( - ( - obj && - typeof obj.write === 'function' && - typeof obj.on === 'function' && - (!obj._readableState || - ((_obj$_writableState = obj._writableState) === null || _obj$_writableState === undefined - ? undefined - : _obj$_writableState.writable) !== false) - ) // Duplex - ) -} - -function isDuplexNodeStream(obj) { - return !!( - obj && - typeof obj.pipe === 'function' && - obj._readableState && - typeof obj.on === 'function' && - typeof obj.write === 'function' - ) -} -function isNodeStream(obj) { - return ( - obj && - (obj._readableState || - obj._writableState || - (typeof obj.write === 'function' && typeof obj.on === 'function') || - (typeof obj.pipe === 'function' && typeof obj.on === 'function')) - ) -} -function isReadableStream(obj) { - return !!( - obj && - !isNodeStream(obj) && - typeof obj.pipeThrough === 'function' && - typeof obj.getReader === 'function' && - typeof obj.cancel === 'function' - ) -} -function isWritableStream(obj) { - return !!(obj && !isNodeStream(obj) && typeof obj.getWriter === 'function' && typeof obj.abort === 'function') -} -function isTransformStream(obj) { - return !!(obj && !isNodeStream(obj) && typeof obj.readable === 'object' && typeof obj.writable === 'object') -} -function isWebStream(obj) { - return isReadableStream(obj) || isWritableStream(obj) || isTransformStream(obj) -} -function isIterable(obj, isAsync) { - if (obj == null) return false - if (isAsync === true) return typeof obj[SymbolAsyncIterator] === 'function' - if (isAsync === false) return typeof obj[SymbolIterator] === 'function' - return typeof obj[SymbolAsyncIterator] === 'function' || typeof obj[SymbolIterator] === 'function' -} -function isDestroyed(stream) { - if (!isNodeStream(stream)) return null - const wState = stream._writableState - const rState = stream._readableState - const state = wState || rState - return !!(stream.destroyed || stream[kDestroyed] || (state !== null && state !== undefined && state.destroyed)) -} - -// Have been end():d. -function isWritableEnded(stream) { - if (!isWritableNodeStream(stream)) return null - if (stream.writableEnded === true) return true - const wState = stream._writableState - if (wState !== null && wState !== undefined && wState.errored) return false - if (typeof (wState === null || wState === undefined ? undefined : wState.ended) !== 'boolean') return null - return wState.ended -} - -// Have emitted 'finish'. -function isWritableFinished(stream, strict) { - if (!isWritableNodeStream(stream)) return null - if (stream.writableFinished === true) return true - const wState = stream._writableState - if (wState !== null && wState !== undefined && wState.errored) return false - if (typeof (wState === null || wState === undefined ? undefined : wState.finished) !== 'boolean') return null - return !!(wState.finished || (strict === false && wState.ended === true && wState.length === 0)) -} - -// Have been push(null):d. -function isReadableEnded(stream) { - if (!isReadableNodeStream(stream)) return null - if (stream.readableEnded === true) return true - const rState = stream._readableState - if (!rState || rState.errored) return false - if (typeof (rState === null || rState === undefined ? undefined : rState.ended) !== 'boolean') return null - return rState.ended -} - -// Have emitted 'end'. -function isReadableFinished(stream, strict) { - if (!isReadableNodeStream(stream)) return null - const rState = stream._readableState - if (rState !== null && rState !== undefined && rState.errored) return false - if (typeof (rState === null || rState === undefined ? undefined : rState.endEmitted) !== 'boolean') return null - return !!(rState.endEmitted || (strict === false && rState.ended === true && rState.length === 0)) -} -function isReadable(stream) { - if (stream && stream[kIsReadable] != null) return stream[kIsReadable] - if (typeof (stream === null || stream === undefined ? undefined : stream.readable) !== 'boolean') return null - if (isDestroyed(stream)) return false - return isReadableNodeStream(stream) && stream.readable && !isReadableFinished(stream) -} -function isWritable(stream) { - if (typeof (stream === null || stream === undefined ? undefined : stream.writable) !== 'boolean') return null - if (isDestroyed(stream)) return false - return isWritableNodeStream(stream) && stream.writable && !isWritableEnded(stream) -} -function isFinished(stream, opts) { - if (!isNodeStream(stream)) { - return null - } - if (isDestroyed(stream)) { - return true - } - if ((opts === null || opts === undefined ? undefined : opts.readable) !== false && isReadable(stream)) { - return false - } - if ((opts === null || opts === undefined ? undefined : opts.writable) !== false && isWritable(stream)) { - return false - } - return true -} -function isWritableErrored(stream) { - var _stream$_writableStat, _stream$_writableStat2 - if (!isNodeStream(stream)) { - return null - } - if (stream.writableErrored) { - return stream.writableErrored - } - return (_stream$_writableStat = - (_stream$_writableStat2 = stream._writableState) === null || _stream$_writableStat2 === undefined - ? undefined - : _stream$_writableStat2.errored) !== null && _stream$_writableStat !== undefined - ? _stream$_writableStat - : null -} -function isReadableErrored(stream) { - var _stream$_readableStat, _stream$_readableStat2 - if (!isNodeStream(stream)) { - return null - } - if (stream.readableErrored) { - return stream.readableErrored - } - return (_stream$_readableStat = - (_stream$_readableStat2 = stream._readableState) === null || _stream$_readableStat2 === undefined - ? undefined - : _stream$_readableStat2.errored) !== null && _stream$_readableStat !== undefined - ? _stream$_readableStat - : null -} -function isClosed(stream) { - if (!isNodeStream(stream)) { - return null - } - if (typeof stream.closed === 'boolean') { - return stream.closed - } - const wState = stream._writableState - const rState = stream._readableState - if ( - typeof (wState === null || wState === undefined ? undefined : wState.closed) === 'boolean' || - typeof (rState === null || rState === undefined ? undefined : rState.closed) === 'boolean' - ) { - return ( - (wState === null || wState === undefined ? undefined : wState.closed) || - (rState === null || rState === undefined ? undefined : rState.closed) - ) - } - if (typeof stream._closed === 'boolean' && isOutgoingMessage(stream)) { - return stream._closed - } - return null -} -function isOutgoingMessage(stream) { - return ( - typeof stream._closed === 'boolean' && - typeof stream._defaultKeepAlive === 'boolean' && - typeof stream._removedConnection === 'boolean' && - typeof stream._removedContLen === 'boolean' - ) -} -function isServerResponse(stream) { - return typeof stream._sent100 === 'boolean' && isOutgoingMessage(stream) -} -function isServerRequest(stream) { - var _stream$req - return ( - typeof stream._consuming === 'boolean' && - typeof stream._dumped === 'boolean' && - ((_stream$req = stream.req) === null || _stream$req === undefined ? undefined : _stream$req.upgradeOrConnect) === - undefined - ) -} -function willEmitClose(stream) { - if (!isNodeStream(stream)) return null - const wState = stream._writableState - const rState = stream._readableState - const state = wState || rState - return ( - (!state && isServerResponse(stream)) || !!(state && state.autoDestroy && state.emitClose && state.closed === false) - ) -} -function isDisturbed(stream) { - var _stream$kIsDisturbed - return !!( - stream && - ((_stream$kIsDisturbed = stream[kIsDisturbed]) !== null && _stream$kIsDisturbed !== undefined - ? _stream$kIsDisturbed - : stream.readableDidRead || stream.readableAborted) - ) -} -function isErrored(stream) { - var _ref, - _ref2, - _ref3, - _ref4, - _ref5, - _stream$kIsErrored, - _stream$_readableStat3, - _stream$_writableStat3, - _stream$_readableStat4, - _stream$_writableStat4 - return !!( - stream && - ((_ref = - (_ref2 = - (_ref3 = - (_ref4 = - (_ref5 = - (_stream$kIsErrored = stream[kIsErrored]) !== null && _stream$kIsErrored !== undefined - ? _stream$kIsErrored - : stream.readableErrored) !== null && _ref5 !== undefined - ? _ref5 - : stream.writableErrored) !== null && _ref4 !== undefined - ? _ref4 - : (_stream$_readableStat3 = stream._readableState) === null || _stream$_readableStat3 === undefined - ? undefined - : _stream$_readableStat3.errorEmitted) !== null && _ref3 !== undefined - ? _ref3 - : (_stream$_writableStat3 = stream._writableState) === null || _stream$_writableStat3 === undefined - ? undefined - : _stream$_writableStat3.errorEmitted) !== null && _ref2 !== undefined - ? _ref2 - : (_stream$_readableStat4 = stream._readableState) === null || _stream$_readableStat4 === undefined - ? undefined - : _stream$_readableStat4.errored) !== null && _ref !== undefined - ? _ref - : (_stream$_writableStat4 = stream._writableState) === null || _stream$_writableStat4 === undefined - ? undefined - : _stream$_writableStat4.errored) - ) -} -module.exports = { - kDestroyed, - isDisturbed, - kIsDisturbed, - isErrored, - kIsErrored, - isReadable, - kIsReadable, - kIsClosedPromise, - kControllerErrorFunction, - isClosed, - isDestroyed, - isDuplexNodeStream, - isFinished, - isIterable, - isReadableNodeStream, - isReadableStream, - isReadableEnded, - isReadableFinished, - isReadableErrored, - isNodeStream, - isWebStream, - isWritable, - isWritableNodeStream, - isWritableStream, - isWritableEnded, - isWritableFinished, - isWritableErrored, - isServerRequest, - isServerResponse, - willEmitClose, - isTransformStream -} diff --git a/node_modules/readable-stream/lib/internal/streams/writable.js b/node_modules/readable-stream/lib/internal/streams/writable.js deleted file mode 100644 index 8a28003465766..0000000000000 --- a/node_modules/readable-stream/lib/internal/streams/writable.js +++ /dev/null @@ -1,817 +0,0 @@ -/* replacement start */ - -const process = require('process/') - -/* replacement end */ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// A bit simpler than readable streams. -// Implement an async ._write(chunk, encoding, cb), and it'll handle all -// the drain event emission and buffering. - -;('use strict') -const { - ArrayPrototypeSlice, - Error, - FunctionPrototypeSymbolHasInstance, - ObjectDefineProperty, - ObjectDefineProperties, - ObjectSetPrototypeOf, - StringPrototypeToLowerCase, - Symbol, - SymbolHasInstance -} = require('../../ours/primordials') -module.exports = Writable -Writable.WritableState = WritableState -const { EventEmitter: EE } = require('events') -const Stream = require('./legacy').Stream -const { Buffer } = require('buffer') -const destroyImpl = require('./destroy') -const { addAbortSignal } = require('./add-abort-signal') -const { getHighWaterMark, getDefaultHighWaterMark } = require('./state') -const { - ERR_INVALID_ARG_TYPE, - ERR_METHOD_NOT_IMPLEMENTED, - ERR_MULTIPLE_CALLBACK, - ERR_STREAM_CANNOT_PIPE, - ERR_STREAM_DESTROYED, - ERR_STREAM_ALREADY_FINISHED, - ERR_STREAM_NULL_VALUES, - ERR_STREAM_WRITE_AFTER_END, - ERR_UNKNOWN_ENCODING -} = require('../../ours/errors').codes -const { errorOrDestroy } = destroyImpl -ObjectSetPrototypeOf(Writable.prototype, Stream.prototype) -ObjectSetPrototypeOf(Writable, Stream) -function nop() {} -const kOnFinished = Symbol('kOnFinished') -function WritableState(options, stream, isDuplex) { - // Duplex streams are both readable and writable, but share - // the same options object. - // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream, - // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. - if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof require('./duplex') - - // Object stream flag to indicate whether or not this stream - // contains buffers or objects. - this.objectMode = !!(options && options.objectMode) - if (isDuplex) this.objectMode = this.objectMode || !!(options && options.writableObjectMode) - - // The point at which write() starts returning false - // Note: 0 is a valid value, means that we always return false if - // the entire buffer is not flushed immediately on write(). - this.highWaterMark = options - ? getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex) - : getDefaultHighWaterMark(false) - - // if _final has been called. - this.finalCalled = false - - // drain event flag. - this.needDrain = false - // At the start of calling end() - this.ending = false - // When end() has been called, and returned. - this.ended = false - // When 'finish' is emitted. - this.finished = false - - // Has it been destroyed - this.destroyed = false - - // Should we decode strings into buffers before passing to _write? - // this is here so that some node-core streams can optimize string - // handling at a lower level. - const noDecode = !!(options && options.decodeStrings === false) - this.decodeStrings = !noDecode - - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = (options && options.defaultEncoding) || 'utf8' - - // Not an actual buffer we keep track of, but a measurement - // of how much we're waiting to get pushed to some underlying - // socket or file. - this.length = 0 - - // A flag to see when we're in the middle of a write. - this.writing = false - - // When true all writes will be buffered until .uncork() call. - this.corked = 0 - - // A flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true - - // A flag to know if we're processing previously buffered items, which - // may call the _write() callback in the same tick, so that we don't - // end up in an overlapped onwrite situation. - this.bufferProcessing = false - - // The callback that's passed to _write(chunk, cb). - this.onwrite = onwrite.bind(undefined, stream) - - // The callback that the user supplies to write(chunk, encoding, cb). - this.writecb = null - - // The amount that is being written when _write is called. - this.writelen = 0 - - // Storage for data passed to the afterWrite() callback in case of - // synchronous _write() completion. - this.afterWriteTickInfo = null - resetBuffer(this) - - // Number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted. - this.pendingcb = 0 - - // Stream is still being constructed and cannot be - // destroyed until construction finished or failed. - // Async construction is opt in, therefore we start as - // constructed. - this.constructed = true - - // Emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams. - this.prefinished = false - - // True if the error was already emitted and should not be thrown again. - this.errorEmitted = false - - // Should close be emitted on destroy. Defaults to true. - this.emitClose = !options || options.emitClose !== false - - // Should .destroy() be called after 'finish' (and potentially 'end'). - this.autoDestroy = !options || options.autoDestroy !== false - - // Indicates whether the stream has errored. When true all write() calls - // should return false. This is needed since when autoDestroy - // is disabled we need a way to tell whether the stream has failed. - this.errored = null - - // Indicates whether the stream has finished destroying. - this.closed = false - - // True if close has been emitted or would have been emitted - // depending on emitClose. - this.closeEmitted = false - this[kOnFinished] = [] -} -function resetBuffer(state) { - state.buffered = [] - state.bufferedIndex = 0 - state.allBuffers = true - state.allNoop = true -} -WritableState.prototype.getBuffer = function getBuffer() { - return ArrayPrototypeSlice(this.buffered, this.bufferedIndex) -} -ObjectDefineProperty(WritableState.prototype, 'bufferedRequestCount', { - __proto__: null, - get() { - return this.buffered.length - this.bufferedIndex - } -}) -function Writable(options) { - // Writable ctor is applied to Duplexes, too. - // `realHasInstance` is necessary because using plain `instanceof` - // would return false, as no `_writableState` property is attached. - - // Trying to use the custom `instanceof` for Writable here will also break the - // Node.js LazyTransform implementation, which has a non-trivial getter for - // `_writableState` that would lead to infinite recursion. - - // Checking for a Stream.Duplex instance is faster here instead of inside - // the WritableState constructor, at least with V8 6.5. - const isDuplex = this instanceof require('./duplex') - if (!isDuplex && !FunctionPrototypeSymbolHasInstance(Writable, this)) return new Writable(options) - this._writableState = new WritableState(options, this, isDuplex) - if (options) { - if (typeof options.write === 'function') this._write = options.write - if (typeof options.writev === 'function') this._writev = options.writev - if (typeof options.destroy === 'function') this._destroy = options.destroy - if (typeof options.final === 'function') this._final = options.final - if (typeof options.construct === 'function') this._construct = options.construct - if (options.signal) addAbortSignal(options.signal, this) - } - Stream.call(this, options) - destroyImpl.construct(this, () => { - const state = this._writableState - if (!state.writing) { - clearBuffer(this, state) - } - finishMaybe(this, state) - }) -} -ObjectDefineProperty(Writable, SymbolHasInstance, { - __proto__: null, - value: function (object) { - if (FunctionPrototypeSymbolHasInstance(this, object)) return true - if (this !== Writable) return false - return object && object._writableState instanceof WritableState - } -}) - -// Otherwise people can pipe Writable streams, which is just wrong. -Writable.prototype.pipe = function () { - errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()) -} -function _write(stream, chunk, encoding, cb) { - const state = stream._writableState - if (typeof encoding === 'function') { - cb = encoding - encoding = state.defaultEncoding - } else { - if (!encoding) encoding = state.defaultEncoding - else if (encoding !== 'buffer' && !Buffer.isEncoding(encoding)) throw new ERR_UNKNOWN_ENCODING(encoding) - if (typeof cb !== 'function') cb = nop - } - if (chunk === null) { - throw new ERR_STREAM_NULL_VALUES() - } else if (!state.objectMode) { - if (typeof chunk === 'string') { - if (state.decodeStrings !== false) { - chunk = Buffer.from(chunk, encoding) - encoding = 'buffer' - } - } else if (chunk instanceof Buffer) { - encoding = 'buffer' - } else if (Stream._isUint8Array(chunk)) { - chunk = Stream._uint8ArrayToBuffer(chunk) - encoding = 'buffer' - } else { - throw new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk) - } - } - let err - if (state.ending) { - err = new ERR_STREAM_WRITE_AFTER_END() - } else if (state.destroyed) { - err = new ERR_STREAM_DESTROYED('write') - } - if (err) { - process.nextTick(cb, err) - errorOrDestroy(stream, err, true) - return err - } - state.pendingcb++ - return writeOrBuffer(stream, state, chunk, encoding, cb) -} -Writable.prototype.write = function (chunk, encoding, cb) { - return _write(this, chunk, encoding, cb) === true -} -Writable.prototype.cork = function () { - this._writableState.corked++ -} -Writable.prototype.uncork = function () { - const state = this._writableState - if (state.corked) { - state.corked-- - if (!state.writing) clearBuffer(this, state) - } -} -Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - // node::ParseEncoding() requires lower case. - if (typeof encoding === 'string') encoding = StringPrototypeToLowerCase(encoding) - if (!Buffer.isEncoding(encoding)) throw new ERR_UNKNOWN_ENCODING(encoding) - this._writableState.defaultEncoding = encoding - return this -} - -// If we're already writing something, then just put this -// in the queue, and wait our turn. Otherwise, call _write -// If we return false, then we need a drain event, so set that flag. -function writeOrBuffer(stream, state, chunk, encoding, callback) { - const len = state.objectMode ? 1 : chunk.length - state.length += len - - // stream._write resets state.length - const ret = state.length < state.highWaterMark - // We must ensure that previous needDrain will not be reset to false. - if (!ret) state.needDrain = true - if (state.writing || state.corked || state.errored || !state.constructed) { - state.buffered.push({ - chunk, - encoding, - callback - }) - if (state.allBuffers && encoding !== 'buffer') { - state.allBuffers = false - } - if (state.allNoop && callback !== nop) { - state.allNoop = false - } - } else { - state.writelen = len - state.writecb = callback - state.writing = true - state.sync = true - stream._write(chunk, encoding, state.onwrite) - state.sync = false - } - - // Return false if errored or destroyed in order to break - // any synchronous while(stream.write(data)) loops. - return ret && !state.errored && !state.destroyed -} -function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len - state.writecb = cb - state.writing = true - state.sync = true - if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write')) - else if (writev) stream._writev(chunk, state.onwrite) - else stream._write(chunk, encoding, state.onwrite) - state.sync = false -} -function onwriteError(stream, state, er, cb) { - --state.pendingcb - cb(er) - // Ensure callbacks are invoked even when autoDestroy is - // not enabled. Passing `er` here doesn't make sense since - // it's related to one specific write, not to the buffered - // writes. - errorBuffer(state) - // This can emit error, but error must always follow cb. - errorOrDestroy(stream, er) -} -function onwrite(stream, er) { - const state = stream._writableState - const sync = state.sync - const cb = state.writecb - if (typeof cb !== 'function') { - errorOrDestroy(stream, new ERR_MULTIPLE_CALLBACK()) - return - } - state.writing = false - state.writecb = null - state.length -= state.writelen - state.writelen = 0 - if (er) { - // Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364 - er.stack // eslint-disable-line no-unused-expressions - - if (!state.errored) { - state.errored = er - } - - // In case of duplex streams we need to notify the readable side of the - // error. - if (stream._readableState && !stream._readableState.errored) { - stream._readableState.errored = er - } - if (sync) { - process.nextTick(onwriteError, stream, state, er, cb) - } else { - onwriteError(stream, state, er, cb) - } - } else { - if (state.buffered.length > state.bufferedIndex) { - clearBuffer(stream, state) - } - if (sync) { - // It is a common case that the callback passed to .write() is always - // the same. In that case, we do not schedule a new nextTick(), but - // rather just increase a counter, to improve performance and avoid - // memory allocations. - if (state.afterWriteTickInfo !== null && state.afterWriteTickInfo.cb === cb) { - state.afterWriteTickInfo.count++ - } else { - state.afterWriteTickInfo = { - count: 1, - cb, - stream, - state - } - process.nextTick(afterWriteTick, state.afterWriteTickInfo) - } - } else { - afterWrite(stream, state, 1, cb) - } - } -} -function afterWriteTick({ stream, state, count, cb }) { - state.afterWriteTickInfo = null - return afterWrite(stream, state, count, cb) -} -function afterWrite(stream, state, count, cb) { - const needDrain = !state.ending && !stream.destroyed && state.length === 0 && state.needDrain - if (needDrain) { - state.needDrain = false - stream.emit('drain') - } - while (count-- > 0) { - state.pendingcb-- - cb() - } - if (state.destroyed) { - errorBuffer(state) - } - finishMaybe(stream, state) -} - -// If there's something in the buffer waiting, then invoke callbacks. -function errorBuffer(state) { - if (state.writing) { - return - } - for (let n = state.bufferedIndex; n < state.buffered.length; ++n) { - var _state$errored - const { chunk, callback } = state.buffered[n] - const len = state.objectMode ? 1 : chunk.length - state.length -= len - callback( - (_state$errored = state.errored) !== null && _state$errored !== undefined - ? _state$errored - : new ERR_STREAM_DESTROYED('write') - ) - } - const onfinishCallbacks = state[kOnFinished].splice(0) - for (let i = 0; i < onfinishCallbacks.length; i++) { - var _state$errored2 - onfinishCallbacks[i]( - (_state$errored2 = state.errored) !== null && _state$errored2 !== undefined - ? _state$errored2 - : new ERR_STREAM_DESTROYED('end') - ) - } - resetBuffer(state) -} - -// If there's something in the buffer waiting, then process it. -function clearBuffer(stream, state) { - if (state.corked || state.bufferProcessing || state.destroyed || !state.constructed) { - return - } - const { buffered, bufferedIndex, objectMode } = state - const bufferedLength = buffered.length - bufferedIndex - if (!bufferedLength) { - return - } - let i = bufferedIndex - state.bufferProcessing = true - if (bufferedLength > 1 && stream._writev) { - state.pendingcb -= bufferedLength - 1 - const callback = state.allNoop - ? nop - : (err) => { - for (let n = i; n < buffered.length; ++n) { - buffered[n].callback(err) - } - } - // Make a copy of `buffered` if it's going to be used by `callback` above, - // since `doWrite` will mutate the array. - const chunks = state.allNoop && i === 0 ? buffered : ArrayPrototypeSlice(buffered, i) - chunks.allBuffers = state.allBuffers - doWrite(stream, state, true, state.length, chunks, '', callback) - resetBuffer(state) - } else { - do { - const { chunk, encoding, callback } = buffered[i] - buffered[i++] = null - const len = objectMode ? 1 : chunk.length - doWrite(stream, state, false, len, chunk, encoding, callback) - } while (i < buffered.length && !state.writing) - if (i === buffered.length) { - resetBuffer(state) - } else if (i > 256) { - buffered.splice(0, i) - state.bufferedIndex = 0 - } else { - state.bufferedIndex = i - } - } - state.bufferProcessing = false -} -Writable.prototype._write = function (chunk, encoding, cb) { - if (this._writev) { - this._writev( - [ - { - chunk, - encoding - } - ], - cb - ) - } else { - throw new ERR_METHOD_NOT_IMPLEMENTED('_write()') - } -} -Writable.prototype._writev = null -Writable.prototype.end = function (chunk, encoding, cb) { - const state = this._writableState - if (typeof chunk === 'function') { - cb = chunk - chunk = null - encoding = null - } else if (typeof encoding === 'function') { - cb = encoding - encoding = null - } - let err - if (chunk !== null && chunk !== undefined) { - const ret = _write(this, chunk, encoding) - if (ret instanceof Error) { - err = ret - } - } - - // .end() fully uncorks. - if (state.corked) { - state.corked = 1 - this.uncork() - } - if (err) { - // Do nothing... - } else if (!state.errored && !state.ending) { - // This is forgiving in terms of unnecessary calls to end() and can hide - // logic errors. However, usually such errors are harmless and causing a - // hard error can be disproportionately destructive. It is not always - // trivial for the user to determine whether end() needs to be called - // or not. - - state.ending = true - finishMaybe(this, state, true) - state.ended = true - } else if (state.finished) { - err = new ERR_STREAM_ALREADY_FINISHED('end') - } else if (state.destroyed) { - err = new ERR_STREAM_DESTROYED('end') - } - if (typeof cb === 'function') { - if (err || state.finished) { - process.nextTick(cb, err) - } else { - state[kOnFinished].push(cb) - } - } - return this -} -function needFinish(state) { - return ( - state.ending && - !state.destroyed && - state.constructed && - state.length === 0 && - !state.errored && - state.buffered.length === 0 && - !state.finished && - !state.writing && - !state.errorEmitted && - !state.closeEmitted - ) -} -function callFinal(stream, state) { - let called = false - function onFinish(err) { - if (called) { - errorOrDestroy(stream, err !== null && err !== undefined ? err : ERR_MULTIPLE_CALLBACK()) - return - } - called = true - state.pendingcb-- - if (err) { - const onfinishCallbacks = state[kOnFinished].splice(0) - for (let i = 0; i < onfinishCallbacks.length; i++) { - onfinishCallbacks[i](err) - } - errorOrDestroy(stream, err, state.sync) - } else if (needFinish(state)) { - state.prefinished = true - stream.emit('prefinish') - // Backwards compat. Don't check state.sync here. - // Some streams assume 'finish' will be emitted - // asynchronously relative to _final callback. - state.pendingcb++ - process.nextTick(finish, stream, state) - } - } - state.sync = true - state.pendingcb++ - try { - stream._final(onFinish) - } catch (err) { - onFinish(err) - } - state.sync = false -} -function prefinish(stream, state) { - if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function' && !state.destroyed) { - state.finalCalled = true - callFinal(stream, state) - } else { - state.prefinished = true - stream.emit('prefinish') - } - } -} -function finishMaybe(stream, state, sync) { - if (needFinish(state)) { - prefinish(stream, state) - if (state.pendingcb === 0) { - if (sync) { - state.pendingcb++ - process.nextTick( - (stream, state) => { - if (needFinish(state)) { - finish(stream, state) - } else { - state.pendingcb-- - } - }, - stream, - state - ) - } else if (needFinish(state)) { - state.pendingcb++ - finish(stream, state) - } - } - } -} -function finish(stream, state) { - state.pendingcb-- - state.finished = true - const onfinishCallbacks = state[kOnFinished].splice(0) - for (let i = 0; i < onfinishCallbacks.length; i++) { - onfinishCallbacks[i]() - } - stream.emit('finish') - if (state.autoDestroy) { - // In case of duplex streams we need a way to detect - // if the readable side is ready for autoDestroy as well. - const rState = stream._readableState - const autoDestroy = - !rState || - (rState.autoDestroy && - // We don't expect the readable to ever 'end' - // if readable is explicitly set to false. - (rState.endEmitted || rState.readable === false)) - if (autoDestroy) { - stream.destroy() - } - } -} -ObjectDefineProperties(Writable.prototype, { - closed: { - __proto__: null, - get() { - return this._writableState ? this._writableState.closed : false - } - }, - destroyed: { - __proto__: null, - get() { - return this._writableState ? this._writableState.destroyed : false - }, - set(value) { - // Backward compatibility, the user is explicitly managing destroyed. - if (this._writableState) { - this._writableState.destroyed = value - } - } - }, - writable: { - __proto__: null, - get() { - const w = this._writableState - // w.writable === false means that this is part of a Duplex stream - // where the writable side was disabled upon construction. - // Compat. The user might manually disable writable side through - // deprecated setter. - return !!w && w.writable !== false && !w.destroyed && !w.errored && !w.ending && !w.ended - }, - set(val) { - // Backwards compatible. - if (this._writableState) { - this._writableState.writable = !!val - } - } - }, - writableFinished: { - __proto__: null, - get() { - return this._writableState ? this._writableState.finished : false - } - }, - writableObjectMode: { - __proto__: null, - get() { - return this._writableState ? this._writableState.objectMode : false - } - }, - writableBuffer: { - __proto__: null, - get() { - return this._writableState && this._writableState.getBuffer() - } - }, - writableEnded: { - __proto__: null, - get() { - return this._writableState ? this._writableState.ending : false - } - }, - writableNeedDrain: { - __proto__: null, - get() { - const wState = this._writableState - if (!wState) return false - return !wState.destroyed && !wState.ending && wState.needDrain - } - }, - writableHighWaterMark: { - __proto__: null, - get() { - return this._writableState && this._writableState.highWaterMark - } - }, - writableCorked: { - __proto__: null, - get() { - return this._writableState ? this._writableState.corked : 0 - } - }, - writableLength: { - __proto__: null, - get() { - return this._writableState && this._writableState.length - } - }, - errored: { - __proto__: null, - enumerable: false, - get() { - return this._writableState ? this._writableState.errored : null - } - }, - writableAborted: { - __proto__: null, - enumerable: false, - get: function () { - return !!( - this._writableState.writable !== false && - (this._writableState.destroyed || this._writableState.errored) && - !this._writableState.finished - ) - } - } -}) -const destroy = destroyImpl.destroy -Writable.prototype.destroy = function (err, cb) { - const state = this._writableState - - // Invoke pending callbacks. - if (!state.destroyed && (state.bufferedIndex < state.buffered.length || state[kOnFinished].length)) { - process.nextTick(errorBuffer, state) - } - destroy.call(this, err, cb) - return this -} -Writable.prototype._undestroy = destroyImpl.undestroy -Writable.prototype._destroy = function (err, cb) { - cb(err) -} -Writable.prototype[EE.captureRejectionSymbol] = function (err) { - this.destroy(err) -} -let webStreamsAdapters - -// Lazy to avoid circular references -function lazyWebStreams() { - if (webStreamsAdapters === undefined) webStreamsAdapters = {} - return webStreamsAdapters -} -Writable.fromWeb = function (writableStream, options) { - return lazyWebStreams().newStreamWritableFromWritableStream(writableStream, options) -} -Writable.toWeb = function (streamWritable) { - return lazyWebStreams().newWritableStreamFromStreamWritable(streamWritable) -} diff --git a/node_modules/readable-stream/lib/internal/validators.js b/node_modules/readable-stream/lib/internal/validators.js deleted file mode 100644 index 85b2e9cd593d9..0000000000000 --- a/node_modules/readable-stream/lib/internal/validators.js +++ /dev/null @@ -1,510 +0,0 @@ -/* eslint jsdoc/require-jsdoc: "error" */ - -'use strict' - -const { - ArrayIsArray, - ArrayPrototypeIncludes, - ArrayPrototypeJoin, - ArrayPrototypeMap, - NumberIsInteger, - NumberIsNaN, - NumberMAX_SAFE_INTEGER, - NumberMIN_SAFE_INTEGER, - NumberParseInt, - ObjectPrototypeHasOwnProperty, - RegExpPrototypeExec, - String, - StringPrototypeToUpperCase, - StringPrototypeTrim -} = require('../ours/primordials') -const { - hideStackFrames, - codes: { ERR_SOCKET_BAD_PORT, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_OUT_OF_RANGE, ERR_UNKNOWN_SIGNAL } -} = require('../ours/errors') -const { normalizeEncoding } = require('../ours/util') -const { isAsyncFunction, isArrayBufferView } = require('../ours/util').types -const signals = {} - -/** - * @param {*} value - * @returns {boolean} - */ -function isInt32(value) { - return value === (value | 0) -} - -/** - * @param {*} value - * @returns {boolean} - */ -function isUint32(value) { - return value === value >>> 0 -} -const octalReg = /^[0-7]+$/ -const modeDesc = 'must be a 32-bit unsigned integer or an octal string' - -/** - * Parse and validate values that will be converted into mode_t (the S_* - * constants). Only valid numbers and octal strings are allowed. They could be - * converted to 32-bit unsigned integers or non-negative signed integers in the - * C++ land, but any value higher than 0o777 will result in platform-specific - * behaviors. - * - * @param {*} value Values to be validated - * @param {string} name Name of the argument - * @param {number} [def] If specified, will be returned for invalid values - * @returns {number} - */ -function parseFileMode(value, name, def) { - if (typeof value === 'undefined') { - value = def - } - if (typeof value === 'string') { - if (RegExpPrototypeExec(octalReg, value) === null) { - throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc) - } - value = NumberParseInt(value, 8) - } - validateUint32(value, name) - return value -} - -/** - * @callback validateInteger - * @param {*} value - * @param {string} name - * @param {number} [min] - * @param {number} [max] - * @returns {asserts value is number} - */ - -/** @type {validateInteger} */ -const validateInteger = hideStackFrames((value, name, min = NumberMIN_SAFE_INTEGER, max = NumberMAX_SAFE_INTEGER) => { - if (typeof value !== 'number') throw new ERR_INVALID_ARG_TYPE(name, 'number', value) - if (!NumberIsInteger(value)) throw new ERR_OUT_OF_RANGE(name, 'an integer', value) - if (value < min || value > max) throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value) -}) - -/** - * @callback validateInt32 - * @param {*} value - * @param {string} name - * @param {number} [min] - * @param {number} [max] - * @returns {asserts value is number} - */ - -/** @type {validateInt32} */ -const validateInt32 = hideStackFrames((value, name, min = -2147483648, max = 2147483647) => { - // The defaults for min and max correspond to the limits of 32-bit integers. - if (typeof value !== 'number') { - throw new ERR_INVALID_ARG_TYPE(name, 'number', value) - } - if (!NumberIsInteger(value)) { - throw new ERR_OUT_OF_RANGE(name, 'an integer', value) - } - if (value < min || value > max) { - throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value) - } -}) - -/** - * @callback validateUint32 - * @param {*} value - * @param {string} name - * @param {number|boolean} [positive=false] - * @returns {asserts value is number} - */ - -/** @type {validateUint32} */ -const validateUint32 = hideStackFrames((value, name, positive = false) => { - if (typeof value !== 'number') { - throw new ERR_INVALID_ARG_TYPE(name, 'number', value) - } - if (!NumberIsInteger(value)) { - throw new ERR_OUT_OF_RANGE(name, 'an integer', value) - } - const min = positive ? 1 : 0 - // 2 ** 32 === 4294967296 - const max = 4294967295 - if (value < min || value > max) { - throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value) - } -}) - -/** - * @callback validateString - * @param {*} value - * @param {string} name - * @returns {asserts value is string} - */ - -/** @type {validateString} */ -function validateString(value, name) { - if (typeof value !== 'string') throw new ERR_INVALID_ARG_TYPE(name, 'string', value) -} - -/** - * @callback validateNumber - * @param {*} value - * @param {string} name - * @param {number} [min] - * @param {number} [max] - * @returns {asserts value is number} - */ - -/** @type {validateNumber} */ -function validateNumber(value, name, min = undefined, max) { - if (typeof value !== 'number') throw new ERR_INVALID_ARG_TYPE(name, 'number', value) - if ( - (min != null && value < min) || - (max != null && value > max) || - ((min != null || max != null) && NumberIsNaN(value)) - ) { - throw new ERR_OUT_OF_RANGE( - name, - `${min != null ? `>= ${min}` : ''}${min != null && max != null ? ' && ' : ''}${max != null ? `<= ${max}` : ''}`, - value - ) - } -} - -/** - * @callback validateOneOf - * @template T - * @param {T} value - * @param {string} name - * @param {T[]} oneOf - */ - -/** @type {validateOneOf} */ -const validateOneOf = hideStackFrames((value, name, oneOf) => { - if (!ArrayPrototypeIncludes(oneOf, value)) { - const allowed = ArrayPrototypeJoin( - ArrayPrototypeMap(oneOf, (v) => (typeof v === 'string' ? `'${v}'` : String(v))), - ', ' - ) - const reason = 'must be one of: ' + allowed - throw new ERR_INVALID_ARG_VALUE(name, value, reason) - } -}) - -/** - * @callback validateBoolean - * @param {*} value - * @param {string} name - * @returns {asserts value is boolean} - */ - -/** @type {validateBoolean} */ -function validateBoolean(value, name) { - if (typeof value !== 'boolean') throw new ERR_INVALID_ARG_TYPE(name, 'boolean', value) -} - -/** - * @param {any} options - * @param {string} key - * @param {boolean} defaultValue - * @returns {boolean} - */ -function getOwnPropertyValueOrDefault(options, key, defaultValue) { - return options == null || !ObjectPrototypeHasOwnProperty(options, key) ? defaultValue : options[key] -} - -/** - * @callback validateObject - * @param {*} value - * @param {string} name - * @param {{ - * allowArray?: boolean, - * allowFunction?: boolean, - * nullable?: boolean - * }} [options] - */ - -/** @type {validateObject} */ -const validateObject = hideStackFrames((value, name, options = null) => { - const allowArray = getOwnPropertyValueOrDefault(options, 'allowArray', false) - const allowFunction = getOwnPropertyValueOrDefault(options, 'allowFunction', false) - const nullable = getOwnPropertyValueOrDefault(options, 'nullable', false) - if ( - (!nullable && value === null) || - (!allowArray && ArrayIsArray(value)) || - (typeof value !== 'object' && (!allowFunction || typeof value !== 'function')) - ) { - throw new ERR_INVALID_ARG_TYPE(name, 'Object', value) - } -}) - -/** - * @callback validateDictionary - We are using the Web IDL Standard definition - * of "dictionary" here, which means any value - * whose Type is either Undefined, Null, or - * Object (which includes functions). - * @param {*} value - * @param {string} name - * @see https://webidl.spec.whatwg.org/#es-dictionary - * @see https://tc39.es/ecma262/#table-typeof-operator-results - */ - -/** @type {validateDictionary} */ -const validateDictionary = hideStackFrames((value, name) => { - if (value != null && typeof value !== 'object' && typeof value !== 'function') { - throw new ERR_INVALID_ARG_TYPE(name, 'a dictionary', value) - } -}) - -/** - * @callback validateArray - * @param {*} value - * @param {string} name - * @param {number} [minLength] - * @returns {asserts value is any[]} - */ - -/** @type {validateArray} */ -const validateArray = hideStackFrames((value, name, minLength = 0) => { - if (!ArrayIsArray(value)) { - throw new ERR_INVALID_ARG_TYPE(name, 'Array', value) - } - if (value.length < minLength) { - const reason = `must be longer than ${minLength}` - throw new ERR_INVALID_ARG_VALUE(name, value, reason) - } -}) - -/** - * @callback validateStringArray - * @param {*} value - * @param {string} name - * @returns {asserts value is string[]} - */ - -/** @type {validateStringArray} */ -function validateStringArray(value, name) { - validateArray(value, name) - for (let i = 0; i < value.length; i++) { - validateString(value[i], `${name}[${i}]`) - } -} - -/** - * @callback validateBooleanArray - * @param {*} value - * @param {string} name - * @returns {asserts value is boolean[]} - */ - -/** @type {validateBooleanArray} */ -function validateBooleanArray(value, name) { - validateArray(value, name) - for (let i = 0; i < value.length; i++) { - validateBoolean(value[i], `${name}[${i}]`) - } -} - -/** - * @param {*} signal - * @param {string} [name='signal'] - * @returns {asserts signal is keyof signals} - */ -function validateSignalName(signal, name = 'signal') { - validateString(signal, name) - if (signals[signal] === undefined) { - if (signals[StringPrototypeToUpperCase(signal)] !== undefined) { - throw new ERR_UNKNOWN_SIGNAL(signal + ' (signals must use all capital letters)') - } - throw new ERR_UNKNOWN_SIGNAL(signal) - } -} - -/** - * @callback validateBuffer - * @param {*} buffer - * @param {string} [name='buffer'] - * @returns {asserts buffer is ArrayBufferView} - */ - -/** @type {validateBuffer} */ -const validateBuffer = hideStackFrames((buffer, name = 'buffer') => { - if (!isArrayBufferView(buffer)) { - throw new ERR_INVALID_ARG_TYPE(name, ['Buffer', 'TypedArray', 'DataView'], buffer) - } -}) - -/** - * @param {string} data - * @param {string} encoding - */ -function validateEncoding(data, encoding) { - const normalizedEncoding = normalizeEncoding(encoding) - const length = data.length - if (normalizedEncoding === 'hex' && length % 2 !== 0) { - throw new ERR_INVALID_ARG_VALUE('encoding', encoding, `is invalid for data of length ${length}`) - } -} - -/** - * Check that the port number is not NaN when coerced to a number, - * is an integer and that it falls within the legal range of port numbers. - * @param {*} port - * @param {string} [name='Port'] - * @param {boolean} [allowZero=true] - * @returns {number} - */ -function validatePort(port, name = 'Port', allowZero = true) { - if ( - (typeof port !== 'number' && typeof port !== 'string') || - (typeof port === 'string' && StringPrototypeTrim(port).length === 0) || - +port !== +port >>> 0 || - port > 0xffff || - (port === 0 && !allowZero) - ) { - throw new ERR_SOCKET_BAD_PORT(name, port, allowZero) - } - return port | 0 -} - -/** - * @callback validateAbortSignal - * @param {*} signal - * @param {string} name - */ - -/** @type {validateAbortSignal} */ -const validateAbortSignal = hideStackFrames((signal, name) => { - if (signal !== undefined && (signal === null || typeof signal !== 'object' || !('aborted' in signal))) { - throw new ERR_INVALID_ARG_TYPE(name, 'AbortSignal', signal) - } -}) - -/** - * @callback validateFunction - * @param {*} value - * @param {string} name - * @returns {asserts value is Function} - */ - -/** @type {validateFunction} */ -const validateFunction = hideStackFrames((value, name) => { - if (typeof value !== 'function') throw new ERR_INVALID_ARG_TYPE(name, 'Function', value) -}) - -/** - * @callback validatePlainFunction - * @param {*} value - * @param {string} name - * @returns {asserts value is Function} - */ - -/** @type {validatePlainFunction} */ -const validatePlainFunction = hideStackFrames((value, name) => { - if (typeof value !== 'function' || isAsyncFunction(value)) throw new ERR_INVALID_ARG_TYPE(name, 'Function', value) -}) - -/** - * @callback validateUndefined - * @param {*} value - * @param {string} name - * @returns {asserts value is undefined} - */ - -/** @type {validateUndefined} */ -const validateUndefined = hideStackFrames((value, name) => { - if (value !== undefined) throw new ERR_INVALID_ARG_TYPE(name, 'undefined', value) -}) - -/** - * @template T - * @param {T} value - * @param {string} name - * @param {T[]} union - */ -function validateUnion(value, name, union) { - if (!ArrayPrototypeIncludes(union, value)) { - throw new ERR_INVALID_ARG_TYPE(name, `('${ArrayPrototypeJoin(union, '|')}')`, value) - } -} - -/* - The rules for the Link header field are described here: - https://www.rfc-editor.org/rfc/rfc8288.html#section-3 - - This regex validates any string surrounded by angle brackets - (not necessarily a valid URI reference) followed by zero or more - link-params separated by semicolons. -*/ -const linkValueRegExp = /^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/ - -/** - * @param {any} value - * @param {string} name - */ -function validateLinkHeaderFormat(value, name) { - if (typeof value === 'undefined' || !RegExpPrototypeExec(linkValueRegExp, value)) { - throw new ERR_INVALID_ARG_VALUE( - name, - value, - 'must be an array or string of format "; rel=preload; as=style"' - ) - } -} - -/** - * @param {any} hints - * @return {string} - */ -function validateLinkHeaderValue(hints) { - if (typeof hints === 'string') { - validateLinkHeaderFormat(hints, 'hints') - return hints - } else if (ArrayIsArray(hints)) { - const hintsLength = hints.length - let result = '' - if (hintsLength === 0) { - return result - } - for (let i = 0; i < hintsLength; i++) { - const link = hints[i] - validateLinkHeaderFormat(link, 'hints') - result += link - if (i !== hintsLength - 1) { - result += ', ' - } - } - return result - } - throw new ERR_INVALID_ARG_VALUE( - 'hints', - hints, - 'must be an array or string of format "; rel=preload; as=style"' - ) -} -module.exports = { - isInt32, - isUint32, - parseFileMode, - validateArray, - validateStringArray, - validateBooleanArray, - validateBoolean, - validateBuffer, - validateDictionary, - validateEncoding, - validateFunction, - validateInt32, - validateInteger, - validateNumber, - validateObject, - validateOneOf, - validatePlainFunction, - validatePort, - validateSignalName, - validateString, - validateUint32, - validateUndefined, - validateUnion, - validateAbortSignal, - validateLinkHeaderValue -} diff --git a/node_modules/readable-stream/lib/ours/browser.js b/node_modules/readable-stream/lib/ours/browser.js deleted file mode 100644 index 39acef3d7d9f6..0000000000000 --- a/node_modules/readable-stream/lib/ours/browser.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict' - -const CustomStream = require('../stream') -const promises = require('../stream/promises') -const originalDestroy = CustomStream.Readable.destroy -module.exports = CustomStream.Readable - -// Explicit export naming is needed for ESM -module.exports._uint8ArrayToBuffer = CustomStream._uint8ArrayToBuffer -module.exports._isUint8Array = CustomStream._isUint8Array -module.exports.isDisturbed = CustomStream.isDisturbed -module.exports.isErrored = CustomStream.isErrored -module.exports.isReadable = CustomStream.isReadable -module.exports.Readable = CustomStream.Readable -module.exports.Writable = CustomStream.Writable -module.exports.Duplex = CustomStream.Duplex -module.exports.Transform = CustomStream.Transform -module.exports.PassThrough = CustomStream.PassThrough -module.exports.addAbortSignal = CustomStream.addAbortSignal -module.exports.finished = CustomStream.finished -module.exports.destroy = CustomStream.destroy -module.exports.destroy = originalDestroy -module.exports.pipeline = CustomStream.pipeline -module.exports.compose = CustomStream.compose -Object.defineProperty(CustomStream, 'promises', { - configurable: true, - enumerable: true, - get() { - return promises - } -}) -module.exports.Stream = CustomStream.Stream - -// Allow default importing -module.exports.default = module.exports diff --git a/node_modules/readable-stream/lib/ours/errors.js b/node_modules/readable-stream/lib/ours/errors.js deleted file mode 100644 index 97866d14f5351..0000000000000 --- a/node_modules/readable-stream/lib/ours/errors.js +++ /dev/null @@ -1,341 +0,0 @@ -'use strict' - -const { format, inspect, AggregateError: CustomAggregateError } = require('./util') - -/* - This file is a reduced and adapted version of the main lib/internal/errors.js file defined at - - https://github.com/nodejs/node/blob/master/lib/internal/errors.js - - Don't try to replace with the original file and keep it up to date (starting from E(...) definitions) - with the upstream file. -*/ - -const AggregateError = globalThis.AggregateError || CustomAggregateError -const kIsNodeError = Symbol('kIsNodeError') -const kTypes = [ - 'string', - 'function', - 'number', - 'object', - // Accept 'Function' and 'Object' as alternative to the lower cased version. - 'Function', - 'Object', - 'boolean', - 'bigint', - 'symbol' -] -const classRegExp = /^([A-Z][a-z0-9]*)+$/ -const nodeInternalPrefix = '__node_internal_' -const codes = {} -function assert(value, message) { - if (!value) { - throw new codes.ERR_INTERNAL_ASSERTION(message) - } -} - -// Only use this for integers! Decimal numbers do not work with this function. -function addNumericalSeparator(val) { - let res = '' - let i = val.length - const start = val[0] === '-' ? 1 : 0 - for (; i >= start + 4; i -= 3) { - res = `_${val.slice(i - 3, i)}${res}` - } - return `${val.slice(0, i)}${res}` -} -function getMessage(key, msg, args) { - if (typeof msg === 'function') { - assert( - msg.length <= args.length, - // Default options do not count. - `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${msg.length}).` - ) - return msg(...args) - } - const expectedLength = (msg.match(/%[dfijoOs]/g) || []).length - assert( - expectedLength === args.length, - `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).` - ) - if (args.length === 0) { - return msg - } - return format(msg, ...args) -} -function E(code, message, Base) { - if (!Base) { - Base = Error - } - class NodeError extends Base { - constructor(...args) { - super(getMessage(code, message, args)) - } - toString() { - return `${this.name} [${code}]: ${this.message}` - } - } - Object.defineProperties(NodeError.prototype, { - name: { - value: Base.name, - writable: true, - enumerable: false, - configurable: true - }, - toString: { - value() { - return `${this.name} [${code}]: ${this.message}` - }, - writable: true, - enumerable: false, - configurable: true - } - }) - NodeError.prototype.code = code - NodeError.prototype[kIsNodeError] = true - codes[code] = NodeError -} -function hideStackFrames(fn) { - // We rename the functions that will be hidden to cut off the stacktrace - // at the outermost one - const hidden = nodeInternalPrefix + fn.name - Object.defineProperty(fn, 'name', { - value: hidden - }) - return fn -} -function aggregateTwoErrors(innerError, outerError) { - if (innerError && outerError && innerError !== outerError) { - if (Array.isArray(outerError.errors)) { - // If `outerError` is already an `AggregateError`. - outerError.errors.push(innerError) - return outerError - } - const err = new AggregateError([outerError, innerError], outerError.message) - err.code = outerError.code - return err - } - return innerError || outerError -} -class AbortError extends Error { - constructor(message = 'The operation was aborted', options = undefined) { - if (options !== undefined && typeof options !== 'object') { - throw new codes.ERR_INVALID_ARG_TYPE('options', 'Object', options) - } - super(message, options) - this.code = 'ABORT_ERR' - this.name = 'AbortError' - } -} -E('ERR_ASSERTION', '%s', Error) -E( - 'ERR_INVALID_ARG_TYPE', - (name, expected, actual) => { - assert(typeof name === 'string', "'name' must be a string") - if (!Array.isArray(expected)) { - expected = [expected] - } - let msg = 'The ' - if (name.endsWith(' argument')) { - // For cases like 'first argument' - msg += `${name} ` - } else { - msg += `"${name}" ${name.includes('.') ? 'property' : 'argument'} ` - } - msg += 'must be ' - const types = [] - const instances = [] - const other = [] - for (const value of expected) { - assert(typeof value === 'string', 'All expected entries have to be of type string') - if (kTypes.includes(value)) { - types.push(value.toLowerCase()) - } else if (classRegExp.test(value)) { - instances.push(value) - } else { - assert(value !== 'object', 'The value "object" should be written as "Object"') - other.push(value) - } - } - - // Special handle `object` in case other instances are allowed to outline - // the differences between each other. - if (instances.length > 0) { - const pos = types.indexOf('object') - if (pos !== -1) { - types.splice(types, pos, 1) - instances.push('Object') - } - } - if (types.length > 0) { - switch (types.length) { - case 1: - msg += `of type ${types[0]}` - break - case 2: - msg += `one of type ${types[0]} or ${types[1]}` - break - default: { - const last = types.pop() - msg += `one of type ${types.join(', ')}, or ${last}` - } - } - if (instances.length > 0 || other.length > 0) { - msg += ' or ' - } - } - if (instances.length > 0) { - switch (instances.length) { - case 1: - msg += `an instance of ${instances[0]}` - break - case 2: - msg += `an instance of ${instances[0]} or ${instances[1]}` - break - default: { - const last = instances.pop() - msg += `an instance of ${instances.join(', ')}, or ${last}` - } - } - if (other.length > 0) { - msg += ' or ' - } - } - switch (other.length) { - case 0: - break - case 1: - if (other[0].toLowerCase() !== other[0]) { - msg += 'an ' - } - msg += `${other[0]}` - break - case 2: - msg += `one of ${other[0]} or ${other[1]}` - break - default: { - const last = other.pop() - msg += `one of ${other.join(', ')}, or ${last}` - } - } - if (actual == null) { - msg += `. Received ${actual}` - } else if (typeof actual === 'function' && actual.name) { - msg += `. Received function ${actual.name}` - } else if (typeof actual === 'object') { - var _actual$constructor - if ( - (_actual$constructor = actual.constructor) !== null && - _actual$constructor !== undefined && - _actual$constructor.name - ) { - msg += `. Received an instance of ${actual.constructor.name}` - } else { - const inspected = inspect(actual, { - depth: -1 - }) - msg += `. Received ${inspected}` - } - } else { - let inspected = inspect(actual, { - colors: false - }) - if (inspected.length > 25) { - inspected = `${inspected.slice(0, 25)}...` - } - msg += `. Received type ${typeof actual} (${inspected})` - } - return msg - }, - TypeError -) -E( - 'ERR_INVALID_ARG_VALUE', - (name, value, reason = 'is invalid') => { - let inspected = inspect(value) - if (inspected.length > 128) { - inspected = inspected.slice(0, 128) + '...' - } - const type = name.includes('.') ? 'property' : 'argument' - return `The ${type} '${name}' ${reason}. Received ${inspected}` - }, - TypeError -) -E( - 'ERR_INVALID_RETURN_VALUE', - (input, name, value) => { - var _value$constructor - const type = - value !== null && - value !== undefined && - (_value$constructor = value.constructor) !== null && - _value$constructor !== undefined && - _value$constructor.name - ? `instance of ${value.constructor.name}` - : `type ${typeof value}` - return `Expected ${input} to be returned from the "${name}"` + ` function but got ${type}.` - }, - TypeError -) -E( - 'ERR_MISSING_ARGS', - (...args) => { - assert(args.length > 0, 'At least one arg needs to be specified') - let msg - const len = args.length - args = (Array.isArray(args) ? args : [args]).map((a) => `"${a}"`).join(' or ') - switch (len) { - case 1: - msg += `The ${args[0]} argument` - break - case 2: - msg += `The ${args[0]} and ${args[1]} arguments` - break - default: - { - const last = args.pop() - msg += `The ${args.join(', ')}, and ${last} arguments` - } - break - } - return `${msg} must be specified` - }, - TypeError -) -E( - 'ERR_OUT_OF_RANGE', - (str, range, input) => { - assert(range, 'Missing "range" argument') - let received - if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { - received = addNumericalSeparator(String(input)) - } else if (typeof input === 'bigint') { - received = String(input) - if (input > 2n ** 32n || input < -(2n ** 32n)) { - received = addNumericalSeparator(received) - } - received += 'n' - } else { - received = inspect(input) - } - return `The value of "${str}" is out of range. It must be ${range}. Received ${received}` - }, - RangeError -) -E('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times', Error) -E('ERR_METHOD_NOT_IMPLEMENTED', 'The %s method is not implemented', Error) -E('ERR_STREAM_ALREADY_FINISHED', 'Cannot call %s after a stream was finished', Error) -E('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable', Error) -E('ERR_STREAM_DESTROYED', 'Cannot call %s after a stream was destroyed', Error) -E('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError) -E('ERR_STREAM_PREMATURE_CLOSE', 'Premature close', Error) -E('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF', Error) -E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event', Error) -E('ERR_STREAM_WRITE_AFTER_END', 'write after end', Error) -E('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s', TypeError) -module.exports = { - AbortError, - aggregateTwoErrors: hideStackFrames(aggregateTwoErrors), - hideStackFrames, - codes -} diff --git a/node_modules/readable-stream/lib/ours/index.js b/node_modules/readable-stream/lib/ours/index.js deleted file mode 100644 index 6cdd2d7855767..0000000000000 --- a/node_modules/readable-stream/lib/ours/index.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict' - -const Stream = require('stream') -if (Stream && process.env.READABLE_STREAM === 'disable') { - const promises = Stream.promises - - // Explicit export naming is needed for ESM - module.exports._uint8ArrayToBuffer = Stream._uint8ArrayToBuffer - module.exports._isUint8Array = Stream._isUint8Array - module.exports.isDisturbed = Stream.isDisturbed - module.exports.isErrored = Stream.isErrored - module.exports.isReadable = Stream.isReadable - module.exports.Readable = Stream.Readable - module.exports.Writable = Stream.Writable - module.exports.Duplex = Stream.Duplex - module.exports.Transform = Stream.Transform - module.exports.PassThrough = Stream.PassThrough - module.exports.addAbortSignal = Stream.addAbortSignal - module.exports.finished = Stream.finished - module.exports.destroy = Stream.destroy - module.exports.pipeline = Stream.pipeline - module.exports.compose = Stream.compose - Object.defineProperty(Stream, 'promises', { - configurable: true, - enumerable: true, - get() { - return promises - } - }) - module.exports.Stream = Stream.Stream -} else { - const CustomStream = require('../stream') - const promises = require('../stream/promises') - const originalDestroy = CustomStream.Readable.destroy - module.exports = CustomStream.Readable - - // Explicit export naming is needed for ESM - module.exports._uint8ArrayToBuffer = CustomStream._uint8ArrayToBuffer - module.exports._isUint8Array = CustomStream._isUint8Array - module.exports.isDisturbed = CustomStream.isDisturbed - module.exports.isErrored = CustomStream.isErrored - module.exports.isReadable = CustomStream.isReadable - module.exports.Readable = CustomStream.Readable - module.exports.Writable = CustomStream.Writable - module.exports.Duplex = CustomStream.Duplex - module.exports.Transform = CustomStream.Transform - module.exports.PassThrough = CustomStream.PassThrough - module.exports.addAbortSignal = CustomStream.addAbortSignal - module.exports.finished = CustomStream.finished - module.exports.destroy = CustomStream.destroy - module.exports.destroy = originalDestroy - module.exports.pipeline = CustomStream.pipeline - module.exports.compose = CustomStream.compose - Object.defineProperty(CustomStream, 'promises', { - configurable: true, - enumerable: true, - get() { - return promises - } - }) - module.exports.Stream = CustomStream.Stream -} - -// Allow default importing -module.exports.default = module.exports diff --git a/node_modules/readable-stream/lib/ours/primordials.js b/node_modules/readable-stream/lib/ours/primordials.js deleted file mode 100644 index 9464cc7fea6a1..0000000000000 --- a/node_modules/readable-stream/lib/ours/primordials.js +++ /dev/null @@ -1,101 +0,0 @@ -'use strict' - -/* - This file is a reduced and adapted version of the main lib/internal/per_context/primordials.js file defined at - - https://github.com/nodejs/node/blob/master/lib/internal/per_context/primordials.js - - Don't try to replace with the original file and keep it up to date with the upstream file. -*/ -module.exports = { - ArrayIsArray(self) { - return Array.isArray(self) - }, - ArrayPrototypeIncludes(self, el) { - return self.includes(el) - }, - ArrayPrototypeIndexOf(self, el) { - return self.indexOf(el) - }, - ArrayPrototypeJoin(self, sep) { - return self.join(sep) - }, - ArrayPrototypeMap(self, fn) { - return self.map(fn) - }, - ArrayPrototypePop(self, el) { - return self.pop(el) - }, - ArrayPrototypePush(self, el) { - return self.push(el) - }, - ArrayPrototypeSlice(self, start, end) { - return self.slice(start, end) - }, - Error, - FunctionPrototypeCall(fn, thisArgs, ...args) { - return fn.call(thisArgs, ...args) - }, - FunctionPrototypeSymbolHasInstance(self, instance) { - return Function.prototype[Symbol.hasInstance].call(self, instance) - }, - MathFloor: Math.floor, - Number, - NumberIsInteger: Number.isInteger, - NumberIsNaN: Number.isNaN, - NumberMAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER, - NumberMIN_SAFE_INTEGER: Number.MIN_SAFE_INTEGER, - NumberParseInt: Number.parseInt, - ObjectDefineProperties(self, props) { - return Object.defineProperties(self, props) - }, - ObjectDefineProperty(self, name, prop) { - return Object.defineProperty(self, name, prop) - }, - ObjectGetOwnPropertyDescriptor(self, name) { - return Object.getOwnPropertyDescriptor(self, name) - }, - ObjectKeys(obj) { - return Object.keys(obj) - }, - ObjectSetPrototypeOf(target, proto) { - return Object.setPrototypeOf(target, proto) - }, - Promise, - PromisePrototypeCatch(self, fn) { - return self.catch(fn) - }, - PromisePrototypeThen(self, thenFn, catchFn) { - return self.then(thenFn, catchFn) - }, - PromiseReject(err) { - return Promise.reject(err) - }, - ReflectApply: Reflect.apply, - RegExpPrototypeTest(self, value) { - return self.test(value) - }, - SafeSet: Set, - String, - StringPrototypeSlice(self, start, end) { - return self.slice(start, end) - }, - StringPrototypeToLowerCase(self) { - return self.toLowerCase() - }, - StringPrototypeToUpperCase(self) { - return self.toUpperCase() - }, - StringPrototypeTrim(self) { - return self.trim() - }, - Symbol, - SymbolFor: Symbol.for, - SymbolAsyncIterator: Symbol.asyncIterator, - SymbolHasInstance: Symbol.hasInstance, - SymbolIterator: Symbol.iterator, - TypedArrayPrototypeSet(self, buf, len) { - return self.set(buf, len) - }, - Uint8Array -} diff --git a/node_modules/readable-stream/lib/ours/util.js b/node_modules/readable-stream/lib/ours/util.js deleted file mode 100644 index e125ce17aa83c..0000000000000 --- a/node_modules/readable-stream/lib/ours/util.js +++ /dev/null @@ -1,128 +0,0 @@ -'use strict' - -const bufferModule = require('buffer') -const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor -const Blob = globalThis.Blob || bufferModule.Blob -/* eslint-disable indent */ -const isBlob = - typeof Blob !== 'undefined' - ? function isBlob(b) { - // eslint-disable-next-line indent - return b instanceof Blob - } - : function isBlob(b) { - return false - } -/* eslint-enable indent */ - -// This is a simplified version of AggregateError -class AggregateError extends Error { - constructor(errors) { - if (!Array.isArray(errors)) { - throw new TypeError(`Expected input to be an Array, got ${typeof errors}`) - } - let message = '' - for (let i = 0; i < errors.length; i++) { - message += ` ${errors[i].stack}\n` - } - super(message) - this.name = 'AggregateError' - this.errors = errors - } -} -module.exports = { - AggregateError, - kEmptyObject: Object.freeze({}), - once(callback) { - let called = false - return function (...args) { - if (called) { - return - } - called = true - callback.apply(this, args) - } - }, - createDeferredPromise: function () { - let resolve - let reject - - // eslint-disable-next-line promise/param-names - const promise = new Promise((res, rej) => { - resolve = res - reject = rej - }) - return { - promise, - resolve, - reject - } - }, - promisify(fn) { - return new Promise((resolve, reject) => { - fn((err, ...args) => { - if (err) { - return reject(err) - } - return resolve(...args) - }) - }) - }, - debuglog() { - return function () {} - }, - format(format, ...args) { - // Simplified version of https://nodejs.org/api/util.html#utilformatformat-args - return format.replace(/%([sdifj])/g, function (...[_unused, type]) { - const replacement = args.shift() - if (type === 'f') { - return replacement.toFixed(6) - } else if (type === 'j') { - return JSON.stringify(replacement) - } else if (type === 's' && typeof replacement === 'object') { - const ctor = replacement.constructor !== Object ? replacement.constructor.name : '' - return `${ctor} {}`.trim() - } else { - return replacement.toString() - } - }) - }, - inspect(value) { - // Vastly simplified version of https://nodejs.org/api/util.html#utilinspectobject-options - switch (typeof value) { - case 'string': - if (value.includes("'")) { - if (!value.includes('"')) { - return `"${value}"` - } else if (!value.includes('`') && !value.includes('${')) { - return `\`${value}\`` - } - } - return `'${value}'` - case 'number': - if (isNaN(value)) { - return 'NaN' - } else if (Object.is(value, -0)) { - return String(value) - } - return value - case 'bigint': - return `${String(value)}n` - case 'boolean': - case 'undefined': - return String(value) - case 'object': - return '{}' - } - }, - types: { - isAsyncFunction(fn) { - return fn instanceof AsyncFunction - }, - isArrayBufferView(arr) { - return ArrayBuffer.isView(arr) - } - }, - isBlob -} -module.exports.promisify.custom = Symbol.for('nodejs.util.promisify.custom') diff --git a/node_modules/readable-stream/lib/stream.js b/node_modules/readable-stream/lib/stream.js deleted file mode 100644 index e9bb6ba908033..0000000000000 --- a/node_modules/readable-stream/lib/stream.js +++ /dev/null @@ -1,136 +0,0 @@ -/* replacement start */ - -const { Buffer } = require('buffer') - -/* replacement end */ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -;('use strict') -const { ObjectDefineProperty, ObjectKeys, ReflectApply } = require('./ours/primordials') -const { - promisify: { custom: customPromisify } -} = require('./ours/util') -const { streamReturningOperators, promiseReturningOperators } = require('./internal/streams/operators') -const { - codes: { ERR_ILLEGAL_CONSTRUCTOR } -} = require('./ours/errors') -const compose = require('./internal/streams/compose') -const { pipeline } = require('./internal/streams/pipeline') -const { destroyer } = require('./internal/streams/destroy') -const eos = require('./internal/streams/end-of-stream') -const internalBuffer = {} -const promises = require('./stream/promises') -const utils = require('./internal/streams/utils') -const Stream = (module.exports = require('./internal/streams/legacy').Stream) -Stream.isDisturbed = utils.isDisturbed -Stream.isErrored = utils.isErrored -Stream.isReadable = utils.isReadable -Stream.Readable = require('./internal/streams/readable') -for (const key of ObjectKeys(streamReturningOperators)) { - const op = streamReturningOperators[key] - function fn(...args) { - if (new.target) { - throw ERR_ILLEGAL_CONSTRUCTOR() - } - return Stream.Readable.from(ReflectApply(op, this, args)) - } - ObjectDefineProperty(fn, 'name', { - __proto__: null, - value: op.name - }) - ObjectDefineProperty(fn, 'length', { - __proto__: null, - value: op.length - }) - ObjectDefineProperty(Stream.Readable.prototype, key, { - __proto__: null, - value: fn, - enumerable: false, - configurable: true, - writable: true - }) -} -for (const key of ObjectKeys(promiseReturningOperators)) { - const op = promiseReturningOperators[key] - function fn(...args) { - if (new.target) { - throw ERR_ILLEGAL_CONSTRUCTOR() - } - return ReflectApply(op, this, args) - } - ObjectDefineProperty(fn, 'name', { - __proto__: null, - value: op.name - }) - ObjectDefineProperty(fn, 'length', { - __proto__: null, - value: op.length - }) - ObjectDefineProperty(Stream.Readable.prototype, key, { - __proto__: null, - value: fn, - enumerable: false, - configurable: true, - writable: true - }) -} -Stream.Writable = require('./internal/streams/writable') -Stream.Duplex = require('./internal/streams/duplex') -Stream.Transform = require('./internal/streams/transform') -Stream.PassThrough = require('./internal/streams/passthrough') -Stream.pipeline = pipeline -const { addAbortSignal } = require('./internal/streams/add-abort-signal') -Stream.addAbortSignal = addAbortSignal -Stream.finished = eos -Stream.destroy = destroyer -Stream.compose = compose -ObjectDefineProperty(Stream, 'promises', { - __proto__: null, - configurable: true, - enumerable: true, - get() { - return promises - } -}) -ObjectDefineProperty(pipeline, customPromisify, { - __proto__: null, - enumerable: true, - get() { - return promises.pipeline - } -}) -ObjectDefineProperty(eos, customPromisify, { - __proto__: null, - enumerable: true, - get() { - return promises.finished - } -}) - -// Backwards-compat with node 0.4.x -Stream.Stream = Stream -Stream._isUint8Array = function isUint8Array(value) { - return value instanceof Uint8Array -} -Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength) -} diff --git a/node_modules/readable-stream/lib/stream/promises.js b/node_modules/readable-stream/lib/stream/promises.js deleted file mode 100644 index 5d4ce15f4904b..0000000000000 --- a/node_modules/readable-stream/lib/stream/promises.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict' - -const { ArrayPrototypePop, Promise } = require('../ours/primordials') -const { isIterable, isNodeStream, isWebStream } = require('../internal/streams/utils') -const { pipelineImpl: pl } = require('../internal/streams/pipeline') -const { finished } = require('../internal/streams/end-of-stream') -require('../../lib/stream.js') -function pipeline(...streams) { - return new Promise((resolve, reject) => { - let signal - let end - const lastArg = streams[streams.length - 1] - if ( - lastArg && - typeof lastArg === 'object' && - !isNodeStream(lastArg) && - !isIterable(lastArg) && - !isWebStream(lastArg) - ) { - const options = ArrayPrototypePop(streams) - signal = options.signal - end = options.end - } - pl( - streams, - (err, value) => { - if (err) { - reject(err) - } else { - resolve(value) - } - }, - { - signal, - end - } - ) - }) -} -module.exports = { - finished, - pipeline -} diff --git a/node_modules/readable-stream/package.json b/node_modules/readable-stream/package.json deleted file mode 100644 index 289f3a45a634f..0000000000000 --- a/node_modules/readable-stream/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "name": "readable-stream", - "version": "4.4.2", - "description": "Node.js Streams, a user-land copy of the stream library from Node.js", - "homepage": "https://github.com/nodejs/readable-stream", - "license": "MIT", - "licenses": [ - { - "type": "MIT", - "url": "https://choosealicense.com/licenses/mit/" - } - ], - "keywords": [ - "readable", - "stream", - "pipe" - ], - "repository": { - "type": "git", - "url": "git://github.com/nodejs/readable-stream" - }, - "bugs": { - "url": "https://github.com/nodejs/readable-stream/issues" - }, - "main": "lib/ours/index.js", - "files": [ - "lib", - "LICENSE", - "README.md" - ], - "browser": { - "util": "./lib/ours/util.js", - "./lib/ours/index.js": "./lib/ours/browser.js" - }, - "scripts": { - "build": "node build/build.mjs", - "postbuild": "prettier -w lib test", - "test": "tap --rcfile=./tap.yml test/parallel/test-*.js test/ours/test-*.js", - "test:prepare": "node test/browser/runner-prepare.mjs", - "test:browsers": "node test/browser/runner-browser.mjs", - "test:bundlers": "node test/browser/runner-node.mjs", - "test:readable-stream-only": "node readable-stream-test/runner-prepare.mjs", - "coverage": "c8 -c ./c8.json tap --rcfile=./tap.yml test/parallel/test-*.js test/ours/test-*.js", - "format": "prettier -w src lib test", - "lint": "eslint src" - }, - "dependencies": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - }, - "devDependencies": { - "@babel/core": "^7.17.10", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", - "@babel/plugin-proposal-optional-chaining": "^7.16.7", - "@rollup/plugin-commonjs": "^22.0.0", - "@rollup/plugin-inject": "^4.0.4", - "@rollup/plugin-node-resolve": "^13.3.0", - "@sinonjs/fake-timers": "^9.1.2", - "browserify": "^17.0.0", - "c8": "^7.11.2", - "esbuild": "^0.14.39", - "esbuild-plugin-alias": "^0.2.1", - "eslint": "^8.15.0", - "eslint-config-standard": "^17.0.0", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-n": "^15.2.0", - "eslint-plugin-promise": "^6.0.0", - "playwright": "^1.21.1", - "prettier": "^2.6.2", - "rollup": "^2.72.1", - "rollup-plugin-polyfill-node": "^0.9.0", - "tap": "^16.2.0", - "tap-mocha-reporter": "^5.0.3", - "tape": "^5.5.3", - "tar": "^6.1.11", - "undici": "^5.1.1", - "webpack": "^5.72.1", - "webpack-cli": "^4.9.2" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } -} diff --git a/node_modules/safe-buffer/LICENSE b/node_modules/safe-buffer/LICENSE deleted file mode 100644 index 0c068ceecbd48..0000000000000 --- a/node_modules/safe-buffer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Feross Aboukhadijeh - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/safe-buffer/index.js b/node_modules/safe-buffer/index.js deleted file mode 100644 index f8d3ec98852f4..0000000000000 --- a/node_modules/safe-buffer/index.js +++ /dev/null @@ -1,65 +0,0 @@ -/*! safe-buffer. MIT License. Feross Aboukhadijeh */ -/* eslint-disable node/no-deprecated-api */ -var buffer = require('buffer') -var Buffer = buffer.Buffer - -// alternative to using Object.keys for old browsers -function copyProps (src, dst) { - for (var key in src) { - dst[key] = src[key] - } -} -if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { - module.exports = buffer -} else { - // Copy properties from require('buffer') - copyProps(buffer, exports) - exports.Buffer = SafeBuffer -} - -function SafeBuffer (arg, encodingOrOffset, length) { - return Buffer(arg, encodingOrOffset, length) -} - -SafeBuffer.prototype = Object.create(Buffer.prototype) - -// Copy static methods from Buffer -copyProps(Buffer, SafeBuffer) - -SafeBuffer.from = function (arg, encodingOrOffset, length) { - if (typeof arg === 'number') { - throw new TypeError('Argument must not be a number') - } - return Buffer(arg, encodingOrOffset, length) -} - -SafeBuffer.alloc = function (size, fill, encoding) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - var buf = Buffer(size) - if (fill !== undefined) { - if (typeof encoding === 'string') { - buf.fill(fill, encoding) - } else { - buf.fill(fill) - } - } else { - buf.fill(0) - } - return buf -} - -SafeBuffer.allocUnsafe = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return Buffer(size) -} - -SafeBuffer.allocUnsafeSlow = function (size) { - if (typeof size !== 'number') { - throw new TypeError('Argument must be a number') - } - return buffer.SlowBuffer(size) -} diff --git a/node_modules/safe-buffer/package.json b/node_modules/safe-buffer/package.json deleted file mode 100644 index f2869e256477a..0000000000000 --- a/node_modules/safe-buffer/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "safe-buffer", - "description": "Safer Node.js Buffer API", - "version": "5.2.1", - "author": { - "name": "Feross Aboukhadijeh", - "email": "feross@feross.org", - "url": "https://feross.org" - }, - "bugs": { - "url": "https://github.com/feross/safe-buffer/issues" - }, - "devDependencies": { - "standard": "*", - "tape": "^5.0.0" - }, - "homepage": "https://github.com/feross/safe-buffer", - "keywords": [ - "buffer", - "buffer allocate", - "node security", - "safe", - "safe-buffer", - "security", - "uninitialized" - ], - "license": "MIT", - "main": "index.js", - "types": "index.d.ts", - "repository": { - "type": "git", - "url": "git://github.com/feross/safe-buffer.git" - }, - "scripts": { - "test": "standard && tape test/*.js" - }, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] -} diff --git a/node_modules/string_decoder/LICENSE b/node_modules/string_decoder/LICENSE deleted file mode 100644 index 778edb20730ef..0000000000000 --- a/node_modules/string_decoder/LICENSE +++ /dev/null @@ -1,48 +0,0 @@ -Node.js is licensed for use as follows: - -""" -Copyright Node.js contributors. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" - -This license applies to parts of Node.js originating from the -https://github.com/joyent/node repository: - -""" -Copyright Joyent, Inc. and other Node contributors. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -sell copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. -""" - diff --git a/node_modules/string_decoder/lib/string_decoder.js b/node_modules/string_decoder/lib/string_decoder.js deleted file mode 100644 index 2e89e63f7933e..0000000000000 --- a/node_modules/string_decoder/lib/string_decoder.js +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -/**/ - -var Buffer = require('safe-buffer').Buffer; -/**/ - -var isEncoding = Buffer.isEncoding || function (encoding) { - encoding = '' + encoding; - switch (encoding && encoding.toLowerCase()) { - case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': - return true; - default: - return false; - } -}; - -function _normalizeEncoding(enc) { - if (!enc) return 'utf8'; - var retried; - while (true) { - switch (enc) { - case 'utf8': - case 'utf-8': - return 'utf8'; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return 'utf16le'; - case 'latin1': - case 'binary': - return 'latin1'; - case 'base64': - case 'ascii': - case 'hex': - return enc; - default: - if (retried) return; // undefined - enc = ('' + enc).toLowerCase(); - retried = true; - } - } -}; - -// Do not cache `Buffer.isEncoding` when checking encoding names as some -// modules monkey-patch it to support additional encodings -function normalizeEncoding(enc) { - var nenc = _normalizeEncoding(enc); - if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); - return nenc || enc; -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. -exports.StringDecoder = StringDecoder; -function StringDecoder(encoding) { - this.encoding = normalizeEncoding(encoding); - var nb; - switch (this.encoding) { - case 'utf16le': - this.text = utf16Text; - this.end = utf16End; - nb = 4; - break; - case 'utf8': - this.fillLast = utf8FillLast; - nb = 4; - break; - case 'base64': - this.text = base64Text; - this.end = base64End; - nb = 3; - break; - default: - this.write = simpleWrite; - this.end = simpleEnd; - return; - } - this.lastNeed = 0; - this.lastTotal = 0; - this.lastChar = Buffer.allocUnsafe(nb); -} - -StringDecoder.prototype.write = function (buf) { - if (buf.length === 0) return ''; - var r; - var i; - if (this.lastNeed) { - r = this.fillLast(buf); - if (r === undefined) return ''; - i = this.lastNeed; - this.lastNeed = 0; - } else { - i = 0; - } - if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); - return r || ''; -}; - -StringDecoder.prototype.end = utf8End; - -// Returns only complete characters in a Buffer -StringDecoder.prototype.text = utf8Text; - -// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer -StringDecoder.prototype.fillLast = function (buf) { - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); - this.lastNeed -= buf.length; -}; - -// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a -// continuation byte. If an invalid byte is detected, -2 is returned. -function utf8CheckByte(byte) { - if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; - return byte >> 6 === 0x02 ? -1 : -2; -} - -// Checks at most 3 bytes at the end of a Buffer in order to detect an -// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) -// needed to complete the UTF-8 character (if applicable) are returned. -function utf8CheckIncomplete(self, buf, i) { - var j = buf.length - 1; - if (j < i) return 0; - var nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 1; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 2; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) { - if (nb === 2) nb = 0;else self.lastNeed = nb - 3; - } - return nb; - } - return 0; -} - -// Validates as many continuation bytes for a multi-byte UTF-8 character as -// needed or are available. If we see a non-continuation byte where we expect -// one, we "replace" the validated continuation bytes we've seen so far with -// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding -// behavior. The continuation byte check is included three times in the case -// where all of the continuation bytes for a character exist in the same buffer. -// It is also done this way as a slight performance increase instead of using a -// loop. -function utf8CheckExtraBytes(self, buf, p) { - if ((buf[0] & 0xC0) !== 0x80) { - self.lastNeed = 0; - return '\ufffd'; - } - if (self.lastNeed > 1 && buf.length > 1) { - if ((buf[1] & 0xC0) !== 0x80) { - self.lastNeed = 1; - return '\ufffd'; - } - if (self.lastNeed > 2 && buf.length > 2) { - if ((buf[2] & 0xC0) !== 0x80) { - self.lastNeed = 2; - return '\ufffd'; - } - } - } -} - -// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. -function utf8FillLast(buf) { - var p = this.lastTotal - this.lastNeed; - var r = utf8CheckExtraBytes(this, buf, p); - if (r !== undefined) return r; - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, p, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, p, 0, buf.length); - this.lastNeed -= buf.length; -} - -// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a -// partial character, the character's bytes are buffered until the required -// number of bytes are available. -function utf8Text(buf, i) { - var total = utf8CheckIncomplete(this, buf, i); - if (!this.lastNeed) return buf.toString('utf8', i); - this.lastTotal = total; - var end = buf.length - (total - this.lastNeed); - buf.copy(this.lastChar, 0, end); - return buf.toString('utf8', i, end); -} - -// For UTF-8, a replacement character is added when ending on a partial -// character. -function utf8End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + '\ufffd'; - return r; -} - -// UTF-16LE typically needs two bytes per character, but even if we have an even -// number of bytes available, we need to check if we end on a leading/high -// surrogate. In that case, we need to wait for the next two bytes in order to -// decode the last character properly. -function utf16Text(buf, i) { - if ((buf.length - i) % 2 === 0) { - var r = buf.toString('utf16le', i); - if (r) { - var c = r.charCodeAt(r.length - 1); - if (c >= 0xD800 && c <= 0xDBFF) { - this.lastNeed = 2; - this.lastTotal = 4; - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - return r.slice(0, -1); - } - } - return r; - } - this.lastNeed = 1; - this.lastTotal = 2; - this.lastChar[0] = buf[buf.length - 1]; - return buf.toString('utf16le', i, buf.length - 1); -} - -// For UTF-16LE we do not explicitly append special replacement characters if we -// end on a partial character, we simply let v8 handle that. -function utf16End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) { - var end = this.lastTotal - this.lastNeed; - return r + this.lastChar.toString('utf16le', 0, end); - } - return r; -} - -function base64Text(buf, i) { - var n = (buf.length - i) % 3; - if (n === 0) return buf.toString('base64', i); - this.lastNeed = 3 - n; - this.lastTotal = 3; - if (n === 1) { - this.lastChar[0] = buf[buf.length - 1]; - } else { - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - } - return buf.toString('base64', i, buf.length - n); -} - -function base64End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); - return r; -} - -// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) -function simpleWrite(buf) { - return buf.toString(this.encoding); -} - -function simpleEnd(buf) { - return buf && buf.length ? this.write(buf) : ''; -} \ No newline at end of file diff --git a/node_modules/string_decoder/package.json b/node_modules/string_decoder/package.json deleted file mode 100644 index b2bb141160cad..0000000000000 --- a/node_modules/string_decoder/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "string_decoder", - "version": "1.3.0", - "description": "The string_decoder module from Node core", - "main": "lib/string_decoder.js", - "files": [ - "lib" - ], - "dependencies": { - "safe-buffer": "~5.2.0" - }, - "devDependencies": { - "babel-polyfill": "^6.23.0", - "core-util-is": "^1.0.2", - "inherits": "^2.0.3", - "tap": "~0.4.8" - }, - "scripts": { - "test": "tap test/parallel/*.js && node test/verify-dependencies", - "ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/nodejs/string_decoder.git" - }, - "homepage": "https://github.com/nodejs/string_decoder", - "keywords": [ - "string", - "decoder", - "browser", - "browserify" - ], - "license": "MIT" -} diff --git a/package-lock.json b/package-lock.json index 4a12afc0d56e2..9f74b41c86f4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2447,18 +2447,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "inBundle": true, - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, "node_modules/acorn": { "version": "8.11.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", @@ -2647,14 +2635,10 @@ "inBundle": true }, "node_modules/are-we-there-yet": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-4.0.1.tgz", - "integrity": "sha512-2zuA+jpOYBRgoBCfa+fB87Rk0oGJjDX6pxGzqH6f33NzUhG25Xur6R0u0Z9VVAq8Z5JvQpQI6j6rtonuivC8QA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-4.0.2.tgz", + "integrity": "sha512-ncSWAawFhKMJDTdoAeOV+jyW1VCMj5QIAwULIBV0SSR7B/RLPPEQiknKcg/RIIZlUQrxELpsxMiTUoAQ4sIUyg==", "inBundle": true, - "dependencies": { - "delegates": "^1.0.0", - "readable-stream": "^4.1.0" - }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } @@ -2941,26 +2925,6 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "inBundle": true }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "inBundle": true - }, "node_modules/basic-auth-parser": { "version": "0.0.2-1", "resolved": "https://registry.npmjs.org/basic-auth-parser/-/basic-auth-parser-0.0.2-1.tgz", @@ -3069,30 +3033,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "inBundle": true, - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -4310,7 +4250,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", - "inBundle": true + "dev": true }, "node_modules/deprecation": { "version": "2.3.1", @@ -5268,24 +5208,6 @@ "node": ">=0.10.0" } }, - "node_modules/event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "inBundle": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "inBundle": true, - "engines": { - "node": ">=0.8.x" - } - }, "node_modules/events-to-array": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/events-to-array/-/events-to-array-1.1.2.tgz", @@ -6480,26 +6402,6 @@ "node": ">=0.10.0" } }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "inBundle": true - }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -11131,15 +11033,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "inBundle": true, - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/process-on-spawn": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", @@ -11494,22 +11387,6 @@ "node": ">=8" } }, - "node_modules/readable-stream": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.4.2.tgz", - "integrity": "sha512-Lk/fICSyIhodxy1IDK2HazkeGjSmezAWX2egdtJnYhtzKEsBPJowlI6F6LPb5tqIQILrMbx22S5o3GuJavPusA==", - "inBundle": true, - "dependencies": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -12102,6 +11979,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, "funding": [ { "type": "github", @@ -12115,8 +11993,7 @@ "type": "consulting", "url": "https://feross.org/support" } - ], - "inBundle": true + ] }, "node_modules/safe-regex-test": { "version": "1.0.0", @@ -12553,7 +12430,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "inBundle": true, + "dev": true, "dependencies": { "safe-buffer": "~5.2.0" }