diff --git a/.autod.conf.js b/.autod.conf.js deleted file mode 100644 index 10122bba5..000000000 --- a/.autod.conf.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - write: true, - prefix: '^', - devdep: ['mocha', 'autod', 'should', 'thunk-mocha', 'istanbul', 'git-pre-hooks'], - exclude: ['dist', 'browser.js', 'publish.js', 'shims'], - test: ['browser-build.js'] -}; diff --git a/.eslintignore b/.eslintignore index 1c4abd1b6..28baaae9c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -16,3 +16,10 @@ task/ browser-build.js es cjs +dist/ + +lib/common/utils/createRequest.js +lib/common/utils/encodeString.js +lib/common/utils/getStandardRegion.js + +lib/common/bucket/putBucketInventory.d.ts \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 5638fbfb3..794b582dc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,9 @@ -/* eslint max-len: [0] */ +// Ignore checking the js file generated by ts +const buckets = ['dataIndex.js']; +const ignorePatterns = ['lib/common/utils/*.js'].concat(buckets.map(item => `lib/common/bucket/${item}`)); + module.exports = { + ignorePatterns, extends: ['airbnb', 'eslint-config-ali/typescript', 'prettier'], parserOptions: { ecmaFeatures: { @@ -16,7 +20,6 @@ module.exports = { }, rules: { indent: ['error', 2], - // override default options 'no-underscore-dangle': [0], 'no-plusplus': [0], 'no-return-await': [0], @@ -34,6 +37,7 @@ module.exports = { } ], 'no-buffer-constructor': [2], + 'no-void': 'warn', 'comma-dangle': [0], 'import/prefer-default-export': [0] } diff --git a/.github/workflows/codeCov.yml b/.github/workflows/codeCov.yml index 6a3114e15..e6d22b9d6 100644 --- a/.github/workflows/codeCov.yml +++ b/.github/workflows/codeCov.yml @@ -23,8 +23,9 @@ jobs: ALI_SDK_STS_REGION: ${{secrets.ALI_SDK_STS_REGION}} ALI_SDK_STS_ROLE: ${{secrets.ALI_SDK_STS_ROLE}} ALI_SDK_STS_SECRET: ${{secrets.ALI_SDK_STS_SECRET}} + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: test and report upload run: | npm install diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 49928c18c..2ad651bd1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dev_node_test.yml b/.github/workflows/dev_node_test.yml index 4d4cac411..0d7f8081f 100644 --- a/.github/workflows/dev_node_test.yml +++ b/.github/workflows/dev_node_test.yml @@ -31,9 +31,7 @@ jobs: node-version: [14.x] steps: - - uses: actions/checkout@v2 - with: - ref: develop + - uses: actions/checkout@v4 - name: browser build and test run: | curl cip.cc @@ -63,13 +61,12 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 - with: - ref: develop + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + architecture: x64 - run: npm install - run: npm run test @@ -96,13 +93,12 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 - with: - ref: develop + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + architecture: x64 - run: npm install - run: npm run test @@ -129,12 +125,13 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: ref: develop - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + architecture: x64 - run: npm install - run: npm run test diff --git a/.github/workflows/master_node_test.yml b/.github/workflows/master_node_test.yml index dffa43b75..b9dfe0fae 100644 --- a/.github/workflows/master_node_test.yml +++ b/.github/workflows/master_node_test.yml @@ -31,7 +31,7 @@ jobs: node-version: [14.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: browser build and test run: | curl cip.cc @@ -61,11 +61,13 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + architecture: x64 + - run: npm install -D npm@6.14.12 - run: npm install - run: npm run test @@ -92,11 +94,13 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + architecture: x64 + - run: npm install -D npm@6.14.16 - run: npm install - run: npm run test @@ -123,10 +127,12 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + architecture: x64 + - run: npm install -D npm@6.14.18 - run: npm install - run: npm run test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..c81c4f78c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: Release + +on: + push: + branches: + - release +jobs: + release: + name: Release + runs-on: ubuntu-latest + permissions: + # https://docs.github.com/zh/actions/using-jobs/assigning-permissions-to-jobs + contents: write # 为 GITHUB_TOKEN 授予更新tag的权限 + env: + GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} # semantic-release和create-pull-request.js需要 + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # 只有semantic-release需要 + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + architecture: x64 + - name: Install Dependencies + run: npm install + - name: Snyk Protect + run: npm run snyk-protect + - name: Release to npm + run: npx semantic-release + # - name: Publish to cdn + # run: node publish.js # 因为发cdn 的ak权限比较大,有安全风险,故需要在本地发版到cdn + # 为了创建pr,GIT_TOKEN需要public_repo权限(https://github.com/settings/tokens/new) + - name: Create Pull Request + run: node ./task/create-pull-request.js diff --git a/.github/workflows/schedule.yml b/.github/workflows/schedule.yml index ffa0226e3..c55ed19ec 100644 --- a/.github/workflows/schedule.yml +++ b/.github/workflows/schedule.yml @@ -1,9 +1,9 @@ -# Regularly clean test buckets at 4:00 every day +# Regularly clean test buckets at GMT 01:00 every day. name: 'Schdule Delete' on: schedule: - - cron: '0 4 1/1 * *' + - cron: '0 1 1/1 * *' jobs: cleanAllBucket: @@ -25,10 +25,11 @@ jobs: matrix: node-version: [14.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: clean all bucket - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + architecture: x64 - run: npm install - - run: node test/node/cleanAllBucket.js + - run: node test/node/fixtures/cleanAllBucket.js diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml index f8bbf74be..19700d90b 100644 --- a/.github/workflows/snyk.yml +++ b/.github/workflows/snyk.yml @@ -10,8 +10,9 @@ jobs: security: environment: ali_oss_AK runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: npm install - name: Run Snyk to check for vulnerabilities diff --git a/.gitignore b/.gitignore index ecab552ad..05c1d26ac 100644 --- a/.gitignore +++ b/.gitignore @@ -28,8 +28,6 @@ build test/node/.tmp test/browser/.tmp test/demo.js -yarn.lock -package-lock.json .nyc_output/ .env @@ -44,3 +42,6 @@ package-lock.json es .eslintcache + +/test/node/fixtures/nodejs-processed-w200-latest.png +/test/node/fixtures/nodejs-processed-w200.png \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..23dd2e9bb --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +node_modules/ +dist/ + +lib/common/utils/createRequest.js +lib/common/utils/encodeString.js +lib/common/utils/getStandardRegion.js + +lib/common/bucket/putBucketInventory.d.ts \ No newline at end of file diff --git a/.releaserc b/.releaserc new file mode 100644 index 000000000..7f2bb771e --- /dev/null +++ b/.releaserc @@ -0,0 +1,31 @@ +{ + "branches": "release", + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github", + [ + "@semantic-release/npm", + { + "npmPublish": true + } + ], + [ + "@semantic-release/exec", + { + "prepareCmd": "npm run build-dist" + } + ], + [ + "@semantic-release/git", + { + "assets": [ + "package.json", + "lib/browser/version.js", + "dist/*.js" + ], + "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ] + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 100ce8bc8..60b5b7dc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,50 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [6.20.0](https://github.com/ali-sdk/ali-oss/compare/v6.19.0...v6.20.0) (2024-01-19) + +### Features + +* support v4 signature ([#1277](https://github.com/ali-sdk/ali-oss/issues/1277)) ([8bbe9b1](https://github.com/ali-sdk/ali-oss/commit/8bbe9b1ac8aa34c1564a1ad11549b67fc1db7f3a)) + +## [6.19.0](https://github.com/ali-sdk/ali-oss/compare/v6.18.1...v6.19.0) (2023-12-18) + +### Features + +* verify object names strictly when signing URLs and enabled by default ([#1265](https://github.com/ali-sdk/ali-oss/issues/1265)) ([830e36e](https://github.com/ali-sdk/ali-oss/commit/830e36ea143b57e09e42d0634bc0c4d07474a2a5)) + +### [6.18.1](https://github.com/ali-sdk/ali-oss/compare/v6.18.0...v6.18.1) (2023-09-08) + +### Features + +* add default content-type in DingTalk for ios ([#1244](https://github.com/ali-sdk/ali-oss/issues/1244)) ([13a2691](https://github.com/ali-sdk/ali-oss/commit/13a2691e49ee04667f41070d63478301fbc983e3)) + +### Bug Fixes + +* opt.headers in _uploadPart does not use es6 ([#1248](https://github.com/ali-sdk/ali-oss/issues/1248)) ([e2872a0](https://github.com/ali-sdk/ali-oss/commit/e2872a0046af9c5bf537c6eb67e8c32bd119021e)) +* upgrade urllib to 2.41.0 to avoid deps vm2 ([#1239](https://github.com/ali-sdk/ali-oss/issues/1239) [#1232](https://github.com/ali-sdk/ali-oss/issues/1232)) ([7656d6f](https://github.com/ali-sdk/ali-oss/commit/7656d6f49489451a7862015b0893ef1286b2e948)) + +## [6.18.0](https://github.com/aliyun/oss-nodejs-sdk/compare/v6.17.0...v6.18.0) (2023-07-27) + +### Features + +- add asyncSignatureUrl method ([#1057](https://github.com/aliyun/oss-nodejs-sdk/issues/1057)) ([1a05e80](https://github.com/aliyun/oss-nodejs-sdk/commit/1a05e8077b9e2ecbef0579253594ee2e67c45af4)) +- add getBucketStat method ([#1102](https://github.com/aliyun/oss-nodejs-sdk/issues/1102)) ([a63a5a4](https://github.com/aliyun/oss-nodejs-sdk/commit/a63a5a4c6c853f78dbbb97ca065866dcfe212ab0)) +- optimized multipartUpload progress close [#1139](https://github.com/aliyun/oss-nodejs-sdk/issues/1139) ([#1141](https://github.com/aliyun/oss-nodejs-sdk/issues/1141)) ([12fcfd1](https://github.com/aliyun/oss-nodejs-sdk/commit/12fcfd1abd9f6fb7ca0fce9b81c076b2d7518c1f)) +- the browser needs to set cross domain and expose the x-oss-next-append-position header ([#1218](https://github.com/aliyun/oss-nodejs-sdk/issues/1218)) ([ab2f4a3](https://github.com/aliyun/oss-nodejs-sdk/commit/ab2f4a3c795d1ab61b54112f3fc081d8afb39b7f)) + +### Bug Fixes + +- uploadPart not pass all headers parameters ([#1215](https://github.com/aliyun/oss-nodejs-sdk/issues/1215)) ([d842a6c](https://github.com/aliyun/oss-nodejs-sdk/commit/d842a6cd1653901ad865f080f37d40ff0a73cbe1)) +- **6.x:** lock dependencies ([#1088](https://github.com/aliyun/oss-nodejs-sdk/issues/1088)) ([9b65ef2](https://github.com/aliyun/oss-nodejs-sdk/commit/9b65ef28db5859b13238bd6aaccb3c25547b11e3)) +- fix user input header MD5 value being overwritten problem ([#1100](https://github.com/aliyun/oss-nodejs-sdk/issues/1100)) ([3f26b79](https://github.com/aliyun/oss-nodejs-sdk/commit/3f26b79384d733687e9324fa6b03df863a9a43dd)) +- remove Invalid Comparison ([#1090](https://github.com/aliyun/oss-nodejs-sdk/issues/1090)) ([bbb55b8](https://github.com/aliyun/oss-nodejs-sdk/commit/bbb55b821b5b0254827e62042bbadd6f96311c8b)) +- require module exits ([#1052](https://github.com/aliyun/oss-nodejs-sdk/issues/1052)) ([b176fa8](https://github.com/aliyun/oss-nodejs-sdk/commit/b176fa87d0de8b346f0f792f77acaf3002ca3a4d)) +- to fix callback customValue ([#1126](https://github.com/aliyun/oss-nodejs-sdk/issues/1126)) ([e6cdfe5](https://github.com/aliyun/oss-nodejs-sdk/commit/e6cdfe5a778e30de33eebd3f2b95791c38d6a8f6)) +- upgrade address from 1.1.2 to 1.2.2 ([#1114](https://github.com/aliyun/oss-nodejs-sdk/issues/1114)) ([a9b4d03](https://github.com/aliyun/oss-nodejs-sdk/commit/a9b4d03d7c53cb91efe790b9716c8bb8ecc2fda9))([#1184](https://github.com/aliyun/oss-nodejs-sdk/issues/1184)) ([b113222](https://github.com/aliyun/oss-nodejs-sdk/commit/b1132220f430d38e9e8738b6fdd8fb7f20b668a6)) +- upgrade is-type-of from 1.2.1 to 1.4.0 ([#1204](https://github.com/aliyun/oss-nodejs-sdk/issues/1204)) ([39ef9ac](https://github.com/aliyun/oss-nodejs-sdk/commit/39ef9acd9177b5d6348df7b9c83ca3a87c6b6185)) +- upgrade utility from 1.17.0 to 1.18.0 ([#1203](https://github.com/aliyun/oss-nodejs-sdk/issues/1203)) ([bc05406](https://github.com/aliyun/oss-nodejs-sdk/commit/bc05406b1b9326e1e08975e7639259cf04c2bf1e)) + ## [6.17.0](https://github.com/aliyun/oss-nodejs-sdk/compare/v6.15.0...v6.17.0) (2022-01-27) ### Features diff --git a/README.md b/README.md index 01f616e70..39420d69f 100644 --- a/README.md +++ b/README.md @@ -343,7 +343,7 @@ options: - [region] {String} the bucket data region location, please see [Data Regions](#data-regions), default is `oss-cn-hangzhou`. - [internal] {Boolean} access OSS with aliyun internal network or not, default is `false`. - If your servers are running on aliyun too, you can set `true` to save lot of money. + If your servers are running on aliyun too, you can set `true` to save a lot of money. - [secure] {Boolean} instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol. - [timeout] {String|Number} instance level timeout for all operations, default is `60s`. - [cname] {Boolean}, default false, access oss with custom domain name. if true, you can fill `endpoint` field with your custom domain name, @@ -351,10 +351,11 @@ options: the details you can see [requestPay](https://help.aliyun.com/document_detail/91337.htm) - [useFetch] {Boolean}, default false, it just work in Browser, if true,it means upload object with `fetch` mode ,else `XMLHttpRequest` -- [enableProxy] {Boolean}, Enable proxy request, default is false. +- [enableProxy] {Boolean}, Enable proxy request, default is false. **_NOTE:_** When enabling proxy request, please ensure that proxy-agent is installed. - [proxy] {String | Object}, proxy agent uri or options, default is null. - [retryMax] {Number}, used by auto retry send request count when request error is net error or timeout. **_NOTE:_** Not support `put` with stream, `putStream`, `append` with stream because the stream can only be consumed once - [maxSockets] {Number} Maximum number of sockets to allow per host. Default is infinity +- [authorizationV4] {Boolean} Use V4 signature. Default is false. example: @@ -435,6 +436,42 @@ for (let i = 0; i <= store.options.retryMax; i++) { } ``` +6. use V4 signature, and use optional additionalHeaders option which type is a string array, and the values inside need to be included in the header. + +```js +const OSS = require('ali-oss'); + +const store = new OSS({ + accessKeyId: 'your access key', + accessKeySecret: 'your access secret', + bucket: 'your bucket name', + region: 'oss-cn-hangzhou', + authorizationV4: true +}); + +try { + const bucketInfo = await store.getBucketInfo('your bucket name'); + console.log(bucketInfo); +} catch (e) { + console.log(e); +} + +try { + const putObjectResult = await store.put('your bucket name', 'your object name', { + headers: { + // The headers of this request + header1: 'value1', + header2: 'value2' + }, + // The keys of the request headers that need to be calculated into the V4 signature. Please ensure that these additional headers are included in the request headers. + additionalHeaders: ['additional header1', 'additional header2'] + }); + console.log(putObjectResult); +} catch (e) { + console.log(e); +} +``` + ## Bucket Operations ### .listBuckets(query[, options]) @@ -957,12 +994,12 @@ parameters: - [createdBeforeDate] {String} expire date, e.g.: `2022-10-11T00:00:00.000Z` `createdBeforeDate` and `days` must have one. - [transition] {Object} Specifies the time when an object is converted to the IA or archive storage class during a valid life cycle. - - storageClass {String} Specifies the storage class that objects that conform to the rule are converted into. allow values: `IA` or `Archive` + - storageClass {String} Specifies the storage class that objects that conform to the rule are converted into. allow values: `IA` or `Archive` or `ColdArchive` or `DeepColdArchive` - [days] {Number|String} expire after the `days` - [createdBeforeDate] {String} expire date, e.g.: `2022-10-11T00:00:00.000Z` `createdBeforeDate` and `days` must have one. - [noncurrentVersionTransition] {Object} Specifies the time when an object is converted to the IA or archive storage class during a valid life cycle. - - storageClass {String} Specifies the storage class that history objects that conform to the rule are converted into. allow values: `IA` or `Archive` + - storageClass {String} Specifies the storage class that history objects that conform to the rule are converted into. allow values: `IA` or `Archive` or `ColdArchive` or `DeepColdArchive` - noncurrentDays {String} expire after the `noncurrentDays` `expiration`、 `abortMultipartUpload`、 `transition`、 `noncurrentVersionTransition` must have one. - [noncurrentVersionExpiration] {Object} specifies the expiration attribute of the lifecycle rules for the history object. @@ -1452,7 +1489,8 @@ Success will return: - res {Object} response info ```ts -type Field = 'Size | LastModifiedDate | ETag | StorageClass | IsMultipartUploaded | EncryptionStatus'; +type Field = + 'Size | LastModifiedDate | ETag | StorageClass | IsMultipartUploaded | EncryptionStatus | ObjectAcl | TaggingCount | ObjectType | Crc64'; interface Inventory { id: string; isEnabled: true | false; @@ -1501,7 +1539,18 @@ const inventory = { frequency: 'Daily', // `WEEKLY` | `Daily` includedObjectVersions: 'All', // `All` | `Current` optionalFields: { - field: ['Size', 'LastModifiedDate', 'ETag', 'StorageClass', 'IsMultipartUploaded', 'EncryptionStatus'] + field: [ + 'Size', + 'LastModifiedDate', + 'ETag', + 'StorageClass', + 'IsMultipartUploaded', + 'EncryptionStatus', + 'ObjectAcl', + 'TaggingCount', + 'ObjectType', + 'Crc64' + ] } }; @@ -1666,7 +1715,7 @@ parameters: - name {String} object name store on OSS - file {String|Buffer|ReadStream|File(only support Browser)|Blob(only support Browser)} object local path, content buffer or ReadStream content instance use in Node, Blob and html5 File - [options] {Object} optional parameters - - [timeout] {Number} the operation timeout + - [timeout] {Number} the operation timeout (ms) - [mime] {String} custom mime, will send with `Content-Type` entity header - [meta] {Object} user meta, will send with `x-oss-meta-` prefix string e.g.: `{ uid: 123, pid: 110 }` @@ -1675,6 +1724,7 @@ parameters: - [host] {String} The host header value for initiating callback requests. - body {String} The value of the request body when a callback is initiated, for example, `key=${key}&etag=${etag}&my_var=${x:my_var}`. - [contentType] {String} The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value. + - [callbackSNI] {Boolean} Specifies whether OSS sends Server Name Indication (SNI) to the origin address specified by callbackUrl when a callback request is initiated from the client. - [customValue] {Object} Custom parameters are a map of key-values
e.g.: ```js @@ -1800,6 +1850,7 @@ parameters: - [host] {String} The host header value for initiating callback requests. - body {String} The value of the request body when a callback is initiated, for example, key=${key}&etag=${etag}&my_var=${x:my_var}. - [contentType] {String} The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value. + - [callbackSNI] {Boolean} Specifies whether OSS sends Server Name Indication (SNI) to the origin address specified by callbackUrl when a callback request is initiated from the client. - [customValue] {Object} Custom parameters are a map of key-values
e.g.: ```js @@ -1880,7 +1931,7 @@ object: - headers {Object} response headers - size {Number} response size - rt {Number} request total use time (ms) -- nextAppendPosition {String} the next position +- nextAppendPosition {String} the next position(The browser needs to set cross domain and expose the x-oss-next-append-position header) example: @@ -2587,7 +2638,7 @@ console.log(result.objects); console.log(result.deleteMarker); ``` -### .signatureUrl(name[, options]) +### .signatureUrl(name[, options, strictObjectNameValidation]) Create a signature url for download or upload object. When you put object with signatureUrl ,you need to pass `Content-Type`.Please look at the example. @@ -2612,7 +2663,9 @@ parameters: - [host] {String} set the host for callback - body {String} set the body for callback - [contentType] {String} set the type for body + - [callbackSNI] {Boolean} Specifies whether OSS sends Server Name Indication (SNI) to the origin address specified by callbackUrl when a callback request is initiated from the client - [customValue] {Object} set the custom value for callback,eg. {var1: value1,var2:value2} +- [strictObjectNameValidation] {boolean} the flag of verifying object name strictly, default is true Success will return signature url. @@ -2641,13 +2694,17 @@ const url = store.signatureUrl('ossdemo.txt', { console.log(url); // -------------------------------------------------- -const url = store.signatureUrl('ossdemo.txt', { - expires: 3600, - response: { - 'content-type': 'text/custom', - 'content-disposition': 'attachment' - } -}); +const url = store.signatureUrl( + 'ossdemo.txt', + { + expires: 3600, + response: { + 'content-type': 'text/custom', + 'content-disposition': 'attachment' + } + }, + false +); console.log(url); // put operation @@ -2668,7 +2725,7 @@ const url = store.signatureUrl('ossdemo.png', { console.log(url); ``` -### .asyncSignatureUrl(name[, options]) +### .asyncSignatureUrl(name[, options, strictObjectNameValidation]) Basically the same as signatureUrl, if refreshSTSToken is configured asyncSignatureUrl will refresh stsToken @@ -2693,7 +2750,9 @@ parameters: - [host] {String} set the host for callback - body {String} set the body for callback - [contentType] {String} set the type for body + - [callbackSNI] {Boolean} Specifies whether OSS sends Server Name Indication (SNI) to the origin address specified by callbackUrl when a callback request is initiated from the client - [customValue] {Object} set the custom value for callback,eg. {var1: value1,var2:value2} +- [strictObjectNameValidation] {boolean} the flag of verifying object name strictly, default is true Success will return signature url. @@ -2719,13 +2778,17 @@ const url = await store.asyncSignatureUrl('ossdemo.txt', { }); console.log(url); // -------------------------------------------------- -const url = await store.asyncSignatureUrl('ossdemo.txt', { - expires: 3600, - response: { - 'content-type': 'text/custom', - 'content-disposition': 'attachment' - } -}); +const url = await store.asyncSignatureUrl( + 'ossdemo.txt', + { + expires: 3600, + response: { + 'content-type': 'text/custom', + 'content-disposition': 'attachment' + } + }, + false +); console.log(url); // put operation ``` @@ -2745,6 +2808,66 @@ const url = await store.asyncSignatureUrl('ossdemo.png', { console.log(url); ``` +### .signatureUrlV4(method, expires[, request, objectName, additionalHeaders]) + +Generate a signed URL for V4 of an OSS resource and share the URL to allow authorized third-party users to access the resource. + +parameters: + +- method {string} the HTTP method +- expires {number} the signed URL will expire after the set number of seconds +- [request] {Object} optional request parameters + - [headers] {Object} headers of http requests, please make sure these request headers are set during the actual request + - [queries] {Object} queries of the signed URL, please ensure that if the query only has key, the value is set to null +- [objectName] {string} object name +- [additionalHeaders] {string[]} the keys of the request headers that need to be calculated into the V4 signature, please ensure that these additional headers are included in the request headers + +Success will return signature url. + +example: + +```js +// GetObject +const getObjectUrl = await store.signatureUrlV4('GET', 60, undefined, 'your obejct name'); +console.log(getObjectUrl); +// -------------------------------------------------- +const getObjectUrl = await store.signatureUrlV4( + 'GET', + 60, + { + headers: { + 'Cache-Control': 'no-cache' + }, + queries: { + versionId: 'version ID of your object' + } + }, + 'your obejct name', + ['Cache-Control'] +); +console.log(getObjectUrl); + +// ------------------------------------------------- +// PutObject +const putObejctUrl = await store.signatureUrlV4('PUT', 60, undefined, 'your obejct name'); +console.log(putObejctUrl); +// -------------------------------------------------- +const putObejctUrl = await store.signatureUrlV4( + 'PUT', + 60, + { + headers: { + 'Content-Type': 'text/plain', + 'Content-MD5': 'xxx', + 'Content-Length': 1 + } + }, + 'your obejct name', + ['Content-Length'] +); +console.log(putObejctUrl); +``` + ### .putACL(name, acl[, options]) Set object's ACL. @@ -3154,6 +3277,7 @@ parameters: - [host] {String} The host header value for initiating callback requests. - body {String} The value of the request body when a callback is initiated, for example, key=${key}&etag=${etag}&my_var=${x:my_var}. - [contentType] {String} The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value. + - [callbackSNI] {Boolean} Specifies whether OSS sends Server Name Indication (SNI) to the origin address specified by callbackUrl when a callback request is initiated from the client. - [customValue] {Object} Custom parameters are a map of key-values
e.g.: ```js @@ -3239,6 +3363,7 @@ parameters: - [host] {String} The host header value for initiating callback requests. - body {String} The value of the request body when a callback is initiated, for example, key=${key}&etag=${etag}&my_var=${x:my_var}. - [contentType] {String} The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value. + - [callbackSNI] {Boolean} Specifies whether OSS sends Server Name Indication (SNI) to the origin address specified by callbackUrl when a callback request is initiated from the client. - [customValue] {Object} Custom parameters are a map of key-values
e.g.: ```js @@ -4565,7 +4690,29 @@ Each error return by OSS server will contains these properties: you can send this request id to OSS engineer to find out what's happend. - hostId {String} OSS cluster name for this request -The following table lists the OSS error codes: +### ResponseTimeoutError + +The default timeout is 60 seconds. Please set the timeout as needed. The timeout unit is milliseconds. + +```javascript +client.get('example.txt', { timeout: 60000 * 2 }); + +client.get('example.txt', { headers: { Range: `bytes=0-${1024 * 1024 * 100}` } }); // Download the first 100MB +``` + +### ConnectionTimeoutError + +The network link timed out. Please check the network status. If there is no problem with the network, please reduce the partSize or increase the timeout. + +```javascript +const client = new OSS({ ak, sk, retryMax: 10 }); + +client.multipartUpload('example.txt', { timeout: 60000 * 2 }); + +client.multipartUpload('example.txt', { partSize: 1024 * 512 }); // partSize 512KB +``` + +### The following table lists the OSS error codes: [More code info](https://help.aliyun.com/knowledge_detail/32005.html) diff --git a/bower.json b/bower.json deleted file mode 100644 index 59c6398ab..000000000 --- a/bower.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "ali-oss", - "ignore": ["lib", "test", ".*", "browser.js", "package.json"], - "main": "dist/aliyun-oss-sdk.js", - "version": "6.17.0" -} diff --git a/browser-build.js b/browser-build.js index 1c4480df8..adee326f6 100644 --- a/browser-build.js +++ b/browser-build.js @@ -21,7 +21,7 @@ function build(options, callback) { options = {}; } - console.error('Building with options: %j', options); + console.error('Building with options: %j %j', options, pkg.version); const verStr = `exports.version = '${pkg.version}';`; fs.writeFileSync(path.resolve(__dirname + '/lib/browser/version.js'), verStr); diff --git a/commitlint.config.js b/commitlint.config.js index 422b19445..67ecf38e2 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1 +1 @@ -module.exports = { extends: ['@commitlint/config-conventional'] }; +module.exports = { extends: ['@commitlint/config-conventional'], ignores: [message => /\[skip ci\]/m.test(message)] }; diff --git a/dist/aliyun-oss-sdk.js b/dist/aliyun-oss-sdk.js index 6670e6c16..77ebe84b5 100644 --- a/dist/aliyun-oss-sdk.js +++ b/dist/aliyun-oss-sdk.js @@ -1,53 +1,44 @@ -// Aliyun OSS SDK for JavaScript v6.17.1 +// Aliyun OSS SDK for JavaScript v6.20.0 // Copyright Aliyun.com, Inc. or its affiliates. All Rights Reserved. // License at https://github.com/ali-sdk/ali-oss/blob/master/LICENSE -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.OSS = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i\n\n' + '\n').concat(name, "\n"); - - if (prefix) { - xml += "".concat(prefix, "\n"); - } - - xml += '\n'; - params.content = xml; - params.mime = 'xml'; - params.successStatuses = [200]; - _context4.next = 9; - return this.request(params); - - case 9: - result = _context4.sent; - return _context4.abrupt("return", { - res: result.res - }); - - case 11: - case "end": - return _context4.stop(); - } + while (1) switch (_context4.prev = _context4.next) { + case 0: + params = this._bucketRequestParams('PUT', name, 'logging', options); + xml = '\n\n\n'.concat(name, "\n"); + if (prefix) { + xml += "".concat(prefix, "\n"); + } + xml += '\n'; + params.content = xml; + params.mime = 'xml'; + params.successStatuses = [200]; + _context4.next = 9; + return this.request(params); + case 9: + result = _context4.sent; + return _context4.abrupt("return", { + res: result.res + }); + case 11: + case "end": + return _context4.stop(); } }, _callee4, this); })); - function putBucketLogging(_x8, _x9, _x10) { return _putBucketLogging.apply(this, arguments); } - return putBucketLogging; }(); - proto.getBucketLogging = /*#__PURE__*/function () { var _getBucketLogging = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(name, options) { var params, result, enable; return _regenerator.default.wrap(function _callee5$(_context5) { - while (1) { - switch (_context5.prev = _context5.next) { - case 0: - params = this._bucketRequestParams('GET', name, 'logging', options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context5.next = 5; - return this.request(params); - - case 5: - result = _context5.sent; - enable = result.data.LoggingEnabled; - return _context5.abrupt("return", { - enable: !!enable, - prefix: enable && enable.TargetPrefix || null, - res: result.res - }); - - case 8: - case "end": - return _context5.stop(); - } + while (1) switch (_context5.prev = _context5.next) { + case 0: + params = this._bucketRequestParams('GET', name, 'logging', options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context5.next = 5; + return this.request(params); + case 5: + result = _context5.sent; + enable = result.data.LoggingEnabled; + return _context5.abrupt("return", { + enable: !!enable, + prefix: enable && enable.TargetPrefix || null, + res: result.res + }); + case 8: + case "end": + return _context5.stop(); } }, _callee5, this); })); - function getBucketLogging(_x11, _x12) { return _getBucketLogging.apply(this, arguments); } - return getBucketLogging; }(); - proto.deleteBucketLogging = /*#__PURE__*/function () { var _deleteBucketLogging = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(name, options) { var params, result; return _regenerator.default.wrap(function _callee6$(_context6) { - while (1) { - switch (_context6.prev = _context6.next) { - case 0: - params = this._bucketRequestParams('DELETE', name, 'logging', options); - params.successStatuses = [204, 200]; - _context6.next = 4; - return this.request(params); - - case 4: - result = _context6.sent; - return _context6.abrupt("return", { - res: result.res - }); - - case 6: - case "end": - return _context6.stop(); - } + while (1) switch (_context6.prev = _context6.next) { + case 0: + params = this._bucketRequestParams('DELETE', name, 'logging', options); + params.successStatuses = [204, 200]; + _context6.next = 4; + return this.request(params); + case 4: + result = _context6.sent; + return _context6.abrupt("return", { + res: result.res + }); + case 6: + case "end": + return _context6.stop(); } }, _callee6, this); })); - function deleteBucketLogging(_x13, _x14) { return _deleteBucketLogging.apply(this, arguments); } - return deleteBucketLogging; }(); - proto.putBucketCORS = /*#__PURE__*/function () { var _putBucketCORS = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(name, rules, options) { var params, xml, parseOrigin, parseMethod, parseHeader, parseExposeHeader, i, l, rule, result; return _regenerator.default.wrap(function _callee7$(_context7) { - while (1) { - switch (_context7.prev = _context7.next) { - case 0: - rules = rules || []; - assert(rules.length, 'rules is required'); - rules.forEach(function (rule) { - assert(rule.allowedOrigin, 'allowedOrigin is required'); - assert(rule.allowedMethod, 'allowedMethod is required'); - }); - params = this._bucketRequestParams('PUT', name, 'cors', options); - xml = '\n'; - - parseOrigin = function parseOrigin(val) { - xml += "".concat(val, ""); - }; - - parseMethod = function parseMethod(val) { - xml += "".concat(val, ""); - }; - - parseHeader = function parseHeader(val) { - xml += "".concat(val, ""); - }; - - parseExposeHeader = function parseExposeHeader(val) { - xml += "".concat(val, ""); - }; - - for (i = 0, l = rules.length; i < l; i++) { - rule = rules[i]; - xml += ''; - toArray(rule.allowedOrigin).forEach(parseOrigin); - toArray(rule.allowedMethod).forEach(parseMethod); - toArray(rule.allowedHeader).forEach(parseHeader); - toArray(rule.exposeHeader).forEach(parseExposeHeader); - - if (rule.maxAgeSeconds) { - xml += "".concat(rule.maxAgeSeconds, ""); - } - - xml += ''; + while (1) switch (_context7.prev = _context7.next) { + case 0: + rules = rules || []; + assert(rules.length, 'rules is required'); + rules.forEach(function (rule) { + assert(rule.allowedOrigin, 'allowedOrigin is required'); + assert(rule.allowedMethod, 'allowedMethod is required'); + }); + params = this._bucketRequestParams('PUT', name, 'cors', options); + xml = '\n'; + parseOrigin = function parseOrigin(val) { + xml += "".concat(val, ""); + }; + parseMethod = function parseMethod(val) { + xml += "".concat(val, ""); + }; + parseHeader = function parseHeader(val) { + xml += "".concat(val, ""); + }; + parseExposeHeader = function parseExposeHeader(val) { + xml += "".concat(val, ""); + }; + for (i = 0, l = rules.length; i < l; i++) { + rule = rules[i]; + xml += ''; + toArray(rule.allowedOrigin).forEach(parseOrigin); + toArray(rule.allowedMethod).forEach(parseMethod); + toArray(rule.allowedHeader).forEach(parseHeader); + toArray(rule.exposeHeader).forEach(parseExposeHeader); + if (rule.maxAgeSeconds) { + xml += "".concat(rule.maxAgeSeconds, ""); } - - xml += ''; - params.content = xml; - params.mime = 'xml'; - params.successStatuses = [200]; - _context7.next = 16; - return this.request(params); - - case 16: - result = _context7.sent; - return _context7.abrupt("return", { - res: result.res - }); - - case 18: - case "end": - return _context7.stop(); - } + xml += ''; + } + xml += ''; + params.content = xml; + params.mime = 'xml'; + params.successStatuses = [200]; + _context7.next = 16; + return this.request(params); + case 16: + result = _context7.sent; + return _context7.abrupt("return", { + res: result.res + }); + case 18: + case "end": + return _context7.stop(); } }, _callee7, this); })); - function putBucketCORS(_x15, _x16, _x17) { return _putBucketCORS.apply(this, arguments); } - return putBucketCORS; }(); - proto.getBucketCORS = /*#__PURE__*/function () { var _getBucketCORS = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(name, options) { var params, result, rules, CORSRule; return _regenerator.default.wrap(function _callee8$(_context8) { - while (1) { - switch (_context8.prev = _context8.next) { - case 0: - params = this._bucketRequestParams('GET', name, 'cors', options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context8.next = 5; - return this.request(params); - - case 5: - result = _context8.sent; - rules = []; - - if (result.data && result.data.CORSRule) { - CORSRule = result.data.CORSRule; - if (!isArray(CORSRule)) CORSRule = [CORSRule]; - CORSRule.forEach(function (rule) { - var r = {}; - Object.keys(rule).forEach(function (key) { - r[key.slice(0, 1).toLowerCase() + key.slice(1, key.length)] = rule[key]; - }); - rules.push(r); + while (1) switch (_context8.prev = _context8.next) { + case 0: + params = this._bucketRequestParams('GET', name, 'cors', options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context8.next = 5; + return this.request(params); + case 5: + result = _context8.sent; + rules = []; + if (result.data && result.data.CORSRule) { + CORSRule = result.data.CORSRule; + if (!isArray(CORSRule)) CORSRule = [CORSRule]; + CORSRule.forEach(function (rule) { + var r = {}; + Object.keys(rule).forEach(function (key) { + r[key.slice(0, 1).toLowerCase() + key.slice(1, key.length)] = rule[key]; }); - } - - return _context8.abrupt("return", { - rules: rules, - res: result.res + rules.push(r); }); - - case 9: - case "end": - return _context8.stop(); - } + } + return _context8.abrupt("return", { + rules: rules, + res: result.res + }); + case 9: + case "end": + return _context8.stop(); } }, _callee8, this); })); - function getBucketCORS(_x18, _x19) { return _getBucketCORS.apply(this, arguments); } - return getBucketCORS; }(); - proto.deleteBucketCORS = /*#__PURE__*/function () { var _deleteBucketCORS = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(name, options) { var params, result; return _regenerator.default.wrap(function _callee9$(_context9) { - while (1) { - switch (_context9.prev = _context9.next) { - case 0: - params = this._bucketRequestParams('DELETE', name, 'cors', options); - params.successStatuses = [204]; - _context9.next = 4; - return this.request(params); - - case 4: - result = _context9.sent; - return _context9.abrupt("return", { - res: result.res - }); - - case 6: - case "end": - return _context9.stop(); - } + while (1) switch (_context9.prev = _context9.next) { + case 0: + params = this._bucketRequestParams('DELETE', name, 'cors', options); + params.successStatuses = [204]; + _context9.next = 4; + return this.request(params); + case 4: + result = _context9.sent; + return _context9.abrupt("return", { + res: result.res + }); + case 6: + case "end": + return _context9.stop(); } }, _callee9, this); })); - function deleteBucketCORS(_x20, _x21) { return _deleteBucketCORS.apply(this, arguments); } - return deleteBucketCORS; -}(); // referer +}(); +// referer proto.putBucketReferer = /*#__PURE__*/function () { var _putBucketReferer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(name, allowEmpty, referers, options) { var params, xml, i, result; return _regenerator.default.wrap(function _callee10$(_context10) { - while (1) { - switch (_context10.prev = _context10.next) { - case 0: - params = this._bucketRequestParams('PUT', name, 'referer', options); - xml = '\n\n'; - xml += " ".concat(allowEmpty ? 'true' : 'false', "\n"); - - if (referers && referers.length > 0) { - xml += ' \n'; - - for (i = 0; i < referers.length; i++) { - xml += " ".concat(referers[i], "\n"); - } - - xml += ' \n'; - } else { - xml += ' \n'; + while (1) switch (_context10.prev = _context10.next) { + case 0: + params = this._bucketRequestParams('PUT', name, 'referer', options); + xml = '\n\n'; + xml += " ".concat(allowEmpty ? 'true' : 'false', "\n"); + if (referers && referers.length > 0) { + xml += ' \n'; + for (i = 0; i < referers.length; i++) { + xml += " ".concat(referers[i], "\n"); } - - xml += ''; - params.content = xml; - params.mime = 'xml'; - params.successStatuses = [200]; - _context10.next = 10; - return this.request(params); - - case 10: - result = _context10.sent; - return _context10.abrupt("return", { - res: result.res - }); - - case 12: - case "end": - return _context10.stop(); - } + xml += ' \n'; + } else { + xml += ' \n'; + } + xml += ''; + params.content = xml; + params.mime = 'xml'; + params.successStatuses = [200]; + _context10.next = 10; + return this.request(params); + case 10: + result = _context10.sent; + return _context10.abrupt("return", { + res: result.res + }); + case 12: + case "end": + return _context10.stop(); } }, _callee10, this); })); - function putBucketReferer(_x22, _x23, _x24, _x25) { return _putBucketReferer.apply(this, arguments); } - return putBucketReferer; }(); - proto.getBucketReferer = /*#__PURE__*/function () { var _getBucketReferer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(name, options) { var params, result, referers; return _regenerator.default.wrap(function _callee11$(_context11) { - while (1) { - switch (_context11.prev = _context11.next) { - case 0: - params = this._bucketRequestParams('GET', name, 'referer', options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context11.next = 5; - return this.request(params); - - case 5: - result = _context11.sent; - referers = result.data.RefererList.Referer || null; - - if (referers) { - if (!isArray(referers)) { - referers = [referers]; - } + while (1) switch (_context11.prev = _context11.next) { + case 0: + params = this._bucketRequestParams('GET', name, 'referer', options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context11.next = 5; + return this.request(params); + case 5: + result = _context11.sent; + referers = result.data.RefererList.Referer || null; + if (referers) { + if (!isArray(referers)) { + referers = [referers]; } - - return _context11.abrupt("return", { - allowEmpty: result.data.AllowEmptyReferer === 'true', - referers: referers, - res: result.res - }); - - case 9: - case "end": - return _context11.stop(); - } + } + return _context11.abrupt("return", { + allowEmpty: result.data.AllowEmptyReferer === 'true', + referers: referers, + res: result.res + }); + case 9: + case "end": + return _context11.stop(); } }, _callee11, this); })); - function getBucketReferer(_x26, _x27) { return _getBucketReferer.apply(this, arguments); } - return getBucketReferer; }(); - proto.deleteBucketReferer = /*#__PURE__*/function () { var _deleteBucketReferer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(name, options) { return _regenerator.default.wrap(function _callee12$(_context12) { - while (1) { - switch (_context12.prev = _context12.next) { - case 0: - _context12.next = 2; - return this.putBucketReferer(name, true, null, options); - - case 2: - return _context12.abrupt("return", _context12.sent); - - case 3: - case "end": - return _context12.stop(); - } + while (1) switch (_context12.prev = _context12.next) { + case 0: + _context12.next = 2; + return this.putBucketReferer(name, true, null, options); + case 2: + return _context12.abrupt("return", _context12.sent); + case 3: + case "end": + return _context12.stop(); } }, _callee12, this); })); - function deleteBucketReferer(_x28, _x29) { return _deleteBucketReferer.apply(this, arguments); } - return deleteBucketReferer; -}(); // private apis +}(); +// private apis proto._bucketRequestParams = function _bucketRequestParams(method, bucket, subres, options) { return { method: method, bucket: bucket, subres: subres, + additionalHeaders: options && options.additionalHeaders, timeout: options && options.timeout, ctx: options && options.ctx }; }; -},{"../common/utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"assert":78,"core-js/modules/es.array.slice.js":250,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.object.to-string.js":258,"core-js/modules/web.dom-collections.for-each.js":296}],3:[function(require,module,exports){ +},{"../common/utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"assert":95,"core-js/modules/es.array.slice.js":319,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/web.dom-collections.for-each.js":382}],3:[function(require,module,exports){ (function (Buffer,process){(function (){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - require("core-js/modules/es.function.name.js"); - -require("core-js/modules/es.regexp.exec.js"); - -require("core-js/modules/es.string.split.js"); - require("core-js/modules/es.object.assign.js"); - require("core-js/modules/es.array.includes.js"); - +require("core-js/modules/es.regexp.exec.js"); require("core-js/modules/es.string.replace.js"); - require("core-js/modules/es.array.concat.js"); - require("core-js/modules/es.symbol.js"); - require("core-js/modules/es.symbol.description.js"); - require("core-js/modules/es.array.slice.js"); - require("core-js/modules/es.object.to-string.js"); - require("core-js/modules/es.promise.js"); - require("core-js/modules/es.regexp.to-string.js"); - var debug = require('debug')('ali-oss'); - var xml = require('xml2js'); - var AgentKeepalive = require('agentkeepalive'); - var merge = require('merge-descriptors'); - var platform = require('platform'); - var utility = require('utility'); - var urllib = require('urllib'); - var pkg = require('./version'); - var bowser = require('bowser'); - var signUtils = require('../common/signUtils'); - var _initOptions = require('../common/client/initOptions'); - var _require = require('../common/utils/createRequest'), - createRequest = _require.createRequest; - + createRequest = _require.createRequest; var _require2 = require('../common/utils/encoder'), - encoder = _require2.encoder; - + encoder = _require2.encoder; var _require3 = require('../common/client/getReqUrl'), - getReqUrl = _require3.getReqUrl; - + getReqUrl = _require3.getReqUrl; var _require4 = require('../common/utils/setSTSToken'), - setSTSToken = _require4.setSTSToken; - + setSTSToken = _require4.setSTSToken; var _require5 = require('../common/utils/retry'), - retry = _require5.retry; - + retry = _require5.retry; var _require6 = require('../common/utils/isFunction'), - isFunction = _require6.isFunction; - + isFunction = _require6.isFunction; +var _require7 = require('../common/utils/getStandardRegion'), + getStandardRegion = _require7.getStandardRegion; var globalHttpAgent = new AgentKeepalive(); - function _unSupportBrowserTip() { var name = platform.name, - version = platform.version; - + version = platform.version; if (name && name.toLowerCase && name.toLowerCase() === 'ie' && version.split('.')[0] < 10) { // eslint-disable-next-line no-console console.warn('ali-oss does not support the current browser'); } -} // check local web protocol,if https secure default set true , if http secure default set false - - +} +// check local web protocol,if https secure default set true , if http secure default set false function isHttpsWebProtocol() { // for web worker not use window.location. // eslint-disable-next-line no-restricted-globals return location && location.protocol === 'https:'; } - function Client(options, ctx) { _unSupportBrowserTip(); - if (!(this instanceof Client)) { return new Client(options, ctx); } - if (options && options.inited) { this.options = options; } else { this.options = Client.initOptions(options); } - this.options.cancelFlag = false; // cancel flag: if true need to be cancelled, default false - // support custom agent and urllib client + // support custom agent and urllib client if (this.options.urllib) { this.urllib = this.options.urllib; } else { this.urllib = urllib; this.agent = this.options.agent || globalHttpAgent; } - this.ctx = ctx; this.userAgent = this._getUserAgent(); - this.stsTokenFreshTime = new Date(); // record the time difference between client and server + this.stsTokenFreshTime = new Date(); + // record the time difference between client and server this.options.amendTimeSkewed = 0; } + /** * Expose `Client` */ - module.exports = Client; - Client.initOptions = function initOptions(options) { if (!options.stsToken) { console.warn('Please use STS Token for safety, see more details at https://help.aliyun.com/document_detail/32077.html'); } - var opts = Object.assign({ secure: isHttpsWebProtocol(), // for browser compatibility disable fetch. @@ -779,74 +626,77 @@ Client.initOptions = function initOptions(options) { }, options); return _initOptions(opts); }; + /** * prototype */ +var proto = Client.prototype; -var proto = Client.prototype; // mount debug on proto - +// mount debug on proto proto.debug = debug; + /** * Object operations */ - merge(proto, require('./object')); /** * Bucket operations */ - merge(proto, require('./bucket')); merge(proto, require('../common/bucket/getBucketWebsite')); merge(proto, require('../common/bucket/putBucketWebsite')); -merge(proto, require('../common/bucket/deleteBucketWebsite')); // lifecycle +merge(proto, require('../common/bucket/deleteBucketWebsite')); +// lifecycle merge(proto, require('../common/bucket/getBucketLifecycle')); merge(proto, require('../common/bucket/putBucketLifecycle')); -merge(proto, require('../common/bucket/deleteBucketLifecycle')); // multiversion +merge(proto, require('../common/bucket/deleteBucketLifecycle')); +// multiversion merge(proto, require('../common/bucket/putBucketVersioning')); -merge(proto, require('../common/bucket/getBucketVersioning')); // inventory +merge(proto, require('../common/bucket/getBucketVersioning')); +// inventory merge(proto, require('../common/bucket/getBucketInventory')); merge(proto, require('../common/bucket/deleteBucketInventory')); merge(proto, require('../common/bucket/listBucketInventory')); -merge(proto, require('../common/bucket/putBucketInventory')); // worm +merge(proto, require('../common/bucket/putBucketInventory')); +// worm merge(proto, require('../common/bucket/abortBucketWorm')); merge(proto, require('../common/bucket/completeBucketWorm')); merge(proto, require('../common/bucket/extendBucketWorm')); merge(proto, require('../common/bucket/getBucketWorm')); -merge(proto, require('../common/bucket/initiateBucketWorm')); // multipart upload +merge(proto, require('../common/bucket/initiateBucketWorm')); +// multipart upload merge(proto, require('./managed-upload')); /** * common multipart-copy support node and browser */ - merge(proto, require('../common/multipart-copy')); /** * Multipart operations */ - merge(proto, require('../common/multipart')); + /** * Common module parallel */ - merge(proto, require('../common/parallel')); + /** * get OSS signature * @param {String} stringToSign * @return {String} the signature */ - proto.signature = function signature(stringToSign) { this.debug('authorization stringToSign: %s', stringToSign, 'info'); return signUtils.computeSignature(this.options.accessKeySecret, stringToSign, this.options.headerEncoding); }; - proto._getReqUrl = getReqUrl; + /** * get author header * @@ -875,6 +725,25 @@ proto.authorization = function authorization(method, resource, subres, headers) }); return signUtils.authorization(this.options.accessKeyId, this.options.accessKeySecret, stringToSign, this.options.headerEncoding); }; + +/** + * get authorization header v4 + * + * @param {string} method + * @param {Object} requestParams + * @param {Object} requestParams.headers + * @param {(string|string[]|Object)} [requestParams.queries] + * @param {string} [bucketName] + * @param {string} [objectName] + * @param {string[]} [additionalHeaders] + * @return {string} + * + * @api private + */ +proto.authorizationV4 = function authorizationV4(method, requestParams, bucketName, objectName, additionalHeaders) { + return signUtils.authorizationV4(this.options.accessKeyId, this.options.accessKeySecret, getStandardRegion(this.options.region), method, requestParams, bucketName, objectName, additionalHeaders, this.options.headerEncoding); +}; + /** * request oss server * @param {Object} params @@ -894,185 +763,145 @@ proto.authorization = function authorization(method, resource, subres, headers) * @api private */ - proto.request = /*#__PURE__*/function () { var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(params) { var _this = this; - return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - if (!this.options.retryMax) { - _context.next = 6; - break; - } - - _context.next = 3; - return retry(request.bind(this), this.options.retryMax, { - errorHandler: function errorHandler(err) { - var _errHandle = function _errHandle(_err) { - if (params.stream) return false; - var statusErr = [-1, -2].includes(_err.status); - - var requestErrorRetryHandle = _this.options.requestErrorRetryHandle || function () { - return true; - }; - - return statusErr && requestErrorRetryHandle(_err); + while (1) switch (_context.prev = _context.next) { + case 0: + if (!this.options.retryMax) { + _context.next = 6; + break; + } + _context.next = 3; + return retry(request.bind(this), this.options.retryMax, { + errorHandler: function errorHandler(err) { + var _errHandle = function _errHandle(_err) { + if (params.stream) return false; + var statusErr = [-1, -2].includes(_err.status); + var requestErrorRetryHandle = _this.options.requestErrorRetryHandle || function () { + return true; }; - - if (_errHandle(err)) return true; - return false; - } - })(params); - - case 3: - return _context.abrupt("return", _context.sent); - - case 6: - return _context.abrupt("return", request.call(this, params)); - - case 7: - case "end": - return _context.stop(); - } + return statusErr && requestErrorRetryHandle(_err); + }; + if (_errHandle(err)) return true; + return false; + } + })(params); + case 3: + return _context.abrupt("return", _context.sent); + case 6: + return _context.abrupt("return", request.call(this, params)); + case 7: + case "end": + return _context.stop(); } }, _callee, this); })); - return function (_x) { return _ref.apply(this, arguments); }; }(); - function request(_x2) { return _request.apply(this, arguments); } - function _request() { _request = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(params) { var reqParams, result, reqErr, useStream, err, parseData; return _regenerator.default.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - if (!(this.options.stsToken && isFunction(this.options.refreshSTSToken))) { - _context3.next = 3; - break; - } - + while (1) switch (_context3.prev = _context3.next) { + case 0: + if (!(this.options.stsToken && isFunction(this.options.refreshSTSToken))) { _context3.next = 3; - return setSTSToken.call(this); - - case 3: - reqParams = createRequest.call(this, params); - - if (!this.options.useFetch) { - reqParams.params.mode = 'disable-fetch'; - } - - useStream = !!params.stream; - _context3.prev = 6; - _context3.next = 9; - return this.urllib.request(reqParams.url, reqParams.params); - - case 9: - result = _context3.sent; - this.debug('response %s %s, got %s, headers: %j', params.method, reqParams.url, result.status, result.headers, 'info'); - _context3.next = 16; break; - - case 13: - _context3.prev = 13; - _context3.t0 = _context3["catch"](6); - reqErr = _context3.t0; - - case 16: - if (!(result && params.successStatuses && params.successStatuses.indexOf(result.status) === -1)) { - _context3.next = 28; - break; - } - - _context3.next = 19; - return this.requestError(result); - - case 19: - err = _context3.sent; - - if (!(err.code === 'RequestTimeTooSkewed' && !useStream)) { - _context3.next = 25; - break; - } - - this.options.amendTimeSkewed = +new Date(err.serverTime) - new Date(); - _context3.next = 24; - return this.request(params); - - case 24: - return _context3.abrupt("return", _context3.sent); - - case 25: - err.params = params; + } + _context3.next = 3; + return setSTSToken.call(this); + case 3: + reqParams = createRequest.call(this, params); + if (!this.options.useFetch) { + reqParams.params.mode = 'disable-fetch'; + } + useStream = !!params.stream; + _context3.prev = 6; + _context3.next = 9; + return this.urllib.request(reqParams.url, reqParams.params); + case 9: + result = _context3.sent; + this.debug('response %s %s, got %s, headers: %j', params.method, reqParams.url, result.status, result.headers, 'info'); + _context3.next = 16; + break; + case 13: + _context3.prev = 13; + _context3.t0 = _context3["catch"](6); + reqErr = _context3.t0; + case 16: + if (!(result && params.successStatuses && params.successStatuses.indexOf(result.status) === -1)) { + _context3.next = 28; + break; + } + _context3.next = 19; + return this.requestError(result); + case 19: + err = _context3.sent; + if (!(err.code === 'RequestTimeTooSkewed' && !useStream)) { + _context3.next = 25; + break; + } + this.options.amendTimeSkewed = +new Date(err.serverTime) - new Date(); + _context3.next = 24; + return this.request(params); + case 24: + return _context3.abrupt("return", _context3.sent); + case 25: + err.params = params; + _context3.next = 32; + break; + case 28: + if (!reqErr) { _context3.next = 32; break; - - case 28: - if (!reqErr) { - _context3.next = 32; - break; - } - - _context3.next = 31; - return this.requestError(reqErr); - - case 31: - err = _context3.sent; - - case 32: - if (!err) { - _context3.next = 34; - break; - } - - throw err; - - case 34: - if (!params.xmlResponse) { - _context3.next = 39; - break; - } - - _context3.next = 37; - return this.parseXML(result.data); - - case 37: - parseData = _context3.sent; - result.data = parseData; - - case 39: - return _context3.abrupt("return", result); - - case 40: - case "end": - return _context3.stop(); - } + } + _context3.next = 31; + return this.requestError(reqErr); + case 31: + err = _context3.sent; + case 32: + if (!err) { + _context3.next = 34; + break; + } + throw err; + case 34: + if (!params.xmlResponse) { + _context3.next = 39; + break; + } + _context3.next = 37; + return this.parseXML(result.data); + case 37: + parseData = _context3.sent; + result.data = parseData; + case 39: + return _context3.abrupt("return", result); + case 40: + case "end": + return _context3.stop(); } }, _callee3, this, [[6, 13]]); })); return _request.apply(this, arguments); } - proto._getResource = function _getResource(params) { var resource = '/'; if (params.bucket) resource += "".concat(params.bucket, "/"); if (params.object) resource += encoder(params.object, this.options.headerEncoding); return resource; }; - proto._escape = function _escape(name) { return utility.encodeURIComponent(name).replace(/%2F/g, '/'); }; + /* * Get User-Agent for browser & node.js * @example @@ -1081,23 +910,20 @@ proto._escape = function _escape(name) { * aliyun-sdk-js/4.1.2 Chrome 43.0.2357.134 32-bit on Windows Server 2008 R2 / 7 64-bit */ - proto._getUserAgent = function _getUserAgent() { var agent = process && process.browser ? 'js' : 'nodejs'; var sdk = "aliyun-sdk-".concat(agent, "/").concat(pkg.version); var plat = platform.description; - if (!plat && process) { plat = "Node.js ".concat(process.version.slice(1), " on ").concat(process.platform, " ").concat(process.arch); } - return this._checkUserAgent("".concat(sdk, " ").concat(plat)); }; - proto._checkUserAgent = function _checkUserAgent(ua) { var userAgent = ua.replace(/\u03b1/, 'alpha').replace(/\u03b2/, 'beta'); return userAgent; }; + /* * Check Browser And Version * @param {String} [name] browser name: like IE, Chrome, Firefox @@ -1106,10 +932,10 @@ proto._checkUserAgent = function _checkUserAgent(ua) { * @api private */ - proto.checkBrowserAndVersion = function checkBrowserAndVersion(name, version) { return bowser.name === name && bowser.version.split('.')[0] === version; }; + /** * thunkify xml.parseString * @param {String|Buffer} str @@ -1117,13 +943,11 @@ proto.checkBrowserAndVersion = function checkBrowserAndVersion(name, version) { * @api private */ - proto.parseXML = function parseXMLThunk(str) { return new Promise(function (resolve, reject) { if (Buffer.isBuffer(str)) { str = str.toString(); } - xml.parseString(str, { explicitRoot: false, explicitArray: false @@ -1136,6 +960,7 @@ proto.parseXML = function parseXMLThunk(str) { }); }); }; + /** * generater a request error with request response * @param {Object} result @@ -1143,227 +968,155 @@ proto.parseXML = function parseXMLThunk(str) { * @api private */ - proto.requestError = /*#__PURE__*/function () { var _requestError = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(result) { var err, message, info, msg; return _regenerator.default.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - err = null; - - if (!(!result.data || !result.data.length)) { - _context2.next = 5; - break; - } - - if (result.status === -1 || result.status === -2) { - // -1 is net error , -2 is timeout - err = new Error(result.message); - err.name = result.name; - err.status = result.status; - err.code = result.name; - } else { - // HEAD not exists resource - if (result.status === 404) { - err = new Error('Object not exists'); - err.name = 'NoSuchKeyError'; - err.status = 404; - err.code = 'NoSuchKey'; - } else if (result.status === 412) { - err = new Error('Pre condition failed'); - err.name = 'PreconditionFailedError'; - err.status = 412; - err.code = 'PreconditionFailed'; - } else { - err = new Error("Unknow error, status: ".concat(result.status)); - err.name = 'UnknowError'; - err.status = result.status; - } - - err.requestId = result.headers['x-oss-request-id']; - err.host = ''; - } - - _context2.next = 32; + while (1) switch (_context2.prev = _context2.next) { + case 0: + err = null; + if (!(!result.data || !result.data.length)) { + _context2.next = 5; break; - - case 5: - message = String(result.data); - this.debug('request response error data: %s', message, 'error'); - _context2.prev = 7; - _context2.next = 10; - return this.parseXML(message); - - case 10: - _context2.t0 = _context2.sent; - - if (_context2.t0) { - _context2.next = 13; - break; + } + if (result.status === -1 || result.status === -2) { + // -1 is net error , -2 is timeout + err = new Error(result.message); + err.name = result.name; + err.status = result.status; + err.code = result.name; + } else { + // HEAD not exists resource + if (result.status === 404) { + err = new Error('Object not exists'); + err.name = 'NoSuchKeyError'; + err.status = 404; + err.code = 'NoSuchKey'; + } else if (result.status === 412) { + err = new Error('Pre condition failed'); + err.name = 'PreconditionFailedError'; + err.status = 412; + err.code = 'PreconditionFailed'; + } else { + err = new Error("Unknow error, status: ".concat(result.status)); + err.name = 'UnknownError'; + err.status = result.status; } - - _context2.t0 = {}; - - case 13: - info = _context2.t0; - _context2.next = 23; + err.requestId = result.headers['x-oss-request-id']; + err.host = ''; + } + _context2.next = 32; + break; + case 5: + message = String(result.data); + this.debug('request response error data: %s', message, 'error'); + _context2.prev = 7; + _context2.next = 10; + return this.parseXML(message); + case 10: + _context2.t0 = _context2.sent; + if (_context2.t0) { + _context2.next = 13; break; - - case 16: - _context2.prev = 16; - _context2.t1 = _context2["catch"](7); - this.debug(message, 'error'); - _context2.t1.message += "\nraw xml: ".concat(message); - _context2.t1.status = result.status; - _context2.t1.requestId = result.headers['x-oss-request-id']; - return _context2.abrupt("return", _context2.t1); - - case 23: - msg = info.Message || "unknow request error, status: ".concat(result.status); - - if (info.Condition) { - msg += " (condition: ".concat(info.Condition, ")"); - } - - err = new Error(msg); - err.name = info.Code ? "".concat(info.Code, "Error") : 'UnknowError'; - err.status = result.status; - err.code = info.Code; - err.requestId = info.RequestId; - err.hostId = info.HostId; - err.serverTime = info.ServerTime; - - case 32: - this.debug('generate error %j', err, 'error'); - return _context2.abrupt("return", err); - - case 34: - case "end": - return _context2.stop(); - } + } + _context2.t0 = {}; + case 13: + info = _context2.t0; + _context2.next = 23; + break; + case 16: + _context2.prev = 16; + _context2.t1 = _context2["catch"](7); + this.debug(message, 'error'); + _context2.t1.message += "\nraw xml: ".concat(message); + _context2.t1.status = result.status; + _context2.t1.requestId = result.headers['x-oss-request-id']; + return _context2.abrupt("return", _context2.t1); + case 23: + msg = info.Message || "unknow request error, status: ".concat(result.status); + if (info.Condition) { + msg += " (condition: ".concat(info.Condition, ")"); + } + err = new Error(msg); + err.name = info.Code ? "".concat(info.Code, "Error") : 'UnknownError'; + err.status = result.status; + err.code = info.Code; + err.requestId = info.RequestId; + err.hostId = info.HostId; + err.serverTime = info.ServerTime; + case 32: + this.debug('generate error %j', err, 'error'); + return _context2.abrupt("return", err); + case 34: + case "end": + return _context2.stop(); } }, _callee2, this, [[7, 16]]); })); - function requestError(_x3) { return _requestError.apply(this, arguments); } - return requestError; }(); }).call(this)}).call(this,{"isBuffer":require("../../node_modules/is-buffer/index.js")},require('_process')) -},{"../../node_modules/is-buffer/index.js":312,"../common/bucket/abortBucketWorm":7,"../common/bucket/completeBucketWorm":8,"../common/bucket/deleteBucketInventory":9,"../common/bucket/deleteBucketLifecycle":10,"../common/bucket/deleteBucketWebsite":11,"../common/bucket/extendBucketWorm":12,"../common/bucket/getBucketInventory":13,"../common/bucket/getBucketLifecycle":14,"../common/bucket/getBucketVersioning":15,"../common/bucket/getBucketWebsite":16,"../common/bucket/getBucketWorm":17,"../common/bucket/initiateBucketWorm":18,"../common/bucket/listBucketInventory":19,"../common/bucket/putBucketInventory":20,"../common/bucket/putBucketLifecycle":21,"../common/bucket/putBucketVersioning":22,"../common/bucket/putBucketWebsite":23,"../common/client/getReqUrl":25,"../common/client/initOptions":26,"../common/multipart":30,"../common/multipart-copy":29,"../common/parallel":48,"../common/signUtils":49,"../common/utils/createRequest":54,"../common/utils/encoder":57,"../common/utils/isFunction":65,"../common/utils/retry":70,"../common/utils/setSTSToken":72,"./bucket":2,"./managed-upload":4,"./object":5,"./version":6,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"_process":399,"agentkeepalive":77,"bowser":83,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.array.includes.js":246,"core-js/modules/es.array.slice.js":250,"core-js/modules/es.function.name.js":253,"core-js/modules/es.object.assign.js":255,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.promise.js":259,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.regexp.to-string.js":262,"core-js/modules/es.string.replace.js":266,"core-js/modules/es.string.split.js":268,"core-js/modules/es.symbol.description.js":270,"core-js/modules/es.symbol.js":271,"debug":397,"merge-descriptors":315,"platform":322,"urllib":407,"utility":406,"xml2js":358}],4:[function(require,module,exports){ +},{"../../node_modules/is-buffer/index.js":411,"../common/bucket/abortBucketWorm":7,"../common/bucket/completeBucketWorm":8,"../common/bucket/deleteBucketInventory":9,"../common/bucket/deleteBucketLifecycle":10,"../common/bucket/deleteBucketWebsite":11,"../common/bucket/extendBucketWorm":12,"../common/bucket/getBucketInventory":13,"../common/bucket/getBucketLifecycle":14,"../common/bucket/getBucketVersioning":15,"../common/bucket/getBucketWebsite":16,"../common/bucket/getBucketWorm":17,"../common/bucket/initiateBucketWorm":18,"../common/bucket/listBucketInventory":19,"../common/bucket/putBucketInventory":20,"../common/bucket/putBucketLifecycle":21,"../common/bucket/putBucketVersioning":22,"../common/bucket/putBucketWebsite":23,"../common/client/getReqUrl":25,"../common/client/initOptions":26,"../common/multipart":30,"../common/multipart-copy":29,"../common/parallel":50,"../common/signUtils":51,"../common/utils/createRequest":57,"../common/utils/encoder":61,"../common/utils/getStandardRegion":64,"../common/utils/isFunction":71,"../common/utils/retry":77,"../common/utils/setSTSToken":79,"./bucket":2,"./managed-upload":4,"./object":5,"./version":6,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"_process":540,"agentkeepalive":94,"bowser":101,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.includes.js":315,"core-js/modules/es.array.slice.js":319,"core-js/modules/es.function.name.js":322,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.promise.js":335,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.string.replace.js":347,"core-js/modules/es.symbol.description.js":353,"core-js/modules/es.symbol.js":356,"debug":538,"merge-descriptors":430,"platform":442,"urllib":548,"utility":547,"xml2js":498}],4:[function(require,module,exports){ (function (Buffer){(function (){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.function.name.js"); - require("core-js/modules/es.object.to-string.js"); - require("core-js/modules/es.promise.js"); - require("core-js/modules/es.array.from.js"); - require("core-js/modules/es.string.iterator.js"); - require("core-js/modules/es.array.map.js"); - require("core-js/modules/es.array.filter.js"); - require("core-js/modules/es.array.find.js"); - require("core-js/modules/es.array.concat.js"); - require("core-js/modules/es.regexp.to-string.js"); - require("core-js/modules/es.array.slice.js"); - require("core-js/modules/es.array.iterator.js"); - require("core-js/modules/es.array-buffer.slice.js"); - require("core-js/modules/es.typed-array.uint8-array.js"); - require("core-js/modules/es.typed-array.copy-within.js"); - require("core-js/modules/es.typed-array.every.js"); - require("core-js/modules/es.typed-array.fill.js"); - require("core-js/modules/es.typed-array.filter.js"); - require("core-js/modules/es.typed-array.find.js"); - require("core-js/modules/es.typed-array.find-index.js"); - require("core-js/modules/es.typed-array.for-each.js"); - require("core-js/modules/es.typed-array.includes.js"); - require("core-js/modules/es.typed-array.index-of.js"); - require("core-js/modules/es.typed-array.iterator.js"); - require("core-js/modules/es.typed-array.join.js"); - require("core-js/modules/es.typed-array.last-index-of.js"); - require("core-js/modules/es.typed-array.map.js"); - require("core-js/modules/es.typed-array.reduce.js"); - require("core-js/modules/es.typed-array.reduce-right.js"); - require("core-js/modules/es.typed-array.reverse.js"); - require("core-js/modules/es.typed-array.set.js"); - require("core-js/modules/es.typed-array.slice.js"); - require("core-js/modules/es.typed-array.some.js"); - require("core-js/modules/es.typed-array.sort.js"); - require("core-js/modules/es.typed-array.subarray.js"); - require("core-js/modules/es.typed-array.to-locale-string.js"); - require("core-js/modules/es.typed-array.to-string.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - // var debug = require('debug')('ali-oss:multipart'); var util = require('util'); - var path = require('path'); - var mime = require('mime'); - var copy = require('copy-to'); - var _require = require('../common/utils/isBlob'), - isBlob = _require.isBlob; - + isBlob = _require.isBlob; var _require2 = require('../common/utils/isFile'), - isFile = _require2.isFile; - -var _require3 = require('../common/utils/isArray'), - isArray = _require3.isArray; - -var _require4 = require('../common/utils/isBuffer'), - isBuffer = _require4.isBuffer; - -var _require5 = require('../common/utils/retry'), - retry = _require5.retry; - + isFile = _require2.isFile; +var _require3 = require('../common/utils/isBuffer'), + isBuffer = _require3.isBuffer; var proto = exports; + /** * Multipart operations */ @@ -1384,450 +1137,355 @@ var proto = exports; * key2: 'value2' * } */ - proto.multipartUpload = /*#__PURE__*/function () { var _multipartUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, file) { var options, - minPartSize, - fileSize, - result, - ret, - initResult, - uploadId, - partSize, - checkpoint, - _args = arguments; + minPartSize, + fileSize, + result, + ret, + initResult, + uploadId, + partSize, + checkpoint, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; - this.resetCancelFlag(); - options.disabledMD5 = options.disabledMD5 === undefined ? true : !!options.disabledMD5; - - if (!(options.checkpoint && options.checkpoint.uploadId)) { - _context.next = 8; - break; - } - - if (file && isFile(file)) options.checkpoint.file = file; - _context.next = 7; - return this._resumeMultipart(options.checkpoint, options); - - case 7: - return _context.abrupt("return", _context.sent); - - case 8: - minPartSize = 100 * 1024; - - if (!options.mime) { - if (isFile(file)) { - options.mime = mime.getType(path.extname(file.name)); - } else if (isBlob(file)) { - options.mime = file.type; - } else if (isBuffer(file)) { - options.mime = ''; - } else { - options.mime = mime.getType(path.extname(file)); - } - } - - options.headers = options.headers || {}; - - this._convertMetaToHeaders(options.meta, options.headers); - - _context.next = 14; - return this._getFileSize(file); - - case 14: - fileSize = _context.sent; - - if (!(fileSize < minPartSize)) { - _context.next = 26; - break; - } - - options.contentLength = fileSize; - _context.next = 19; - return this.put(name, file, options); - - case 19: - result = _context.sent; - - if (!(options && options.progress)) { - _context.next = 23; - break; + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; + this.resetCancelFlag(); + options.disabledMD5 = options.disabledMD5 === undefined ? true : !!options.disabledMD5; + if (!(options.checkpoint && options.checkpoint.uploadId)) { + _context.next = 8; + break; + } + if (file && isFile(file)) options.checkpoint.file = file; + _context.next = 7; + return this._resumeMultipart(options.checkpoint, options); + case 7: + return _context.abrupt("return", _context.sent); + case 8: + minPartSize = 100 * 1024; + if (!options.mime) { + if (isFile(file)) { + options.mime = mime.getType(path.extname(file.name)); + } else if (isBlob(file)) { + options.mime = file.type; + } else if (isBuffer(file)) { + options.mime = ''; + } else { + options.mime = mime.getType(path.extname(file)); } - + } + options.headers = options.headers || {}; + this._convertMetaToHeaders(options.meta, options.headers); + _context.next = 14; + return this._getFileSize(file); + case 14: + fileSize = _context.sent; + if (!(fileSize < minPartSize)) { + _context.next = 26; + break; + } + options.contentLength = fileSize; + _context.next = 19; + return this.put(name, file, options); + case 19: + result = _context.sent; + if (!(options && options.progress)) { _context.next = 23; - return options.progress(1); - - case 23: - ret = { - res: result.res, - bucket: this.options.bucket, - name: name, - etag: result.res.headers.etag - }; - - if (options.headers && options.headers['x-oss-callback'] || options.callback) { - ret.data = result.data; - } - - return _context.abrupt("return", ret); - - case 26: - if (!(options.partSize && !(parseInt(options.partSize, 10) === options.partSize))) { - _context.next = 28; - break; - } - - throw new Error('partSize must be int number'); - - case 28: - if (!(options.partSize && options.partSize < minPartSize)) { - _context.next = 30; - break; - } - - throw new Error("partSize must not be smaller than ".concat(minPartSize)); - - case 30: - _context.next = 32; - return this.initMultipartUpload(name, options); - - case 32: - initResult = _context.sent; - uploadId = initResult.uploadId; - partSize = this._getPartSize(fileSize, options.partSize); - checkpoint = { - file: file, - name: name, - fileSize: fileSize, - partSize: partSize, - uploadId: uploadId, - doneParts: [] - }; - - if (!(options && options.progress)) { - _context.next = 39; - break; - } - + break; + } + _context.next = 23; + return options.progress(1); + case 23: + ret = { + res: result.res, + bucket: this.options.bucket, + name: name, + etag: result.res.headers.etag + }; + if (options.headers && options.headers['x-oss-callback'] || options.callback) { + ret.data = result.data; + } + return _context.abrupt("return", ret); + case 26: + if (!(options.partSize && !(parseInt(options.partSize, 10) === options.partSize))) { + _context.next = 28; + break; + } + throw new Error('partSize must be int number'); + case 28: + if (!(options.partSize && options.partSize < minPartSize)) { + _context.next = 30; + break; + } + throw new Error("partSize must not be smaller than ".concat(minPartSize)); + case 30: + _context.next = 32; + return this.initMultipartUpload(name, options); + case 32: + initResult = _context.sent; + uploadId = initResult.uploadId; + partSize = this._getPartSize(fileSize, options.partSize); + checkpoint = { + file: file, + name: name, + fileSize: fileSize, + partSize: partSize, + uploadId: uploadId, + doneParts: [] + }; + if (!(options && options.progress)) { _context.next = 39; - return options.progress(0, checkpoint, initResult.res); - - case 39: - _context.next = 41; - return this._resumeMultipart(checkpoint, options); - - case 41: - return _context.abrupt("return", _context.sent); - - case 42: - case "end": - return _context.stop(); - } + break; + } + _context.next = 39; + return options.progress(0, checkpoint, initResult.res); + case 39: + _context.next = 41; + return this._resumeMultipart(checkpoint, options); + case 41: + return _context.abrupt("return", _context.sent); + case 42: + case "end": + return _context.stop(); } }, _callee, this); })); - function multipartUpload(_x, _x2) { return _multipartUpload.apply(this, arguments); } - return multipartUpload; }(); + /* * Resume multipart upload from checkpoint. The checkpoint will be * updated after each successful part upload. * @param {Object} checkpoint the checkpoint * @param {Object} options */ - - proto._resumeMultipart = /*#__PURE__*/function () { var _resumeMultipart2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(checkpoint, options) { var that, file, fileSize, partSize, uploadId, doneParts, name, internalDoneParts, partOffs, numParts, multipartFinish, uploadPartJob, all, done, todo, defaultParallel, parallel, jobErr, abortEvent; return _regenerator.default.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - that = this; - - if (!this.isCancel()) { - _context3.next = 3; - break; - } - - throw this._makeCancelEvent(); - - case 3: - file = checkpoint.file, fileSize = checkpoint.fileSize, partSize = checkpoint.partSize, uploadId = checkpoint.uploadId, doneParts = checkpoint.doneParts, name = checkpoint.name; - internalDoneParts = []; - - if (doneParts.length > 0) { - copy(doneParts).to(internalDoneParts); - } - - partOffs = this._divideParts(fileSize, partSize); - numParts = partOffs.length; - multipartFinish = false; - - uploadPartJob = function uploadPartJob(self, partNo) { - // eslint-disable-next-line no-async-promise-executor - return new Promise( /*#__PURE__*/function () { - var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resolve, reject) { - var pi, content, data, result, tempErr; - return _regenerator.default.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - _context2.prev = 0; - - if (self.isCancel()) { - _context2.next = 29; - break; - } - - pi = partOffs[partNo - 1]; - _context2.next = 5; - return self._createBuffer(file, pi.start, pi.end); - - case 5: - content = _context2.sent; - data = { - content: content, - size: pi.end - pi.start - }; - _context2.prev = 7; - _context2.next = 10; - return self._uploadPart(name, uploadId, partNo, data, { - timeout: options.timeout, - disabledMD5: options.disabledMD5 - }); - - case 10: - result = _context2.sent; - _context2.next = 18; - break; - - case 13: - _context2.prev = 13; - _context2.t0 = _context2["catch"](7); - - if (!(_context2.t0.status === 404)) { - _context2.next = 17; - break; - } - - throw self._makeAbortEvent(); - - case 17: - throw _context2.t0; - - case 18: - if (!(!self.isCancel() && !multipartFinish)) { - _context2.next = 26; - break; - } - - checkpoint.doneParts.push({ - number: partNo, - etag: result.res.headers.etag - }); - - if (!options.progress) { - _context2.next = 23; - break; - } - - _context2.next = 23; - return options.progress(doneParts.length / numParts, checkpoint, result.res); - - case 23: - resolve({ - number: partNo, - etag: result.res.headers.etag - }); - _context2.next = 27; - break; - - case 26: - resolve(); - - case 27: - _context2.next = 30; - break; - - case 29: - resolve(); - - case 30: - _context2.next = 41; - break; - - case 32: - _context2.prev = 32; - _context2.t1 = _context2["catch"](0); - tempErr = new Error(); - tempErr.name = _context2.t1.name; - tempErr.message = _context2.t1.message; - tempErr.stack = _context2.t1.stack; - tempErr.partNum = partNo; - copy(_context2.t1).to(tempErr); - reject(tempErr); - - case 41: - case "end": - return _context2.stop(); + while (1) switch (_context3.prev = _context3.next) { + case 0: + that = this; + if (!this.isCancel()) { + _context3.next = 3; + break; + } + throw this._makeCancelEvent(); + case 3: + file = checkpoint.file, fileSize = checkpoint.fileSize, partSize = checkpoint.partSize, uploadId = checkpoint.uploadId, doneParts = checkpoint.doneParts, name = checkpoint.name; + internalDoneParts = []; + if (doneParts.length > 0) { + copy(doneParts).to(internalDoneParts); + } + partOffs = this._divideParts(fileSize, partSize); + numParts = partOffs.length; + multipartFinish = false; + uploadPartJob = function uploadPartJob(self, partNo) { + // eslint-disable-next-line no-async-promise-executor + return new Promise( /*#__PURE__*/function () { + var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(resolve, reject) { + var pi, content, data, result, tempErr; + return _regenerator.default.wrap(function _callee2$(_context2) { + while (1) switch (_context2.prev = _context2.next) { + case 0: + _context2.prev = 0; + if (self.isCancel()) { + _context2.next = 29; + break; } - } - }, _callee2, null, [[0, 32], [7, 13]]); - })); - - return function (_x5, _x6) { - return _ref.apply(this, arguments); - }; - }()); - }; - - all = Array.from(new Array(numParts), function (x, i) { - return i + 1; - }); - done = internalDoneParts.map(function (p) { - return p.number; - }); - todo = all.filter(function (p) { - return done.indexOf(p) < 0; - }); - defaultParallel = 5; - parallel = options.parallel || defaultParallel; // upload in parallel - - _context3.next = 17; - return this._parallel(todo, parallel, function (value) { - return new Promise(function (resolve, reject) { - uploadPartJob(that, value).then(function (result) { - if (result) { - internalDoneParts.push(result); - } - - resolve(); - }).catch(function (err) { - reject(err); - }); + pi = partOffs[partNo - 1]; + _context2.next = 5; + return self._createBuffer(file, pi.start, pi.end); + case 5: + content = _context2.sent; + data = { + content: content, + size: pi.end - pi.start + }; + _context2.prev = 7; + _context2.next = 10; + return self._uploadPart(name, uploadId, partNo, data, options); + case 10: + result = _context2.sent; + _context2.next = 18; + break; + case 13: + _context2.prev = 13; + _context2.t0 = _context2["catch"](7); + if (!(_context2.t0.status === 404)) { + _context2.next = 17; + break; + } + throw self._makeAbortEvent(); + case 17: + throw _context2.t0; + case 18: + if (!(!self.isCancel() && !multipartFinish)) { + _context2.next = 26; + break; + } + checkpoint.doneParts.push({ + number: partNo, + etag: result.res.headers.etag + }); + if (!options.progress) { + _context2.next = 23; + break; + } + _context2.next = 23; + return options.progress(doneParts.length / (numParts + 1), checkpoint, result.res); + case 23: + resolve({ + number: partNo, + etag: result.res.headers.etag + }); + _context2.next = 27; + break; + case 26: + resolve(); + case 27: + _context2.next = 30; + break; + case 29: + resolve(); + case 30: + _context2.next = 41; + break; + case 32: + _context2.prev = 32; + _context2.t1 = _context2["catch"](0); + tempErr = new Error(); + tempErr.name = _context2.t1.name; + tempErr.message = _context2.t1.message; + tempErr.stack = _context2.t1.stack; + tempErr.partNum = partNo; + copy(_context2.t1).to(tempErr); + reject(tempErr); + case 41: + case "end": + return _context2.stop(); + } + }, _callee2, null, [[0, 32], [7, 13]]); + })); + return function (_x5, _x6) { + return _ref.apply(this, arguments); + }; + }()); + }; + all = Array.from(new Array(numParts), function (x, i) { + return i + 1; + }); + done = internalDoneParts.map(function (p) { + return p.number; + }); + todo = all.filter(function (p) { + return done.indexOf(p) < 0; + }); + defaultParallel = 5; + parallel = options.parallel || defaultParallel; // upload in parallel + _context3.next = 17; + return this._parallel(todo, parallel, function (value) { + return new Promise(function (resolve, reject) { + uploadPartJob(that, value).then(function (result) { + if (result) { + internalDoneParts.push(result); + } + resolve(); + }).catch(function (err) { + reject(err); }); }); - - case 17: - jobErr = _context3.sent; - multipartFinish = true; - abortEvent = jobErr.find(function (err) { - return err.name === 'abort'; - }); - - if (!abortEvent) { - _context3.next = 22; - break; - } - - throw abortEvent; - - case 22: - if (!this.isCancel()) { - _context3.next = 25; - break; - } - - uploadPartJob = null; - throw this._makeCancelEvent(); - - case 25: - if (!(jobErr && jobErr.length > 0)) { - _context3.next = 28; - break; - } - - jobErr[0].message = "Failed to upload some parts with error: ".concat(jobErr[0].toString(), " part_num: ").concat(jobErr[0].partNum); - throw jobErr[0]; - - case 28: - _context3.next = 30; - return this.completeMultipartUpload(name, uploadId, internalDoneParts, options); - - case 30: - return _context3.abrupt("return", _context3.sent); - - case 31: - case "end": - return _context3.stop(); - } + }); + case 17: + jobErr = _context3.sent; + multipartFinish = true; + abortEvent = jobErr.find(function (err) { + return err.name === 'abort'; + }); + if (!abortEvent) { + _context3.next = 22; + break; + } + throw abortEvent; + case 22: + if (!this.isCancel()) { + _context3.next = 25; + break; + } + uploadPartJob = null; + throw this._makeCancelEvent(); + case 25: + if (!(jobErr && jobErr.length > 0)) { + _context3.next = 28; + break; + } + jobErr[0].message = "Failed to upload some parts with error: ".concat(jobErr[0].toString(), " part_num: ").concat(jobErr[0].partNum); + throw jobErr[0]; + case 28: + _context3.next = 30; + return this.completeMultipartUpload(name, uploadId, internalDoneParts, options); + case 30: + return _context3.abrupt("return", _context3.sent); + case 31: + case "end": + return _context3.stop(); } }, _callee3, this); })); - function _resumeMultipart(_x3, _x4) { return _resumeMultipart2.apply(this, arguments); } - return _resumeMultipart; }(); + /** * Get file size */ - - proto._getFileSize = /*#__PURE__*/function () { var _getFileSize2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(file) { return _regenerator.default.wrap(function _callee4$(_context4) { - while (1) { - switch (_context4.prev = _context4.next) { - case 0: - if (!isBuffer(file)) { - _context4.next = 4; - break; - } - - return _context4.abrupt("return", file.length); - - case 4: - if (!(isBlob(file) || isFile(file))) { - _context4.next = 6; - break; - } - - return _context4.abrupt("return", file.size); - - case 6: - throw new Error('_getFileSize requires Buffer/File/Blob.'); - - case 7: - case "end": - return _context4.stop(); - } + while (1) switch (_context4.prev = _context4.next) { + case 0: + if (!isBuffer(file)) { + _context4.next = 4; + break; + } + return _context4.abrupt("return", file.length); + case 4: + if (!(isBlob(file) || isFile(file))) { + _context4.next = 6; + break; + } + return _context4.abrupt("return", file.size); + case 6: + throw new Error('_getFileSize requires Buffer/File/Blob.'); + case 7: + case "end": + return _context4.stop(); } }, _callee4); })); - function _getFileSize(_x7) { return _getFileSize2.apply(this, arguments); } - return _getFileSize; }(); + /* * Readable stream for Web File */ - - -var _require6 = require('stream'), - Readable = _require6.Readable; - +var _require4 = require('stream'), + Readable = _require4.Readable; function WebFileReadStream(file, options) { if (!(this instanceof WebFileReadStream)) { return new WebFileReadStream(file, options); } - Readable.call(this, options); this.file = file; this.reader = new FileReader(); @@ -1835,13 +1493,10 @@ function WebFileReadStream(file, options) { this.finish = false; this.fileBuffer = null; } - util.inherits(WebFileReadStream, Readable); - WebFileReadStream.prototype.readFileAndPush = function readFileAndPush(size) { if (this.fileBuffer) { var pushRet = true; - while (pushRet && this.fileBuffer && this.start < this.fileBuffer.length) { var start = this.start; var end = start + size; @@ -1851,118 +1506,92 @@ WebFileReadStream.prototype.readFileAndPush = function readFileAndPush(size) { } } }; - WebFileReadStream.prototype._read = function _read(size) { if (this.file && this.start >= this.file.size || this.fileBuffer && this.start >= this.fileBuffer.length || this.finish || this.start === 0 && !this.file) { if (!this.finish) { this.fileBuffer = null; this.finish = true; } - this.push(null); return; } - var defaultReadSize = 16 * 1024; size = size || defaultReadSize; var that = this; - this.reader.onload = function onload(e) { that.fileBuffer = Buffer.from(new Uint8Array(e.target.result)); that.file = null; that.readFileAndPush(size); }; - if (this.start === 0) { this.reader.readAsArrayBuffer(this.file); } else { this.readFileAndPush(size); } }; - function getBuffer(file) { // Some browsers do not support Blob.prototype.arrayBuffer, such as IE if (file.arrayBuffer) return file.arrayBuffer(); return new Promise(function (resolve, reject) { var reader = new FileReader(); - reader.onload = function (e) { resolve(e.target.result); }; - reader.onerror = function (e) { reject(e); }; - reader.readAsArrayBuffer(file); }); } - proto._createBuffer = /*#__PURE__*/function () { var _createBuffer2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(file, start, end) { var _file, fileContent; - return _regenerator.default.wrap(function _callee5$(_context5) { - while (1) { - switch (_context5.prev = _context5.next) { - case 0: - if (!(isBlob(file) || isFile(file))) { - _context5.next = 8; - break; - } - - _file = file.slice(start, end); - _context5.next = 4; - return getBuffer(_file); - - case 4: - fileContent = _context5.sent; - return _context5.abrupt("return", Buffer.from(fileContent)); - - case 8: - if (!isBuffer(file)) { - _context5.next = 12; - break; - } - - return _context5.abrupt("return", file.subarray(start, end)); - - case 12: - throw new Error('_createBuffer requires File/Blob/Buffer.'); - - case 13: - case "end": - return _context5.stop(); - } + while (1) switch (_context5.prev = _context5.next) { + case 0: + if (!(isBlob(file) || isFile(file))) { + _context5.next = 8; + break; + } + _file = file.slice(start, end); + _context5.next = 4; + return getBuffer(_file); + case 4: + fileContent = _context5.sent; + return _context5.abrupt("return", Buffer.from(fileContent)); + case 8: + if (!isBuffer(file)) { + _context5.next = 12; + break; + } + return _context5.abrupt("return", file.subarray(start, end)); + case 12: + throw new Error('_createBuffer requires File/Blob/Buffer.'); + case 13: + case "end": + return _context5.stop(); } }, _callee5); })); - function _createBuffer(_x8, _x9, _x10) { return _createBuffer2.apply(this, arguments); } - return _createBuffer; }(); - proto._getPartSize = function _getPartSize(fileSize, partSize) { var maxNumParts = 10 * 1000; var defaultPartSize = 1 * 1024 * 1024; if (!partSize) partSize = defaultPartSize; var safeSize = Math.ceil(fileSize / maxNumParts); - if (partSize < safeSize) { partSize = safeSize; console.warn("partSize has been set to ".concat(partSize, ", because the partSize you provided causes partNumber to be greater than 10,000")); } - return partSize; }; - proto._divideParts = function _divideParts(fileSize, partSize) { var numParts = Math.ceil(fileSize / partSize); var partOffs = []; - for (var i = 0; i < numParts; i++) { var start = partSize * i; var end = Math.min(start + partSize, fileSize); @@ -1971,69 +1600,47 @@ proto._divideParts = function _divideParts(fileSize, partSize) { end: end }); } - return partOffs; }; }).call(this)}).call(this,require("buffer").Buffer) -},{"../common/utils/isArray":61,"../common/utils/isBlob":62,"../common/utils/isBuffer":63,"../common/utils/isFile":64,"../common/utils/retry":70,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"buffer":85,"copy-to":88,"core-js/modules/es.array-buffer.slice.js":240,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.array.filter.js":243,"core-js/modules/es.array.find.js":244,"core-js/modules/es.array.from.js":245,"core-js/modules/es.array.iterator.js":247,"core-js/modules/es.array.map.js":249,"core-js/modules/es.array.slice.js":250,"core-js/modules/es.function.name.js":253,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.promise.js":259,"core-js/modules/es.regexp.to-string.js":262,"core-js/modules/es.string.iterator.js":264,"core-js/modules/es.typed-array.copy-within.js":272,"core-js/modules/es.typed-array.every.js":273,"core-js/modules/es.typed-array.fill.js":274,"core-js/modules/es.typed-array.filter.js":275,"core-js/modules/es.typed-array.find-index.js":276,"core-js/modules/es.typed-array.find.js":277,"core-js/modules/es.typed-array.for-each.js":278,"core-js/modules/es.typed-array.includes.js":279,"core-js/modules/es.typed-array.index-of.js":280,"core-js/modules/es.typed-array.iterator.js":281,"core-js/modules/es.typed-array.join.js":282,"core-js/modules/es.typed-array.last-index-of.js":283,"core-js/modules/es.typed-array.map.js":284,"core-js/modules/es.typed-array.reduce-right.js":285,"core-js/modules/es.typed-array.reduce.js":286,"core-js/modules/es.typed-array.reverse.js":287,"core-js/modules/es.typed-array.set.js":288,"core-js/modules/es.typed-array.slice.js":289,"core-js/modules/es.typed-array.some.js":290,"core-js/modules/es.typed-array.sort.js":291,"core-js/modules/es.typed-array.subarray.js":292,"core-js/modules/es.typed-array.to-locale-string.js":293,"core-js/modules/es.typed-array.to-string.js":294,"core-js/modules/es.typed-array.uint8-array.js":295,"mime":317,"path":321,"stream":345,"util":352}],5:[function(require,module,exports){ +},{"../common/utils/isBlob":67,"../common/utils/isBuffer":68,"../common/utils/isFile":70,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"buffer":103,"copy-to":107,"core-js/modules/es.array-buffer.slice.js":309,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.filter.js":312,"core-js/modules/es.array.find.js":313,"core-js/modules/es.array.from.js":314,"core-js/modules/es.array.iterator.js":316,"core-js/modules/es.array.map.js":318,"core-js/modules/es.array.slice.js":319,"core-js/modules/es.function.name.js":322,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.promise.js":335,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.string.iterator.js":345,"core-js/modules/es.typed-array.copy-within.js":358,"core-js/modules/es.typed-array.every.js":359,"core-js/modules/es.typed-array.fill.js":360,"core-js/modules/es.typed-array.filter.js":361,"core-js/modules/es.typed-array.find-index.js":362,"core-js/modules/es.typed-array.find.js":363,"core-js/modules/es.typed-array.for-each.js":364,"core-js/modules/es.typed-array.includes.js":365,"core-js/modules/es.typed-array.index-of.js":366,"core-js/modules/es.typed-array.iterator.js":367,"core-js/modules/es.typed-array.join.js":368,"core-js/modules/es.typed-array.last-index-of.js":369,"core-js/modules/es.typed-array.map.js":370,"core-js/modules/es.typed-array.reduce-right.js":371,"core-js/modules/es.typed-array.reduce.js":372,"core-js/modules/es.typed-array.reverse.js":373,"core-js/modules/es.typed-array.set.js":374,"core-js/modules/es.typed-array.slice.js":375,"core-js/modules/es.typed-array.some.js":376,"core-js/modules/es.typed-array.sort.js":377,"core-js/modules/es.typed-array.subarray.js":378,"core-js/modules/es.typed-array.to-locale-string.js":379,"core-js/modules/es.typed-array.to-string.js":380,"core-js/modules/es.typed-array.uint8-array.js":381,"mime":432,"path":441,"stream":470,"util":491}],5:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - require("core-js/modules/es.function.name.js"); - +require("core-js/modules/es.object.keys.js"); require("core-js/modules/es.object.to-string.js"); - require("core-js/modules/es.regexp.to-string.js"); - require("core-js/modules/es.array.map.js"); - require("core-js/modules/es.number.constructor.js"); - require("core-js/modules/es.object.assign.js"); - require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - require("core-js/modules/web.dom-collections.for-each.js"); - -require("core-js/modules/es.object.keys.js"); - require("core-js/modules/es.promise.js"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - // const debug = require('debug')('ali-oss:object'); var fs = require('fs'); - var copy = require('copy-to'); - var path = require('path'); - var mime = require('mime'); - var callback = require('../common/callback'); - var merge = require('merge-descriptors'); - var _require = require('../common/utils/isBlob'), - isBlob = _require.isBlob; - + isBlob = _require.isBlob; var _require2 = require('../common/utils/isFile'), - isFile = _require2.isFile; - + isFile = _require2.isFile; var _require3 = require('../common/utils/isBuffer'), - isBuffer = _require3.isBuffer; - + isBuffer = _require3.isBuffer; var _require4 = require('../common/utils/obj2xml'), - obj2xml = _require4.obj2xml; // var assert = require('assert'); + obj2xml = _require4.obj2xml; +// var assert = require('assert'); var proto = exports; + /** * Object operations */ @@ -2045,43 +1652,37 @@ var proto = exports; * @param {Object} options * @return {Object} */ - proto.append = /*#__PURE__*/function () { var _append = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, file, options) { var result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = options || {}; - if (options.position === undefined) options.position = '0'; - options.subres = { - append: '', - position: options.position - }; - options.method = 'POST'; - _context.next = 6; - return this.put(name, file, options); - - case 6: - result = _context.sent; - result.nextAppendPosition = result.res.headers['x-oss-next-append-position']; - return _context.abrupt("return", result); - - case 9: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = options || {}; + if (options.position === undefined) options.position = '0'; + options.subres = { + append: '', + position: options.position + }; + options.method = 'POST'; + _context.next = 6; + return this.put(name, file, options); + case 6: + result = _context.sent; + result.nextAppendPosition = result.res.headers['x-oss-next-append-position']; + return _context.abrupt("return", result); + case 9: + case "end": + return _context.stop(); } }, _callee, this); })); - function append(_x, _x2, _x3) { return _append.apply(this, arguments); } - return append; }(); + /** * put an object from String(file path)/Buffer/ReadableStream * @param {String} name the object key @@ -2099,100 +1700,81 @@ proto.append = /*#__PURE__*/function () { * } * @return {Object} */ - - proto.put = /*#__PURE__*/function () { var _put = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name, file, options) { var content, method, params, result, ret; return _regenerator.default.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - options = options || {}; - options.disabledMD5 = options.disabledMD5 === undefined ? true : !!options.disabledMD5; - options.headers = options.headers || {}; - name = this._objectName(name); - - if (!isBuffer(file)) { - _context2.next = 8; - break; - } - - content = file; - _context2.next = 19; + while (1) switch (_context2.prev = _context2.next) { + case 0: + options = options || {}; + options.disabledMD5 = options.disabledMD5 === undefined ? true : !!options.disabledMD5; + options.headers = options.headers || {}; + name = this._objectName(name); + if (!isBuffer(file)) { + _context2.next = 8; break; - - case 8: - if (!(isBlob(file) || isFile(file))) { - _context2.next = 18; - break; - } - - if (!options.mime) { - if (isFile(file)) { - options.mime = mime.getType(path.extname(file.name)); - } else { - options.mime = file.type; - } - } - - _context2.next = 12; - return this._createBuffer(file, 0, file.size); - - case 12: - content = _context2.sent; - _context2.next = 15; - return this._getFileSize(file); - - case 15: - options.contentLength = _context2.sent; - _context2.next = 19; + } + content = file; + _context2.next = 19; + break; + case 8: + if (!(isBlob(file) || isFile(file))) { + _context2.next = 18; break; - - case 18: - throw new TypeError('Must provide Buffer/Blob/File for put.'); - - case 19: - this._convertMetaToHeaders(options.meta, options.headers); - - method = options.method || 'PUT'; - params = this._objectRequestParams(method, name, options); - callback.encodeCallback(params, options); - params.mime = options.mime; - params.disabledMD5 = options.disabledMD5; - params.content = content; - params.successStatuses = [200]; - _context2.next = 29; - return this.request(params); - - case 29: - result = _context2.sent; - ret = { - name: name, - url: this._objectUrl(name), - res: result.res - }; - - if (params.headers && params.headers['x-oss-callback']) { - ret.data = JSON.parse(result.data.toString()); + } + if (!options.mime) { + if (isFile(file)) { + options.mime = mime.getType(path.extname(file.name)); + } else { + options.mime = file.type; } - - return _context2.abrupt("return", ret); - - case 33: - case "end": - return _context2.stop(); - } + } + _context2.next = 12; + return this._createBuffer(file, 0, file.size); + case 12: + content = _context2.sent; + _context2.next = 15; + return this._getFileSize(file); + case 15: + options.contentLength = _context2.sent; + _context2.next = 19; + break; + case 18: + throw new TypeError('Must provide Buffer/Blob/File for put.'); + case 19: + this._convertMetaToHeaders(options.meta, options.headers); + method = options.method || 'PUT'; + params = this._objectRequestParams(method, name, options); + callback.encodeCallback(params, options); + params.mime = options.mime; + params.disabledMD5 = options.disabledMD5; + params.content = content; + params.successStatuses = [200]; + _context2.next = 29; + return this.request(params); + case 29: + result = _context2.sent; + ret = { + name: name, + url: this._objectUrl(name), + res: result.res + }; + if (params.headers && params.headers['x-oss-callback']) { + ret.data = JSON.parse(result.data.toString()); + } + return _context2.abrupt("return", ret); + case 33: + case "end": + return _context2.stop(); } }, _callee2, this); })); - function put(_x4, _x5, _x6) { return _put.apply(this, arguments); } - return put; }(); + /** * put an object from ReadableStream. If `options.contentLength` is * not provided, chunked encoding is used. @@ -2201,65 +1783,51 @@ proto.put = /*#__PURE__*/function () { * @param {Object} options * @return {Object} */ - - proto.putStream = /*#__PURE__*/function () { var _putStream = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name, stream, options) { var method, params, result, ret; return _regenerator.default.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - options = options || {}; - options.headers = options.headers || {}; - name = this._objectName(name); - - if (options.contentLength) { - options.headers['Content-Length'] = options.contentLength; - } else { - options.headers['Transfer-Encoding'] = 'chunked'; - } - - this._convertMetaToHeaders(options.meta, options.headers); - - method = options.method || 'PUT'; - params = this._objectRequestParams(method, name, options); - callback.encodeCallback(params, options); - params.mime = options.mime; - params.stream = stream; - params.successStatuses = [200]; - _context3.next = 13; - return this.request(params); - - case 13: - result = _context3.sent; - ret = { - name: name, - url: this._objectUrl(name), - res: result.res - }; - - if (params.headers && params.headers['x-oss-callback']) { - ret.data = JSON.parse(result.data.toString()); - } - - return _context3.abrupt("return", ret); - - case 17: - case "end": - return _context3.stop(); - } + while (1) switch (_context3.prev = _context3.next) { + case 0: + options = options || {}; + options.headers = options.headers || {}; + name = this._objectName(name); + if (options.contentLength) { + options.headers['Content-Length'] = options.contentLength; + } else { + options.headers['Transfer-Encoding'] = 'chunked'; + } + this._convertMetaToHeaders(options.meta, options.headers); + method = options.method || 'PUT'; + params = this._objectRequestParams(method, name, options); + callback.encodeCallback(params, options); + params.mime = options.mime; + params.stream = stream; + params.successStatuses = [200]; + _context3.next = 13; + return this.request(params); + case 13: + result = _context3.sent; + ret = { + name: name, + url: this._objectUrl(name), + res: result.res + }; + if (params.headers && params.headers['x-oss-callback']) { + ret.data = JSON.parse(result.data.toString()); + } + return _context3.abrupt("return", ret); + case 17: + case "end": + return _context3.stop(); } }, _callee3, this); })); - function putStream(_x7, _x8, _x9) { return _putStream.apply(this, arguments); } - return putStream; }(); - merge(proto, require('../common/object/copyObject')); merge(proto, require('../common/object/getObjectTagging')); merge(proto, require('../common/object/putObjectTagging')); @@ -2278,293 +1846,253 @@ merge(proto, require('../common/object/getObjectMeta')); merge(proto, require('../common/object/getObjectUrl')); merge(proto, require('../common/object/generateObjectUrl')); merge(proto, require('../common/object/signatureUrl')); - +merge(proto, require('../common/object/asyncSignatureUrl')); +merge(proto, require('../common/object/signatureUrlV4')); proto.putMeta = /*#__PURE__*/function () { var _putMeta = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(name, meta, options) { var copyResult; return _regenerator.default.wrap(function _callee4$(_context4) { - while (1) { - switch (_context4.prev = _context4.next) { - case 0: - _context4.next = 2; - return this.copy(name, name, { - meta: meta || {}, - timeout: options && options.timeout, - ctx: options && options.ctx - }); - - case 2: - copyResult = _context4.sent; - return _context4.abrupt("return", copyResult); - - case 4: - case "end": - return _context4.stop(); - } + while (1) switch (_context4.prev = _context4.next) { + case 0: + _context4.next = 2; + return this.copy(name, name, { + meta: meta || {}, + timeout: options && options.timeout, + ctx: options && options.ctx + }); + case 2: + copyResult = _context4.sent; + return _context4.abrupt("return", copyResult); + case 4: + case "end": + return _context4.stop(); } }, _callee4, this); })); - function putMeta(_x10, _x11, _x12) { return _putMeta.apply(this, arguments); } - return putMeta; }(); - proto.list = /*#__PURE__*/function () { var _list = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(query, options) { var params, result, objects, that, prefixes; return _regenerator.default.wrap(function _callee5$(_context5) { - while (1) { - switch (_context5.prev = _context5.next) { - case 0: - // prefix, marker, max-keys, delimiter - params = this._objectRequestParams('GET', '', options); - params.query = query; - params.xmlResponse = true; - params.successStatuses = [200]; - _context5.next = 6; - return this.request(params); - - case 6: - result = _context5.sent; - objects = result.data.Contents || []; - that = this; - - if (objects) { - if (!Array.isArray(objects)) { - objects = [objects]; - } - - objects = objects.map(function (obj) { - return { - name: obj.Key, - url: that._objectUrl(obj.Key), - lastModified: obj.LastModified, - etag: obj.ETag, - type: obj.Type, - size: Number(obj.Size), - storageClass: obj.StorageClass, - owner: { - id: obj.Owner.ID, - displayName: obj.Owner.DisplayName - } - }; - }); + while (1) switch (_context5.prev = _context5.next) { + case 0: + // prefix, marker, max-keys, delimiter + params = this._objectRequestParams('GET', '', options); + params.query = query; + params.xmlResponse = true; + params.successStatuses = [200]; + _context5.next = 6; + return this.request(params); + case 6: + result = _context5.sent; + objects = result.data.Contents || []; + that = this; + if (objects) { + if (!Array.isArray(objects)) { + objects = [objects]; } - - prefixes = result.data.CommonPrefixes || null; - - if (prefixes) { - if (!Array.isArray(prefixes)) { - prefixes = [prefixes]; - } - - prefixes = prefixes.map(function (item) { - return item.Prefix; - }); + objects = objects.map(function (obj) { + return { + name: obj.Key, + url: that._objectUrl(obj.Key), + lastModified: obj.LastModified, + etag: obj.ETag, + type: obj.Type, + size: Number(obj.Size), + storageClass: obj.StorageClass, + owner: { + id: obj.Owner.ID, + displayName: obj.Owner.DisplayName + } + }; + }); + } + prefixes = result.data.CommonPrefixes || null; + if (prefixes) { + if (!Array.isArray(prefixes)) { + prefixes = [prefixes]; } - - return _context5.abrupt("return", { - res: result.res, - objects: objects, - prefixes: prefixes, - nextMarker: result.data.NextMarker || null, - isTruncated: result.data.IsTruncated === 'true' + prefixes = prefixes.map(function (item) { + return item.Prefix; }); - - case 13: - case "end": - return _context5.stop(); - } + } + return _context5.abrupt("return", { + res: result.res, + objects: objects, + prefixes: prefixes, + nextMarker: result.data.NextMarker || null, + isTruncated: result.data.IsTruncated === 'true' + }); + case 13: + case "end": + return _context5.stop(); } }, _callee5, this); })); - function list(_x13, _x14) { return _list.apply(this, arguments); } - return list; }(); - proto.listV2 = /*#__PURE__*/function () { var _listV = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(query) { var options, - continuation_token, - params, - result, - objects, - that, - prefixes, - _args6 = arguments; + continuation_token, + params, + result, + objects, + that, + prefixes, + _args6 = arguments; return _regenerator.default.wrap(function _callee6$(_context6) { - while (1) { - switch (_context6.prev = _context6.next) { - case 0: - options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {}; - continuation_token = query['continuation-token'] || query.continuationToken; - - if (continuation_token) { - options.subres = Object.assign({ - 'continuation-token': continuation_token - }, options.subres); + while (1) switch (_context6.prev = _context6.next) { + case 0: + options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {}; + continuation_token = query['continuation-token'] || query.continuationToken; + if (continuation_token) { + options.subres = Object.assign({ + 'continuation-token': continuation_token + }, options.subres); + } + params = this._objectRequestParams('GET', '', options); + params.query = Object.assign({ + 'list-type': 2 + }, query); + delete params.query['continuation-token']; + delete params.query.continuationToken; + params.xmlResponse = true; + params.successStatuses = [200]; + _context6.next = 11; + return this.request(params); + case 11: + result = _context6.sent; + objects = result.data.Contents || []; + that = this; + if (objects) { + if (!Array.isArray(objects)) { + objects = [objects]; } - - params = this._objectRequestParams('GET', '', options); - params.query = Object.assign({ - 'list-type': 2 - }, query); - delete params.query['continuation-token']; - delete params.query.continuationToken; - params.xmlResponse = true; - params.successStatuses = [200]; - _context6.next = 11; - return this.request(params); - - case 11: - result = _context6.sent; - objects = result.data.Contents || []; - that = this; - - if (objects) { - if (!Array.isArray(objects)) { - objects = [objects]; - } - - objects = objects.map(function (obj) { - return { - name: obj.Key, - url: that._objectUrl(obj.Key), - lastModified: obj.LastModified, - etag: obj.ETag, - type: obj.Type, - size: Number(obj.Size), - storageClass: obj.StorageClass, - owner: obj.Owner ? { - id: obj.Owner.ID, - displayName: obj.Owner.DisplayName - } : null + objects = objects.map(function (obj) { + var owner = null; + if (obj.Owner) { + owner = { + id: obj.Owner.ID, + displayName: obj.Owner.DisplayName }; - }); - } - - prefixes = result.data.CommonPrefixes || null; - - if (prefixes) { - if (!Array.isArray(prefixes)) { - prefixes = [prefixes]; } - - prefixes = prefixes.map(function (item) { - return item.Prefix; - }); + return { + name: obj.Key, + url: that._objectUrl(obj.Key), + lastModified: obj.LastModified, + etag: obj.ETag, + type: obj.Type, + size: Number(obj.Size), + storageClass: obj.StorageClass, + owner: owner + }; + }); + } + prefixes = result.data.CommonPrefixes || null; + if (prefixes) { + if (!Array.isArray(prefixes)) { + prefixes = [prefixes]; } - - return _context6.abrupt("return", { - res: result.res, - objects: objects, - prefixes: prefixes, - isTruncated: result.data.IsTruncated === 'true', - keyCount: +result.data.KeyCount, - continuationToken: result.data.ContinuationToken || null, - nextContinuationToken: result.data.NextContinuationToken || null + prefixes = prefixes.map(function (item) { + return item.Prefix; }); - - case 18: - case "end": - return _context6.stop(); - } + } + return _context6.abrupt("return", { + res: result.res, + objects: objects, + prefixes: prefixes, + isTruncated: result.data.IsTruncated === 'true', + keyCount: +result.data.KeyCount, + continuationToken: result.data.ContinuationToken || null, + nextContinuationToken: result.data.NextContinuationToken || null + }); + case 18: + case "end": + return _context6.stop(); } }, _callee6, this); })); - function listV2(_x15) { return _listV.apply(this, arguments); } - return listV2; }(); + /** * Restore Object * @param {String} name the object key * @param {Object} options * @returns {{res}} */ - - proto.restore = /*#__PURE__*/function () { var _restore = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(name) { var options, - params, - paramsXMLObj, - result, - _args7 = arguments; + params, + paramsXMLObj, + result, + _args7 = arguments; return _regenerator.default.wrap(function _callee7$(_context7) { - while (1) { - switch (_context7.prev = _context7.next) { - case 0: - options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : { - type: 'Archive' - }; - options = options || {}; - options.subres = Object.assign({ - restore: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - params = this._objectRequestParams('POST', name, options); - - if (options.type === 'ColdArchive') { - paramsXMLObj = { - RestoreRequest: { - Days: options.Days ? options.Days : 2, - JobParameters: { - Tier: options.JobParameters ? options.JobParameters : 'Standard' - } + while (1) switch (_context7.prev = _context7.next) { + case 0: + options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : { + type: 'Archive' + }; + options = options || {}; + options.subres = Object.assign({ + restore: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + params = this._objectRequestParams('POST', name, options); + if (options.type === 'ColdArchive') { + paramsXMLObj = { + RestoreRequest: { + Days: options.Days ? options.Days : 2, + JobParameters: { + Tier: options.JobParameters ? options.JobParameters : 'Standard' } - }; - params.content = obj2xml(paramsXMLObj, { - headers: true - }); - params.mime = 'xml'; - } - - params.successStatuses = [202]; - _context7.next = 9; - return this.request(params); - - case 9: - result = _context7.sent; - return _context7.abrupt("return", { - res: result.res + } + }; + params.content = obj2xml(paramsXMLObj, { + headers: true }); - - case 11: - case "end": - return _context7.stop(); - } + params.mime = 'xml'; + } + params.successStatuses = [202]; + _context7.next = 9; + return this.request(params); + case 9: + result = _context7.sent; + return _context7.abrupt("return", { + res: result.res + }); + case 11: + case "end": + return _context7.stop(); } }, _callee7, this); })); - function restore(_x16) { return _restore.apply(this, arguments); } - return restore; }(); - proto._objectUrl = function _objectUrl(name) { return this._getReqUrl({ bucket: this.options.bucket, object: name }); }; + /** * generator request params * @return {Object} params @@ -2572,12 +2100,10 @@ proto._objectUrl = function _objectUrl(name) { * @api private */ - proto._objectRequestParams = function _objectRequestParams(method, name, options) { if (!this.options.bucket && !this.options.cname) { throw new Error('Please create a bucket first'); } - options = options || {}; name = this._objectName(name); var params = { @@ -2585,35 +2111,29 @@ proto._objectRequestParams = function _objectRequestParams(method, name, options bucket: this.options.bucket, method: method, subres: options && options.subres, + additionalHeaders: options && options.additionalHeaders, timeout: options && options.timeout, ctx: options && options.ctx }; - if (options.headers) { params.headers = {}; copy(options.headers).to(params.headers); } - return params; }; - proto._objectName = function _objectName(name) { return name.replace(/^\/+/, ''); }; - proto._convertMetaToHeaders = function _convertMetaToHeaders(meta, headers) { if (!meta) { return; } - Object.keys(meta).forEach(function (k) { headers["x-oss-meta-".concat(k)] = meta[k]; }); }; - proto._deleteFileSafe = function _deleteFileSafe(filepath) { var _this = this; - return new Promise(function (resolve) { fs.exists(filepath, function (exists) { if (!exists) { @@ -2623,7 +2143,6 @@ proto._deleteFileSafe = function _deleteFileSafe(filepath) { if (err) { _this.debug('unlink %j error: %s', filepath, err, 'error'); } - resolve(); }); } @@ -2631,131 +2150,104 @@ proto._deleteFileSafe = function _deleteFileSafe(filepath) { }); }; -},{"../common/callback":24,"../common/image":27,"../common/object/copyObject":31,"../common/object/delete":32,"../common/object/deleteMulti":33,"../common/object/deleteObjectTagging":34,"../common/object/generateObjectUrl":35,"../common/object/get":36,"../common/object/getACL":37,"../common/object/getBucketVersions":38,"../common/object/getObjectMeta":39,"../common/object/getObjectTagging":40,"../common/object/getObjectUrl":41,"../common/object/getSymlink":42,"../common/object/head":43,"../common/object/putACL":44,"../common/object/putObjectTagging":45,"../common/object/putSymlink":46,"../common/object/signatureUrl":47,"../common/utils/isBlob":62,"../common/utils/isBuffer":63,"../common/utils/isFile":64,"../common/utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"copy-to":88,"core-js/modules/es.array.map.js":249,"core-js/modules/es.function.name.js":253,"core-js/modules/es.number.constructor.js":254,"core-js/modules/es.object.assign.js":255,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.promise.js":259,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.regexp.to-string.js":262,"core-js/modules/es.string.replace.js":266,"core-js/modules/web.dom-collections.for-each.js":296,"fs":84,"merge-descriptors":315,"mime":317,"path":321}],6:[function(require,module,exports){ +},{"../common/callback":24,"../common/image":27,"../common/object/asyncSignatureUrl":31,"../common/object/copyObject":32,"../common/object/delete":33,"../common/object/deleteMulti":34,"../common/object/deleteObjectTagging":35,"../common/object/generateObjectUrl":36,"../common/object/get":37,"../common/object/getACL":38,"../common/object/getBucketVersions":39,"../common/object/getObjectMeta":40,"../common/object/getObjectTagging":41,"../common/object/getObjectUrl":42,"../common/object/getSymlink":43,"../common/object/head":44,"../common/object/putACL":45,"../common/object/putObjectTagging":46,"../common/object/putSymlink":47,"../common/object/signatureUrl":48,"../common/object/signatureUrlV4":49,"../common/utils/isBlob":67,"../common/utils/isBuffer":68,"../common/utils/isFile":70,"../common/utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"copy-to":107,"core-js/modules/es.array.map.js":318,"core-js/modules/es.function.name.js":322,"core-js/modules/es.number.constructor.js":324,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.promise.js":335,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.string.replace.js":347,"core-js/modules/web.dom-collections.for-each.js":382,"fs":102,"merge-descriptors":430,"mime":432,"path":441}],6:[function(require,module,exports){ "use strict"; -exports.version = "6.17.1"; +exports.version = '6.20.0'; },{}],7:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.abortBucketWorm = void 0; - var checkBucketName_1 = require("../utils/checkBucketName"); - function abortBucketWorm(_x, _x2) { return _abortBucketWorm.apply(this, arguments); } - function _abortBucketWorm() { _abortBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) { var params, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - checkBucketName_1.checkBucketName(name); - params = this._bucketRequestParams('DELETE', name, 'worm', options); - _context.next = 4; - return this.request(params); - - case 4: - result = _context.sent; - return _context.abrupt("return", { - res: result.res, - status: result.status - }); - - case 6: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + checkBucketName_1.checkBucketName(name); + params = this._bucketRequestParams('DELETE', name, 'worm', options); + _context.next = 4; + return this.request(params); + case 4: + result = _context.sent; + return _context.abrupt("return", { + res: result.res, + status: result.status + }); + case 6: + case "end": + return _context.stop(); } }, _callee, this); })); return _abortBucketWorm.apply(this, arguments); } - exports.abortBucketWorm = abortBucketWorm; -},{"../utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],8:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],8:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.completeBucketWorm = void 0; - var checkBucketName_1 = require("../utils/checkBucketName"); - function completeBucketWorm(_x, _x2, _x3) { return _completeBucketWorm.apply(this, arguments); } - function _completeBucketWorm() { _completeBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, wormId, options) { var params, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - checkBucketName_1.checkBucketName(name); - params = this._bucketRequestParams('POST', name, { - wormId: wormId - }, options); - _context.next = 4; - return this.request(params); - - case 4: - result = _context.sent; - return _context.abrupt("return", { - res: result.res, - status: result.status - }); - - case 6: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + checkBucketName_1.checkBucketName(name); + params = this._bucketRequestParams('POST', name, { + wormId: wormId + }, options); + _context.next = 4; + return this.request(params); + case 4: + result = _context.sent; + return _context.abrupt("return", { + res: result.res, + status: result.status + }); + case 6: + case "end": + return _context.stop(); } }, _callee, this); })); return _completeBucketWorm.apply(this, arguments); } - exports.completeBucketWorm = completeBucketWorm; -},{"../utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],9:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],9:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.deleteBucketInventory = void 0; - var checkBucketName_1 = require("../utils/checkBucketName"); /** * deleteBucketInventory @@ -2763,235 +2255,185 @@ var checkBucketName_1 = require("../utils/checkBucketName"); * @param {String} inventoryId * @param {Object} options */ - - function deleteBucketInventory(_x, _x2) { return _deleteBucketInventory.apply(this, arguments); } - function _deleteBucketInventory() { _deleteBucketInventory = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName, inventoryId) { var options, - subres, - params, - result, - _args = arguments; + subres, + params, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; - subres = Object.assign({ - inventory: '', - inventoryId: inventoryId - }, options.subres); - checkBucketName_1.checkBucketName(bucketName); - params = this._bucketRequestParams('DELETE', bucketName, subres, options); - params.successStatuses = [204]; - _context.next = 7; - return this.request(params); - - case 7: - result = _context.sent; - return _context.abrupt("return", { - status: result.status, - res: result.res - }); - - case 9: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; + subres = Object.assign({ + inventory: '', + inventoryId: inventoryId + }, options.subres); + checkBucketName_1.checkBucketName(bucketName); + params = this._bucketRequestParams('DELETE', bucketName, subres, options); + params.successStatuses = [204]; + _context.next = 7; + return this.request(params); + case 7: + result = _context.sent; + return _context.abrupt("return", { + status: result.status, + res: result.res + }); + case 9: + case "end": + return _context.stop(); } }, _callee, this); })); return _deleteBucketInventory.apply(this, arguments); } - exports.deleteBucketInventory = deleteBucketInventory; -},{"../utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],10:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],10:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var proto = exports; - proto.deleteBucketLifecycle = /*#__PURE__*/function () { var _deleteBucketLifecycle = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) { var params, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _checkBucketName(name); - - params = this._bucketRequestParams('DELETE', name, 'lifecycle', options); - params.successStatuses = [204]; - _context.next = 5; - return this.request(params); - - case 5: - result = _context.sent; - return _context.abrupt("return", { - res: result.res - }); - - case 7: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + _checkBucketName(name); + params = this._bucketRequestParams('DELETE', name, 'lifecycle', options); + params.successStatuses = [204]; + _context.next = 5; + return this.request(params); + case 5: + result = _context.sent; + return _context.abrupt("return", { + res: result.res + }); + case 7: + case "end": + return _context.stop(); } }, _callee, this); })); - function deleteBucketLifecycle(_x, _x2) { return _deleteBucketLifecycle.apply(this, arguments); } - return deleteBucketLifecycle; }(); -},{"../utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],11:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],11:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var proto = exports; - proto.deleteBucketWebsite = /*#__PURE__*/function () { var _deleteBucketWebsite = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) { var params, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _checkBucketName(name); - - params = this._bucketRequestParams('DELETE', name, 'website', options); - params.successStatuses = [204]; - _context.next = 5; - return this.request(params); - - case 5: - result = _context.sent; - return _context.abrupt("return", { - res: result.res - }); - - case 7: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + _checkBucketName(name); + params = this._bucketRequestParams('DELETE', name, 'website', options); + params.successStatuses = [204]; + _context.next = 5; + return this.request(params); + case 5: + result = _context.sent; + return _context.abrupt("return", { + res: result.res + }); + case 7: + case "end": + return _context.stop(); } }, _callee, this); })); - function deleteBucketWebsite(_x, _x2) { return _deleteBucketWebsite.apply(this, arguments); } - return deleteBucketWebsite; }(); -},{"../utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],12:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],12:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.extendBucketWorm = void 0; - var checkBucketName_1 = require("../utils/checkBucketName"); - var obj2xml_1 = require("../utils/obj2xml"); - function extendBucketWorm(_x, _x2, _x3, _x4) { return _extendBucketWorm.apply(this, arguments); } - function _extendBucketWorm() { _extendBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, wormId, days, options) { var params, paramlXMLObJ, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - checkBucketName_1.checkBucketName(name); - params = this._bucketRequestParams('POST', name, { - wormExtend: '', - wormId: wormId - }, options); - paramlXMLObJ = { - ExtendWormConfiguration: { - RetentionPeriodInDays: days - } - }; - params.mime = 'xml'; - params.content = obj2xml_1.obj2xml(paramlXMLObJ, { - headers: true - }); - params.successStatuses = [200]; - _context.next = 8; - return this.request(params); - - case 8: - result = _context.sent; - return _context.abrupt("return", { - res: result.res, - status: result.status - }); - - case 10: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + checkBucketName_1.checkBucketName(name); + params = this._bucketRequestParams('POST', name, { + wormExtend: '', + wormId: wormId + }, options); + paramlXMLObJ = { + ExtendWormConfiguration: { + RetentionPeriodInDays: days + } + }; + params.mime = 'xml'; + params.content = obj2xml_1.obj2xml(paramlXMLObJ, { + headers: true + }); + params.successStatuses = [200]; + _context.next = 8; + return this.request(params); + case 8: + result = _context.sent; + return _context.abrupt("return", { + res: result.res, + status: result.status + }); + case 10: + case "end": + return _context.stop(); } }, _callee, this); })); return _extendBucketWorm.apply(this, arguments); } - exports.extendBucketWorm = extendBucketWorm; -},{"../utils/checkBucketName":50,"../utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],13:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],13:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.getBucketInventory = void 0; - var checkBucketName_1 = require("../utils/checkBucketName"); - var formatInventoryConfig_1 = require("../utils/formatInventoryConfig"); /** * getBucketInventory @@ -2999,147 +2441,115 @@ var formatInventoryConfig_1 = require("../utils/formatInventoryConfig"); * @param {String} inventoryId * @param {Object} options */ - - function getBucketInventory(_x, _x2) { return _getBucketInventory.apply(this, arguments); } - function _getBucketInventory() { _getBucketInventory = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName, inventoryId) { var options, - subres, - params, - result, - _args = arguments; + subres, + params, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; - subres = Object.assign({ - inventory: '', - inventoryId: inventoryId - }, options.subres); - checkBucketName_1.checkBucketName(bucketName); - params = this._bucketRequestParams('GET', bucketName, subres, options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context.next = 8; - return this.request(params); - - case 8: - result = _context.sent; - return _context.abrupt("return", { - status: result.status, - res: result.res, - inventory: formatInventoryConfig_1.formatInventoryConfig(result.data) - }); - - case 10: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; + subres = Object.assign({ + inventory: '', + inventoryId: inventoryId + }, options.subres); + checkBucketName_1.checkBucketName(bucketName); + params = this._bucketRequestParams('GET', bucketName, subres, options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context.next = 8; + return this.request(params); + case 8: + result = _context.sent; + return _context.abrupt("return", { + status: result.status, + res: result.res, + inventory: formatInventoryConfig_1.formatInventoryConfig(result.data) + }); + case 10: + case "end": + return _context.stop(); } }, _callee, this); })); return _getBucketInventory.apply(this, arguments); } - exports.getBucketInventory = getBucketInventory; -},{"../utils/checkBucketName":50,"../utils/formatInventoryConfig":58,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],14:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/formatInventoryConfig":62,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],14:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.array.map.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var _require2 = require('../utils/isArray'), - isArray = _require2.isArray; - + isArray = _require2.isArray; var _require3 = require('../utils/formatObjKey'), - formatObjKey = _require3.formatObjKey; - + formatObjKey = _require3.formatObjKey; var proto = exports; - proto.getBucketLifecycle = /*#__PURE__*/function () { var _getBucketLifecycle = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) { var params, result, rules; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _checkBucketName(name); - - params = this._bucketRequestParams('GET', name, 'lifecycle', options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context.next = 6; - return this.request(params); - - case 6: - result = _context.sent; - rules = result.data.Rule || null; - - if (rules) { - if (!isArray(rules)) { - rules = [rules]; - } - - rules = rules.map(function (_) { - if (_.ID) { - _.id = _.ID; - delete _.ID; - } - - if (_.Tag && !isArray(_.Tag)) { - _.Tag = [_.Tag]; - } - - return formatObjKey(_, 'firstLowerCase'); - }); + while (1) switch (_context.prev = _context.next) { + case 0: + _checkBucketName(name); + params = this._bucketRequestParams('GET', name, 'lifecycle', options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context.next = 6; + return this.request(params); + case 6: + result = _context.sent; + rules = result.data.Rule || null; + if (rules) { + if (!isArray(rules)) { + rules = [rules]; } - - return _context.abrupt("return", { - rules: rules, - res: result.res + rules = rules.map(function (_) { + if (_.ID) { + _.id = _.ID; + delete _.ID; + } + if (_.Tag && !isArray(_.Tag)) { + _.Tag = [_.Tag]; + } + return formatObjKey(_, 'firstLowerCase'); }); - - case 10: - case "end": - return _context.stop(); - } + } + return _context.abrupt("return", { + rules: rules, + res: result.res + }); + case 10: + case "end": + return _context.stop(); } }, _callee, this); })); - function getBucketLifecycle(_x, _x2) { return _getBucketLifecycle.apply(this, arguments); } - return getBucketLifecycle; }(); -},{"../utils/checkBucketName":50,"../utils/formatObjKey":59,"../utils/isArray":61,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.map.js":249}],15:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/formatObjKey":63,"../utils/isArray":66,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.map.js":318}],15:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var proto = exports; /** * getBucketVersioning @@ -3150,254 +2560,201 @@ proto.getBucketVersioning = /*#__PURE__*/function () { var _getBucketVersioning = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName, options) { var params, result, versionStatus; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _checkBucketName(bucketName); - - params = this._bucketRequestParams('GET', bucketName, 'versioning', options); - params.xmlResponse = true; - params.successStatuses = [200]; - _context.next = 6; - return this.request(params); - - case 6: - result = _context.sent; - versionStatus = result.data.Status; - return _context.abrupt("return", { - status: result.status, - versionStatus: versionStatus, - res: result.res - }); - - case 9: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + _checkBucketName(bucketName); + params = this._bucketRequestParams('GET', bucketName, 'versioning', options); + params.xmlResponse = true; + params.successStatuses = [200]; + _context.next = 6; + return this.request(params); + case 6: + result = _context.sent; + versionStatus = result.data.Status; + return _context.abrupt("return", { + status: result.status, + versionStatus: versionStatus, + res: result.res + }); + case 9: + case "end": + return _context.stop(); } }, _callee, this); })); - function getBucketVersioning(_x, _x2) { return _getBucketVersioning.apply(this, arguments); } - return getBucketVersioning; }(); -},{"../utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],16:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],16:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var _require2 = require('../utils/isObject'), - isObject = _require2.isObject; - + isObject = _require2.isObject; var proto = exports; - proto.getBucketWebsite = /*#__PURE__*/function () { var _getBucketWebsite = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) { var params, result, routingRules; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _checkBucketName(name); - - params = this._bucketRequestParams('GET', name, 'website', options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context.next = 6; - return this.request(params); - - case 6: - result = _context.sent; - routingRules = []; - - if (result.data.RoutingRules && result.data.RoutingRules.RoutingRule) { - if (isObject(result.data.RoutingRules.RoutingRule)) { - routingRules = [result.data.RoutingRules.RoutingRule]; - } else { - routingRules = result.data.RoutingRules.RoutingRule; - } + while (1) switch (_context.prev = _context.next) { + case 0: + _checkBucketName(name); + params = this._bucketRequestParams('GET', name, 'website', options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context.next = 6; + return this.request(params); + case 6: + result = _context.sent; + routingRules = []; + if (result.data.RoutingRules && result.data.RoutingRules.RoutingRule) { + if (isObject(result.data.RoutingRules.RoutingRule)) { + routingRules = [result.data.RoutingRules.RoutingRule]; + } else { + routingRules = result.data.RoutingRules.RoutingRule; } - - return _context.abrupt("return", { - index: result.data.IndexDocument && result.data.IndexDocument.Suffix || '', - supportSubDir: result.data.IndexDocument && result.data.IndexDocument.SupportSubDir || 'false', - type: result.data.IndexDocument && result.data.IndexDocument.Type, - routingRules: routingRules, - error: result.data.ErrorDocument && result.data.ErrorDocument.Key || null, - res: result.res - }); - - case 10: - case "end": - return _context.stop(); - } + } + return _context.abrupt("return", { + index: result.data.IndexDocument && result.data.IndexDocument.Suffix || '', + supportSubDir: result.data.IndexDocument && result.data.IndexDocument.SupportSubDir || 'false', + type: result.data.IndexDocument && result.data.IndexDocument.Type, + routingRules: routingRules, + error: result.data.ErrorDocument && result.data.ErrorDocument.Key || null, + res: result.res + }); + case 10: + case "end": + return _context.stop(); } }, _callee, this); })); - function getBucketWebsite(_x, _x2) { return _getBucketWebsite.apply(this, arguments); } - return getBucketWebsite; }(); -},{"../utils/checkBucketName":50,"../utils/isObject":67,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],17:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/isObject":73,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],17:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.getBucketWorm = void 0; - var checkBucketName_1 = require("../utils/checkBucketName"); - var dataFix_1 = require("../utils/dataFix"); - function getBucketWorm(_x, _x2) { return _getBucketWorm.apply(this, arguments); } - function _getBucketWorm() { _getBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) { var params, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - checkBucketName_1.checkBucketName(name); - params = this._bucketRequestParams('GET', name, 'worm', options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context.next = 6; - return this.request(params); - - case 6: - result = _context.sent; - dataFix_1.dataFix(result.data, { - lowerFirst: true, - rename: { - RetentionPeriodInDays: 'days' - } - }); - return _context.abrupt("return", Object.assign(Object.assign({}, result.data), { - res: result.res, - status: result.status - })); - - case 9: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + checkBucketName_1.checkBucketName(name); + params = this._bucketRequestParams('GET', name, 'worm', options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context.next = 6; + return this.request(params); + case 6: + result = _context.sent; + dataFix_1.dataFix(result.data, { + lowerFirst: true, + rename: { + RetentionPeriodInDays: 'days' + } + }); + return _context.abrupt("return", Object.assign(Object.assign({}, result.data), { + res: result.res, + status: result.status + })); + case 9: + case "end": + return _context.stop(); } }, _callee, this); })); return _getBucketWorm.apply(this, arguments); } - exports.getBucketWorm = getBucketWorm; -},{"../utils/checkBucketName":50,"../utils/dataFix":55,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],18:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/dataFix":58,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],18:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.initiateBucketWorm = void 0; - var obj2xml_1 = require("../utils/obj2xml"); - var checkBucketName_1 = require("../utils/checkBucketName"); - function initiateBucketWorm(_x, _x2, _x3) { return _initiateBucketWorm.apply(this, arguments); } - function _initiateBucketWorm() { _initiateBucketWorm = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, days, options) { var params, paramlXMLObJ, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - checkBucketName_1.checkBucketName(name); - params = this._bucketRequestParams('POST', name, 'worm', options); - paramlXMLObJ = { - InitiateWormConfiguration: { - RetentionPeriodInDays: days - } - }; - params.mime = 'xml'; - params.content = obj2xml_1.obj2xml(paramlXMLObJ, { - headers: true - }); - params.successStatuses = [200]; - _context.next = 8; - return this.request(params); - - case 8: - result = _context.sent; - return _context.abrupt("return", { - res: result.res, - wormId: result.res.headers['x-oss-worm-id'], - status: result.status - }); - - case 10: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + checkBucketName_1.checkBucketName(name); + params = this._bucketRequestParams('POST', name, 'worm', options); + paramlXMLObJ = { + InitiateWormConfiguration: { + RetentionPeriodInDays: days + } + }; + params.mime = 'xml'; + params.content = obj2xml_1.obj2xml(paramlXMLObJ, { + headers: true + }); + params.successStatuses = [200]; + _context.next = 8; + return this.request(params); + case 8: + result = _context.sent; + return _context.abrupt("return", { + res: result.res, + wormId: result.res.headers['x-oss-worm-id'], + status: result.status + }); + case 10: + case "end": + return _context.stop(); } }, _callee, this); })); return _initiateBucketWorm.apply(this, arguments); } - exports.initiateBucketWorm = initiateBucketWorm; -},{"../utils/checkBucketName":50,"../utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],19:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],19:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.listBucketInventory = void 0; - var checkBucketName_1 = require("../utils/checkBucketName"); - var formatInventoryConfig_1 = require("../utils/formatInventoryConfig"); /** * listBucketInventory @@ -3405,84 +2762,69 @@ var formatInventoryConfig_1 = require("../utils/formatInventoryConfig"); * @param {String} inventoryId * @param {Object} options */ - - function listBucketInventory(_x) { return _listBucketInventory.apply(this, arguments); } - function _listBucketInventory() { _listBucketInventory = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName) { var options, - continuationToken, - subres, - params, - result, - data, - res, - status, - _args = arguments; + continuationToken, + subres, + params, + result, + data, + res, + status, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - continuationToken = options.continuationToken; - subres = Object.assign({ - inventory: '' - }, continuationToken && { - 'continuation-token': continuationToken - }, options.subres); - checkBucketName_1.checkBucketName(bucketName); - params = this._bucketRequestParams('GET', bucketName, subres, options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context.next = 9; - return this.request(params); - - case 9: - result = _context.sent; - data = result.data, res = result.res, status = result.status; - return _context.abrupt("return", { - isTruncated: data.IsTruncated === 'true', - nextContinuationToken: data.NextContinuationToken, - inventoryList: formatInventoryConfig_1.formatInventoryConfig(data.InventoryConfiguration, true), - status: status, - res: res - }); - - case 12: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + continuationToken = options.continuationToken; + subres = Object.assign({ + inventory: '' + }, continuationToken && { + 'continuation-token': continuationToken + }, options.subres); + checkBucketName_1.checkBucketName(bucketName); + params = this._bucketRequestParams('GET', bucketName, subres, options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context.next = 9; + return this.request(params); + case 9: + result = _context.sent; + data = result.data, res = result.res, status = result.status; + return _context.abrupt("return", { + isTruncated: data.IsTruncated === 'true', + nextContinuationToken: data.NextContinuationToken, + inventoryList: formatInventoryConfig_1.formatInventoryConfig(data.InventoryConfiguration, true), + status: status, + res: res + }); + case 12: + case "end": + return _context.stop(); } }, _callee, this); })); return _listBucketInventory.apply(this, arguments); } - exports.listBucketInventory = listBucketInventory; -},{"../utils/checkBucketName":50,"../utils/formatInventoryConfig":58,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],20:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/formatInventoryConfig":62,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],20:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - require("core-js/modules/es.array.concat.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.putBucketInventory = void 0; - var checkBucketName_1 = require("../utils/checkBucketName"); - var obj2xml_1 = require("../utils/obj2xml"); /** * putBucketInventory @@ -3490,218 +2832,184 @@ var obj2xml_1 = require("../utils/obj2xml"); * @param {Inventory} inventory * @param {Object} options */ - - function putBucketInventory(_x, _x2) { return _putBucketInventory.apply(this, arguments); } - function _putBucketInventory() { _putBucketInventory = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(bucketName, inventory) { var options, - subres, - OSSBucketDestination, - optionalFields, - includedObjectVersions, - destinationBucketPrefix, - rolePrefix, - paramXMLObj, - paramXML, - params, - result, - _args = arguments; + subres, + OSSBucketDestination, + optionalFields, + includedObjectVersions, + destinationBucketPrefix, + rolePrefix, + paramXMLObj, + paramXML, + params, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; - subres = Object.assign({ - inventory: '', - inventoryId: inventory.id - }, options.subres); - checkBucketName_1.checkBucketName(bucketName); - OSSBucketDestination = inventory.OSSBucketDestination, optionalFields = inventory.optionalFields, includedObjectVersions = inventory.includedObjectVersions; - destinationBucketPrefix = 'acs:oss:::'; - rolePrefix = "acs:ram::".concat(OSSBucketDestination.accountId, ":role/"); - paramXMLObj = { - InventoryConfiguration: { - Id: inventory.id, - IsEnabled: inventory.isEnabled, - Filter: { - Prefix: inventory.prefix || '' - }, - Destination: { - OSSBucketDestination: { - Format: OSSBucketDestination.format, - AccountId: OSSBucketDestination.accountId, - RoleArn: "".concat(rolePrefix).concat(OSSBucketDestination.rolename), - Bucket: "".concat(destinationBucketPrefix).concat(OSSBucketDestination.bucket), - Prefix: OSSBucketDestination.prefix || '', - Encryption: OSSBucketDestination.encryption || '' - } - }, - Schedule: { - Frequency: inventory.frequency - }, - IncludedObjectVersions: includedObjectVersions, - OptionalFields: { - Field: (optionalFields === null || optionalFields === void 0 ? void 0 : optionalFields.field) || [] + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; + subres = Object.assign({ + inventory: '', + inventoryId: inventory.id + }, options.subres); + checkBucketName_1.checkBucketName(bucketName); + OSSBucketDestination = inventory.OSSBucketDestination, optionalFields = inventory.optionalFields, includedObjectVersions = inventory.includedObjectVersions; + destinationBucketPrefix = 'acs:oss:::'; + rolePrefix = "acs:ram::".concat(OSSBucketDestination.accountId, ":role/"); + paramXMLObj = { + InventoryConfiguration: { + Id: inventory.id, + IsEnabled: inventory.isEnabled, + Filter: { + Prefix: inventory.prefix || '' + }, + Destination: { + OSSBucketDestination: { + Format: OSSBucketDestination.format, + AccountId: OSSBucketDestination.accountId, + RoleArn: "".concat(rolePrefix).concat(OSSBucketDestination.rolename), + Bucket: "".concat(destinationBucketPrefix).concat(OSSBucketDestination.bucket), + Prefix: OSSBucketDestination.prefix || '', + Encryption: OSSBucketDestination.encryption || '' } + }, + Schedule: { + Frequency: inventory.frequency + }, + IncludedObjectVersions: includedObjectVersions, + OptionalFields: { + Field: (optionalFields === null || optionalFields === void 0 ? void 0 : optionalFields.field) || [] } - }; - paramXML = obj2xml_1.obj2xml(paramXMLObj, { - headers: true, - firstUpperCase: true - }); - params = this._bucketRequestParams('PUT', bucketName, subres, options); - params.successStatuses = [200]; - params.mime = 'xml'; - params.content = paramXML; - _context.next = 14; - return this.request(params); - - case 14: - result = _context.sent; - return _context.abrupt("return", { - status: result.status, - res: result.res - }); - - case 16: - case "end": - return _context.stop(); - } + } + }; + paramXML = obj2xml_1.obj2xml(paramXMLObj, { + headers: true, + firstUpperCase: true + }); + params = this._bucketRequestParams('PUT', bucketName, subres, options); + params.successStatuses = [200]; + params.mime = 'xml'; + params.content = paramXML; + _context.next = 14; + return this.request(params); + case 14: + result = _context.sent; + return _context.abrupt("return", { + status: result.status, + res: result.res + }); + case 16: + case "end": + return _context.stop(); } }, _callee, this); })); return _putBucketInventory.apply(this, arguments); } - exports.putBucketInventory = putBucketInventory; -},{"../utils/checkBucketName":50,"../utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.object.assign.js":255}],21:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.object.assign.js":325}],21:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - +require("core-js/modules/es.regexp.exec.js"); require("core-js/modules/es.array.includes.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - /* eslint-disable no-use-before-define */ var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var _require2 = require('../utils/isArray'), - isArray = _require2.isArray; - + isArray = _require2.isArray; var _require3 = require('../utils/deepCopy'), - deepCopy = _require3.deepCopy; - + deepCopy = _require3.deepCopy; var _require4 = require('../utils/isObject'), - isObject = _require4.isObject; - + isObject = _require4.isObject; var _require5 = require('../utils/obj2xml'), - obj2xml = _require5.obj2xml; - + obj2xml = _require5.obj2xml; var _require6 = require('../utils/checkObjectTag'), - checkObjectTag = _require6.checkObjectTag; - + checkObjectTag = _require6.checkObjectTag; var _require7 = require('../utils/getStrBytesCount'), - getStrBytesCount = _require7.getStrBytesCount; - + getStrBytesCount = _require7.getStrBytesCount; var proto = exports; - proto.putBucketLifecycle = /*#__PURE__*/function () { var _putBucketLifecycle = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, rules, options) { var params, Rule, paramXMLObj, paramXML, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - _checkBucketName(name); - - if (isArray(rules)) { - _context.next = 3; - break; + while (1) switch (_context.prev = _context.next) { + case 0: + _checkBucketName(name); + if (isArray(rules)) { + _context.next = 3; + break; + } + throw new Error('rules must be Array'); + case 3: + params = this._bucketRequestParams('PUT', name, 'lifecycle', options); + Rule = []; + paramXMLObj = { + LifecycleConfiguration: { + Rule: Rule } - - throw new Error('rules must be Array'); - - case 3: - params = this._bucketRequestParams('PUT', name, 'lifecycle', options); - Rule = []; - paramXMLObj = { - LifecycleConfiguration: { - Rule: Rule - } - }; - rules.forEach(function (_) { - defaultDaysAndDate2Expiration(_); // todo delete, 兼容旧版本 - - checkRule(_); - - if (_.id) { - _.ID = _.id; - delete _.id; - } - - Rule.push(_); - }); - paramXML = obj2xml(paramXMLObj, { - headers: true, - firstUpperCase: true - }); - params.content = paramXML; - params.mime = 'xml'; - params.successStatuses = [200]; - _context.next = 13; - return this.request(params); - - case 13: - result = _context.sent; - return _context.abrupt("return", { - res: result.res - }); - - case 15: - case "end": - return _context.stop(); - } + }; + rules.forEach(function (_) { + defaultDaysAndDate2Expiration(_); // todo delete, 兼容旧版本 + checkRule(_); + if (_.id) { + _.ID = _.id; + delete _.id; + } + Rule.push(_); + }); + paramXML = obj2xml(paramXMLObj, { + headers: true, + firstUpperCase: true + }); + params.content = paramXML; + params.mime = 'xml'; + params.successStatuses = [200]; + _context.next = 13; + return this.request(params); + case 13: + result = _context.sent; + return _context.abrupt("return", { + res: result.res + }); + case 15: + case "end": + return _context.stop(); } }, _callee, this); })); - function putBucketLifecycle(_x, _x2, _x3) { return _putBucketLifecycle.apply(this, arguments); } - return putBucketLifecycle; -}(); // todo delete, 兼容旧版本 - +}(); +// todo delete, 兼容旧版本 function defaultDaysAndDate2Expiration(obj) { if (obj.days) { obj.expiration = { days: obj.days }; } - if (obj.date) { obj.expiration = { createdBeforeDate: obj.date }; } } - function checkDaysAndDate(obj, key) { var days = obj.days, - createdBeforeDate = obj.createdBeforeDate; - + createdBeforeDate = obj.createdBeforeDate; if (!days && !createdBeforeDate) { throw new Error("".concat(key, " must includes days or createdBeforeDate")); } else if (days && !/^[1-9][0-9]*$/.test(days)) { @@ -3710,12 +3018,10 @@ function checkDaysAndDate(obj, key) { throw new Error('createdBeforeDate must be date and conform to iso8601 format'); } } - function handleCheckTag(tag) { if (!isArray(tag) && !isObject(tag)) { throw new Error('tag must be Object or Array'); } - tag = isObject(tag) ? [tag] : tag; var tagObj = {}; var tagClone = deepCopy(tag); @@ -3724,17 +3030,14 @@ function handleCheckTag(tag) { }); checkObjectTag(tagObj); } - function checkRule(rule) { if (rule.id && getStrBytesCount(rule.id) > 255) throw new Error('ID is composed of 255 bytes at most'); if (rule.prefix === undefined) throw new Error('Rule must includes prefix'); if (!['Enabled', 'Disabled'].includes(rule.status)) throw new Error('Status must be Enabled or Disabled'); - if (rule.transition) { if (!['IA', 'Archive'].includes(rule.transition.storageClass)) throw new Error('StorageClass must be IA or Archive'); checkDaysAndDate(rule.transition, 'Transition'); } - if (rule.expiration) { if (!rule.expiration.expiredObjectDeleteMarker) { checkDaysAndDate(rule.expiration, 'Expiration'); @@ -3742,41 +3045,31 @@ function checkRule(rule) { throw new Error('expiredObjectDeleteMarker cannot be used with days or createdBeforeDate'); } } - if (rule.abortMultipartUpload) { checkDaysAndDate(rule.abortMultipartUpload, 'AbortMultipartUpload'); } - if (!rule.expiration && !rule.abortMultipartUpload && !rule.transition && !rule.noncurrentVersionTransition) { throw new Error('Rule must includes expiration or abortMultipartUpload or transition or noncurrentVersionTransition'); } - if (rule.tag) { if (rule.abortMultipartUpload) { throw new Error('Tag cannot be used with abortMultipartUpload'); } - handleCheckTag(rule.tag); } } -},{"../utils/checkBucketName":50,"../utils/checkObjectTag":52,"../utils/deepCopy":56,"../utils/getStrBytesCount":60,"../utils/isArray":61,"../utils/isObject":67,"../utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.includes.js":246,"core-js/modules/web.dom-collections.for-each.js":296}],22:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/checkObjectTag":55,"../utils/deepCopy":59,"../utils/getStrBytesCount":65,"../utils/isArray":66,"../utils/isObject":73,"../utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.includes.js":315,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/web.dom-collections.for-each.js":382}],22:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.array.includes.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var _require2 = require('../utils/obj2xml'), - obj2xml = _require2.obj2xml; - + obj2xml = _require2.obj2xml; var proto = exports; /** * putBucketVersioning @@ -3788,208 +3081,166 @@ var proto = exports; proto.putBucketVersioning = /*#__PURE__*/function () { var _putBucketVersioning = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, status) { var options, - params, - paramXMLObj, - result, - _args = arguments; + params, + paramXMLObj, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; - - _checkBucketName(name); - - if (['Enabled', 'Suspended'].includes(status)) { - _context.next = 4; - break; + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; + _checkBucketName(name); + if (['Enabled', 'Suspended'].includes(status)) { + _context.next = 4; + break; + } + throw new Error('status must be Enabled or Suspended'); + case 4: + params = this._bucketRequestParams('PUT', name, 'versioning', options); + paramXMLObj = { + VersioningConfiguration: { + Status: status } - - throw new Error('status must be Enabled or Suspended'); - - case 4: - params = this._bucketRequestParams('PUT', name, 'versioning', options); - paramXMLObj = { - VersioningConfiguration: { - Status: status - } - }; - params.mime = 'xml'; - params.content = obj2xml(paramXMLObj, { - headers: true - }); - _context.next = 10; - return this.request(params); - - case 10: - result = _context.sent; - return _context.abrupt("return", { - res: result.res, - status: result.status - }); - - case 12: - case "end": - return _context.stop(); - } + }; + params.mime = 'xml'; + params.content = obj2xml(paramXMLObj, { + headers: true + }); + _context.next = 10; + return this.request(params); + case 10: + result = _context.sent; + return _context.abrupt("return", { + res: result.res, + status: result.status + }); + case 12: + case "end": + return _context.stop(); } }, _callee, this); })); - function putBucketVersioning(_x, _x2) { return _putBucketVersioning.apply(this, arguments); } - return putBucketVersioning; }(); -},{"../utils/checkBucketName":50,"../utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.includes.js":246}],23:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.includes.js":315}],23:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var _require2 = require('../utils/obj2xml'), - obj2xml = _require2.obj2xml; - + obj2xml = _require2.obj2xml; var _require3 = require('../utils/isArray'), - isArray = _require3.isArray; - + isArray = _require3.isArray; var proto = exports; - proto.putBucketWebsite = /*#__PURE__*/function () { var _putBucketWebsite = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) { var config, - options, - params, - IndexDocument, - WebsiteConfiguration, - website, - result, - _args = arguments; + options, + params, + IndexDocument, + WebsiteConfiguration, + website, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - config = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - options = _args.length > 2 ? _args[2] : undefined; - - _checkBucketName(name); - - params = this._bucketRequestParams('PUT', name, 'website', options); - IndexDocument = { - Suffix: config.index || 'index.html' - }; - WebsiteConfiguration = { - IndexDocument: IndexDocument - }; - website = { - WebsiteConfiguration: WebsiteConfiguration - }; - - if (config.supportSubDir) { - IndexDocument.SupportSubDir = config.supportSubDir; - } - - if (config.type) { - IndexDocument.Type = config.type; - } - - if (config.error) { - WebsiteConfiguration.ErrorDocument = { - Key: config.error - }; - } - - if (!(config.routingRules !== undefined)) { - _context.next = 14; - break; - } - - if (isArray(config.routingRules)) { - _context.next = 13; - break; - } - - throw new Error('RoutingRules must be Array'); - - case 13: - WebsiteConfiguration.RoutingRules = { - RoutingRule: config.routingRules + while (1) switch (_context.prev = _context.next) { + case 0: + config = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + options = _args.length > 2 ? _args[2] : undefined; + _checkBucketName(name); + params = this._bucketRequestParams('PUT', name, 'website', options); + IndexDocument = { + Suffix: config.index || 'index.html' + }; + WebsiteConfiguration = { + IndexDocument: IndexDocument + }; + website = { + WebsiteConfiguration: WebsiteConfiguration + }; + if (config.supportSubDir) { + IndexDocument.SupportSubDir = config.supportSubDir; + } + if (config.type) { + IndexDocument.Type = config.type; + } + if (config.error) { + WebsiteConfiguration.ErrorDocument = { + Key: config.error }; - - case 14: - website = obj2xml(website); - params.content = website; - params.mime = 'xml'; - params.successStatuses = [200]; - _context.next = 20; - return this.request(params); - - case 20: - result = _context.sent; - return _context.abrupt("return", { - res: result.res - }); - - case 22: - case "end": - return _context.stop(); - } + } + if (!(config.routingRules !== undefined)) { + _context.next = 14; + break; + } + if (isArray(config.routingRules)) { + _context.next = 13; + break; + } + throw new Error('RoutingRules must be Array'); + case 13: + WebsiteConfiguration.RoutingRules = { + RoutingRule: config.routingRules + }; + case 14: + website = obj2xml(website); + params.content = website; + params.mime = 'xml'; + params.successStatuses = [200]; + _context.next = 20; + return this.request(params); + case 20: + result = _context.sent; + return _context.abrupt("return", { + res: result.res + }); + case 22: + case "end": + return _context.stop(); } }, _callee, this); })); - function putBucketWebsite(_x) { return _putBucketWebsite.apply(this, arguments); } - return putBucketWebsite; }(); -},{"../utils/checkBucketName":50,"../utils/isArray":61,"../utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76}],24:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/isArray":66,"../utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93}],24:[function(require,module,exports){ (function (Buffer){(function (){ "use strict"; require("core-js/modules/es.object.to-string.js"); - require("core-js/modules/es.regexp.to-string.js"); - require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.keys.js"); - exports.encodeCallback = function encodeCallback(reqParams, options) { reqParams.headers = reqParams.headers || {}; - if (!Object.prototype.hasOwnProperty.call(reqParams.headers, 'x-oss-callback')) { if (options.callback) { var json = { callbackUrl: encodeURI(options.callback.url), callbackBody: options.callback.body }; - if (options.callback.host) { json.callbackHost = options.callback.host; } - if (options.callback.contentType) { json.callbackBodyType = options.callback.contentType; } - var callback = Buffer.from(JSON.stringify(json)).toString('base64'); reqParams.headers['x-oss-callback'] = callback; - if (options.callback.customValue) { var callbackVar = {}; Object.keys(options.callback.customValue).forEach(function (key) { - callbackVar["x:".concat(key)] = options.callback.customValue[key]; + callbackVar["x:".concat(key)] = options.callback.customValue[key].toString(); }); reqParams.headers['x-oss-callback-var'] = Buffer.from(JSON.stringify(callbackVar)).toString('base64'); } @@ -3998,71 +3249,52 @@ exports.encodeCallback = function encodeCallback(reqParams, options) { }; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":85,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.regexp.to-string.js":262,"core-js/modules/web.dom-collections.for-each.js":296}],25:[function(require,module,exports){ +},{"buffer":103,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/web.dom-collections.for-each.js":382}],25:[function(require,module,exports){ "use strict"; require("core-js/modules/es.array.concat.js"); - require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - var __importDefault = void 0 && (void 0).__importDefault || function (mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; - Object.defineProperty(exports, "__esModule", { value: true }); exports.getReqUrl = void 0; - var copy_to_1 = __importDefault(require("copy-to")); - var url_1 = __importDefault(require("url")); - var merge_descriptors_1 = __importDefault(require("merge-descriptors")); - var is_type_of_1 = __importDefault(require("is-type-of")); - var isIP_1 = require("../utils/isIP"); - var checkConfigValid_1 = require("../utils/checkConfigValid"); - function getReqUrl(params) { var ep = {}; var isCname = this.options.cname; checkConfigValid_1.checkConfigValid(this.options.endpoint, 'endpoint'); copy_to_1.default(this.options.endpoint, false).to(ep); - if (params.bucket && !isCname && !isIP_1.isIP(ep.hostname) && !this.options.sldEnable) { ep.host = "".concat(params.bucket, ".").concat(ep.host); } - var resourcePath = '/'; - if (params.bucket && this.options.sldEnable) { resourcePath += "".concat(params.bucket, "/"); } - if (params.object) { // Preserve '/' in result url resourcePath += this._escape(params.object).replace(/\+/g, '%2B'); } - ep.pathname = resourcePath; var query = {}; - if (params.query) { merge_descriptors_1.default(query, params.query); } - if (params.subres) { var subresAsQuery = {}; - if (is_type_of_1.default.string(params.subres)) { subresAsQuery[params.subres] = ''; } else if (is_type_of_1.default.array(params.subres)) { @@ -4072,66 +3304,48 @@ function getReqUrl(params) { } else { subresAsQuery = params.subres; } - merge_descriptors_1.default(query, subresAsQuery); } - ep.query = query; return url_1.default.format(ep); } - exports.getReqUrl = getReqUrl; -},{"../utils/checkConfigValid":51,"../utils/isIP":66,"copy-to":88,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.string.replace.js":266,"core-js/modules/web.dom-collections.for-each.js":296,"is-type-of":398,"merge-descriptors":315,"url":404}],26:[function(require,module,exports){ +},{"../utils/checkConfigValid":53,"../utils/isIP":72,"copy-to":107,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.string.replace.js":347,"core-js/modules/web.dom-collections.for-each.js":382,"is-type-of":539,"merge-descriptors":430,"url":545}],26:[function(require,module,exports){ "use strict"; require("core-js/modules/es.array.concat.js"); - require("core-js/modules/es.object.assign.js"); - require("core-js/modules/es.string.trim.js"); - var ms = require('humanize-ms'); - var urlutil = require('url'); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var _require2 = require('../utils/setRegion'), - setRegion = _require2.setRegion; - + setRegion = _require2.setRegion; var _require3 = require('../utils/checkConfigValid'), - checkConfigValid = _require3.checkConfigValid; - + checkConfigValid = _require3.checkConfigValid; function setEndpoint(endpoint, secure) { checkConfigValid(endpoint, 'endpoint'); var url = urlutil.parse(endpoint); - if (!url.protocol) { url = urlutil.parse("http".concat(secure ? 's' : '', "://").concat(endpoint)); } - if (url.protocol !== 'http:' && url.protocol !== 'https:') { throw new Error('Endpoint protocol must be http or https.'); } - return url; } - module.exports = function (options) { if (!options || !options.accessKeyId || !options.accessKeySecret) { throw new Error('require accessKeyId, accessKeySecret'); } - if (options.stsToken && !options.refreshSTSToken && !options.refreshSTSTokenInterval) { console.warn("It's recommended to set 'refreshSTSToken' and 'refreshSTSTokenInterval' to refresh" + ' stsToken、accessKeyId、accessKeySecret automatically when sts token has expired'); } - if (options.bucket) { _checkBucketName(options.bucket); } - var opts = Object.assign({ region: 'oss-cn-hangzhou', internal: false, @@ -4145,15 +3359,14 @@ module.exports = function (options) { headerEncoding: 'utf-8', refreshSTSToken: null, refreshSTSTokenInterval: 60000 * 5, - retryMax: 0 + retryMax: 0, + authorizationV4: false // 启用v4签名,默认关闭 }, options); opts.accessKeyId = opts.accessKeyId.trim(); opts.accessKeySecret = opts.accessKeySecret.trim(); - if (opts.timeout) { opts.timeout = ms(opts.timeout); } - if (opts.endpoint) { opts.endpoint = setEndpoint(opts.endpoint, opts.secure); } else if (opts.region) { @@ -4161,136 +3374,103 @@ module.exports = function (options) { } else { throw new Error('require options.endpoint or options.region'); } - opts.inited = true; return opts; }; -},{"../utils/checkBucketName":50,"../utils/checkConfigValid":51,"../utils/setRegion":71,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.object.assign.js":255,"core-js/modules/es.string.trim.js":269,"humanize-ms":303,"url":404}],27:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"../utils/checkConfigValid":53,"../utils/setRegion":78,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.string.trim.js":351,"humanize-ms":401,"url":545}],27:[function(require,module,exports){ "use strict"; var merge = require('merge-descriptors'); - var proto = exports; merge(proto, require('./processObjectSave')); -},{"./processObjectSave":28,"merge-descriptors":315}],28:[function(require,module,exports){ +},{"./processObjectSave":28,"merge-descriptors":430}],28:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.array.concat.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - /* eslint-disable no-use-before-define */ var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var querystring = require('querystring'); - var _require2 = require('js-base64'), - str2Base64 = _require2.Base64.encode; - + str2Base64 = _require2.Base64.encode; var proto = exports; - proto.processObjectSave = /*#__PURE__*/function () { var _processObjectSave = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(sourceObject, targetObject, process, targetBucket) { var params, bucketParam, content, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - checkArgs(sourceObject, 'sourceObject'); - checkArgs(targetObject, 'targetObject'); - checkArgs(process, 'process'); - targetObject = this._objectName(targetObject); - - if (targetBucket) { - _checkBucketName(targetBucket); - } - - params = this._objectRequestParams('POST', sourceObject, { - subres: 'x-oss-process' - }); - bucketParam = targetBucket ? ",b_".concat(str2Base64(targetBucket)) : ''; - targetObject = str2Base64(targetObject); - content = { - 'x-oss-process': "".concat(process, "|sys/saveas,o_").concat(targetObject).concat(bucketParam) - }; - params.content = querystring.stringify(content); - _context.next = 12; - return this.request(params); - - case 12: - result = _context.sent; - return _context.abrupt("return", { - res: result.res, - status: result.res.status - }); - - case 14: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + checkArgs(sourceObject, 'sourceObject'); + checkArgs(targetObject, 'targetObject'); + checkArgs(process, 'process'); + targetObject = this._objectName(targetObject); + if (targetBucket) { + _checkBucketName(targetBucket); + } + params = this._objectRequestParams('POST', sourceObject, { + subres: 'x-oss-process' + }); + bucketParam = targetBucket ? ",b_".concat(str2Base64(targetBucket)) : ''; + targetObject = str2Base64(targetObject); + content = { + 'x-oss-process': "".concat(process, "|sys/saveas,o_").concat(targetObject).concat(bucketParam) + }; + params.content = querystring.stringify(content); + _context.next = 12; + return this.request(params); + case 12: + result = _context.sent; + return _context.abrupt("return", { + res: result.res, + status: result.res.status + }); + case 14: + case "end": + return _context.stop(); } }, _callee, this); })); - function processObjectSave(_x, _x2, _x3, _x4) { return _processObjectSave.apply(this, arguments); } - return processObjectSave; }(); - function checkArgs(name, key) { if (!name) { throw new Error("".concat(key, " is required")); } - if (typeof name !== 'string') { throw new Error("".concat(key, " must be String")); } } -},{"../utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.concat.js":241,"js-base64":314,"querystring":328}],29:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.concat.js":310,"js-base64":415,"querystring":453}],29:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.array.concat.js"); - require("core-js/modules/es.function.name.js"); - require("core-js/modules/es.object.to-string.js"); - require("core-js/modules/es.promise.js"); - require("core-js/modules/es.array.from.js"); - require("core-js/modules/es.string.iterator.js"); - require("core-js/modules/es.array.map.js"); - require("core-js/modules/es.array.filter.js"); - require("core-js/modules/es.array.find.js"); - require("core-js/modules/es.regexp.to-string.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - /* eslint-disable no-async-promise-executor */ -var debug = require('debug')('ali-oss:multipart-copy'); +var debug = require('debug')('ali-oss:multipart-copy'); var copy = require('copy-to'); - var proto = exports; + /** * Upload a part copy in a multipart from the source bucket/object * used with initMultipartUpload and completeMultipartUpload. @@ -4303,69 +3483,58 @@ var proto = exports; * {String} sourceData.sourceBucketName the source bucket name * @param {Object} options */ - /* eslint max-len: [0] */ - proto.uploadPartCopy = /*#__PURE__*/function () { var _uploadPartCopy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, uploadId, partNo, range, sourceData) { var options, - versionId, - copySource, - params, - result, - _args = arguments; + versionId, + copySource, + params, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 5 && _args[5] !== undefined ? _args[5] : {}; - options.headers = options.headers || {}; - versionId = options.versionId || options.subres && options.subres.versionId || null; - - if (versionId) { - copySource = "/".concat(sourceData.sourceBucketName, "/").concat(encodeURIComponent(sourceData.sourceKey), "?versionId=").concat(versionId); - } else { - copySource = "/".concat(sourceData.sourceBucketName, "/").concat(encodeURIComponent(sourceData.sourceKey)); - } - - options.headers['x-oss-copy-source'] = copySource; - - if (range) { - options.headers['x-oss-copy-source-range'] = "bytes=".concat(range); - } - - options.subres = { - partNumber: partNo, - uploadId: uploadId - }; - params = this._objectRequestParams('PUT', name, options); - params.mime = options.mime; - params.successStatuses = [200]; - _context.next = 12; - return this.request(params); - - case 12: - result = _context.sent; - return _context.abrupt("return", { - name: name, - etag: result.res.headers.etag, - res: result.res - }); - - case 14: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 5 && _args[5] !== undefined ? _args[5] : {}; + options.headers = options.headers || {}; + versionId = options.versionId || options.subres && options.subres.versionId || null; + if (versionId) { + copySource = "/".concat(sourceData.sourceBucketName, "/").concat(encodeURIComponent(sourceData.sourceKey), "?versionId=").concat(versionId); + } else { + copySource = "/".concat(sourceData.sourceBucketName, "/").concat(encodeURIComponent(sourceData.sourceKey)); + } + options.headers['x-oss-copy-source'] = copySource; + if (range) { + options.headers['x-oss-copy-source-range'] = "bytes=".concat(range); + } + options.subres = { + partNumber: partNo, + uploadId: uploadId + }; + params = this._objectRequestParams('PUT', name, options); + params.mime = options.mime; + params.successStatuses = [200]; + _context.next = 12; + return this.request(params); + case 12: + result = _context.sent; + return _context.abrupt("return", { + name: name, + etag: result.res.headers.etag, + res: result.res + }); + case 14: + case "end": + return _context.stop(); } }, _callee, this); })); - function uploadPartCopy(_x, _x2, _x3, _x4, _x5) { return _uploadPartCopy.apply(this, arguments); } - return uploadPartCopy; }(); + /** * @param {String} name copy object name * @param {Object} sourceData @@ -4376,353 +3545,280 @@ proto.uploadPartCopy = /*#__PURE__*/function () { * @param {Object} options * {Number} options.partSize */ - - proto.multipartUploadCopy = /*#__PURE__*/function () { var _multipartUploadCopy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name, sourceData) { var options, - _options$versionId, - versionId, - metaOpt, - objectMeta, - fileSize, - minPartSize, - copySize, - init, - uploadId, - partSize, - checkpoint, - _args2 = arguments; - + _options$versionId, + versionId, + metaOpt, + objectMeta, + fileSize, + minPartSize, + copySize, + init, + uploadId, + partSize, + checkpoint, + _args2 = arguments; return _regenerator.default.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {}; - this.resetCancelFlag(); - _options$versionId = options.versionId, versionId = _options$versionId === void 0 ? null : _options$versionId; - metaOpt = { - versionId: versionId - }; - _context2.next = 6; - return this._getObjectMeta(sourceData.sourceBucketName, sourceData.sourceKey, metaOpt); - - case 6: - objectMeta = _context2.sent; - fileSize = objectMeta.res.headers['content-length']; - sourceData.startOffset = sourceData.startOffset || 0; - sourceData.endOffset = sourceData.endOffset || fileSize; - - if (!(options.checkpoint && options.checkpoint.uploadId)) { - _context2.next = 14; - break; - } - - _context2.next = 13; - return this._resumeMultipartCopy(options.checkpoint, sourceData, options); - - case 13: - return _context2.abrupt("return", _context2.sent); - - case 14: - minPartSize = 100 * 1024; - copySize = sourceData.endOffset - sourceData.startOffset; - - if (!(copySize < minPartSize)) { - _context2.next = 18; - break; - } - - throw new Error("copySize must not be smaller than ".concat(minPartSize)); - - case 18: - if (!(options.partSize && options.partSize < minPartSize)) { - _context2.next = 20; - break; - } - - throw new Error("partSize must not be smaller than ".concat(minPartSize)); - - case 20: - _context2.next = 22; - return this.initMultipartUpload(name, options); - - case 22: - init = _context2.sent; - uploadId = init.uploadId; - partSize = this._getPartSize(copySize, options.partSize); - checkpoint = { - name: name, - copySize: copySize, - partSize: partSize, - uploadId: uploadId, - doneParts: [] - }; - - if (!(options && options.progress)) { - _context2.next = 29; - break; - } - + while (1) switch (_context2.prev = _context2.next) { + case 0: + options = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {}; + this.resetCancelFlag(); + _options$versionId = options.versionId, versionId = _options$versionId === void 0 ? null : _options$versionId; + metaOpt = { + versionId: versionId + }; + _context2.next = 6; + return this._getObjectMeta(sourceData.sourceBucketName, sourceData.sourceKey, metaOpt); + case 6: + objectMeta = _context2.sent; + fileSize = objectMeta.res.headers['content-length']; + sourceData.startOffset = sourceData.startOffset || 0; + sourceData.endOffset = sourceData.endOffset || fileSize; + if (!(options.checkpoint && options.checkpoint.uploadId)) { + _context2.next = 14; + break; + } + _context2.next = 13; + return this._resumeMultipartCopy(options.checkpoint, sourceData, options); + case 13: + return _context2.abrupt("return", _context2.sent); + case 14: + minPartSize = 100 * 1024; + copySize = sourceData.endOffset - sourceData.startOffset; + if (!(copySize < minPartSize)) { + _context2.next = 18; + break; + } + throw new Error("copySize must not be smaller than ".concat(minPartSize)); + case 18: + if (!(options.partSize && options.partSize < minPartSize)) { + _context2.next = 20; + break; + } + throw new Error("partSize must not be smaller than ".concat(minPartSize)); + case 20: + _context2.next = 22; + return this.initMultipartUpload(name, options); + case 22: + init = _context2.sent; + uploadId = init.uploadId; + partSize = this._getPartSize(copySize, options.partSize); + checkpoint = { + name: name, + copySize: copySize, + partSize: partSize, + uploadId: uploadId, + doneParts: [] + }; + if (!(options && options.progress)) { _context2.next = 29; - return options.progress(0, checkpoint, init.res); - - case 29: - _context2.next = 31; - return this._resumeMultipartCopy(checkpoint, sourceData, options); - - case 31: - return _context2.abrupt("return", _context2.sent); - - case 32: - case "end": - return _context2.stop(); - } + break; + } + _context2.next = 29; + return options.progress(0, checkpoint, init.res); + case 29: + _context2.next = 31; + return this._resumeMultipartCopy(checkpoint, sourceData, options); + case 31: + return _context2.abrupt("return", _context2.sent); + case 32: + case "end": + return _context2.stop(); } }, _callee2, this); })); - function multipartUploadCopy(_x6, _x7) { return _multipartUploadCopy.apply(this, arguments); } - return multipartUploadCopy; }(); + /* * Resume multipart copy from checkpoint. The checkpoint will be * updated after each successful part copy. * @param {Object} checkpoint the checkpoint * @param {Object} options */ - - proto._resumeMultipartCopy = /*#__PURE__*/function () { var _resumeMultipartCopy2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(checkpoint, sourceData, options) { var _options$versionId2, versionId, metaOpt, copySize, partSize, uploadId, doneParts, name, partOffs, numParts, uploadPartCopyOptions, uploadPartJob, all, done, todo, defaultParallel, parallel, i, errors, abortEvent, err; - return _regenerator.default.wrap(function _callee4$(_context4) { - while (1) { - switch (_context4.prev = _context4.next) { - case 0: - if (!this.isCancel()) { - _context4.next = 2; - break; - } - - throw this._makeCancelEvent(); - - case 2: - _options$versionId2 = options.versionId, versionId = _options$versionId2 === void 0 ? null : _options$versionId2; - metaOpt = { - versionId: versionId - }; - copySize = checkpoint.copySize, partSize = checkpoint.partSize, uploadId = checkpoint.uploadId, doneParts = checkpoint.doneParts, name = checkpoint.name; - partOffs = this._divideMultipartCopyParts(copySize, partSize, sourceData.startOffset); - numParts = partOffs.length; - uploadPartCopyOptions = { - headers: {} - }; - - if (options.copyheaders) { - copy(options.copyheaders).to(uploadPartCopyOptions.headers); - } - - if (versionId) { - copy(metaOpt).to(uploadPartCopyOptions); - } - - uploadPartJob = function uploadPartJob(self, partNo, source) { - return new Promise( /*#__PURE__*/function () { - var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resolve, reject) { - var pi, range, result; - return _regenerator.default.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - _context3.prev = 0; - - if (self.isCancel()) { - _context3.next = 22; - break; - } - - pi = partOffs[partNo - 1]; - range = "".concat(pi.start, "-").concat(pi.end - 1); - _context3.prev = 4; - _context3.next = 7; - return self.uploadPartCopy(name, uploadId, partNo, range, source, uploadPartCopyOptions); - - case 7: - result = _context3.sent; - _context3.next = 15; - break; - - case 10: - _context3.prev = 10; - _context3.t0 = _context3["catch"](4); - - if (!(_context3.t0.status === 404)) { - _context3.next = 14; - break; - } - - throw self._makeAbortEvent(); - - case 14: - throw _context3.t0; - - case 15: - if (self.isCancel()) { - _context3.next = 22; - break; - } - - debug("content-range ".concat(result.res.headers['content-range'])); - doneParts.push({ - number: partNo, - etag: result.res.headers.etag - }); - checkpoint.doneParts = doneParts; - - if (!(options && options.progress)) { - _context3.next = 22; - break; - } - - _context3.next = 22; - return options.progress(doneParts.length / numParts, checkpoint, result.res); - - case 22: - resolve(); - _context3.next = 29; - break; - - case 25: - _context3.prev = 25; - _context3.t1 = _context3["catch"](0); - _context3.t1.partNum = partNo; - reject(_context3.t1); - - case 29: - case "end": - return _context3.stop(); + while (1) switch (_context4.prev = _context4.next) { + case 0: + if (!this.isCancel()) { + _context4.next = 2; + break; + } + throw this._makeCancelEvent(); + case 2: + _options$versionId2 = options.versionId, versionId = _options$versionId2 === void 0 ? null : _options$versionId2; + metaOpt = { + versionId: versionId + }; + copySize = checkpoint.copySize, partSize = checkpoint.partSize, uploadId = checkpoint.uploadId, doneParts = checkpoint.doneParts, name = checkpoint.name; + partOffs = this._divideMultipartCopyParts(copySize, partSize, sourceData.startOffset); + numParts = partOffs.length; + uploadPartCopyOptions = { + headers: {} + }; + if (options.copyheaders) { + copy(options.copyheaders).to(uploadPartCopyOptions.headers); + } + if (versionId) { + copy(metaOpt).to(uploadPartCopyOptions); + } + uploadPartJob = function uploadPartJob(self, partNo, source) { + return new Promise( /*#__PURE__*/function () { + var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(resolve, reject) { + var pi, range, result; + return _regenerator.default.wrap(function _callee3$(_context3) { + while (1) switch (_context3.prev = _context3.next) { + case 0: + _context3.prev = 0; + if (self.isCancel()) { + _context3.next = 22; + break; } - } - }, _callee3, null, [[0, 25], [4, 10]]); - })); - - return function (_x11, _x12) { - return _ref.apply(this, arguments); - }; - }()); - }; - - all = Array.from(new Array(numParts), function (x, i) { - return i + 1; - }); - done = doneParts.map(function (p) { - return p.number; - }); - todo = all.filter(function (p) { - return done.indexOf(p) < 0; - }); - defaultParallel = 5; - parallel = options.parallel || defaultParallel; - - if (!(this.checkBrowserAndVersion('Internet Explorer', '10') || parallel === 1)) { - _context4.next = 28; - break; - } - - i = 0; - - case 18: - if (!(i < todo.length)) { - _context4.next = 26; - break; - } - - if (!this.isCancel()) { - _context4.next = 21; - break; - } - - throw this._makeCancelEvent(); - - case 21: - _context4.next = 23; - return uploadPartJob(this, todo[i], sourceData); - - case 23: - i++; - _context4.next = 18; + pi = partOffs[partNo - 1]; + range = "".concat(pi.start, "-").concat(pi.end - 1); + _context3.prev = 4; + _context3.next = 7; + return self.uploadPartCopy(name, uploadId, partNo, range, source, uploadPartCopyOptions); + case 7: + result = _context3.sent; + _context3.next = 15; + break; + case 10: + _context3.prev = 10; + _context3.t0 = _context3["catch"](4); + if (!(_context3.t0.status === 404)) { + _context3.next = 14; + break; + } + throw self._makeAbortEvent(); + case 14: + throw _context3.t0; + case 15: + if (self.isCancel()) { + _context3.next = 22; + break; + } + debug("content-range ".concat(result.res.headers['content-range'])); + doneParts.push({ + number: partNo, + etag: result.res.headers.etag + }); + checkpoint.doneParts = doneParts; + if (!(options && options.progress)) { + _context3.next = 22; + break; + } + _context3.next = 22; + return options.progress(doneParts.length / numParts, checkpoint, result.res); + case 22: + resolve(); + _context3.next = 29; + break; + case 25: + _context3.prev = 25; + _context3.t1 = _context3["catch"](0); + _context3.t1.partNum = partNo; + reject(_context3.t1); + case 29: + case "end": + return _context3.stop(); + } + }, _callee3, null, [[0, 25], [4, 10]]); + })); + return function (_x11, _x12) { + return _ref.apply(this, arguments); + }; + }()); + }; + all = Array.from(new Array(numParts), function (x, i) { + return i + 1; + }); + done = doneParts.map(function (p) { + return p.number; + }); + todo = all.filter(function (p) { + return done.indexOf(p) < 0; + }); + defaultParallel = 5; + parallel = options.parallel || defaultParallel; + if (!(this.checkBrowserAndVersion('Internet Explorer', '10') || parallel === 1)) { + _context4.next = 28; break; - - case 26: + } + i = 0; + case 18: + if (!(i < todo.length)) { + _context4.next = 26; + break; + } + if (!this.isCancel()) { + _context4.next = 21; + break; + } + throw this._makeCancelEvent(); + case 21: + _context4.next = 23; + return uploadPartJob(this, todo[i], sourceData); + case 23: + i++; + _context4.next = 18; + break; + case 26: + _context4.next = 40; + break; + case 28: + _context4.next = 30; + return this._parallelNode(todo, parallel, uploadPartJob, sourceData); + case 30: + errors = _context4.sent; + abortEvent = errors.find(function (err) { + return err.name === 'abort'; + }); + if (!abortEvent) { + _context4.next = 34; + break; + } + throw abortEvent; + case 34: + if (!this.isCancel()) { + _context4.next = 36; + break; + } + throw this._makeCancelEvent(); + case 36: + if (!(errors && errors.length > 0)) { _context4.next = 40; break; - - case 28: - _context4.next = 30; - return this._parallelNode(todo, parallel, uploadPartJob, sourceData); - - case 30: - errors = _context4.sent; - abortEvent = errors.find(function (err) { - return err.name === 'abort'; - }); - - if (!abortEvent) { - _context4.next = 34; - break; - } - - throw abortEvent; - - case 34: - if (!this.isCancel()) { - _context4.next = 36; - break; - } - - throw this._makeCancelEvent(); - - case 36: - if (!(errors && errors.length > 0)) { - _context4.next = 40; - break; - } - - err = errors[0]; - err.message = "Failed to copy some parts with error: ".concat(err.toString(), " part_num: ").concat(err.partNum); - throw err; - - case 40: - _context4.next = 42; - return this.completeMultipartUpload(name, uploadId, doneParts, options); - - case 42: - return _context4.abrupt("return", _context4.sent); - - case 43: - case "end": - return _context4.stop(); - } + } + err = errors[0]; + err.message = "Failed to copy some parts with error: ".concat(err.toString(), " part_num: ").concat(err.partNum); + throw err; + case 40: + _context4.next = 42; + return this.completeMultipartUpload(name, uploadId, doneParts, options); + case 42: + return _context4.abrupt("return", _context4.sent); + case 43: + case "end": + return _context4.stop(); } }, _callee4, this); })); - function _resumeMultipartCopy(_x8, _x9, _x10) { return _resumeMultipartCopy2.apply(this, arguments); } - return _resumeMultipartCopy; }(); - proto._divideMultipartCopyParts = function _divideMultipartCopyParts(fileSize, partSize, startOffset) { var numParts = Math.ceil(fileSize / partSize); var partOffs = []; - for (var i = 0; i < numParts; i++) { var start = partSize * i + startOffset; var end = Math.min(start + partSize, fileSize + startOffset); @@ -4731,145 +3827,120 @@ proto._divideMultipartCopyParts = function _divideMultipartCopyParts(fileSize, p end: end }); } - return partOffs; }; + /** * Get Object Meta * @param {String} bucket bucket name * @param {String} name object name * @param {Object} options */ - - proto._getObjectMeta = /*#__PURE__*/function () { var _getObjectMeta2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(bucket, name, options) { var currentBucket, data; return _regenerator.default.wrap(function _callee5$(_context5) { - while (1) { - switch (_context5.prev = _context5.next) { - case 0: - currentBucket = this.getBucket(); - this.setBucket(bucket); - _context5.next = 4; - return this.head(name, options); - - case 4: - data = _context5.sent; - this.setBucket(currentBucket); - return _context5.abrupt("return", data); - - case 7: - case "end": - return _context5.stop(); - } + while (1) switch (_context5.prev = _context5.next) { + case 0: + currentBucket = this.getBucket(); + this.setBucket(bucket); + _context5.next = 4; + return this.head(name, options); + case 4: + data = _context5.sent; + this.setBucket(currentBucket); + return _context5.abrupt("return", data); + case 7: + case "end": + return _context5.stop(); } }, _callee5, this); })); - function _getObjectMeta(_x13, _x14, _x15) { return _getObjectMeta2.apply(this, arguments); } - return _getObjectMeta; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"copy-to":88,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.array.filter.js":243,"core-js/modules/es.array.find.js":244,"core-js/modules/es.array.from.js":245,"core-js/modules/es.array.map.js":249,"core-js/modules/es.function.name.js":253,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.promise.js":259,"core-js/modules/es.regexp.to-string.js":262,"core-js/modules/es.string.iterator.js":264,"debug":397}],30:[function(require,module,exports){ +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"copy-to":107,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.filter.js":312,"core-js/modules/es.array.find.js":313,"core-js/modules/es.array.from.js":314,"core-js/modules/es.array.map.js":318,"core-js/modules/es.function.name.js":322,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.promise.js":335,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.string.iterator.js":345,"debug":538}],30:[function(require,module,exports){ (function (process){(function (){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.array.map.js"); - require("core-js/modules/es.array.filter.js"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/es.array.sort.js"); - require("core-js/modules/es.array.concat.js"); - -require("core-js/modules/es.object.to-string.js"); - +require("core-js/modules/es.object.keys.js"); require("core-js/modules/es.regexp.to-string.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var copy = require('copy-to'); - var callback = require('./callback'); - var _require = require('./utils/deepCopy'), - deepCopyWith = _require.deepCopyWith; - + deepCopyWith = _require.deepCopyWith; var _require2 = require('./utils/isBuffer'), - isBuffer = _require2.isBuffer; - + isBuffer = _require2.isBuffer; +var _require3 = require('./utils/omit'), + omit = _require3.omit; var proto = exports; + /** * List the on-going multipart uploads * https://help.aliyun.com/document_detail/31997.html * @param {Object} options * @return {Array} the multipart uploads */ - proto.listUploads = /*#__PURE__*/function () { var _listUploads = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(query, options) { var opt, params, result, uploads; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = options || {}; - opt = {}; - copy(options).to(opt); - opt.subres = 'uploads'; - params = this._objectRequestParams('GET', '', opt); - params.query = query; - params.xmlResponse = true; - params.successStatuses = [200]; - _context.next = 10; - return this.request(params); - - case 10: - result = _context.sent; - uploads = result.data.Upload || []; - - if (!Array.isArray(uploads)) { - uploads = [uploads]; - } - - uploads = uploads.map(function (up) { - return { - name: up.Key, - uploadId: up.UploadId, - initiated: up.Initiated - }; - }); - return _context.abrupt("return", { - res: result.res, - uploads: uploads, - bucket: result.data.Bucket, - nextKeyMarker: result.data.NextKeyMarker, - nextUploadIdMarker: result.data.NextUploadIdMarker, - isTruncated: result.data.IsTruncated === 'true' - }); - - case 15: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = options || {}; + opt = {}; + copy(options).to(opt); + opt.subres = 'uploads'; + params = this._objectRequestParams('GET', '', opt); + params.query = query; + params.xmlResponse = true; + params.successStatuses = [200]; + _context.next = 10; + return this.request(params); + case 10: + result = _context.sent; + uploads = result.data.Upload || []; + if (!Array.isArray(uploads)) { + uploads = [uploads]; + } + uploads = uploads.map(function (up) { + return { + name: up.Key, + uploadId: up.UploadId, + initiated: up.Initiated + }; + }); + return _context.abrupt("return", { + res: result.res, + uploads: uploads, + bucket: result.data.Bucket, + nextKeyMarker: result.data.NextKeyMarker, + nextUploadIdMarker: result.data.NextUploadIdMarker, + isTruncated: result.data.IsTruncated === 'true' + }); + case 15: + case "end": + return _context.stop(); } }, _callee, this); })); - function listUploads(_x, _x2) { return _listUploads.apply(this, arguments); } - return listUploads; }(); + /** * List the done uploadPart parts * @param {String} name object name @@ -4881,157 +3952,133 @@ proto.listUploads = /*#__PURE__*/function () { * @param {Object} options * @return {Object} result */ - - proto.listParts = /*#__PURE__*/function () { var _listParts = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name, uploadId, query, options) { var opt, params, result; return _regenerator.default.wrap(function _callee2$(_context2) { - while (1) { - switch (_context2.prev = _context2.next) { - case 0: - options = options || {}; - opt = {}; - copy(options).to(opt); - opt.subres = { - uploadId: uploadId - }; - params = this._objectRequestParams('GET', name, opt); - params.query = query; - params.xmlResponse = true; - params.successStatuses = [200]; - _context2.next = 10; - return this.request(params); - - case 10: - result = _context2.sent; - return _context2.abrupt("return", { - res: result.res, - uploadId: result.data.UploadId, - bucket: result.data.Bucket, - name: result.data.Key, - partNumberMarker: result.data.PartNumberMarker, - nextPartNumberMarker: result.data.NextPartNumberMarker, - maxParts: result.data.MaxParts, - isTruncated: result.data.IsTruncated, - parts: result.data.Part || [] - }); - - case 12: - case "end": - return _context2.stop(); - } + while (1) switch (_context2.prev = _context2.next) { + case 0: + options = options || {}; + opt = {}; + copy(options).to(opt); + opt.subres = { + uploadId: uploadId + }; + params = this._objectRequestParams('GET', name, opt); + params.query = query; + params.xmlResponse = true; + params.successStatuses = [200]; + _context2.next = 10; + return this.request(params); + case 10: + result = _context2.sent; + return _context2.abrupt("return", { + res: result.res, + uploadId: result.data.UploadId, + bucket: result.data.Bucket, + name: result.data.Key, + partNumberMarker: result.data.PartNumberMarker, + nextPartNumberMarker: result.data.NextPartNumberMarker, + maxParts: result.data.MaxParts, + isTruncated: result.data.IsTruncated, + parts: result.data.Part || [] + }); + case 12: + case "end": + return _context2.stop(); } }, _callee2, this); })); - function listParts(_x3, _x4, _x5, _x6) { return _listParts.apply(this, arguments); } - return listParts; }(); + /** * Abort a multipart upload transaction * @param {String} name the object name * @param {String} uploadId the upload id * @param {Object} options */ - - proto.abortMultipartUpload = /*#__PURE__*/function () { var _abortMultipartUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(name, uploadId, options) { var opt, params, result; return _regenerator.default.wrap(function _callee3$(_context3) { - while (1) { - switch (_context3.prev = _context3.next) { - case 0: - this._stop(); - - options = options || {}; - opt = {}; - copy(options).to(opt); - opt.subres = { - uploadId: uploadId - }; - params = this._objectRequestParams('DELETE', name, opt); - params.successStatuses = [204]; - _context3.next = 9; - return this.request(params); - - case 9: - result = _context3.sent; - return _context3.abrupt("return", { - res: result.res - }); - - case 11: - case "end": - return _context3.stop(); - } + while (1) switch (_context3.prev = _context3.next) { + case 0: + this._stop(); + options = options || {}; + opt = {}; + copy(options).to(opt); + opt.subres = { + uploadId: uploadId + }; + params = this._objectRequestParams('DELETE', name, opt); + params.successStatuses = [204]; + _context3.next = 9; + return this.request(params); + case 9: + result = _context3.sent; + return _context3.abrupt("return", { + res: result.res + }); + case 11: + case "end": + return _context3.stop(); } }, _callee3, this); })); - function abortMultipartUpload(_x7, _x8, _x9) { return _abortMultipartUpload.apply(this, arguments); } - return abortMultipartUpload; }(); + /** * Initiate a multipart upload transaction * @param {String} name the object name * @param {Object} options * @return {String} upload id */ - - proto.initMultipartUpload = /*#__PURE__*/function () { var _initMultipartUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(name, options) { var opt, params, result; return _regenerator.default.wrap(function _callee4$(_context4) { - while (1) { - switch (_context4.prev = _context4.next) { - case 0: - options = options || {}; - opt = {}; - copy(options).to(opt); - opt.headers = opt.headers || {}; - - this._convertMetaToHeaders(options.meta, opt.headers); - - opt.subres = 'uploads'; - params = this._objectRequestParams('POST', name, opt); - params.mime = options.mime; - params.xmlResponse = true; - params.successStatuses = [200]; - _context4.next = 12; - return this.request(params); - - case 12: - result = _context4.sent; - return _context4.abrupt("return", { - res: result.res, - bucket: result.data.Bucket, - name: result.data.Key, - uploadId: result.data.UploadId - }); - - case 14: - case "end": - return _context4.stop(); - } + while (1) switch (_context4.prev = _context4.next) { + case 0: + options = options || {}; + opt = {}; + copy(options).to(opt); + opt.headers = opt.headers || {}; + this._convertMetaToHeaders(options.meta, opt.headers); + opt.subres = 'uploads'; + params = this._objectRequestParams('POST', name, opt); + params.mime = options.mime; + params.xmlResponse = true; + params.successStatuses = [200]; + _context4.next = 12; + return this.request(params); + case 12: + result = _context4.sent; + return _context4.abrupt("return", { + res: result.res, + bucket: result.data.Bucket, + name: result.data.Key, + uploadId: result.data.UploadId + }); + case 14: + case "end": + return _context4.stop(); } }, _callee4, this); })); - function initMultipartUpload(_x10, _x11) { return _initMultipartUpload.apply(this, arguments); } - return initMultipartUpload; }(); + /** * Upload a part in a multipart upload transaction * @param {String} name the object name @@ -5042,61 +4089,48 @@ proto.initMultipartUpload = /*#__PURE__*/function () { * @param {Integer} end part end bytes e.g: 204800 * @param {Object} options */ - - proto.uploadPart = /*#__PURE__*/function () { var _uploadPart2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(name, uploadId, partNo, file, start, end, options) { var data, isBrowserEnv; return _regenerator.default.wrap(function _callee5$(_context5) { - while (1) { - switch (_context5.prev = _context5.next) { - case 0: - data = { - size: end - start - }; - isBrowserEnv = process && process.browser; - - if (!isBrowserEnv) { - _context5.next = 8; - break; - } - - _context5.next = 5; - return this._createBuffer(file, start, end); - - case 5: - data.content = _context5.sent; - _context5.next = 11; + while (1) switch (_context5.prev = _context5.next) { + case 0: + data = { + size: end - start + }; + isBrowserEnv = process && process.browser; + if (!isBrowserEnv) { + _context5.next = 8; break; - - case 8: - _context5.next = 10; - return this._createStream(file, start, end); - - case 10: - data.stream = _context5.sent; - - case 11: - _context5.next = 13; - return this._uploadPart(name, uploadId, partNo, data, options); - - case 13: - return _context5.abrupt("return", _context5.sent); - - case 14: - case "end": - return _context5.stop(); - } + } + _context5.next = 5; + return this._createBuffer(file, start, end); + case 5: + data.content = _context5.sent; + _context5.next = 11; + break; + case 8: + _context5.next = 10; + return this._createStream(file, start, end); + case 10: + data.stream = _context5.sent; + case 11: + _context5.next = 13; + return this._uploadPart(name, uploadId, partNo, data, options); + case 13: + return _context5.abrupt("return", _context5.sent); + case 14: + case "end": + return _context5.stop(); } }, _callee5, this); })); - function uploadPart(_x12, _x13, _x14, _x15, _x16, _x17, _x18) { return _uploadPart2.apply(this, arguments); } - return uploadPart; }(); + /** * Complete a multipart upload transaction * @param {String} name the object name @@ -5116,82 +4150,76 @@ proto.uploadPart = /*#__PURE__*/function () { * key2: 'value2' * } */ - - proto.completeMultipartUpload = /*#__PURE__*/function () { var _completeMultipartUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(name, uploadId, parts, options) { var completeParts, xml, i, p, opt, params, result, ret; return _regenerator.default.wrap(function _callee6$(_context6) { - while (1) { - switch (_context6.prev = _context6.next) { - case 0: - completeParts = parts.concat().sort(function (a, b) { - return a.number - b.number; - }).filter(function (item, index, arr) { - return !index || item.number !== arr[index - 1].number; - }); - xml = '\n\n'; - - for (i = 0; i < completeParts.length; i++) { - p = completeParts[i]; - xml += '\n'; - xml += "".concat(p.number, "\n"); - xml += "".concat(p.etag, "\n"); - xml += '\n'; - } - - xml += ''; - options = options || {}; - opt = {}; - opt = deepCopyWith(options, function (_) { - if (isBuffer(_)) return null; - }); - if (opt.headers) delete opt.headers['x-oss-server-side-encryption']; - opt.subres = { - uploadId: uploadId - }; - params = this._objectRequestParams('POST', name, opt); - callback.encodeCallback(params, opt); - params.mime = 'xml'; - params.content = xml; - - if (!(params.headers && params.headers['x-oss-callback'])) { - params.xmlResponse = true; - } - - params.successStatuses = [200]; - _context6.next = 17; - return this.request(params); - - case 17: - result = _context6.sent; - ret = { - res: result.res, - bucket: params.bucket, - name: name, - etag: result.res.headers.etag - }; - - if (params.headers && params.headers['x-oss-callback']) { - ret.data = JSON.parse(result.data.toString()); - } - - return _context6.abrupt("return", ret); - - case 21: - case "end": - return _context6.stop(); - } + while (1) switch (_context6.prev = _context6.next) { + case 0: + completeParts = parts.concat().sort(function (a, b) { + return a.number - b.number; + }).filter(function (item, index, arr) { + return !index || item.number !== arr[index - 1].number; + }); + xml = '\n\n'; + for (i = 0; i < completeParts.length; i++) { + p = completeParts[i]; + xml += '\n'; + xml += "".concat(p.number, "\n"); + xml += "".concat(p.etag, "\n"); + xml += '\n'; + } + xml += ''; + options = options || {}; + opt = {}; + opt = deepCopyWith(options, function (_) { + if (isBuffer(_)) return null; + }); + opt.subres = { + uploadId: uploadId + }; + opt.headers = omit(opt.headers, ['x-oss-server-side-encryption', 'x-oss-storage-class']); + params = this._objectRequestParams('POST', name, opt); + callback.encodeCallback(params, opt); + params.mime = 'xml'; + params.content = xml; + if (!(params.headers && params.headers['x-oss-callback'])) { + params.xmlResponse = true; + } + params.successStatuses = [200]; + _context6.next = 17; + return this.request(params); + case 17: + result = _context6.sent; + if (!options.progress) { + _context6.next = 21; + break; + } + _context6.next = 21; + return options.progress(1, null, result.res); + case 21: + ret = { + res: result.res, + bucket: params.bucket, + name: name, + etag: result.res.headers.etag + }; + if (params.headers && params.headers['x-oss-callback']) { + ret.data = JSON.parse(result.data.toString()); + } + return _context6.abrupt("return", ret); + case 24: + case "end": + return _context6.stop(); } }, _callee6, this); })); - function completeMultipartUpload(_x19, _x20, _x21, _x22) { return _completeMultipartUpload.apply(this, arguments); } - return completeMultipartUpload; }(); + /** * Upload a part in a multipart upload transaction * @param {String} name the object name @@ -5200,173 +4228,227 @@ proto.completeMultipartUpload = /*#__PURE__*/function () { * @param {Object} data the body data * @param {Object} options */ - - proto._uploadPart = /*#__PURE__*/function () { var _uploadPart3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(name, uploadId, partNo, data, options) { var opt, params, isBrowserEnv, result; return _regenerator.default.wrap(function _callee7$(_context7) { - while (1) { - switch (_context7.prev = _context7.next) { - case 0: - options = options || {}; - opt = {}; - copy(options).to(opt); - opt.headers = { - 'Content-Length': data.size - }; - opt.subres = { - partNumber: partNo, - uploadId: uploadId - }; - params = this._objectRequestParams('PUT', name, opt); - params.mime = opt.mime; - isBrowserEnv = process && process.browser; - isBrowserEnv ? params.content = data.content : params.stream = data.stream; - params.successStatuses = [200]; - params.disabledMD5 = options.disabledMD5; - _context7.next = 13; - return this.request(params); - - case 13: - result = _context7.sent; - - if (result.res.headers.etag) { - _context7.next = 16; - break; - } - - throw new Error('Please set the etag of expose-headers in OSS \n https://help.aliyun.com/document_detail/32069.html'); - - case 16: - if (data.stream) { - data.stream = null; - params.stream = null; - } - - return _context7.abrupt("return", { - name: name, - etag: result.res.headers.etag, - res: result.res - }); - - case 18: - case "end": - return _context7.stop(); - } + while (1) switch (_context7.prev = _context7.next) { + case 0: + options = options || {}; + opt = {}; + copy(options).to(opt); + opt.headers = opt.headers || {}; + opt.headers['Content-Length'] = data.size; + + // Uploading shards does not require x-oss server side encryption + opt.headers = omit(opt.headers, ['x-oss-server-side-encryption']); + opt.subres = { + partNumber: partNo, + uploadId: uploadId + }; + params = this._objectRequestParams('PUT', name, opt); + params.mime = opt.mime; + isBrowserEnv = process && process.browser; + isBrowserEnv ? params.content = data.content : params.stream = data.stream; + params.successStatuses = [200]; + params.disabledMD5 = options.disabledMD5; + _context7.next = 15; + return this.request(params); + case 15: + result = _context7.sent; + if (result.res.headers.etag) { + _context7.next = 18; + break; + } + throw new Error('Please set the etag of expose-headers in OSS \n https://help.aliyun.com/document_detail/32069.html'); + case 18: + if (data.stream) { + data.stream = null; + params.stream = null; + } + return _context7.abrupt("return", { + name: name, + etag: result.res.headers.etag, + res: result.res + }); + case 20: + case "end": + return _context7.stop(); } }, _callee7, this); })); - function _uploadPart(_x23, _x24, _x25, _x26, _x27) { return _uploadPart3.apply(this, arguments); } - return _uploadPart; }(); }).call(this)}).call(this,require('_process')) -},{"./callback":24,"./utils/deepCopy":56,"./utils/isBuffer":63,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"_process":399,"copy-to":88,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.array.filter.js":243,"core-js/modules/es.array.map.js":249,"core-js/modules/es.array.sort.js":251,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.regexp.to-string.js":262}],31:[function(require,module,exports){ +},{"./callback":24,"./utils/deepCopy":59,"./utils/isBuffer":68,"./utils/omit":76,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"_process":540,"copy-to":107,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.filter.js":312,"core-js/modules/es.array.map.js":318,"core-js/modules/es.array.sort.js":320,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.to-string.js":341}],31:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); +require("core-js/modules/es.regexp.exec.js"); +var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); +var urlutil = require('url'); +var utility = require('utility'); +var copy = require('copy-to'); +var signHelper = require('../../common/signUtils'); +var _require = require('../utils/isIP'), + isIP = _require.isIP; +var _require2 = require('../utils/setSTSToken'), + setSTSToken = _require2.setSTSToken; +var _require3 = require('../utils/isFunction'), + isFunction = _require3.isFunction; +var proto = exports; -require("core-js/modules/web.dom-collections.for-each.js"); +/** + * asyncSignatureUrl + * @param {String} name object name + * @param {Object} options options + * @param {boolean} [strictObjectNameValidation=true] the flag of verifying object name strictly + */ +proto.asyncSignatureUrl = /*#__PURE__*/function () { + var _asyncSignatureUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) { + var strictObjectNameValidation, + expires, + params, + resource, + signRes, + url, + _args = arguments; + return _regenerator.default.wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + strictObjectNameValidation = _args.length > 2 && _args[2] !== undefined ? _args[2] : true; + if (!isIP(this.options.endpoint.hostname)) { + _context.next = 3; + break; + } + throw new Error('can not get the object URL when endpoint is IP'); + case 3: + if (!(strictObjectNameValidation && /^\?/.test(name))) { + _context.next = 5; + break; + } + throw new Error("Invalid object name ".concat(name)); + case 5: + options = options || {}; + name = this._objectName(name); + options.method = options.method || 'GET'; + expires = utility.timestamp() + (options.expires || 1800); + params = { + bucket: this.options.bucket, + object: name + }; + resource = this._getResource(params); + if (!(this.options.stsToken && isFunction(this.options.refreshSTSToken))) { + _context.next = 14; + break; + } + _context.next = 14; + return setSTSToken.call(this); + case 14: + if (this.options.stsToken) { + options['security-token'] = this.options.stsToken; + } + signRes = signHelper._signatureForURL(this.options.accessKeySecret, options, resource, expires); + url = urlutil.parse(this._getReqUrl(params)); + url.query = { + OSSAccessKeyId: this.options.accessKeyId, + Expires: expires, + Signature: signRes.Signature + }; + copy(signRes.subResource).to(url.query); + return _context.abrupt("return", url.format()); + case 20: + case "end": + return _context.stop(); + } + }, _callee, this); + })); + function asyncSignatureUrl(_x, _x2) { + return _asyncSignatureUrl.apply(this, arguments); + } + return asyncSignatureUrl; +}(); -require("core-js/modules/es.object.keys.js"); +},{"../../common/signUtils":51,"../utils/isFunction":71,"../utils/isIP":72,"../utils/setSTSToken":79,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"copy-to":107,"core-js/modules/es.regexp.exec.js":340,"url":545,"utility":547}],32:[function(require,module,exports){ +"use strict"; +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); +var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); +require("core-js/modules/es.object.to-string.js"); +require("core-js/modules/web.dom-collections.for-each.js"); +require("core-js/modules/es.object.keys.js"); require("core-js/modules/es.array.find.js"); - require("core-js/modules/es.array.includes.js"); - require("core-js/modules/es.array.concat.js"); - require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/checkBucketName'), - _checkBucketName = _require.checkBucketName; - + _checkBucketName = _require.checkBucketName; var proto = exports; var REPLACE_HEDERS = ['content-type', 'content-encoding', 'content-language', 'content-disposition', 'cache-control', 'expires']; - proto.copy = /*#__PURE__*/function () { var _copy = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, sourceName, bucketName, options) { var params, result, data; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - if ((0, _typeof2.default)(bucketName) === 'object') { - options = bucketName; // 兼容旧版本,旧版本第三个参数为options - } - - options = options || {}; - options.headers = options.headers || {}; - Object.keys(options.headers).forEach(function (key) { - options.headers["x-oss-copy-source-".concat(key.toLowerCase())] = options.headers[key]; - }); - - if (options.meta || Object.keys(options.headers).find(function (_) { - return REPLACE_HEDERS.includes(_.toLowerCase()); - })) { - options.headers['x-oss-metadata-directive'] = 'REPLACE'; - } - - this._convertMetaToHeaders(options.meta, options.headers); - - sourceName = this._getSourceName(sourceName, bucketName); - - if (options.versionId) { - sourceName = "".concat(sourceName, "?versionId=").concat(options.versionId); - } - - options.headers['x-oss-copy-source'] = sourceName; - params = this._objectRequestParams('PUT', name, options); - params.xmlResponse = true; - params.successStatuses = [200, 304]; - _context.next = 14; - return this.request(params); - - case 14: - result = _context.sent; - data = result.data; - - if (data) { - data = { - etag: data.ETag, - lastModified: data.LastModified - }; - } - - return _context.abrupt("return", { - data: data, - res: result.res - }); - - case 18: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + if ((0, _typeof2.default)(bucketName) === 'object') { + options = bucketName; // 兼容旧版本,旧版本第三个参数为options + } + options = options || {}; + options.headers = options.headers || {}; + Object.keys(options.headers).forEach(function (key) { + options.headers["x-oss-copy-source-".concat(key.toLowerCase())] = options.headers[key]; + }); + if (options.meta || Object.keys(options.headers).find(function (_) { + return REPLACE_HEDERS.includes(_.toLowerCase()); + })) { + options.headers['x-oss-metadata-directive'] = 'REPLACE'; + } + this._convertMetaToHeaders(options.meta, options.headers); + sourceName = this._getSourceName(sourceName, bucketName); + if (options.versionId) { + sourceName = "".concat(sourceName, "?versionId=").concat(options.versionId); + } + options.headers['x-oss-copy-source'] = sourceName; + params = this._objectRequestParams('PUT', name, options); + params.xmlResponse = true; + params.successStatuses = [200, 304]; + _context.next = 14; + return this.request(params); + case 14: + result = _context.sent; + data = result.data; + if (data) { + data = { + etag: data.ETag, + lastModified: data.LastModified + }; + } + return _context.abrupt("return", { + data: data, + res: result.res + }); + case 18: + case "end": + return _context.stop(); } }, _callee, this); })); - function copy(_x, _x2, _x3, _x4) { return _copy.apply(this, arguments); } - return copy; -}(); // todo delete - +}(); +// todo delete proto._getSourceName = function _getSourceName(sourceName, bucketName) { if (typeof bucketName === 'string') { sourceName = this._objectName(sourceName); @@ -5376,25 +4458,19 @@ proto._getSourceName = function _getSourceName(sourceName, bucketName) { bucketName = sourceName.replace(/\/(.+?)(\/.*)/, '$1'); sourceName = sourceName.replace(/(\/.+?\/)(.*)/, '$2'); } - _checkBucketName(bucketName); - sourceName = encodeURIComponent(sourceName); sourceName = "/".concat(bucketName, "/").concat(sourceName); return sourceName; }; -},{"../utils/checkBucketName":50,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/helpers/typeof":75,"@babel/runtime/regenerator":76,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.array.find.js":244,"core-js/modules/es.array.includes.js":246,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.string.replace.js":266,"core-js/modules/web.dom-collections.for-each.js":296}],32:[function(require,module,exports){ +},{"../utils/checkBucketName":52,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/helpers/typeof":91,"@babel/runtime/regenerator":93,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.find.js":313,"core-js/modules/es.array.includes.js":315,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.string.replace.js":347,"core-js/modules/web.dom-collections.for-each.js":382}],33:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var proto = exports; /** * delete @@ -5406,178 +4482,142 @@ var proto = exports; proto.delete = /*#__PURE__*/function () { var _delete2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) { var options, - params, - result, - _args = arguments; + params, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - options.subres = Object.assign({}, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - params = this._objectRequestParams('DELETE', name, options); - params.successStatuses = [204]; - _context.next = 7; - return this.request(params); - - case 7: - result = _context.sent; - return _context.abrupt("return", { - res: result.res - }); - - case 9: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + options.subres = Object.assign({}, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + params = this._objectRequestParams('DELETE', name, options); + params.successStatuses = [204]; + _context.next = 7; + return this.request(params); + case 7: + result = _context.sent; + return _context.abrupt("return", { + res: result.res + }); + case 9: + case "end": + return _context.stop(); } }, _callee, this); })); - function _delete(_x) { return _delete2.apply(this, arguments); } - return _delete; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],33:[function(require,module,exports){ +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],34:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - /* eslint-disable object-curly-newline */ var utility = require('utility'); - var _require = require('../utils/obj2xml'), - obj2xml = _require.obj2xml; - + obj2xml = _require.obj2xml; var proto = exports; - proto.deleteMulti = /*#__PURE__*/function () { var _deleteMulti = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(names) { var options, - objects, - i, - object, - _names$i, - key, - versionId, - paramXMLObj, - paramXML, - params, - result, - r, - deleted, - _args = arguments; - + objects, + i, + object, + _names$i, + key, + versionId, + paramXMLObj, + paramXML, + params, + result, + r, + deleted, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - objects = []; - - if (!(!names || !names.length)) { - _context.next = 4; - break; - } - - throw new Error('names is required'); - - case 4: - for (i = 0; i < names.length; i++) { - object = {}; - - if (typeof names[i] === 'string') { - object.Key = utility.escape(this._objectName(names[i])); - } else { - _names$i = names[i], key = _names$i.key, versionId = _names$i.versionId; - object.Key = utility.escape(this._objectName(key)); - object.VersionId = versionId; - } - - objects.push(object); + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + objects = []; + if (!(!names || !names.length)) { + _context.next = 4; + break; + } + throw new Error('names is required'); + case 4: + for (i = 0; i < names.length; i++) { + object = {}; + if (typeof names[i] === 'string') { + object.Key = utility.escape(this._objectName(names[i])); + } else { + _names$i = names[i], key = _names$i.key, versionId = _names$i.versionId; + object.Key = utility.escape(this._objectName(key)); + object.VersionId = versionId; } - - paramXMLObj = { - Delete: { - Quiet: !!options.quiet, - Object: objects - } - }; - paramXML = obj2xml(paramXMLObj, { - headers: true - }); - options.subres = Object.assign({ - delete: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; + objects.push(object); + } + paramXMLObj = { + Delete: { + Quiet: !!options.quiet, + Object: objects } - - params = this._objectRequestParams('POST', '', options); - params.mime = 'xml'; - params.content = paramXML; - params.xmlResponse = true; - params.successStatuses = [200]; - _context.next = 16; - return this.request(params); - - case 16: - result = _context.sent; - r = result.data; - deleted = r && r.Deleted || null; - - if (deleted) { - if (!Array.isArray(deleted)) { - deleted = [deleted]; - } + }; + paramXML = obj2xml(paramXMLObj, { + headers: true + }); + options.subres = Object.assign({ + delete: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + params = this._objectRequestParams('POST', '', options); + params.mime = 'xml'; + params.content = paramXML; + params.xmlResponse = true; + params.successStatuses = [200]; + _context.next = 16; + return this.request(params); + case 16: + result = _context.sent; + r = result.data; + deleted = r && r.Deleted || null; + if (deleted) { + if (!Array.isArray(deleted)) { + deleted = [deleted]; } - - return _context.abrupt("return", { - res: result.res, - deleted: deleted || [] - }); - - case 21: - case "end": - return _context.stop(); - } + } + return _context.abrupt("return", { + res: result.res, + deleted: deleted || [] + }); + case 21: + case "end": + return _context.stop(); } }, _callee, this); })); - function deleteMulti(_x) { return _deleteMulti.apply(this, arguments); } - return deleteMulti; }(); -},{"../utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255,"utility":406}],34:[function(require,module,exports){ +},{"../utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325,"utility":547}],35:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var proto = exports; /** * deleteObjectTagging @@ -5588,73 +4628,61 @@ var proto = exports; proto.deleteObjectTagging = /*#__PURE__*/function () { var _deleteObjectTagging = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) { var options, - params, - result, - _args = arguments; + params, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - options.subres = Object.assign({ - tagging: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - name = this._objectName(name); - params = this._objectRequestParams('DELETE', name, options); - params.successStatuses = [204]; - _context.next = 8; - return this.request(params); - - case 8: - result = _context.sent; - return _context.abrupt("return", { - status: result.status, - res: result.res - }); - - case 10: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + options.subres = Object.assign({ + tagging: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + name = this._objectName(name); + params = this._objectRequestParams('DELETE', name, options); + params.successStatuses = [204]; + _context.next = 8; + return this.request(params); + case 8: + result = _context.sent; + return _context.abrupt("return", { + status: result.status, + res: result.res + }); + case 10: + case "end": + return _context.stop(); } }, _callee, this); })); - function deleteObjectTagging(_x) { return _deleteObjectTagging.apply(this, arguments); } - return deleteObjectTagging; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],35:[function(require,module,exports){ +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],36:[function(require,module,exports){ "use strict"; require("core-js/modules/es.array.concat.js"); - var urlutil = require('url'); - var _require = require('../utils/isIP'), - isIP = _require.isIP; - + isIP = _require.isIP; var proto = exports; + /** * Get Object url by name * @param {String} name - object name * @param {String} [baseUrl] - If provide `baseUrl`, will use `baseUrl` instead the default `endpoint and bucket`. * @return {String} object url include bucket */ - proto.generateObjectUrl = function generateObjectUrl(name, baseUrl) { if (isIP(this.options.endpoint.hostname)) { throw new Error('can not get the object URL when endpoint is IP'); } - if (!baseUrl) { baseUrl = this.options.endpoint.format(); var copyUrl = urlutil.parse(baseUrl); @@ -5665,26 +4693,19 @@ proto.generateObjectUrl = function generateObjectUrl(name, baseUrl) { } else if (baseUrl[baseUrl.length - 1] !== '/') { baseUrl += '/'; } - return baseUrl + this._escape(this._objectName(name)); }; -},{"../utils/isIP":66,"core-js/modules/es.array.concat.js":241,"url":404}],36:[function(require,module,exports){ +},{"../utils/isIP":72,"core-js/modules/es.array.concat.js":310,"url":545}],37:[function(require,module,exports){ (function (process){(function (){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var fs = require('fs'); - var is = require('is-type-of'); - var proto = exports; /** * get @@ -5693,371 +4714,301 @@ var proto = exports; * @param {Object} options * @param {{res}} */ - proto.get = /*#__PURE__*/function () { var _get = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, file) { var options, - writeStream, - needDestroy, - isBrowserEnv, - responseCacheControl, - defaultSubresOptions, - result, - params, - _args = arguments; + writeStream, + needDestroy, + isBrowserEnv, + responseCacheControl, + defaultSubresOptions, + result, + params, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; - writeStream = null; - needDestroy = false; - - if (is.writableStream(file)) { - writeStream = file; - } else if (is.string(file)) { - writeStream = fs.createWriteStream(file); - needDestroy = true; - } else { - // get(name, options) - options = file; - } - - options = options || {}; - isBrowserEnv = process && process.browser; - responseCacheControl = options.responseCacheControl === null ? '' : 'no-cache'; - defaultSubresOptions = isBrowserEnv && responseCacheControl ? { - 'response-cache-control': responseCacheControl - } : {}; - options.subres = Object.assign(defaultSubresOptions, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - if (options.process) { - options.subres['x-oss-process'] = options.process; - } - - _context.prev = 11; - params = this._objectRequestParams('GET', name, options); - params.writeStream = writeStream; - params.successStatuses = [200, 206, 304]; - _context.next = 17; - return this.request(params); - - case 17: - result = _context.sent; - - if (needDestroy) { - writeStream.destroy(); - } - - _context.next = 28; + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; + writeStream = null; + needDestroy = false; + if (is.writableStream(file)) { + writeStream = file; + } else if (is.string(file)) { + writeStream = fs.createWriteStream(file); + needDestroy = true; + } else { + // get(name, options) + options = file; + } + options = options || {}; + isBrowserEnv = process && process.browser; + responseCacheControl = options.responseCacheControl === null ? '' : 'no-cache'; + defaultSubresOptions = isBrowserEnv && responseCacheControl ? { + 'response-cache-control': responseCacheControl + } : {}; + options.subres = Object.assign(defaultSubresOptions, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + if (options.process) { + options.subres['x-oss-process'] = options.process; + } + _context.prev = 11; + params = this._objectRequestParams('GET', name, options); + params.writeStream = writeStream; + params.successStatuses = [200, 206, 304]; + _context.next = 17; + return this.request(params); + case 17: + result = _context.sent; + if (needDestroy) { + writeStream.destroy(); + } + _context.next = 28; + break; + case 21: + _context.prev = 21; + _context.t0 = _context["catch"](11); + if (!needDestroy) { + _context.next = 27; break; + } + writeStream.destroy(); + // should delete the exists file before throw error + _context.next = 27; + return this._deleteFileSafe(file); + case 27: + throw _context.t0; + case 28: + return _context.abrupt("return", { + res: result.res, + content: result.data + }); + case 29: + case "end": + return _context.stop(); + } + }, _callee, this, [[11, 21]]); + })); + function get(_x, _x2) { + return _get.apply(this, arguments); + } + return get; +}(); - case 21: - _context.prev = 21; - _context.t0 = _context["catch"](11); - - if (!needDestroy) { - _context.next = 27; - break; - } - - writeStream.destroy(); // should delete the exists file before throw error - - _context.next = 27; - return this._deleteFileSafe(file); - - case 27: - throw _context.t0; - - case 28: - return _context.abrupt("return", { - res: result.res, - content: result.data - }); - - case 29: - case "end": - return _context.stop(); - } - } - }, _callee, this, [[11, 21]]); - })); - - function get(_x, _x2) { - return _get.apply(this, arguments); - } - - return get; -}(); - -}).call(this)}).call(this,require('_process')) -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"_process":399,"core-js/modules/es.object.assign.js":255,"fs":84,"is-type-of":398}],37:[function(require,module,exports){ -"use strict"; +}).call(this)}).call(this,require('_process')) +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"_process":540,"core-js/modules/es.object.assign.js":325,"fs":102,"is-type-of":539}],38:[function(require,module,exports){ +"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var proto = exports; + /* * Get object's ACL * @param {String} name the object key * @param {Object} options * @return {Object} */ - proto.getACL = /*#__PURE__*/function () { var _getACL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) { var options, - params, - result, - _args = arguments; + params, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - options.subres = Object.assign({ - acl: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - name = this._objectName(name); - params = this._objectRequestParams('GET', name, options); - params.successStatuses = [200]; - params.xmlResponse = true; - _context.next = 9; - return this.request(params); - - case 9: - result = _context.sent; - return _context.abrupt("return", { - acl: result.data.AccessControlList.Grant, - owner: { - id: result.data.Owner.ID, - displayName: result.data.Owner.DisplayName - }, - res: result.res - }); - - case 11: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + options.subres = Object.assign({ + acl: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + name = this._objectName(name); + params = this._objectRequestParams('GET', name, options); + params.successStatuses = [200]; + params.xmlResponse = true; + _context.next = 9; + return this.request(params); + case 9: + result = _context.sent; + return _context.abrupt("return", { + acl: result.data.AccessControlList.Grant, + owner: { + id: result.data.Owner.ID, + displayName: result.data.Owner.DisplayName + }, + res: result.res + }); + case 11: + case "end": + return _context.stop(); } }, _callee, this); })); - function getACL(_x) { return _getACL.apply(this, arguments); } - return getACL; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],38:[function(require,module,exports){ +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],39:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.keys.js"); - require("core-js/modules/es.object.assign.js"); - require("core-js/modules/es.array.map.js"); - require("core-js/modules/es.number.constructor.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - /* eslint-disable no-use-before-define */ var proto = exports; - var _require = require('../utils/isObject'), - isObject = _require.isObject; - + isObject = _require.isObject; var _require2 = require('../utils/isArray'), - isArray = _require2.isArray; - + isArray = _require2.isArray; proto.getBucketVersions = getBucketVersions; proto.listObjectVersions = getBucketVersions; - function getBucketVersions() { return _getBucketVersions.apply(this, arguments); } - function _getBucketVersions() { _getBucketVersions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() { var query, - options, - params, - result, - objects, - deleteMarker, - that, - prefixes, - _args = arguments; + options, + params, + result, + objects, + deleteMarker, + that, + prefixes, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - query = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - - if (!(query.versionIdMarker && query.keyMarker === undefined)) { - _context.next = 4; - break; - } - - throw new Error('A version-id marker cannot be specified without a key marker'); - - case 4: - options.subres = Object.assign({ - versions: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - params = this._objectRequestParams('GET', '', options); - params.xmlResponse = true; - params.successStatuses = [200]; - params.query = formatQuery(query); - _context.next = 12; - return this.request(params); - - case 12: - result = _context.sent; - objects = result.data.Version || []; - deleteMarker = result.data.DeleteMarker || []; - that = this; - - if (objects) { - if (!Array.isArray(objects)) { - objects = [objects]; - } - - objects = objects.map(function (obj) { - return { - name: obj.Key, - url: that._objectUrl(obj.Key), - lastModified: obj.LastModified, - isLatest: obj.IsLatest === 'true', - versionId: obj.VersionId, - etag: obj.ETag, - type: obj.Type, - size: Number(obj.Size), - storageClass: obj.StorageClass, - owner: { - id: obj.Owner.ID, - displayName: obj.Owner.DisplayName - } - }; - }); + while (1) switch (_context.prev = _context.next) { + case 0: + query = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + if (!(query.versionIdMarker && query.keyMarker === undefined)) { + _context.next = 4; + break; + } + throw new Error('A version-id marker cannot be specified without a key marker'); + case 4: + options.subres = Object.assign({ + versions: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + params = this._objectRequestParams('GET', '', options); + params.xmlResponse = true; + params.successStatuses = [200]; + params.query = formatQuery(query); + _context.next = 12; + return this.request(params); + case 12: + result = _context.sent; + objects = result.data.Version || []; + deleteMarker = result.data.DeleteMarker || []; + that = this; + if (objects) { + if (!Array.isArray(objects)) { + objects = [objects]; } - - if (deleteMarker) { - if (!isArray(deleteMarker)) { - deleteMarker = [deleteMarker]; - } - - deleteMarker = deleteMarker.map(function (obj) { - return { - name: obj.Key, - lastModified: obj.LastModified, - versionId: obj.VersionId, - owner: { - id: obj.Owner.ID, - displayName: obj.Owner.DisplayName - } - }; - }); + objects = objects.map(function (obj) { + return { + name: obj.Key, + url: that._objectUrl(obj.Key), + lastModified: obj.LastModified, + isLatest: obj.IsLatest === 'true', + versionId: obj.VersionId, + etag: obj.ETag, + type: obj.Type, + size: Number(obj.Size), + storageClass: obj.StorageClass, + owner: { + id: obj.Owner.ID, + displayName: obj.Owner.DisplayName + } + }; + }); + } + if (deleteMarker) { + if (!isArray(deleteMarker)) { + deleteMarker = [deleteMarker]; } - - prefixes = result.data.CommonPrefixes || null; - - if (prefixes) { - if (!isArray(prefixes)) { - prefixes = [prefixes]; - } - - prefixes = prefixes.map(function (item) { - return item.Prefix; - }); + deleteMarker = deleteMarker.map(function (obj) { + return { + name: obj.Key, + lastModified: obj.LastModified, + versionId: obj.VersionId, + owner: { + id: obj.Owner.ID, + displayName: obj.Owner.DisplayName + } + }; + }); + } + prefixes = result.data.CommonPrefixes || null; + if (prefixes) { + if (!isArray(prefixes)) { + prefixes = [prefixes]; } - - return _context.abrupt("return", { - res: result.res, - objects: objects, - deleteMarker: deleteMarker, - prefixes: prefixes, - // attirbute of legacy error - nextMarker: result.data.NextKeyMarker || null, - // attirbute of legacy error - NextVersionIdMarker: result.data.NextVersionIdMarker || null, - nextKeyMarker: result.data.NextKeyMarker || null, - nextVersionIdMarker: result.data.NextVersionIdMarker || null, - isTruncated: result.data.IsTruncated === 'true' + prefixes = prefixes.map(function (item) { + return item.Prefix; }); - - case 21: - case "end": - return _context.stop(); - } + } + return _context.abrupt("return", { + res: result.res, + objects: objects, + deleteMarker: deleteMarker, + prefixes: prefixes, + // attirbute of legacy error + nextMarker: result.data.NextKeyMarker || null, + // attirbute of legacy error + NextVersionIdMarker: result.data.NextVersionIdMarker || null, + nextKeyMarker: result.data.NextKeyMarker || null, + nextVersionIdMarker: result.data.NextVersionIdMarker || null, + isTruncated: result.data.IsTruncated === 'true' + }); + case 21: + case "end": + return _context.stop(); } }, _callee, this); })); return _getBucketVersions.apply(this, arguments); } - function camel2Line(name) { return name.replace(/([A-Z])/g, '-$1').toLowerCase(); } - function formatQuery() { var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var obj = {}; - if (isObject(query)) { Object.keys(query).forEach(function (key) { obj[camel2Line(key)] = query[key]; }); } - return obj; } -},{"../utils/isArray":61,"../utils/isObject":67,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.map.js":249,"core-js/modules/es.number.constructor.js":254,"core-js/modules/es.object.assign.js":255,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.string.replace.js":266,"core-js/modules/web.dom-collections.for-each.js":296}],39:[function(require,module,exports){ +},{"../utils/isArray":66,"../utils/isObject":73,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.map.js":318,"core-js/modules/es.number.constructor.js":324,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.string.replace.js":347,"core-js/modules/web.dom-collections.for-each.js":382}],40:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var proto = exports; /** * getObjectMeta @@ -6070,63 +5021,50 @@ proto.getObjectMeta = /*#__PURE__*/function () { var _getObjectMeta = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, options) { var params, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = options || {}; - name = this._objectName(name); - options.subres = Object.assign({ - objectMeta: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - params = this._objectRequestParams('HEAD', name, options); - params.successStatuses = [200]; - _context.next = 8; - return this.request(params); - - case 8: - result = _context.sent; - return _context.abrupt("return", { - status: result.status, - res: result.res - }); - - case 10: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = options || {}; + name = this._objectName(name); + options.subres = Object.assign({ + objectMeta: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + params = this._objectRequestParams('HEAD', name, options); + params.successStatuses = [200]; + _context.next = 8; + return this.request(params); + case 8: + result = _context.sent; + return _context.abrupt("return", { + status: result.status, + res: result.res + }); + case 10: + case "end": + return _context.stop(); } }, _callee, this); })); - function getObjectMeta(_x, _x2) { return _getObjectMeta.apply(this, arguments); } - return getObjectMeta; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],40:[function(require,module,exports){ +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],41:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var proto = exports; - var _require = require('../utils/isObject'), - isObject = _require.isObject; + isObject = _require.isObject; /** * getObjectTagging * @param {String} name - object name @@ -6134,75 +5072,64 @@ var _require = require('../utils/isObject'), * @return {Object} */ - proto.getObjectTagging = /*#__PURE__*/function () { var _getObjectTagging = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) { var options, - params, - result, - Tagging, - Tag, - tag, - _args = arguments; + params, + result, + Tagging, + Tag, + tag, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - options.subres = Object.assign({ - tagging: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - name = this._objectName(name); - params = this._objectRequestParams('GET', name, options); - params.successStatuses = [200]; - _context.next = 8; - return this.request(params); - - case 8: - result = _context.sent; - _context.next = 11; - return this.parseXML(result.data); - - case 11: - Tagging = _context.sent; - Tag = Tagging.TagSet.Tag; - Tag = Tag && isObject(Tag) ? [Tag] : Tag || []; - tag = {}; - Tag.forEach(function (item) { - tag[item.Key] = item.Value; - }); - return _context.abrupt("return", { - status: result.status, - res: result.res, - tag: tag - }); - - case 17: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + options.subres = Object.assign({ + tagging: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + name = this._objectName(name); + params = this._objectRequestParams('GET', name, options); + params.successStatuses = [200]; + _context.next = 8; + return this.request(params); + case 8: + result = _context.sent; + _context.next = 11; + return this.parseXML(result.data); + case 11: + Tagging = _context.sent; + Tag = Tagging.TagSet.Tag; + Tag = Tag && isObject(Tag) ? [Tag] : Tag || []; + tag = {}; + Tag.forEach(function (item) { + tag[item.Key] = item.Value; + }); + return _context.abrupt("return", { + status: result.status, + res: result.res, + tag: tag + }); + case 17: + case "end": + return _context.stop(); } }, _callee, this); })); - function getObjectTagging(_x) { return _getObjectTagging.apply(this, arguments); } - return getObjectTagging; }(); -},{"../utils/isObject":67,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255,"core-js/modules/web.dom-collections.for-each.js":296}],41:[function(require,module,exports){ +},{"../utils/isObject":73,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.to-string.js":331,"core-js/modules/web.dom-collections.for-each.js":382}],42:[function(require,module,exports){ "use strict"; var _require = require('../utils/isIP'), - isIP = _require.isIP; - + isIP = _require.isIP; var proto = exports; /** * Get Object url by name @@ -6211,32 +5138,25 @@ var proto = exports; * will use `baseUrl` instead the default `endpoint`. * @return {String} object url */ - proto.getObjectUrl = function getObjectUrl(name, baseUrl) { if (isIP(this.options.endpoint.hostname)) { throw new Error('can not get the object URL when endpoint is IP'); } - if (!baseUrl) { baseUrl = this.options.endpoint.format(); } else if (baseUrl[baseUrl.length - 1] !== '/') { baseUrl += '/'; } - return baseUrl + this._escape(this._objectName(name)); }; -},{"../utils/isIP":66}],42:[function(require,module,exports){ +},{"../utils/isIP":72}],43:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var proto = exports; /** * getSymlink @@ -6248,67 +5168,56 @@ var proto = exports; proto.getSymlink = /*#__PURE__*/function () { var _getSymlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) { var options, - params, - result, - target, - _args = arguments; + params, + result, + target, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - options.subres = Object.assign({ - symlink: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - name = this._objectName(name); - params = this._objectRequestParams('GET', name, options); - params.successStatuses = [200]; - _context.next = 8; - return this.request(params); - - case 8: - result = _context.sent; - target = result.res.headers['x-oss-symlink-target']; - return _context.abrupt("return", { - targetName: decodeURIComponent(target), - res: result.res - }); - - case 11: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + options.subres = Object.assign({ + symlink: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + name = this._objectName(name); + params = this._objectRequestParams('GET', name, options); + params.successStatuses = [200]; + _context.next = 8; + return this.request(params); + case 8: + result = _context.sent; + target = result.res.headers['x-oss-symlink-target']; + return _context.abrupt("return", { + targetName: decodeURIComponent(target), + res: result.res + }); + case 11: + case "end": + return _context.stop(); } }, _callee, this); })); - function getSymlink(_x) { return _getSymlink.apply(this, arguments); } - return getSymlink; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],43:[function(require,module,exports){ +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],44:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.keys.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - +var _require = require('../utils/checkEnv'), + checkEnv = _require.checkEnv; var proto = exports; /** * head @@ -6320,148 +5229,118 @@ var proto = exports; proto.head = /*#__PURE__*/function () { var _head = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name) { var options, - params, - result, - data, - _args = arguments; + params, + result, + data, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; - options.subres = Object.assign({}, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - params = this._objectRequestParams('HEAD', name, options); - params.successStatuses = [200, 304]; - _context.next = 7; - return this.request(params); - - case 7: - result = _context.sent; - data = { - meta: null, - res: result.res, - status: result.status - }; - - if (result.status === 200) { - Object.keys(result.headers).forEach(function (k) { - if (k.indexOf('x-oss-meta-') === 0) { - if (!data.meta) { - data.meta = {}; - } - - data.meta[k.substring(11)] = result.headers[k]; + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + checkEnv('Because HeadObject has gzip enabled, head cannot get the file size correctly. If you need to get the file size, please use getObjectMeta'); + options.subres = Object.assign({}, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + params = this._objectRequestParams('HEAD', name, options); + params.successStatuses = [200, 304]; + _context.next = 8; + return this.request(params); + case 8: + result = _context.sent; + data = { + meta: null, + res: result.res, + status: result.status + }; + if (result.status === 200) { + Object.keys(result.headers).forEach(function (k) { + if (k.indexOf('x-oss-meta-') === 0) { + if (!data.meta) { + data.meta = {}; } - }); - } - - return _context.abrupt("return", data); - - case 11: - case "end": - return _context.stop(); - } + data.meta[k.substring(11)] = result.headers[k]; + } + }); + } + return _context.abrupt("return", data); + case 12: + case "end": + return _context.stop(); } }, _callee, this); })); - function head(_x) { return _head.apply(this, arguments); } - return head; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255,"core-js/modules/es.object.keys.js":257,"core-js/modules/web.dom-collections.for-each.js":296}],44:[function(require,module,exports){ +},{"../utils/checkEnv":54,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/web.dom-collections.for-each.js":382}],45:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var proto = exports; + /* * Set object's ACL * @param {String} name the object key * @param {String} acl the object ACL * @param {Object} options */ - proto.putACL = /*#__PURE__*/function () { var _putACL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, acl, options) { var params, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = options || {}; - options.subres = Object.assign({ - acl: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - options.headers = options.headers || {}; - options.headers['x-oss-object-acl'] = acl; - name = this._objectName(name); - params = this._objectRequestParams('PUT', name, options); - params.successStatuses = [200]; - _context.next = 10; - return this.request(params); - - case 10: - result = _context.sent; - return _context.abrupt("return", { - res: result.res - }); - - case 12: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = options || {}; + options.subres = Object.assign({ + acl: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + options.headers = options.headers || {}; + options.headers['x-oss-object-acl'] = acl; + name = this._objectName(name); + params = this._objectRequestParams('PUT', name, options); + params.successStatuses = [200]; + _context.next = 10; + return this.request(params); + case 10: + result = _context.sent; + return _context.abrupt("return", { + res: result.res + }); + case 12: + case "end": + return _context.stop(); } }, _callee, this); })); - function putACL(_x, _x2, _x3) { return _putACL.apply(this, arguments); } - return putACL; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],45:[function(require,module,exports){ +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],46:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - require("core-js/modules/es.array.map.js"); - require("core-js/modules/es.object.keys.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('../utils/obj2xml'), - obj2xml = _require.obj2xml; - + obj2xml = _require.obj2xml; var _require2 = require('../utils/checkObjectTag'), - checkObjectTag = _require2.checkObjectTag; - + checkObjectTag = _require2.checkObjectTag; var proto = exports; /** * putObjectTagging @@ -6473,78 +5352,66 @@ var proto = exports; proto.putObjectTagging = /*#__PURE__*/function () { var _putObjectTagging = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, tag) { var options, - params, - paramXMLObj, - result, - _args = arguments; + params, + paramXMLObj, + result, + _args = arguments; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; - checkObjectTag(tag); - options.subres = Object.assign({ - tagging: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - name = this._objectName(name); - params = this._objectRequestParams('PUT', name, options); - params.successStatuses = [200]; - tag = Object.keys(tag).map(function (key) { - return { - Key: key, - Value: tag[key] - }; - }); - paramXMLObj = { - Tagging: { - TagSet: { - Tag: tag - } - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {}; + checkObjectTag(tag); + options.subres = Object.assign({ + tagging: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + name = this._objectName(name); + params = this._objectRequestParams('PUT', name, options); + params.successStatuses = [200]; + tag = Object.keys(tag).map(function (key) { + return { + Key: key, + Value: tag[key] }; - params.mime = 'xml'; - params.content = obj2xml(paramXMLObj); - _context.next = 13; - return this.request(params); - - case 13: - result = _context.sent; - return _context.abrupt("return", { - res: result.res, - status: result.status - }); - - case 15: - case "end": - return _context.stop(); - } + }); + paramXMLObj = { + Tagging: { + TagSet: { + Tag: tag + } + } + }; + params.mime = 'xml'; + params.content = obj2xml(paramXMLObj); + _context.next = 13; + return this.request(params); + case 13: + result = _context.sent; + return _context.abrupt("return", { + res: result.res, + status: result.status + }); + case 15: + case "end": + return _context.stop(); } }, _callee, this); })); - function putObjectTagging(_x, _x2) { return _putObjectTagging.apply(this, arguments); } - return putObjectTagging; }(); -},{"../utils/checkObjectTag":52,"../utils/obj2xml":69,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.map.js":249,"core-js/modules/es.object.assign.js":255,"core-js/modules/es.object.keys.js":257}],46:[function(require,module,exports){ +},{"../utils/checkObjectTag":55,"../utils/obj2xml":75,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.map.js":318,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.keys.js":330}],47:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var proto = exports; /** * putSymlink @@ -6558,89 +5425,71 @@ proto.putSymlink = /*#__PURE__*/function () { var _putSymlink = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(name, targetName, options) { var params, result; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - options = options || {}; - options.headers = options.headers || {}; - targetName = this._escape(this._objectName(targetName)); - - this._convertMetaToHeaders(options.meta, options.headers); - - options.headers['x-oss-symlink-target'] = targetName; - options.subres = Object.assign({ - symlink: '' - }, options.subres); - - if (options.versionId) { - options.subres.versionId = options.versionId; - } - - if (options.storageClass) { - options.headers['x-oss-storage-class'] = options.storageClass; - } - - name = this._objectName(name); - params = this._objectRequestParams('PUT', name, options); - params.successStatuses = [200]; - _context.next = 13; - return this.request(params); - - case 13: - result = _context.sent; - return _context.abrupt("return", { - res: result.res - }); - - case 15: - case "end": - return _context.stop(); - } + while (1) switch (_context.prev = _context.next) { + case 0: + options = options || {}; + options.headers = options.headers || {}; + targetName = this._escape(this._objectName(targetName)); + this._convertMetaToHeaders(options.meta, options.headers); + options.headers['x-oss-symlink-target'] = targetName; + options.subres = Object.assign({ + symlink: '' + }, options.subres); + if (options.versionId) { + options.subres.versionId = options.versionId; + } + if (options.storageClass) { + options.headers['x-oss-storage-class'] = options.storageClass; + } + name = this._objectName(name); + params = this._objectRequestParams('PUT', name, options); + params.successStatuses = [200]; + _context.next = 13; + return this.request(params); + case 13: + result = _context.sent; + return _context.abrupt("return", { + res: result.res + }); + case 15: + case "end": + return _context.stop(); } }, _callee, this); })); - function putSymlink(_x, _x2, _x3) { return _putSymlink.apply(this, arguments); } - return putSymlink; }(); -},{"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.object.assign.js":255}],47:[function(require,module,exports){ +},{"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.object.assign.js":325}],48:[function(require,module,exports){ "use strict"; -require("core-js/modules/es.object.assign.js"); - +require("core-js/modules/es.regexp.exec.js"); var urlutil = require('url'); - var utility = require('utility'); - var copy = require('copy-to'); - var signHelper = require('../../common/signUtils'); - var _require = require('../utils/isIP'), - isIP = _require.isIP; - -var _require2 = require('../../common/utils/isFunction'), - isFunction = _require2.isFunction; - -var _require3 = require('../utils/setSTSToken'), - checkCredentials = _require3.checkCredentials; - -var _require4 = require('../utils/formatObjKey'), - formatObjKey = _require4.formatObjKey; - + isIP = _require.isIP; var proto = exports; +/** + * signatureUrl + * @deprecated will be deprecated in 7.x + * @param {String} name object name + * @param {Object} options options + * @param {boolean} [strictObjectNameValidation=true] the flag of verifying object name strictly + */ proto.signatureUrl = function signatureUrl(name, options) { - var _this = this; - + var strictObjectNameValidation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; if (isIP(this.options.endpoint.hostname)) { throw new Error('can not get the object URL when endpoint is IP'); } - + if (strictObjectNameValidation && /^\?/.test(name)) { + throw new Error("Invalid object name ".concat(name)); + } options = options || {}; name = this._objectName(name); options.method = options.method || 'GET'; @@ -6649,35 +5498,11 @@ proto.signatureUrl = function signatureUrl(name, options) { bucket: this.options.bucket, object: name }; - var resource = this._getResource(params); - - if (this.options.stsToken && isFunction(this.options.refreshSTSToken)) { - var now = new Date(); - - if (this.stsTokenFreshTime >= this.options.refreshSTSTokenInterval) { - this.stsTokenFreshTime = now; - this.options.refreshSTSToken().then(function (r) { - var credentials = formatObjKey(r, 'firstLowerCase'); - - if (credentials.securityToken) { - credentials.stsToken = credentials.securityToken; - } - - checkCredentials(credentials); - Object.assign(_this.options, credentials); - }); - } else { - this.stsTokenFreshTime = now; - } - } - if (this.options.stsToken) { options['security-token'] = this.options.stsToken; } - var signRes = signHelper._signatureForURL(this.options.accessKeySecret, options, resource, expires); - var url = urlutil.parse(this._getReqUrl(params)); url.query = { OSSAccessKeyId: this.options.accessKeyId, @@ -6688,142 +5513,200 @@ proto.signatureUrl = function signatureUrl(name, options) { return url.format(); }; -},{"../../common/signUtils":49,"../../common/utils/isFunction":65,"../utils/formatObjKey":59,"../utils/isIP":66,"../utils/setSTSToken":72,"copy-to":88,"core-js/modules/es.object.assign.js":255,"url":404,"utility":406}],48:[function(require,module,exports){ +},{"../../common/signUtils":51,"../utils/isIP":72,"copy-to":107,"core-js/modules/es.regexp.exec.js":340,"url":545,"utility":547}],49:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.object.keys.js"); +require("core-js/modules/es.symbol.js"); +require("core-js/modules/es.array.filter.js"); +require("core-js/modules/es.object.to-string.js"); +require("core-js/modules/es.object.get-own-property-descriptor.js"); +require("core-js/modules/web.dom-collections.for-each.js"); +require("core-js/modules/es.object.get-own-property-descriptors.js"); var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); +require("core-js/modules/es.array.join.js"); +require("core-js/modules/es.array.concat.js"); +var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); +var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } +var dateFormat = require('dateformat'); +var urlUtil = require('url'); +var signHelper = require('../../common/signUtils'); +var _require = require('../utils/setSTSToken'), + setSTSToken = _require.setSTSToken; +var _require2 = require('../utils/isFunction'), + isFunction = _require2.isFunction; +var _require3 = require('../utils/getStandardRegion'), + getStandardRegion = _require3.getStandardRegion; +var proto = exports; -require("core-js/modules/es.array.iterator.js"); +/** + * signatureUrlV4 + * + * @param {string} method + * @param {number} expires + * @param {Object} [request] + * @param {Object} [request.headers] + * @param {Object} [request.queries] + * @param {string} [objectName] + * @param {string[]} [additionalHeaders] + */ +proto.signatureUrlV4 = /*#__PURE__*/function () { + var _signatureUrlV = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(method, expires, request, objectName, additionalHeaders) { + var headers, queries, date, formattedDate, onlyDate, fixedAdditionalHeaders, region, canonicalRequest, stringToSign, signedUrl; + return _regenerator.default.wrap(function _callee$(_context) { + while (1) switch (_context.prev = _context.next) { + case 0: + headers = request && request.headers || {}; + queries = _objectSpread({}, request && request.queries || {}); + date = new Date(); + formattedDate = dateFormat(date, "UTC:yyyymmdd'T'HHMMss'Z'"); + onlyDate = formattedDate.split('T')[0]; + fixedAdditionalHeaders = signHelper.fixAdditionalHeaders(additionalHeaders); + region = getStandardRegion(this.options.region); + if (fixedAdditionalHeaders.length > 0) { + queries['x-oss-additional-headers'] = fixedAdditionalHeaders.join(';'); + } + queries['x-oss-credential'] = "".concat(this.options.accessKeyId, "/").concat(onlyDate, "/").concat(region, "/oss/aliyun_v4_request"); + queries['x-oss-date'] = formattedDate; + queries['x-oss-expires'] = expires; + queries['x-oss-signature-version'] = 'OSS4-HMAC-SHA256'; + if (!(this.options.stsToken && isFunction(this.options.refreshSTSToken))) { + _context.next = 15; + break; + } + _context.next = 15; + return setSTSToken.call(this); + case 15: + if (this.options.stsToken) { + queries['x-oss-security-token'] = this.options.stsToken; + } + canonicalRequest = signHelper.getCanonicalRequest(method, { + headers: headers, + queries: queries + }, this.options.bucket, objectName, fixedAdditionalHeaders); + stringToSign = signHelper.getStringToSign(region, formattedDate, canonicalRequest); + queries['x-oss-signature'] = signHelper.getSignatureV4(this.options.accessKeySecret, onlyDate, region, stringToSign); + signedUrl = urlUtil.parse(this._getReqUrl({ + bucket: this.options.bucket, + object: objectName + })); + signedUrl.query = _objectSpread({}, queries); + return _context.abrupt("return", signedUrl.format()); + case 22: + case "end": + return _context.stop(); + } + }, _callee, this); + })); + function signatureUrlV4(_x, _x2, _x3, _x4, _x5) { + return _signatureUrlV.apply(this, arguments); + } + return signatureUrlV4; +}(); -require("core-js/modules/es.object.to-string.js"); +},{"../../common/signUtils":51,"../utils/getStandardRegion":64,"../utils/isFunction":71,"../utils/setSTSToken":79,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/defineProperty":83,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.filter.js":312,"core-js/modules/es.array.join.js":317,"core-js/modules/es.object.get-own-property-descriptor.js":327,"core-js/modules/es.object.get-own-property-descriptors.js":328,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.symbol.js":356,"core-js/modules/web.dom-collections.for-each.js":382,"dateformat":385,"url":545}],50:[function(require,module,exports){ +"use strict"; +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); +var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); +require("core-js/modules/es.array.iterator.js"); +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/es.promise.js"); - require("core-js/modules/es.string.iterator.js"); - require("core-js/modules/web.dom-collections.iterator.js"); - require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.function.name.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - var _require = require('./utils/isArray'), - isArray = _require.isArray; - + isArray = _require.isArray; var proto = exports; - proto._parallelNode = /*#__PURE__*/function () { var _parallelNode2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(todo, parallel, fn, sourceData) { var that, jobErr, jobs, tempBatch, remainder, batch, taskIndex, i; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - that = this; // upload in parallel - - jobErr = []; - jobs = []; - tempBatch = todo.length / parallel; - remainder = todo.length % parallel; - batch = remainder === 0 ? tempBatch : (todo.length - remainder) / parallel + 1; - taskIndex = 1; - i = 0; - - case 8: - if (!(i < todo.length)) { - _context.next = 26; - break; - } - - if (!that.isCancel()) { - _context.next = 11; - break; - } - - return _context.abrupt("break", 26); - - case 11: - if (sourceData) { - jobs.push(fn(that, todo[i], sourceData)); - } else { - jobs.push(fn(that, todo[i])); - } - - if (!(jobs.length === parallel || taskIndex === batch && i === todo.length - 1)) { - _context.next = 23; - break; - } - - _context.prev = 13; - taskIndex += 1; - /* eslint no-await-in-loop: [0] */ - - _context.next = 17; - return Promise.all(jobs); - - case 17: - _context.next = 22; + while (1) switch (_context.prev = _context.next) { + case 0: + that = this; // upload in parallel + jobErr = []; + jobs = []; + tempBatch = todo.length / parallel; + remainder = todo.length % parallel; + batch = remainder === 0 ? tempBatch : (todo.length - remainder) / parallel + 1; + taskIndex = 1; + i = 0; + case 8: + if (!(i < todo.length)) { + _context.next = 26; break; - - case 19: - _context.prev = 19; - _context.t0 = _context["catch"](13); - jobErr.push(_context.t0); - - case 22: - jobs = []; - - case 23: - i++; - _context.next = 8; + } + if (!that.isCancel()) { + _context.next = 11; break; - - case 26: - return _context.abrupt("return", jobErr); - - case 27: - case "end": - return _context.stop(); - } + } + return _context.abrupt("break", 26); + case 11: + if (sourceData) { + jobs.push(fn(that, todo[i], sourceData)); + } else { + jobs.push(fn(that, todo[i])); + } + if (!(jobs.length === parallel || taskIndex === batch && i === todo.length - 1)) { + _context.next = 23; + break; + } + _context.prev = 13; + taskIndex += 1; + /* eslint no-await-in-loop: [0] */ + _context.next = 17; + return Promise.all(jobs); + case 17: + _context.next = 22; + break; + case 19: + _context.prev = 19; + _context.t0 = _context["catch"](13); + jobErr.push(_context.t0); + case 22: + jobs = []; + case 23: + i++; + _context.next = 8; + break; + case 26: + return _context.abrupt("return", jobErr); + case 27: + case "end": + return _context.stop(); } }, _callee, this, [[13, 19]]); })); - function _parallelNode(_x, _x2, _x3, _x4) { return _parallelNode2.apply(this, arguments); } - return _parallelNode; }(); - proto._parallel = function _parallel(todo, parallel, jobPromise) { var that = this; return new Promise(function (resolve) { var _jobErr = []; - if (parallel <= 0 || !todo) { resolve(_jobErr); return; } - function onlyOnce(fn) { return function () { if (fn === null) throw new Error('Callback was already called.'); var callFn = fn; fn = null; - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } - callFn.apply(this, args); }; } - function createArrayIterator(coll) { var i = -1; var len = coll.length; @@ -6834,22 +5717,17 @@ proto._parallel = function _parallel(todo, parallel, jobPromise) { } : null; }; } - var nextElem = createArrayIterator(todo); var done = false; var running = 0; var looping = false; - - function iterateeCallback(err, value) { + function iterateeCallback(err) { running -= 1; - if (err) { done = true; - _jobErr.push(err); - resolve(_jobErr); - } else if (value === {} || done && running <= 0) { + } else if (done && running <= 0) { done = true; resolve(_jobErr); } else if (!looping) { @@ -6861,7 +5739,6 @@ proto._parallel = function _parallel(todo, parallel, jobPromise) { } } } - function iteratee(value, callback) { jobPromise(value).then(function (result) { callback(null, result); @@ -6869,33 +5746,26 @@ proto._parallel = function _parallel(todo, parallel, jobPromise) { callback(err); }); } - function replenish() { looping = true; - while (running < parallel && !done && !that.isCancel()) { var elem = nextElem(); - if (elem === null || _jobErr.length > 0) { done = true; - if (running <= 0) { resolve(_jobErr); } - return; } - running += 1; iteratee(elem.value, onlyOnce(iterateeCallback)); } - looping = false; } - replenish(); }); }; + /** * cancel operation, now can use with multipartUpload * @param {Object} abort @@ -6903,11 +5773,8 @@ proto._parallel = function _parallel(todo, parallel, jobPromise) { * {String} anort.uploadId upload id * {String} anort.options timeout */ - - proto.cancel = function cancel(abort) { this.options.cancelFlag = true; - if (isArray(this.multipartUploadStreams)) { this.multipartUploadStreams.forEach(function (_) { if (_.destroyed === false) { @@ -6915,41 +5782,35 @@ proto.cancel = function cancel(abort) { name: 'cancel', message: 'cancel' }; - _.destroy(err); } }); } - this.multipartUploadStreams = []; - if (abort) { this.abortMultipartUpload(abort.name, abort.uploadId, abort.options); } }; - proto.isCancel = function isCancel() { return this.options.cancelFlag; }; - proto.resetCancelFlag = function resetCancelFlag() { this.options.cancelFlag = false; }; - proto._stop = function _stop() { this.options.cancelFlag = true; -}; // cancel is not error , so create an object - +}; +// cancel is not error , so create an object proto._makeCancelEvent = function _makeCancelEvent() { var cancelEvent = { status: 0, name: 'cancel' }; return cancelEvent; -}; // abort is not error , so create an object - +}; +// abort is not error , so create an object proto._makeAbortEvent = function _makeAbortEvent() { var abortEvent = { status: 0, @@ -6959,44 +5820,47 @@ proto._makeAbortEvent = function _makeAbortEvent() { return abortEvent; }; -},{"./utils/isArray":61,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.iterator.js":247,"core-js/modules/es.function.name.js":253,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.promise.js":259,"core-js/modules/es.string.iterator.js":264,"core-js/modules/web.dom-collections.for-each.js":296,"core-js/modules/web.dom-collections.iterator.js":297}],49:[function(require,module,exports){ +},{"./utils/isArray":66,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.iterator.js":316,"core-js/modules/es.function.name.js":322,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.promise.js":335,"core-js/modules/es.string.iterator.js":345,"core-js/modules/web.dom-collections.for-each.js":382,"core-js/modules/web.dom-collections.iterator.js":383}],51:[function(require,module,exports){ (function (Buffer){(function (){ "use strict"; +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); +var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); require("core-js/modules/es.string.trim.js"); - require("core-js/modules/es.array.sort.js"); - require("core-js/modules/es.array.join.js"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.keys.js"); - require("core-js/modules/es.array.concat.js"); - -require("core-js/modules/es.object.to-string.js"); - +require("core-js/modules/es.array.filter.js"); +require("core-js/modules/es.array.iterator.js"); +require("core-js/modules/es.set.js"); +require("core-js/modules/es.string.iterator.js"); +require("core-js/modules/web.dom-collections.iterator.js"); +require("core-js/modules/es.array.map.js"); +require("core-js/modules/es.string.starts-with.js"); +require("core-js/modules/es.regexp.exec.js"); +require("core-js/modules/es.string.replace.js"); +require("core-js/modules/es.object.entries.js"); require("core-js/modules/es.regexp.to-string.js"); - var crypto = require('./../../shims/crypto/crypto.js'); - var is = require('is-type-of'); - +var qs = require('qs'); var _require = require('./utils/lowercaseKeyHeader'), - lowercaseKeyHeader = _require.lowercaseKeyHeader; + lowercaseKeyHeader = _require.lowercaseKeyHeader; +var _require2 = require('./utils/encodeString'), + encodeString = _require2.encodeString; + /** * * @param {String} resourcePath * @param {Object} parameters * @return */ - - exports.buildCanonicalizedResource = function buildCanonicalizedResource(resourcePath, parameters) { var canonicalizedResource = "".concat(resourcePath); var separatorString = '?'; - if (is.string(parameters) && parameters.trim() !== '') { canonicalizedResource += separatorString + parameters; } else if (is.array(parameters)) { @@ -7009,25 +5873,20 @@ exports.buildCanonicalizedResource = function buildCanonicalizedResource(resourc } else if (entry1[0] < entry2[0]) { return -1; } - return 0; }; - var processFunc = function processFunc(key) { canonicalizedResource += separatorString + key; - if (parameters[key] || parameters[key] === 0) { canonicalizedResource += "=".concat(parameters[key]); } - separatorString = '&'; }; - Object.keys(parameters).sort(compareFunc).forEach(processFunc); } - return canonicalizedResource; }; + /** * @param {String} method * @param {String} resourcePath @@ -7035,8 +5894,6 @@ exports.buildCanonicalizedResource = function buildCanonicalizedResource(resourc * @param {String} expires * @return {String} canonicalString */ - - exports.buildCanonicalString = function canonicalString(method, resourcePath, request, expires) { request = request || {}; var headers = lowercaseKeyHeader(request.headers); @@ -7046,7 +5903,6 @@ exports.buildCanonicalString = function canonicalString(method, resourcePath, re var signContent = [method.toUpperCase(), headers['content-md5'] || '', headers['content-type'], expires || headers['x-oss-date']]; Object.keys(headers).forEach(function (key) { var lowerKey = key.toLowerCase(); - if (lowerKey.indexOf(OSS_PREFIX) === 0) { headersToSign[lowerKey] = String(headers[key]).trim(); } @@ -7058,27 +5914,168 @@ exports.buildCanonicalString = function canonicalString(method, resourcePath, re signContent.push(this.buildCanonicalizedResource(resourcePath, request.parameters)); return signContent.join('\n'); }; + /** * @param {String} accessKeySecret * @param {String} canonicalString */ - - exports.computeSignature = function computeSignature(accessKeySecret, canonicalString) { var headerEncoding = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'utf-8'; var signature = crypto.createHmac('sha1', accessKeySecret); return signature.update(Buffer.from(canonicalString, headerEncoding)).digest('base64'); }; + /** * @param {String} accessKeyId * @param {String} accessKeySecret * @param {String} canonicalString */ - - exports.authorization = function authorization(accessKeyId, accessKeySecret, canonicalString, headerEncoding) { return "OSS ".concat(accessKeyId, ":").concat(this.computeSignature(accessKeySecret, canonicalString, headerEncoding)); }; + +/** + * @param {string[]} [additionalHeaders] + * @returns {string[]} + */ +exports.fixAdditionalHeaders = function (additionalHeaders) { + if (!additionalHeaders) { + return []; + } + var OSS_PREFIX = 'x-oss-'; + return (0, _toConsumableArray2.default)(new Set(additionalHeaders.map(function (v) { + return v.toLowerCase(); + }))).filter(function (v) { + return v !== 'content-type' && v !== 'content-md5' && !v.startsWith(OSS_PREFIX); + }).sort(); +}; + +/** + * @param {string} method + * @param {Object} request + * @param {Object} request.headers + * @param {Object} [request.queries] + * @param {string} [bucketName] + * @param {string} [objectName] + * @param {string[]} [additionalHeaders] additional headers after deduplication, lowercase and sorting + * @returns {string} + */ +exports.getCanonicalRequest = function getCanonicalRequest(method, request, bucketName, objectName, additionalHeaders) { + var headers = lowercaseKeyHeader(request.headers); + var queries = request.queries || {}; + var OSS_PREFIX = 'x-oss-'; + if (objectName && !bucketName) { + throw Error('Please ensure that bucketName is passed into getCanonicalRequest.'); + } + var signContent = [method.toUpperCase(), + // HTTP Verb + encodeString("/".concat(bucketName ? "".concat(bucketName, "/") : '').concat(objectName || '')).replace(/%2F/g, '/') // Canonical URI + ]; + + // Canonical Query String + signContent.push(qs.stringify(queries, { + encoder: encodeString, + sort: function sort(a, b) { + return a.localeCompare(b); + }, + strictNullHandling: true + })); + + // Canonical Headers + if (additionalHeaders) { + additionalHeaders.forEach(function (v) { + if (!Object.prototype.hasOwnProperty.call(headers, v)) { + throw Error("Can't find additional header ".concat(v, " in request headers.")); + } + }); + } + var tempHeaders = new Set(additionalHeaders); + Object.keys(headers).forEach(function (v) { + if (v === 'content-type' || v === 'content-md5' || v.startsWith(OSS_PREFIX)) { + tempHeaders.add(v); + } + }); + var canonicalHeaders = "".concat((0, _toConsumableArray2.default)(tempHeaders).sort().map(function (v) { + return "".concat(v, ":").concat(is.string(headers[v]) ? headers[v].trim() : headers[v], "\n"); + }).join('')); + signContent.push(canonicalHeaders); + + // Additional Headers + if (additionalHeaders.length > 0) { + signContent.push(additionalHeaders.join(';')); + } else { + signContent.push(''); + } + + // Hashed Payload + signContent.push(headers['x-oss-content-sha256'] || 'UNSIGNED-PAYLOAD'); + return signContent.join('\n'); +}; + +/** + * @param {string} region Standard region, e.g. cn-hangzhou + * @param {string} date ISO8601 UTC:yyyymmdd'T'HHMMss'Z' + * @param {string} canonicalRequest + * @returns {string} + */ +exports.getStringToSign = function getStringToSign(region, date, canonicalRequest) { + var stringToSign = ['OSS4-HMAC-SHA256', date, // TimeStamp + "".concat(date.split('T')[0], "/").concat(region, "/oss/aliyun_v4_request"), + // Scope + crypto.createHash('sha256').update(canonicalRequest).digest('hex') // Hashed Canonical Request + ]; + return stringToSign.join('\n'); +}; + +/** + * @param {String} accessKeySecret + * @param {string} date yyyymmdd + * @param {string} region Standard region, e.g. cn-hangzhou + * @param {string} stringToSign + * @returns {string} + */ +exports.getSignatureV4 = function getSignatureV4(accessKeySecret, date, region, stringToSign) { + var signingDate = crypto.createHmac('sha256', "aliyun_v4".concat(accessKeySecret)).update(date).digest(); + var signingRegion = crypto.createHmac('sha256', signingDate).update(region).digest(); + var signingOss = crypto.createHmac('sha256', signingRegion).update('oss').digest(); + var signingKey = crypto.createHmac('sha256', signingOss).update('aliyun_v4_request').digest(); + var signatureValue = crypto.createHmac('sha256', signingKey).update(stringToSign).digest('hex'); + return signatureValue; +}; + +/** + * @param {String} accessKeyId + * @param {String} accessKeySecret + * @param {string} region Standard region, e.g. cn-hangzhou + * @param {string} method + * @param {Object} request + * @param {Object} request.headers + * @param {Object} [request.queries] + * @param {string} [bucketName] + * @param {string} [objectName] + * @param {string[]} [additionalHeaders] + * @param {string} [headerEncoding='utf-8'] + * @returns {string} + */ +exports.authorizationV4 = function authorizationV4(accessKeyId, accessKeySecret, region, method, request, bucketName, objectName, additionalHeaders) { + var headerEncoding = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : 'utf-8'; + var fixedAdditionalHeaders = this.fixAdditionalHeaders(additionalHeaders); + var fixedHeaders = {}; + Object.entries(request.headers).forEach(function (v) { + fixedHeaders[v[0]] = is.string(v[1]) ? Buffer.from(v[1], headerEncoding).toString() : v[1]; + }); + var date = fixedHeaders['x-oss-date'] || request.queries && request.queries['x-oss-date']; + var canonicalRequest = this.getCanonicalRequest(method, { + headers: fixedHeaders, + queries: request.queries + }, bucketName, objectName, fixedAdditionalHeaders); + var stringToSign = this.getStringToSign(region, date, canonicalRequest); + var onlyDate = date.split('T')[0]; + var signatureValue = this.getSignatureV4(accessKeySecret, onlyDate, region, stringToSign); + var additionalHeadersValue = fixedAdditionalHeaders.length > 0 ? "AdditionalHeaders=".concat(fixedAdditionalHeaders.join(';'), ",") : ''; + return "OSS4-HMAC-SHA256 Credential=".concat(accessKeyId, "/").concat(onlyDate, "/").concat(region, "/oss/aliyun_v4_request,").concat(additionalHeadersValue, "Signature=").concat(signatureValue); +}; + /** * * @param {String} accessKeySecret @@ -7086,8 +6083,6 @@ exports.authorization = function authorization(accessKeyId, accessKeySecret, can * @param {String} resource * @param {Number} expires */ - - exports._signatureForURL = function _signatureForURL(accessKeySecret) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var resource = arguments.length > 2 ? arguments[2] : undefined; @@ -7095,29 +6090,24 @@ exports._signatureForURL = function _signatureForURL(accessKeySecret) { var headerEncoding = arguments.length > 4 ? arguments[4] : undefined; var headers = {}; var _options$subResource = options.subResource, - subResource = _options$subResource === void 0 ? {} : _options$subResource; - + subResource = _options$subResource === void 0 ? {} : _options$subResource; if (options.process) { var processKeyword = 'x-oss-process'; subResource[processKeyword] = options.process; } - if (options.trafficLimit) { var trafficLimitKey = 'x-oss-traffic-limit'; subResource[trafficLimitKey] = options.trafficLimit; } - if (options.response) { Object.keys(options.response).forEach(function (k) { var key = "response-".concat(k.toLowerCase()); subResource[key] = options.response[k]; }); } - Object.keys(options).forEach(function (key) { var lowerKey = key.toLowerCase(); var value = options[key]; - if (lowerKey.indexOf('x-oss-') === 0) { headers[lowerKey] = value; } else if (lowerKey.indexOf('content-md5') === 0) { @@ -7126,27 +6116,21 @@ exports._signatureForURL = function _signatureForURL(accessKeySecret) { headers[key] = value; } }); - if (Object.prototype.hasOwnProperty.call(options, 'security-token')) { subResource['security-token'] = options['security-token']; } - if (Object.prototype.hasOwnProperty.call(options, 'callback')) { var json = { callbackUrl: encodeURI(options.callback.url), callbackBody: options.callback.body }; - if (options.callback.host) { json.callbackHost = options.callback.host; } - if (options.callback.contentType) { json.callbackBodyType = options.callback.contentType; } - subResource.callback = Buffer.from(JSON.stringify(json)).toString('base64'); - if (options.callback.customValue) { var callbackVar = {}; Object.keys(options.callback.customValue).forEach(function (key) { @@ -7155,7 +6139,6 @@ exports._signatureForURL = function _signatureForURL(accessKeySecret) { subResource['callback-var'] = Buffer.from(JSON.stringify(callbackVar)).toString('base64'); } } - var canonicalString = this.buildCanonicalString(options.method, resource, { headers: headers, parameters: subResource @@ -7167,26 +6150,26 @@ exports._signatureForURL = function _signatureForURL(accessKeySecret) { }; }).call(this)}).call(this,require("buffer").Buffer) -},{"./../../shims/crypto/crypto.js":393,"./utils/lowercaseKeyHeader":68,"buffer":85,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.array.join.js":248,"core-js/modules/es.array.sort.js":251,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.regexp.to-string.js":262,"core-js/modules/es.string.trim.js":269,"core-js/modules/web.dom-collections.for-each.js":296,"is-type-of":398}],50:[function(require,module,exports){ +},{"./../../shims/crypto/crypto.js":533,"./utils/encodeString":60,"./utils/lowercaseKeyHeader":74,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/helpers/toConsumableArray":88,"buffer":103,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.filter.js":312,"core-js/modules/es.array.iterator.js":316,"core-js/modules/es.array.join.js":317,"core-js/modules/es.array.map.js":318,"core-js/modules/es.array.sort.js":320,"core-js/modules/es.object.entries.js":326,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.set.js":343,"core-js/modules/es.string.iterator.js":345,"core-js/modules/es.string.replace.js":347,"core-js/modules/es.string.starts-with.js":350,"core-js/modules/es.string.trim.js":351,"core-js/modules/web.dom-collections.for-each.js":382,"core-js/modules/web.dom-collections.iterator.js":383,"is-type-of":539,"qs":447}],52:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.regexp.exec.js"); Object.defineProperty(exports, "__esModule", { value: true }); exports.checkBucketName = void 0; - exports.checkBucketName = function (name) { var createBucket = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var bucketRegex = createBucket ? /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/ : /^[a-z0-9_][a-z0-9-_]{1,61}[a-z0-9_]$/; - if (!bucketRegex.test(name)) { throw new Error('The bucket must be conform to the specifications'); } }; -},{}],51:[function(require,module,exports){ +},{"core-js/modules/es.regexp.exec.js":340}],53:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.regexp.exec.js"); Object.defineProperty(exports, "__esModule", { value: true }); @@ -7195,53 +6178,59 @@ var checkConfigMap = { endpoint: checkEndpoint, region: /^[a-zA-Z0-9\-_]+$/ }; - function checkEndpoint(endpoint) { if (typeof endpoint === 'string') { return /^[a-zA-Z0-9._:/-]+$/.test(endpoint); } else if (endpoint.host) { return /^[a-zA-Z0-9._:/-]+$/.test(endpoint.host); } - return false; } - exports.checkConfigValid = function (conf, key) { if (checkConfigMap[key]) { var isConfigValid = true; - if (checkConfigMap[key] instanceof Function) { isConfigValid = checkConfigMap[key](conf); } else { isConfigValid = checkConfigMap[key].test(conf); } - if (!isConfigValid) { throw new Error("The ".concat(key, " must be conform to the specifications")); } } }; -},{}],52:[function(require,module,exports){ +},{"core-js/modules/es.regexp.exec.js":340}],54:[function(require,module,exports){ +(function (process){(function (){ "use strict"; -require("core-js/modules/es.array.concat.js"); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.checkEnv = void 0; +function checkEnv(msg) { + if (process.browser) { + console.warn(msg); + } +} +exports.checkEnv = checkEnv; -require("core-js/modules/es.object.entries.js"); +}).call(this)}).call(this,require('_process')) +},{"_process":540}],55:[function(require,module,exports){ +"use strict"; +require("core-js/modules/es.array.concat.js"); +require("core-js/modules/es.object.entries.js"); +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - Object.defineProperty(exports, "__esModule", { value: true }); exports.checkObjectTag = void 0; - var _require = require('./checkValid'), - checkValid = _require.checkValid; - + checkValid = _require.checkValid; var _require2 = require('./isObject'), - isObject = _require2.isObject; - + isObject = _require2.isObject; var commonRules = [{ validator: function validator(value) { if (typeof value !== 'string') { @@ -7262,18 +6251,14 @@ var rules = { msg: 'tag value can be a maximum of 256 bytes in length' }]) }; - function checkObjectTag(tag) { if (!isObject(tag)) { throw new Error('tag must be Object'); } - var entries = Object.entries(tag); - if (entries.length > 10) { throw new Error('maximum of 10 tags for a object'); } - var rulesIndexKey = ['key', 'value']; entries.forEach(function (keyValue) { keyValue.forEach(function (item, index) { @@ -7281,19 +6266,18 @@ function checkObjectTag(tag) { }); }); } - exports.checkObjectTag = checkObjectTag; -},{"./checkValid":53,"./isObject":67,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.object.entries.js":256,"core-js/modules/web.dom-collections.for-each.js":296}],53:[function(require,module,exports){ +},{"./checkValid":56,"./isObject":73,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.object.entries.js":326,"core-js/modules/es.object.to-string.js":331,"core-js/modules/web.dom-collections.for-each.js":382}],56:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - +require("core-js/modules/es.regexp.exec.js"); Object.defineProperty(exports, "__esModule", { value: true }); exports.checkValid = void 0; - function checkValid(_value, _rules) { _rules.forEach(function (rule) { if (rule.validator) { @@ -7303,133 +6287,135 @@ function checkValid(_value, _rules) { } }); } - exports.checkValid = checkValid; -},{"core-js/modules/web.dom-collections.for-each.js":296}],54:[function(require,module,exports){ +},{"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/web.dom-collections.for-each.js":382}],57:[function(require,module,exports){ (function (Buffer){(function (){ "use strict"; require("core-js/modules/es.array.includes.js"); - require("core-js/modules/es.string.includes.js"); - require("core-js/modules/es.object.assign.js"); - +require("core-js/modules/es.object.to-string.js"); +require("core-js/modules/web.dom-collections.for-each.js"); +require("core-js/modules/es.object.entries.js"); require("core-js/modules/es.array.concat.js"); - Object.defineProperty(exports, "__esModule", { value: true }); exports.createRequest = void 0; - var crypto = require('./../../../shims/crypto/crypto.js'); - var debug = require('debug')('ali-oss'); - +var _isString = require('lodash/isString'); +var _isArray = require('lodash/isArray'); +var _isObject = require('lodash/isObject'); var mime = require('mime'); - var dateFormat = require('dateformat'); - var copy = require('copy-to'); - var path = require('path'); - var _require = require('./encoder'), - encoder = _require.encoder; - + encoder = _require.encoder; var _require2 = require('./isIP'), - isIP = _require2.isIP; - + isIP = _require2.isIP; var _require3 = require('./setRegion'), - setRegion = _require3.setRegion; - + setRegion = _require3.setRegion; var _require4 = require('../client/getReqUrl'), - getReqUrl = _require4.getReqUrl; - + getReqUrl = _require4.getReqUrl; +var _require5 = require('./isDingTalk'), + isDingTalk = _require5.isDingTalk; function getHeader(headers, name) { return headers[name] || headers[name.toLowerCase()]; } - function delHeader(headers, name) { delete headers[name]; delete headers[name.toLowerCase()]; } - function createRequest(params) { var date = new Date(); - if (this.options.amendTimeSkewed) { date = +new Date() + this.options.amendTimeSkewed; } - var headers = { - 'x-oss-date': dateFormat(date, 'UTC:ddd, dd mmm yyyy HH:MM:ss \'GMT\'') + 'x-oss-date': dateFormat(date, this.options.authorizationV4 ? "UTC:yyyymmdd'T'HHMMss'Z'" : "UTC:ddd, dd mmm yyyy HH:MM:ss 'GMT'") }; - + if (this.options.authorizationV4) { + headers['x-oss-content-sha256'] = 'UNSIGNED-PAYLOAD'; + } if (typeof window !== 'undefined') { headers['x-oss-user-agent'] = this.userAgent; } - if (this.userAgent.includes('nodejs')) { headers['User-Agent'] = this.userAgent; } - if (this.options.isRequestPay) { Object.assign(headers, { 'x-oss-request-payer': 'requester' }); } - if (this.options.stsToken) { headers['x-oss-security-token'] = this.options.stsToken; } - copy(params.headers).to(headers); - if (!getHeader(headers, 'Content-Type')) { if (params.mime && params.mime.indexOf('/') > 0) { headers['Content-Type'] = params.mime; + } else if (isDingTalk()) { + headers['Content-Type'] = 'application/octet-stream'; } else { headers['Content-Type'] = mime.getType(params.mime || path.extname(params.object || '')); } } - if (!getHeader(headers, 'Content-Type')) { delHeader(headers, 'Content-Type'); } - if (params.content) { if (!params.disabledMD5) { - headers['Content-MD5'] = crypto.createHash('md5').update(Buffer.from(params.content, 'utf8')).digest('base64'); + if (!params.headers || !params.headers['Content-MD5']) { + headers['Content-MD5'] = crypto.createHash('md5').update(Buffer.from(params.content, 'utf8')).digest('base64'); + } else { + headers['Content-MD5'] = params.headers['Content-MD5']; + } } - if (!headers['Content-Length']) { headers['Content-Length'] = params.content.length; } } - var hasOwnProperty = Object.prototype.hasOwnProperty; - for (var k in headers) { if (headers[k] && hasOwnProperty.call(headers, k)) { headers[k] = encoder(String(headers[k]), this.options.headerEncoding); } } - - var authResource = this._getResource(params); - - headers.authorization = this.authorization(params.method, authResource, params.subres, headers, this.options.headerEncoding); // const url = this._getReqUrl(params); - + var queries = {}; + if (_isString(params.subres)) { + queries[params.subres] = null; + } else if (_isArray(params.subres)) { + params.subres.forEach(function (v) { + queries[v] = null; + }); + } else if (_isObject(params.subres)) { + Object.entries(params.subres).forEach(function (v) { + queries[v[0]] = v[1] === '' ? null : v[1]; + }); + } + if (_isObject(params.query)) { + Object.entries(params.query).forEach(function (v) { + queries[v[0]] = v[1]; + }); + } + headers.authorization = this.options.authorizationV4 ? this.authorizationV4(params.method, { + headers: headers, + queries: queries + }, params.bucket, params.object, params.additionalHeaders) : this.authorization(params.method, this._getResource(params), params.subres, headers, this.options.headerEncoding); + // const url = this._getReqUrl(params); if (isIP(this.options.endpoint.hostname)) { var _this$options = this.options, - region = _this$options.region, - internal = _this$options.internal, - secure = _this$options.secure; + region = _this$options.region, + internal = _this$options.internal, + secure = _this$options.secure; var hostInfo = setRegion(region, internal, secure); headers.host = "".concat(params.bucket, ".").concat(hostInfo.host); } - var url = getReqUrl.bind(this)(params); debug('request %s %s, with headers %j, !!stream: %s', params.method, url, headers, !!params.stream); var timeout = params.timeout || this.options.timeout; @@ -7443,15 +6429,12 @@ function createRequest(params) { customResponse: params.customResponse, ctx: params.ctx || this.ctx }; - if (this.agent) { reqParams.agent = this.agent; } - if (this.httpsAgent) { reqParams.httpsAgent = this.httpsAgent; } - reqParams.enableProxy = !!this.options.enableProxy; reqParams.proxy = this.options.proxy ? this.options.proxy : null; return { @@ -7459,59 +6442,50 @@ function createRequest(params) { params: reqParams }; } - exports.createRequest = createRequest; }).call(this)}).call(this,require("buffer").Buffer) -},{"../client/getReqUrl":25,"./../../../shims/crypto/crypto.js":393,"./encoder":57,"./isIP":66,"./setRegion":71,"buffer":85,"copy-to":88,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.array.includes.js":246,"core-js/modules/es.object.assign.js":255,"core-js/modules/es.string.includes.js":263,"dateformat":299,"debug":397,"mime":317,"path":321}],55:[function(require,module,exports){ +},{"../client/getReqUrl":25,"./../../../shims/crypto/crypto.js":533,"./encoder":61,"./isDingTalk":69,"./isIP":72,"./setRegion":78,"buffer":103,"copy-to":107,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.includes.js":315,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.entries.js":326,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.string.includes.js":344,"core-js/modules/web.dom-collections.for-each.js":382,"dateformat":385,"debug":538,"lodash/isArray":424,"lodash/isObject":425,"lodash/isString":427,"mime":432,"path":441}],58:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.entries.js"); - require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - require("core-js/modules/es.array.includes.js"); - require("core-js/modules/es.object.keys.js"); - Object.defineProperty(exports, "__esModule", { value: true }); exports.dataFix = void 0; - var isObject_1 = require("./isObject"); - var TRUE = ['true', 'TRUE', '1', 1]; var FALSE = ['false', 'FALSE', '0', 0]; - function dataFix(o, conf, finalKill) { if (!isObject_1.isObject(o)) return; var _conf$remove = conf.remove, - remove = _conf$remove === void 0 ? [] : _conf$remove, - _conf$rename = conf.rename, - rename = _conf$rename === void 0 ? {} : _conf$rename, - _conf$camel = conf.camel, - camel = _conf$camel === void 0 ? [] : _conf$camel, - _conf$bool = conf.bool, - bool = _conf$bool === void 0 ? [] : _conf$bool, - _conf$lowerFirst = conf.lowerFirst, - lowerFirst = _conf$lowerFirst === void 0 ? false : _conf$lowerFirst; // 删除不需要的数据 - + remove = _conf$remove === void 0 ? [] : _conf$remove, + _conf$rename = conf.rename, + rename = _conf$rename === void 0 ? {} : _conf$rename, + _conf$camel = conf.camel, + camel = _conf$camel === void 0 ? [] : _conf$camel, + _conf$bool = conf.bool, + bool = _conf$bool === void 0 ? [] : _conf$bool, + _conf$lowerFirst = conf.lowerFirst, + lowerFirst = _conf$lowerFirst === void 0 ? false : _conf$lowerFirst; + // 删除不需要的数据 remove.forEach(function (v) { return delete o[v]; - }); // 重命名 - + }); + // 重命名 Object.entries(rename).forEach(function (v) { if (!o[v[0]]) return; if (o[v[1]]) return; o[v[1]] = o[v[0]]; delete o[v[0]]; - }); // 驼峰化 - + }); + // 驼峰化 camel.forEach(function (v) { if (!o[v]) return; var afterKey = v.replace(/^(.)/, function ($0) { @@ -7520,38 +6494,34 @@ function dataFix(o, conf, finalKill) { return $1.toUpperCase(); }); if (o[afterKey]) return; - o[afterKey] = o[v]; // todo 暂时兼容以前数据,不做删除 + o[afterKey] = o[v]; + // todo 暂时兼容以前数据,不做删除 // delete o[v]; - }); // 转换值为布尔值 - + }); + // 转换值为布尔值 bool.forEach(function (v) { o[v] = fixBool(o[v]); - }); // finalKill - + }); + // finalKill if (typeof finalKill === 'function') { finalKill(o); - } // 首字母转小写 - - + } + // 首字母转小写 fixLowerFirst(o, lowerFirst); return dataFix; } - exports.dataFix = dataFix; - function fixBool(value) { if (!value) return false; if (TRUE.includes(value)) return true; return FALSE.includes(value) ? false : value; } - function fixLowerFirst(o, lowerFirst) { if (lowerFirst) { Object.keys(o).forEach(function (key) { var lowerK = key.replace(/^\w/, function (match) { return match.toLowerCase(); }); - if (typeof o[lowerK] === 'undefined') { o[lowerK] = o[key]; delete o[key]; @@ -7560,62 +6530,49 @@ function fixLowerFirst(o, lowerFirst) { } } -},{"./isObject":67,"core-js/modules/es.array.includes.js":246,"core-js/modules/es.object.entries.js":256,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.string.replace.js":266,"core-js/modules/web.dom-collections.for-each.js":296}],56:[function(require,module,exports){ +},{"./isObject":73,"core-js/modules/es.array.includes.js":315,"core-js/modules/es.object.entries.js":326,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.string.replace.js":347,"core-js/modules/web.dom-collections.for-each.js":382}],59:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - require("core-js/modules/es.array.slice.js"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.keys.js"); - var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.deepCopyWith = exports.deepCopy = void 0; - var isBuffer_1 = require("./isBuffer"); - exports.deepCopy = function (obj) { if (obj === null || (0, _typeof2.default)(obj) !== 'object') { return obj; } - if (isBuffer_1.isBuffer(obj)) { return obj.slice(); } - var copy = Array.isArray(obj) ? [] : {}; Object.keys(obj).forEach(function (key) { copy[key] = exports.deepCopy(obj[key]); }); return copy; }; - exports.deepCopyWith = function (obj, customizer) { function deepCopyWithHelper(value, innerKey, innerObject) { var result = customizer(value, innerKey, innerObject); if (result !== undefined) return result; - if (value === null || (0, _typeof2.default)(value) !== 'object') { return value; } - if (isBuffer_1.isBuffer(value)) { return value.slice(); } - var copy = Array.isArray(value) ? [] : {}; Object.keys(value).forEach(function (k) { copy[k] = deepCopyWithHelper(value[k], k, value); }); return copy; } - if (customizer) { return deepCopyWithHelper(obj, '', null); } else { @@ -7623,130 +6580,127 @@ exports.deepCopyWith = function (obj, customizer) { } }; -},{"./isBuffer":63,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/helpers/typeof":75,"core-js/modules/es.array.slice.js":250,"core-js/modules/es.object.keys.js":257,"core-js/modules/web.dom-collections.for-each.js":296}],57:[function(require,module,exports){ -(function (Buffer){(function (){ +},{"./isBuffer":68,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/helpers/typeof":91,"core-js/modules/es.array.slice.js":319,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/web.dom-collections.for-each.js":382}],60:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.regexp.exec.js"); +require("core-js/modules/es.string.replace.js"); require("core-js/modules/es.object.to-string.js"); - require("core-js/modules/es.regexp.to-string.js"); +var __importDefault = void 0 && (void 0).__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.encodeString = void 0; +var toString_1 = __importDefault(require("lodash/toString")); +function encodeString(str) { + var tempStr = toString_1.default(str); + return encodeURIComponent(tempStr).replace(/[!'()*]/g, function (c) { + return "%".concat(c.charCodeAt(0).toString(16).toUpperCase()); + }); +} +exports.encodeString = encodeString; +},{"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.string.replace.js":347,"lodash/toString":429}],61:[function(require,module,exports){ +(function (Buffer){(function (){ +"use strict"; + +require("core-js/modules/es.object.to-string.js"); +require("core-js/modules/es.regexp.to-string.js"); Object.defineProperty(exports, "__esModule", { value: true }); exports.encoder = void 0; - function encoder(str) { var encoding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'utf-8'; if (encoding === 'utf-8') return str; return Buffer.from(str).toString('latin1'); } - exports.encoder = encoder; }).call(this)}).call(this,require("buffer").Buffer) -},{"buffer":85,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.regexp.to-string.js":262}],58:[function(require,module,exports){ +},{"buffer":103,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.to-string.js":341}],62:[function(require,module,exports){ "use strict"; require("core-js/modules/es.array.map.js"); - require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - Object.defineProperty(exports, "__esModule", { value: true }); exports.formatInventoryConfig = void 0; - var dataFix_1 = require("../utils/dataFix"); - var isObject_1 = require("../utils/isObject"); - var isArray_1 = require("../utils/isArray"); - var formatObjKey_1 = require("../utils/formatObjKey"); - function formatInventoryConfig(inventoryConfig) { var toArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; if (toArray && isObject_1.isObject(inventoryConfig)) inventoryConfig = [inventoryConfig]; - if (isArray_1.isArray(inventoryConfig)) { inventoryConfig = inventoryConfig.map(formatFn); } else { inventoryConfig = formatFn(inventoryConfig); } - return inventoryConfig; } - exports.formatInventoryConfig = formatInventoryConfig; - function formatFn(_) { dataFix_1.dataFix(_, { bool: ['IsEnabled'] }, function (conf) { - var _a, _b; // prefix - - + var _a, _b; + // prefix conf.prefix = conf.Filter.Prefix; - delete conf.Filter; // OSSBucketDestination - - conf.OSSBucketDestination = conf.Destination.OSSBucketDestination; // OSSBucketDestination.rolename - + delete conf.Filter; + // OSSBucketDestination + conf.OSSBucketDestination = conf.Destination.OSSBucketDestination; + // OSSBucketDestination.rolename conf.OSSBucketDestination.rolename = conf.OSSBucketDestination.RoleArn.replace(/.*\//, ''); - delete conf.OSSBucketDestination.RoleArn; // OSSBucketDestination.bucket - + delete conf.OSSBucketDestination.RoleArn; + // OSSBucketDestination.bucket conf.OSSBucketDestination.bucket = conf.OSSBucketDestination.Bucket.replace(/.*:::/, ''); delete conf.OSSBucketDestination.Bucket; - delete conf.Destination; // frequency - + delete conf.Destination; + // frequency conf.frequency = conf.Schedule.Frequency; - delete conf.Schedule.Frequency; // optionalFields - + delete conf.Schedule.Frequency; + // optionalFields if (((_a = conf === null || conf === void 0 ? void 0 : conf.OptionalFields) === null || _a === void 0 ? void 0 : _a.Field) && !isArray_1.isArray((_b = conf.OptionalFields) === null || _b === void 0 ? void 0 : _b.Field)) conf.OptionalFields.Field = [conf.OptionalFields.Field]; - }); // firstLowerCase - + }); + // firstLowerCase _ = formatObjKey_1.formatObjKey(_, 'firstLowerCase', { exclude: ['OSSBucketDestination', 'SSE-OSS', 'SSE-KMS'] }); return _; } -},{"../utils/dataFix":55,"../utils/formatObjKey":59,"../utils/isArray":61,"../utils/isObject":67,"core-js/modules/es.array.map.js":249,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.string.replace.js":266}],59:[function(require,module,exports){ +},{"../utils/dataFix":58,"../utils/formatObjKey":63,"../utils/isArray":66,"../utils/isObject":73,"core-js/modules/es.array.map.js":318,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.string.replace.js":347}],63:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.keys.js"); - require("core-js/modules/es.array.includes.js"); - require("core-js/modules/es.string.includes.js"); - require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.formatObjKey = void 0; - function formatObjKey(obj, type, options) { if (obj === null || (0, _typeof2.default)(obj) !== 'object') { return obj; } - var o; - if (Array.isArray(obj)) { o = []; - for (var i = 0; i < obj.length; i++) { o.push(formatObjKey(obj[i], type, options)); } @@ -7756,17 +6710,11 @@ function formatObjKey(obj, type, options) { o[handelFormat(key, type, options)] = formatObjKey(obj[key], type, options); }); } - return o; } - exports.formatObjKey = formatObjKey; - function handelFormat(key, type, options) { - var _a; - - if (options && ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(key))) return key; - + if (options && options.exclude && options.exclude.includes(key)) return key; if (type === 'firstUpperCase') { key = key.replace(/^./, function (_) { return _.toUpperCase(); @@ -7776,65 +6724,71 @@ function handelFormat(key, type, options) { return _.toLowerCase(); }); } - return key; } -},{"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/helpers/typeof":75,"core-js/modules/es.array.includes.js":246,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.string.includes.js":263,"core-js/modules/es.string.replace.js":266,"core-js/modules/web.dom-collections.for-each.js":296}],60:[function(require,module,exports){ +},{"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/helpers/typeof":91,"core-js/modules/es.array.includes.js":315,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.string.includes.js":344,"core-js/modules/es.string.replace.js":347,"core-js/modules/web.dom-collections.for-each.js":382}],64:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.regexp.exec.js"); +require("core-js/modules/es.string.replace.js"); Object.defineProperty(exports, "__esModule", { value: true }); -exports.getStrBytesCount = void 0; +exports.getStandardRegion = void 0; +function getStandardRegion(str) { + return str.replace(/^oss-/g, ''); +} +exports.getStandardRegion = getStandardRegion; + +},{"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.string.replace.js":347}],65:[function(require,module,exports){ +"use strict"; +require("core-js/modules/es.regexp.exec.js"); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getStrBytesCount = void 0; function getStrBytesCount(str) { var bytesCount = 0; - for (var i = 0; i < str.length; i++) { var c = str.charAt(i); - if (/^[\u00-\uff]$/.test(c)) { bytesCount += 1; } else { bytesCount += 2; } } - return bytesCount; } - exports.getStrBytesCount = getStrBytesCount; -},{}],61:[function(require,module,exports){ +},{"core-js/modules/es.regexp.exec.js":340}],66:[function(require,module,exports){ "use strict"; require("core-js/modules/es.object.to-string.js"); - +require("core-js/modules/es.regexp.to-string.js"); Object.defineProperty(exports, "__esModule", { value: true }); exports.isArray = void 0; - exports.isArray = function (obj) { return Object.prototype.toString.call(obj) === '[object Array]'; }; -},{"core-js/modules/es.object.to-string.js":258}],62:[function(require,module,exports){ +},{"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.to-string.js":341}],67:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isBlob = void 0; - function isBlob(blob) { return typeof Blob !== 'undefined' && blob instanceof Blob; } - exports.isBlob = isBlob; -},{}],63:[function(require,module,exports){ +},{}],68:[function(require,module,exports){ (function (Buffer){(function (){ "use strict"; @@ -7842,143 +6796,136 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isBuffer = void 0; - function isBuffer(obj) { return Buffer.isBuffer(obj); } - exports.isBuffer = isBuffer; }).call(this)}).call(this,{"isBuffer":require("../../../node_modules/is-buffer/index.js")}) -},{"../../../node_modules/is-buffer/index.js":312}],64:[function(require,module,exports){ +},{"../../../node_modules/is-buffer/index.js":411}],69:[function(require,module,exports){ +(function (process){(function (){ "use strict"; +require("core-js/modules/es.array.includes.js"); +require("core-js/modules/es.string.includes.js"); Object.defineProperty(exports, "__esModule", { value: true }); -exports.isFile = void 0; +exports.isDingTalk = void 0; +function isDingTalk() { + if (process.browser && window.navigator.userAgent.toLowerCase().includes('aliapp(dingtalk')) { + return true; + } + return false; +} +exports.isDingTalk = isDingTalk; + +}).call(this)}).call(this,require('_process')) +},{"_process":540,"core-js/modules/es.array.includes.js":315,"core-js/modules/es.string.includes.js":344}],70:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isFile = void 0; exports.isFile = function (obj) { return typeof File !== 'undefined' && obj instanceof File; }; -},{}],65:[function(require,module,exports){ +},{}],71:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isFunction = void 0; - exports.isFunction = function (v) { return typeof v === 'function'; }; -},{}],66:[function(require,module,exports){ +},{}],72:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.regexp.exec.js"); Object.defineProperty(exports, "__esModule", { value: true }); -exports.isIP = void 0; // it provide commont methods for node and browser , we will add more solutions later in this file - +exports.isIP = void 0; +// it provide commont methods for node and browser , we will add more solutions later in this file /** * Judge isIP include ipv4 or ipv6 * @param {String} options * @return {Array} the multipart uploads */ - exports.isIP = function (host) { var ipv4Regex = /^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/; var ipv6Regex = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; return ipv4Regex.test(host) || ipv6Regex.test(host); }; -},{}],67:[function(require,module,exports){ +},{"core-js/modules/es.regexp.exec.js":340}],73:[function(require,module,exports){ "use strict"; require("core-js/modules/es.object.to-string.js"); - +require("core-js/modules/es.regexp.to-string.js"); Object.defineProperty(exports, "__esModule", { value: true }); exports.isObject = void 0; - exports.isObject = function (obj) { return Object.prototype.toString.call(obj) === '[object Object]'; }; -},{"core-js/modules/es.object.to-string.js":258}],68:[function(require,module,exports){ +},{"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.to-string.js":341}],74:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.keys.js"); - Object.defineProperty(exports, "__esModule", { value: true }); exports.lowercaseKeyHeader = void 0; - var isObject_1 = require("./isObject"); - function lowercaseKeyHeader(headers) { var lowercaseHeader = {}; - if (isObject_1.isObject(headers)) { Object.keys(headers).forEach(function (key) { lowercaseHeader[key.toLowerCase()] = headers[key]; }); } - return lowercaseHeader; } - exports.lowercaseKeyHeader = lowercaseKeyHeader; -},{"./isObject":67,"core-js/modules/es.object.keys.js":257,"core-js/modules/web.dom-collections.for-each.js":296}],69:[function(require,module,exports){ +},{"./isObject":73,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/web.dom-collections.for-each.js":382}],75:[function(require,module,exports){ "use strict"; require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - require("core-js/modules/es.object.to-string.js"); - +require("core-js/modules/es.regexp.to-string.js"); require("core-js/modules/web.dom-collections.for-each.js"); - require("core-js/modules/es.object.keys.js"); - require("core-js/modules/es.array.concat.js"); - require("core-js/modules/es.array.join.js"); - require("core-js/modules/es.array.map.js"); - -require("core-js/modules/es.regexp.to-string.js"); - Object.defineProperty(exports, "__esModule", { value: true }); exports.obj2xml = void 0; - var formatObjKey_1 = require("./formatObjKey"); - function type(params) { return Object.prototype.toString.call(params).replace(/(.*? |])/g, '').toLowerCase(); } - function obj2xml(obj, options) { var s = ''; - if (options && options.headers) { s = '\n'; } - if (options && options.firstUpperCase) { obj = formatObjKey_1.formatObjKey(obj, 'firstUpperCase'); } - if (type(obj) === 'object') { Object.keys(obj).forEach(function (key) { // filter undefined or null @@ -7999,39 +6946,73 @@ function obj2xml(obj, options) { } else { s += obj.toString(); } - return s; } - exports.obj2xml = obj2xml; -},{"./formatObjKey":59,"core-js/modules/es.array.concat.js":241,"core-js/modules/es.array.join.js":248,"core-js/modules/es.array.map.js":249,"core-js/modules/es.object.keys.js":257,"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.regexp.to-string.js":262,"core-js/modules/es.string.replace.js":266,"core-js/modules/web.dom-collections.for-each.js":296}],70:[function(require,module,exports){ +},{"./formatObjKey":63,"core-js/modules/es.array.concat.js":310,"core-js/modules/es.array.join.js":317,"core-js/modules/es.array.map.js":318,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.string.replace.js":347,"core-js/modules/web.dom-collections.for-each.js":382}],76:[function(require,module,exports){ "use strict"; +require("core-js/modules/es.array.slice.js"); require("core-js/modules/es.object.to-string.js"); +require("core-js/modules/es.regexp.to-string.js"); +require("core-js/modules/es.function.name.js"); +require("core-js/modules/es.array.from.js"); +require("core-js/modules/es.string.iterator.js"); +require("core-js/modules/es.regexp.exec.js"); +require("core-js/modules/es.symbol.js"); +require("core-js/modules/es.symbol.description.js"); +require("core-js/modules/es.symbol.iterator.js"); +require("core-js/modules/es.array.iterator.js"); +require("core-js/modules/web.dom-collections.iterator.js"); +require("core-js/modules/es.object.assign.js"); +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.omit = void 0; +function omit(originalObject, keysToOmit) { + var cloneObject = Object.assign({}, originalObject); + var _iterator = _createForOfIteratorHelper(keysToOmit), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var path = _step.value; + delete cloneObject[path]; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + return cloneObject; +} +exports.omit = omit; -require("core-js/modules/es.promise.js"); +},{"core-js/modules/es.array.from.js":314,"core-js/modules/es.array.iterator.js":316,"core-js/modules/es.array.slice.js":319,"core-js/modules/es.function.name.js":322,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.string.iterator.js":345,"core-js/modules/es.symbol.description.js":353,"core-js/modules/es.symbol.iterator.js":355,"core-js/modules/es.symbol.js":356,"core-js/modules/web.dom-collections.iterator.js":383}],77:[function(require,module,exports){ +"use strict"; +require("core-js/modules/es.object.to-string.js"); +require("core-js/modules/es.promise.js"); Object.defineProperty(exports, "__esModule", { value: true }); exports.retry = void 0; - function retry(func, retryMax) { var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var retryNum = 0; var _config$retryDelay = config.retryDelay, - retryDelay = _config$retryDelay === void 0 ? 500 : _config$retryDelay, - _config$errorHandler = config.errorHandler, - errorHandler = _config$errorHandler === void 0 ? function () { - return true; - } : _config$errorHandler; - + retryDelay = _config$retryDelay === void 0 ? 500 : _config$retryDelay, + _config$errorHandler = config.errorHandler, + errorHandler = _config$errorHandler === void 0 ? function () { + return true; + } : _config$errorHandler; var funcR = function funcR() { for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) { arg[_key] = arguments[_key]; } - return new Promise(function (resolve, reject) { func.apply(void 0, arg).then(function (result) { retryNum = 0; @@ -8049,13 +7030,11 @@ function retry(func, retryMax) { }); }); }; - return funcR; } - exports.retry = retry; -},{"core-js/modules/es.object.to-string.js":258,"core-js/modules/es.promise.js":259}],71:[function(require,module,exports){ +},{"core-js/modules/es.object.to-string.js":331,"core-js/modules/es.promise.js":335}],78:[function(require,module,exports){ "use strict"; var __importDefault = void 0 && (void 0).__importDefault || function (mod) { @@ -8063,116 +7042,88 @@ var __importDefault = void 0 && (void 0).__importDefault || function (mod) { "default": mod }; }; - Object.defineProperty(exports, "__esModule", { value: true }); exports.setRegion = void 0; - var url_1 = __importDefault(require("url")); - var checkConfigValid_1 = require("./checkConfigValid"); - function setRegion(region) { var internal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var secure = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; checkConfigValid_1.checkConfigValid(region, 'region'); var protocol = secure ? 'https://' : 'http://'; var suffix = internal ? '-internal.aliyuncs.com' : '.aliyuncs.com'; - var prefix = 'vpc100-oss-cn-'; // aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html - + var prefix = 'vpc100-oss-cn-'; + // aliyun VPC region: https://help.aliyun.com/knowledge_detail/38740.html if (region.substr(0, prefix.length) === prefix) { suffix = '.aliyuncs.com'; } - return url_1.default.parse(protocol + region + suffix); } - exports.setRegion = setRegion; -},{"./checkConfigValid":51,"url":404}],72:[function(require,module,exports){ +},{"./checkConfigValid":53,"url":545}],79:[function(require,module,exports){ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); - var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); - require("core-js/modules/es.object.keys.js"); - +require("core-js/modules/es.object.to-string.js"); require("core-js/modules/es.array.find.js"); - require("core-js/modules/es.object.assign.js"); - var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); - Object.defineProperty(exports, "__esModule", { value: true }); exports.checkCredentials = exports.setSTSToken = void 0; - var formatObjKey_1 = require("./formatObjKey"); - function setSTSToken() { return _setSTSToken.apply(this, arguments); } - function _setSTSToken() { _setSTSToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() { var now, credentials; return _regenerator.default.wrap(function _callee$(_context) { - while (1) { - switch (_context.prev = _context.next) { - case 0: - if (!this.options) this.options = {}; - now = new Date(); - - if (!this.stsTokenFreshTime) { - _context.next = 14; - break; - } - - if (!(+now - this.stsTokenFreshTime >= this.options.refreshSTSTokenInterval)) { - _context.next = 12; - break; - } - - this.stsTokenFreshTime = now; - _context.next = 7; - return this.options.refreshSTSToken(); - - case 7: - credentials = _context.sent; - credentials = formatObjKey_1.formatObjKey(credentials, 'firstLowerCase'); - - if (credentials.securityToken) { - credentials.stsToken = credentials.securityToken; - } - - checkCredentials(credentials); - Object.assign(this.options, credentials); - - case 12: - _context.next = 15; + while (1) switch (_context.prev = _context.next) { + case 0: + if (!this.options) this.options = {}; + now = new Date(); + if (!this.stsTokenFreshTime) { + _context.next = 14; break; - - case 14: - this.stsTokenFreshTime = now; - - case 15: - return _context.abrupt("return", null); - - case 16: - case "end": - return _context.stop(); - } + } + if (!(+now - this.stsTokenFreshTime >= this.options.refreshSTSTokenInterval)) { + _context.next = 12; + break; + } + this.stsTokenFreshTime = now; + _context.next = 7; + return this.options.refreshSTSToken(); + case 7: + credentials = _context.sent; + credentials = formatObjKey_1.formatObjKey(credentials, 'firstLowerCase'); + if (credentials.securityToken) { + credentials.stsToken = credentials.securityToken; + } + checkCredentials(credentials); + Object.assign(this.options, credentials); + case 12: + _context.next = 15; + break; + case 14: + this.stsTokenFreshTime = now; + case 15: + return _context.abrupt("return", null); + case 16: + case "end": + return _context.stop(); } }, _callee, this); })); return _setSTSToken.apply(this, arguments); } - exports.setSTSToken = setSTSToken; - function checkCredentials(obj) { var stsTokenKey = ['accessKeySecret', 'accessKeyId', 'stsToken']; var objKeys = Object.keys(obj); @@ -8184,10 +7135,22 @@ function checkCredentials(obj) { } }); } - exports.checkCredentials = checkCredentials; -},{"./formatObjKey":59,"@babel/runtime/helpers/asyncToGenerator":73,"@babel/runtime/helpers/interopRequireDefault":74,"@babel/runtime/regenerator":76,"core-js/modules/es.array.find.js":244,"core-js/modules/es.object.assign.js":255,"core-js/modules/es.object.keys.js":257}],73:[function(require,module,exports){ +},{"./formatObjKey":63,"@babel/runtime/helpers/asyncToGenerator":82,"@babel/runtime/helpers/interopRequireDefault":84,"@babel/runtime/regenerator":93,"core-js/modules/es.array.find.js":313,"core-js/modules/es.object.assign.js":325,"core-js/modules/es.object.keys.js":330,"core-js/modules/es.object.to-string.js":331}],80:[function(require,module,exports){ +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; +} +module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{}],81:[function(require,module,exports){ +var arrayLikeToArray = require("./arrayLikeToArray.js"); +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return arrayLikeToArray(arr); +} +module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{"./arrayLikeToArray.js":80}],82:[function(require,module,exports){ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); @@ -8196,83 +7159,449 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { reject(error); return; } - if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } - function _asyncToGenerator(fn) { return function () { var self = this, - args = arguments; + args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); - function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } - function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } - _next(undefined); }); }; } - -module.exports = _asyncToGenerator; -module.exports["default"] = module.exports, module.exports.__esModule = true; -},{}],74:[function(require,module,exports){ +module.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{}],83:[function(require,module,exports){ +var toPropertyKey = require("./toPropertyKey.js"); +function _defineProperty(obj, key, value) { + key = toPropertyKey(key); + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + return obj; +} +module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{"./toPropertyKey.js":90}],84:[function(require,module,exports){ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -module.exports = _interopRequireDefault; -module.exports["default"] = module.exports, module.exports.__esModule = true; -},{}],75:[function(require,module,exports){ -function _typeof(obj) { - "@babel/helpers - typeof"; - - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - module.exports = _typeof = function _typeof(obj) { - return typeof obj; +module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{}],85:[function(require,module,exports){ +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); +} +module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{}],86:[function(require,module,exports){ +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{}],87:[function(require,module,exports){ +var _typeof = require("./typeof.js")["default"]; +function _regeneratorRuntime() { + "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ + module.exports = _regeneratorRuntime = function _regeneratorRuntime() { + return e; + }, module.exports.__esModule = true, module.exports["default"] = module.exports; + var t, + e = {}, + r = Object.prototype, + n = r.hasOwnProperty, + o = Object.defineProperty || function (t, e, r) { + t[e] = r.value; + }, + i = "function" == typeof Symbol ? Symbol : {}, + a = i.iterator || "@@iterator", + c = i.asyncIterator || "@@asyncIterator", + u = i.toStringTag || "@@toStringTag"; + function define(t, e, r) { + return Object.defineProperty(t, e, { + value: r, + enumerable: !0, + configurable: !0, + writable: !0 + }), t[e]; + } + try { + define({}, ""); + } catch (t) { + define = function define(t, e, r) { + return t[e] = r; }; - - module.exports["default"] = module.exports, module.exports.__esModule = true; - } else { - module.exports = _typeof = function _typeof(obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + } + function wrap(t, e, r, n) { + var i = e && e.prototype instanceof Generator ? e : Generator, + a = Object.create(i.prototype), + c = new Context(n || []); + return o(a, "_invoke", { + value: makeInvokeMethod(t, r, c) + }), a; + } + function tryCatch(t, e, r) { + try { + return { + type: "normal", + arg: t.call(e, r) + }; + } catch (t) { + return { + type: "throw", + arg: t + }; + } + } + e.wrap = wrap; + var h = "suspendedStart", + l = "suspendedYield", + f = "executing", + s = "completed", + y = {}; + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + var p = {}; + define(p, a, function () { + return this; + }); + var d = Object.getPrototypeOf, + v = d && d(d(values([]))); + v && v !== r && n.call(v, a) && (p = v); + var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); + function defineIteratorMethods(t) { + ["next", "throw", "return"].forEach(function (e) { + define(t, e, function (t) { + return this._invoke(e, t); + }); + }); + } + function AsyncIterator(t, e) { + function invoke(r, o, i, a) { + var c = tryCatch(t[r], t, o); + if ("throw" !== c.type) { + var u = c.arg, + h = u.value; + return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { + invoke("next", t, i, a); + }, function (t) { + invoke("throw", t, i, a); + }) : e.resolve(h).then(function (t) { + u.value = t, i(u); + }, function (t) { + return invoke("throw", t, i, a); + }); + } + a(c.arg); + } + var r; + o(this, "_invoke", { + value: function value(t, n) { + function callInvokeWithMethodAndArg() { + return new e(function (e, r) { + invoke(t, n, e, r); + }); + } + return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); + } + }); + } + function makeInvokeMethod(e, r, n) { + var o = h; + return function (i, a) { + if (o === f) throw new Error("Generator is already running"); + if (o === s) { + if ("throw" === i) throw a; + return { + value: t, + done: !0 + }; + } + for (n.method = i, n.arg = a;;) { + var c = n.delegate; + if (c) { + var u = maybeInvokeDelegate(c, n); + if (u) { + if (u === y) continue; + return u; + } + } + if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { + if (o === h) throw o = s, n.arg; + n.dispatchException(n.arg); + } else "return" === n.method && n.abrupt("return", n.arg); + o = f; + var p = tryCatch(e, r, n); + if ("normal" === p.type) { + if (o = n.done ? s : l, p.arg === y) continue; + return { + value: p.arg, + done: n.done + }; + } + "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); + } + }; + } + function maybeInvokeDelegate(e, r) { + var n = r.method, + o = e.iterator[n]; + if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; + var i = tryCatch(o, e.iterator, r.arg); + if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; + var a = i.arg; + return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); + } + function pushTryEntry(t) { + var e = { + tryLoc: t[0] + }; + 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); + } + function resetTryEntry(t) { + var e = t.completion || {}; + e.type = "normal", delete e.arg, t.completion = e; + } + function Context(t) { + this.tryEntries = [{ + tryLoc: "root" + }], t.forEach(pushTryEntry, this), this.reset(!0); + } + function values(e) { + if (e || "" === e) { + var r = e[a]; + if (r) return r.call(e); + if ("function" == typeof e.next) return e; + if (!isNaN(e.length)) { + var o = -1, + i = function next() { + for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; + return next.value = t, next.done = !0, next; + }; + return i.next = i; + } + } + throw new TypeError(_typeof(e) + " is not iterable"); + } + return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { + value: GeneratorFunctionPrototype, + configurable: !0 + }), o(GeneratorFunctionPrototype, "constructor", { + value: GeneratorFunction, + configurable: !0 + }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { + var e = "function" == typeof t && t.constructor; + return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); + }, e.mark = function (t) { + return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; + }, e.awrap = function (t) { + return { + __await: t }; + }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { + return this; + }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { + void 0 === i && (i = Promise); + var a = new AsyncIterator(wrap(t, r, n, o), i); + return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { + return t.done ? t.value : a.next(); + }); + }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { + return this; + }), define(g, "toString", function () { + return "[object Generator]"; + }), e.keys = function (t) { + var e = Object(t), + r = []; + for (var n in e) r.push(n); + return r.reverse(), function next() { + for (; r.length;) { + var t = r.pop(); + if (t in e) return next.value = t, next.done = !1, next; + } + return next.done = !0, next; + }; + }, e.values = values, Context.prototype = { + constructor: Context, + reset: function reset(e) { + if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); + }, + stop: function stop() { + this.done = !0; + var t = this.tryEntries[0].completion; + if ("throw" === t.type) throw t.arg; + return this.rval; + }, + dispatchException: function dispatchException(e) { + if (this.done) throw e; + var r = this; + function handle(n, o) { + return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; + } + for (var o = this.tryEntries.length - 1; o >= 0; --o) { + var i = this.tryEntries[o], + a = i.completion; + if ("root" === i.tryLoc) return handle("end"); + if (i.tryLoc <= this.prev) { + var c = n.call(i, "catchLoc"), + u = n.call(i, "finallyLoc"); + if (c && u) { + if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); + if (this.prev < i.finallyLoc) return handle(i.finallyLoc); + } else if (c) { + if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); + } else { + if (!u) throw new Error("try statement without catch or finally"); + if (this.prev < i.finallyLoc) return handle(i.finallyLoc); + } + } + } + }, + abrupt: function abrupt(t, e) { + for (var r = this.tryEntries.length - 1; r >= 0; --r) { + var o = this.tryEntries[r]; + if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { + var i = o; + break; + } + } + i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); + var a = i ? i.completion : {}; + return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); + }, + complete: function complete(t, e) { + if ("throw" === t.type) throw t.arg; + return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; + }, + finish: function finish(t) { + for (var e = this.tryEntries.length - 1; e >= 0; --e) { + var r = this.tryEntries[e]; + if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; + } + }, + "catch": function _catch(t) { + for (var e = this.tryEntries.length - 1; e >= 0; --e) { + var r = this.tryEntries[e]; + if (r.tryLoc === t) { + var n = r.completion; + if ("throw" === n.type) { + var o = n.arg; + resetTryEntry(r); + } + return o; + } + } + throw new Error("illegal catch attempt"); + }, + delegateYield: function delegateYield(e, r, n) { + return this.delegate = { + iterator: values(e), + resultName: r, + nextLoc: n + }, "next" === this.method && (this.arg = t), y; + } + }, e; +} +module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{"./typeof.js":91}],88:[function(require,module,exports){ +var arrayWithoutHoles = require("./arrayWithoutHoles.js"); +var iterableToArray = require("./iterableToArray.js"); +var unsupportedIterableToArray = require("./unsupportedIterableToArray.js"); +var nonIterableSpread = require("./nonIterableSpread.js"); +function _toConsumableArray(arr) { + return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread(); +} +module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{"./arrayWithoutHoles.js":81,"./iterableToArray.js":85,"./nonIterableSpread.js":86,"./unsupportedIterableToArray.js":92}],89:[function(require,module,exports){ +var _typeof = require("./typeof.js")["default"]; +function toPrimitive(t, r) { + if ("object" != _typeof(t) || !t) return t; + var e = t[Symbol.toPrimitive]; + if (void 0 !== e) { + var i = e.call(t, r || "default"); + if ("object" != _typeof(i)) return i; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return ("string" === r ? String : Number)(t); +} +module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{"./typeof.js":91}],90:[function(require,module,exports){ +var _typeof = require("./typeof.js")["default"]; +var toPrimitive = require("./toPrimitive.js"); +function toPropertyKey(t) { + var i = toPrimitive(t, "string"); + return "symbol" == _typeof(i) ? i : String(i); +} +module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{"./toPrimitive.js":89,"./typeof.js":91}],91:[function(require,module,exports){ +function _typeof(o) { + "@babel/helpers - typeof"; - module.exports["default"] = module.exports, module.exports.__esModule = true; + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); +} +module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{}],92:[function(require,module,exports){ +var arrayLikeToArray = require("./arrayLikeToArray.js"); +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen); +} +module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports; +},{"./arrayLikeToArray.js":80}],93:[function(require,module,exports){ +// TODO(Babel 8): Remove this file. + +var runtime = require("../helpers/regeneratorRuntime")(); +module.exports = runtime; + +// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736= +try { + regeneratorRuntime = runtime; +} catch (accidentalStrictMode) { + if (typeof globalThis === "object") { + globalThis.regeneratorRuntime = runtime; + } else { + Function("r", "regeneratorRuntime = r")(runtime); } - - return _typeof(obj); } -module.exports = _typeof; -module.exports["default"] = module.exports, module.exports.__esModule = true; -},{}],76:[function(require,module,exports){ -module.exports = require("regenerator-runtime"); - -},{"regenerator-runtime":342}],77:[function(require,module,exports){ +},{"../helpers/regeneratorRuntime":87}],94:[function(require,module,exports){ module.exports = noop; module.exports.HttpsAgent = noop; // Noop function for browser since native api's don't use agents. function noop () {} -},{}],78:[function(require,module,exports){ +},{}],95:[function(require,module,exports){ (function (global){(function (){ 'use strict'; -var objectAssign = require('object-assign'); +var objectAssign = require('object.assign/polyfill')(); // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js // original notice: @@ -8778,7 +8107,7 @@ var objectKeys = Object.keys || function (obj) { }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"object-assign":320,"util/":81}],79:[function(require,module,exports){ +},{"object.assign/polyfill":440,"util/":98}],96:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -8803,14 +8132,14 @@ if (typeof Object.create === 'function') { } } -},{}],80:[function(require,module,exports){ +},{}],97:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],81:[function(require,module,exports){ +},{}],98:[function(require,module,exports){ (function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // @@ -9400,7 +8729,38 @@ function hasOwnProperty(obj, prop) { } }).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":80,"_process":399,"inherits":79}],82:[function(require,module,exports){ +},{"./support/isBuffer":97,"_process":540,"inherits":96}],99:[function(require,module,exports){ +(function (global){(function (){ +'use strict'; + +var possibleNames = [ + 'BigInt64Array', + 'BigUint64Array', + 'Float32Array', + 'Float64Array', + 'Int16Array', + 'Int32Array', + 'Int8Array', + 'Uint16Array', + 'Uint32Array', + 'Uint8Array', + 'Uint8ClampedArray' +]; + +var g = typeof globalThis === 'undefined' ? global : globalThis; + +module.exports = function availableTypedArrays() { + var out = []; + for (var i = 0; i < possibleNames.length; i++) { + if (typeof g[possibleNames[i]] === 'function') { + out[out.length] = possibleNames[i]; + } + } + return out; +}; + +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],100:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -9552,7 +8912,7 @@ function fromByteArray (uint8) { return parts.join('') } -},{}],83:[function(require,module,exports){ +},{}],101:[function(require,module,exports){ /*! * Bowser - a browser detector * https://github.com/ded/bowser @@ -10198,14 +9558,14 @@ function fromByteArray (uint8) { return bowser }); -},{}],84:[function(require,module,exports){ +},{}],102:[function(require,module,exports){ -},{}],85:[function(require,module,exports){ -(function (global,Buffer){(function (){ +},{}],103:[function(require,module,exports){ +(function (Buffer){(function (){ /*! * The buffer module from node.js, for the browser. * - * @author Feross Aboukhadijeh + * @author Feross Aboukhadijeh * @license MIT */ /* eslint-disable no-proto */ @@ -10214,80 +9574,73 @@ function fromByteArray (uint8) { var base64 = require('base64-js') var ieee754 = require('ieee754') -var isArray = require('isarray') exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer exports.INSPECT_MAX_BYTES = 50 +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + /** * If `Buffer.TYPED_ARRAY_SUPPORT`: * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) + * === 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+. * - * Due to various browser bugs, sometimes the Object implementation will be used even - * when the browser supports typed arrays. - * - * Note: - * - * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they - * get the Object implementation, which is slower but behaves correctly. + * 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 = global.TYPED_ARRAY_SUPPORT !== undefined - ? global.TYPED_ARRAY_SUPPORT - : typedArraySupport() +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() -/* - * Export kMaxLength after typed array support is determined. - */ -exports.kMaxLength = kMaxLength() +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 { var arr = new Uint8Array(1) - arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} - return arr.foo() === 42 && // typed array instances can be augmented - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + return arr.foo() === 42 } catch (e) { return false } } -function kMaxLength () { - return Buffer.TYPED_ARRAY_SUPPORT - ? 0x7fffffff - : 0x3fffffff -} - -function createBuffer (that, length) { - if (kMaxLength() < length) { - throw new RangeError('Invalid typed array length') +Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer } - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = new Uint8Array(length) - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - if (that === null) { - that = new Buffer(length) - } - that.length = length +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset } +}) - return that +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf } /** @@ -10301,44 +9654,77 @@ function createBuffer (that, length) { */ function Buffer (arg, encodingOrOffset, length) { - if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { - return new Buffer(arg, encodingOrOffset, length) - } - // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { - throw new Error( - 'If encoding is specified then the first argument must be a string' + throw new TypeError( + 'The "string" argument must be of type string. Received type number' ) } - return allocUnsafe(this, arg) + return allocUnsafe(arg) } - return from(this, arg, encodingOrOffset, length) + return from(arg, encodingOrOffset, length) +} + +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species != null && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) } Buffer.poolSize = 8192 // not used by this implementation -// TODO: Legacy, not needed anymore. Remove in next major version. -Buffer._augment = function (arr) { - arr.__proto__ = Buffer.prototype - return arr -} +function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayLike(value) + } + + if (value == null) { + throw 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) + } -function from (that, value, encodingOrOffset, length) { if (typeof value === 'number') { - throw new TypeError('"value" argument must not be a number') + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) } - if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { - return fromArrayBuffer(that, value, encodingOrOffset, length) + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) } - if (typeof value === 'string') { - return fromString(that, value, encodingOrOffset) + var 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 + ) } - return fromObject(that, value) + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) } /** @@ -10350,44 +9736,36 @@ function from (that, value, encodingOrOffset, length) { * Buffer.from(arrayBuffer[, byteOffset[, length]]) **/ Buffer.from = function (value, encodingOrOffset, length) { - return from(null, value, encodingOrOffset, length) -} - -if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array - if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true - }) - } + return from(value, encodingOrOffset, length) } +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array + function assertSize (size) { if (typeof size !== 'number') { - throw new TypeError('"size" argument must be a number') + throw new TypeError('"size" argument must be of type number') } else if (size < 0) { - throw new RangeError('"size" argument must not be negative') + throw new RangeError('The value "' + size + '" is invalid for option "size"') } } -function alloc (that, size, fill, encoding) { +function alloc (size, fill, encoding) { assertSize(size) if (size <= 0) { - return createBuffer(that, size) + 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 interpretted as a start offset. return typeof encoding === 'string' - ? createBuffer(that, size).fill(fill, encoding) - : createBuffer(that, size).fill(fill) + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) } - return createBuffer(that, size) + return createBuffer(size) } /** @@ -10395,132 +9773,114 @@ function alloc (that, size, fill, encoding) { * alloc(size[, fill[, encoding]]) **/ Buffer.alloc = function (size, fill, encoding) { - return alloc(null, size, fill, encoding) + return alloc(size, fill, encoding) } -function allocUnsafe (that, size) { +function allocUnsafe (size) { assertSize(size) - that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < size; ++i) { - that[i] = 0 - } - } - return that + 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(null, size) + return allocUnsafe(size) } /** * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. */ Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(null, size) + return allocUnsafe(size) } -function fromString (that, string, encoding) { +function fromString (string, encoding) { if (typeof encoding !== 'string' || encoding === '') { encoding = 'utf8' } if (!Buffer.isEncoding(encoding)) { - throw new TypeError('"encoding" must be a valid string encoding') + throw new TypeError('Unknown encoding: ' + encoding) } var length = byteLength(string, encoding) | 0 - that = createBuffer(that, length) + var buf = createBuffer(length) - var actual = that.write(string, encoding) + var 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') - that = that.slice(0, actual) + buf = buf.slice(0, actual) } - return that + return buf } -function fromArrayLike (that, array) { +function fromArrayLike (array) { var length = array.length < 0 ? 0 : checked(array.length) | 0 - that = createBuffer(that, length) + var buf = createBuffer(length) for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 + buf[i] = array[i] & 255 } - return that + return buf } -function fromArrayBuffer (that, array, byteOffset, length) { - array.byteLength // this throws if `array` is not a valid ArrayBuffer - +function fromArrayBuffer (array, byteOffset, length) { if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('\'offset\' is out of bounds') + throw new RangeError('"offset" is outside of buffer bounds') } if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('\'length\' is out of bounds') + throw new RangeError('"length" is outside of buffer bounds') } + var buf if (byteOffset === undefined && length === undefined) { - array = new Uint8Array(array) + buf = new Uint8Array(array) } else if (length === undefined) { - array = new Uint8Array(array, byteOffset) + buf = new Uint8Array(array, byteOffset) } else { - array = new Uint8Array(array, byteOffset, length) + buf = new Uint8Array(array, byteOffset, length) } - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = array - that.__proto__ = Buffer.prototype - } else { - // Fallback: Return an object instance of the Buffer class - that = fromArrayLike(that, array) - } - return that + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf } -function fromObject (that, obj) { +function fromObject (obj) { if (Buffer.isBuffer(obj)) { var len = checked(obj.length) | 0 - that = createBuffer(that, len) + var buf = createBuffer(len) - if (that.length === 0) { - return that + if (buf.length === 0) { + return buf } - obj.copy(that, 0, 0, len) - return that + obj.copy(buf, 0, 0, len) + return buf } - if (obj) { - if ((typeof ArrayBuffer !== 'undefined' && - obj.buffer instanceof ArrayBuffer) || 'length' in obj) { - if (typeof obj.length !== 'number' || isnan(obj.length)) { - return createBuffer(that, 0) - } - return fromArrayLike(that, obj) - } - - if (obj.type === 'Buffer' && isArray(obj.data)) { - return fromArrayLike(that, obj.data) + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) } + return fromArrayLike(obj) } - throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } } function checked (length) { - // Note: cannot use `length < kMaxLength()` here because that fails when + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when // length is NaN (which is otherwise coerced to zero.) - if (length >= kMaxLength()) { + if (length >= K_MAX_LENGTH) { throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength().toString(16) + ' bytes') + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') } return length | 0 } @@ -10533,12 +9893,17 @@ function SlowBuffer (length) { } Buffer.isBuffer = function isBuffer (b) { - return !!(b != null && b._isBuffer) + 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('Arguments must be Buffers') + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) } if (a === b) return 0 @@ -10579,7 +9944,7 @@ Buffer.isEncoding = function isEncoding (encoding) { } Buffer.concat = function concat (list, length) { - if (!isArray(list)) { + if (!Array.isArray(list)) { throw new TypeError('"list" argument must be an Array of Buffers') } @@ -10599,6 +9964,9 @@ Buffer.concat = function concat (list, length) { var pos = 0 for (i = 0; i < list.length; ++i) { var buf = list[i] + if (isInstance(buf, Uint8Array)) { + buf = Buffer.from(buf) + } if (!Buffer.isBuffer(buf)) { throw new TypeError('"list" argument must be an Array of Buffers') } @@ -10612,16 +9980,19 @@ function byteLength (string, encoding) { if (Buffer.isBuffer(string)) { return string.length } - if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && - (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { return string.byteLength } if (typeof string !== 'string') { - string = '' + string + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) } var len = string.length - if (len === 0) return 0 + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 // Use a for loop to avoid recursion var loweredCase = false @@ -10633,7 +10004,6 @@ function byteLength (string, encoding) { return len case 'utf8': case 'utf-8': - case undefined: return utf8ToBytes(string).length case 'ucs2': case 'ucs-2': @@ -10645,7 +10015,9 @@ function byteLength (string, encoding) { case 'base64': return base64ToBytes(string).length default: - if (loweredCase) return utf8ToBytes(string).length // assume utf8 + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } encoding = ('' + encoding).toLowerCase() loweredCase = true } @@ -10723,8 +10095,12 @@ function slowToString (encoding, start, end) { } } -// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect -// Buffer instances. +// 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) { @@ -10771,12 +10147,14 @@ Buffer.prototype.swap64 = function swap64 () { } Buffer.prototype.toString = function toString () { - var length = this.length | 0 + var 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 @@ -10786,16 +10164,20 @@ Buffer.prototype.equals = function equals (b) { Buffer.prototype.inspect = function inspect () { var str = '' var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) str += ' ... ' - } + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' return '' } 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('Argument must be a Buffer') + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) } if (start === undefined) { @@ -10874,8 +10256,8 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { } else if (byteOffset < -0x80000000) { byteOffset = -0x80000000 } - byteOffset = +byteOffset // Coerce to Number. - if (isNaN(byteOffset)) { + 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) } @@ -10904,8 +10286,7 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { return arrayIndexOf(buffer, val, byteOffset, encoding, dir) } else if (typeof val === 'number') { val = val & 0xFF // Search for a byte value [0-255] - if (Buffer.TYPED_ARRAY_SUPPORT && - typeof Uint8Array.prototype.indexOf === 'function') { + if (typeof Uint8Array.prototype.indexOf === 'function') { if (dir) { return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) } else { @@ -10998,16 +10379,14 @@ function hexWrite (buf, string, offset, length) { } } - // must be an even number of digits var strLen = string.length - if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') if (length > strLen / 2) { length = strLen / 2 } for (var i = 0; i < length; ++i) { var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) return i + if (numberIsNaN(parsed)) return i buf[offset + i] = parsed } return i @@ -11046,15 +10425,14 @@ Buffer.prototype.write = function write (string, offset, length, encoding) { offset = 0 // Buffer#write(string, offset[, length][, encoding]) } else if (isFinite(offset)) { - offset = offset | 0 + offset = offset >>> 0 if (isFinite(length)) { - length = length | 0 + length = length >>> 0 if (encoding === undefined) encoding = 'utf8' } else { encoding = length length = undefined } - // legacy write(string, encoding, offset, length) - remove in v0.13 } else { throw new Error( 'Buffer.write(string, encoding, offset[, length]) is no longer supported' @@ -11130,8 +10508,8 @@ function utf8Slice (buf, start, end) { var codePoint = null var bytesPerSequence = (firstByte > 0xEF) ? 4 : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 + : (firstByte > 0xBF) ? 2 + : 1 if (i + bytesPerSequence <= end) { var secondByte, thirdByte, fourthByte, tempCodePoint @@ -11253,7 +10631,7 @@ function utf16leSlice (buf, start, end) { var bytes = buf.slice(start, end) var res = '' for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) } return res } @@ -11279,18 +10657,9 @@ Buffer.prototype.slice = function slice (start, end) { if (end < start) end = start - var newBuf - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = this.subarray(start, end) - newBuf.__proto__ = Buffer.prototype - } else { - var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; ++i) { - newBuf[i] = this[i + start] - } - } - + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype return newBuf } @@ -11303,8 +10672,8 @@ function checkOffset (offset, ext, length) { } Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] @@ -11318,8 +10687,8 @@ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) } Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) { checkOffset(offset, byteLength, this.length) } @@ -11334,21 +10703,25 @@ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) } Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 1, this.length) return this[offset] } 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 = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 2, this.length) return (this[offset] << 8) | this[offset + 1] } Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return ((this[offset]) | @@ -11358,6 +10731,7 @@ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { } Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] * 0x1000000) + @@ -11367,8 +10741,8 @@ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { } Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] @@ -11385,8 +10759,8 @@ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { } Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) checkOffset(offset, byteLength, this.length) var i = byteLength @@ -11403,24 +10777,28 @@ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { } 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) var 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) var 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]) | @@ -11430,6 +10808,7 @@ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { } Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] << 24) | @@ -11439,21 +10818,25 @@ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { } 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) } @@ -11466,8 +10849,8 @@ function checkInt (buf, value, offset, ext, max, min) { Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1 checkInt(this, value, offset, byteLength, maxBytes, 0) @@ -11485,8 +10868,8 @@ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { value = +value - offset = offset | 0 - byteLength = byteLength | 0 + offset = offset >>> 0 + byteLength = byteLength >>> 0 if (!noAssert) { var maxBytes = Math.pow(2, 8 * byteLength) - 1 checkInt(this, value, offset, byteLength, maxBytes, 0) @@ -11504,89 +10887,57 @@ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) this[offset] = (value & 0xff) return offset + 1 } -function objectWriteUInt16 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { - buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> - (littleEndian ? i : 1 - i) * 8 - } -} - Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) return offset + 2 } Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) return offset + 2 } -function objectWriteUInt32 (buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { - buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff - } -} - Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, true) - } + 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 = function writeUInt32BE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) return offset + 4 } Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) + var limit = Math.pow(2, (8 * byteLength) - 1) checkInt(this, value, offset, byteLength, limit - 1, -limit) } @@ -11607,9 +10958,9 @@ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, no Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1) + var limit = Math.pow(2, (8 * byteLength) - 1) checkInt(this, value, offset, byteLength, limit - 1, -limit) } @@ -11630,9 +10981,8 @@ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, no Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) if (value < 0) value = 0xff + value + 1 this[offset] = (value & 0xff) return offset + 1 @@ -11640,58 +10990,42 @@ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { value = +value - offset = offset | 0 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - } else { - objectWriteUInt16(this, value, offset, true) - } + 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 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - } else { - objectWriteUInt16(this, value, offset, false) - } + 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 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - } else { - objectWriteUInt32(this, value, offset, true) - } + 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 + offset = offset >>> 0 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (value < 0) value = 0xffffffff + value + 1 - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - } else { - objectWriteUInt32(this, value, offset, false) - } + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) return offset + 4 } @@ -11701,6 +11035,8 @@ function checkIEEE754 (buf, value, offset, ext, max, min) { } 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) } @@ -11717,6 +11053,8 @@ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, 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) } @@ -11734,6 +11072,7 @@ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, 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 @@ -11748,7 +11087,7 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) { if (targetStart < 0) { throw new RangeError('targetStart out of bounds') } - if (start < 0 || start >= this.length) throw new RangeError('sourceStart 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? @@ -11758,22 +11097,19 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) { } var len = end - start - var i - if (this === target && start < targetStart && targetStart < end) { + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { // descending copy from end - for (i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - // ascending copy from start - for (i = 0; i < len; ++i) { + for (var i = len - 1; i >= 0; --i) { target[i + targetStart] = this[i + start] } } else { Uint8Array.prototype.set.call( target, - this.subarray(start, start + len), + this.subarray(start, end), targetStart ) } @@ -11796,18 +11132,20 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { encoding = end end = this.length } - if (val.length === 1) { - var code = val.charCodeAt(0) - if (code < 256) { - val = code - } - } 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) { + var 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 } @@ -11834,8 +11172,12 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { } else { var bytes = Buffer.isBuffer(val) ? val - : utf8ToBytes(new Buffer(val, encoding).toString()) + : Buffer.from(val, encoding) var 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] } @@ -11847,11 +11189,13 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) { // HELPER FUNCTIONS // ================ -var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g +var 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 = stringtrim(str).replace(INVALID_BASE64_RE, '') + 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 @@ -11861,11 +11205,6 @@ function base64clean (str) { return str } -function stringtrim (str) { - if (str.trim) return str.trim() - return str.replace(/^\s+|\s+$/g, '') -} - function toHex (n) { if (n < 16) return '0' + n.toString(16) return n.toString(16) @@ -11988,235 +11327,21 @@ function blitBuffer (src, dst, offset, length) { return i } -function isnan (val) { - return val !== val // eslint-disable-line no-self-compare -} - -}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer) -},{"base64-js":82,"buffer":85,"ieee754":304,"isarray":313}],86:[function(require,module,exports){ -// 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 Buffer = require('buffer').Buffer; - -var isBufferEncoding = Buffer.isEncoding - || function(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 assertEncoding(encoding) { - if (encoding && !isBufferEncoding(encoding)) { - throw new Error('Unknown encoding: ' + encoding); - } -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. CESU-8 is handled as part of the UTF-8 encoding. -// -// @TODO Handling all encodings inside a single object makes it very difficult -// to reason about this code, so it should be split up in the future. -// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code -// points as used by CESU-8. -var StringDecoder = exports.StringDecoder = function(encoding) { - this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); - assertEncoding(encoding); - switch (this.encoding) { - case 'utf8': - // CESU-8 represents each of Surrogate Pair by 3-bytes - this.surrogateSize = 3; - break; - case 'ucs2': - case 'utf16le': - // UTF-16 represents each of Surrogate Pair by 2-bytes - this.surrogateSize = 2; - this.detectIncompleteChar = utf16DetectIncompleteChar; - break; - case 'base64': - // Base-64 stores 3 bytes in 4 chars, and pads the remainder. - this.surrogateSize = 3; - this.detectIncompleteChar = base64DetectIncompleteChar; - break; - default: - this.write = passThroughWrite; - return; - } - - // Enough space to store all bytes of a single character. UTF-8 needs 4 - // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). - this.charBuffer = new Buffer(6); - // Number of bytes received for the current incomplete multi-byte character. - this.charReceived = 0; - // Number of bytes expected for the current incomplete multi-byte character. - this.charLength = 0; -}; - - -// write decodes the given buffer and returns it as JS string that is -// guaranteed to not contain any partial multi-byte characters. Any partial -// character found at the end of the buffer is buffered up, and will be -// returned when calling write again with the remaining bytes. -// -// Note: Converting a Buffer containing an orphan surrogate to a String -// currently works, but converting a String to a Buffer (via `new Buffer`, or -// Buffer#write) will replace incomplete surrogates with the unicode -// replacement character. See https://codereview.chromium.org/121173009/ . -StringDecoder.prototype.write = function(buffer) { - var charStr = ''; - // if our last write ended with an incomplete multibyte character - while (this.charLength) { - // determine how many remaining bytes this buffer has to offer for this char - var available = (buffer.length >= this.charLength - this.charReceived) ? - this.charLength - this.charReceived : - buffer.length; - - // add the new bytes to the char buffer - buffer.copy(this.charBuffer, this.charReceived, 0, available); - this.charReceived += available; - - if (this.charReceived < this.charLength) { - // still not enough chars in this buffer? wait for more ... - return ''; - } - - // remove bytes belonging to the current character from the buffer - buffer = buffer.slice(available, buffer.length); - - // get the character that was split - charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); - - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - var charCode = charStr.charCodeAt(charStr.length - 1); - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - this.charLength += this.surrogateSize; - charStr = ''; - continue; - } - this.charReceived = this.charLength = 0; - - // if there are no more bytes in this buffer, just emit our char - if (buffer.length === 0) { - return charStr; - } - break; - } - - // determine and set charLength / charReceived - this.detectIncompleteChar(buffer); - - var end = buffer.length; - if (this.charLength) { - // buffer the incomplete character bytes we got - buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); - end -= this.charReceived; - } - - charStr += buffer.toString(this.encoding, 0, end); - - var end = charStr.length - 1; - var charCode = charStr.charCodeAt(end); - // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character - if (charCode >= 0xD800 && charCode <= 0xDBFF) { - var size = this.surrogateSize; - this.charLength += size; - this.charReceived += size; - this.charBuffer.copy(this.charBuffer, size, 0, size); - buffer.copy(this.charBuffer, 0, 0, size); - return charStr.substring(0, end); - } - - // or just emit the charStr - return charStr; -}; - -// detectIncompleteChar determines if there is an incomplete UTF-8 character at -// the end of the given buffer. If so, it sets this.charLength to the byte -// length that character, and sets this.charReceived to the number of bytes -// that are available for this character. -StringDecoder.prototype.detectIncompleteChar = function(buffer) { - // determine how many bytes we have to check at the end of this buffer - var i = (buffer.length >= 3) ? 3 : buffer.length; - - // Figure out if one of the last i bytes of our buffer announces an - // incomplete char. - for (; i > 0; i--) { - var c = buffer[buffer.length - i]; - - // See http://en.wikipedia.org/wiki/UTF-8#Description - - // 110XXXXX - if (i == 1 && c >> 5 == 0x06) { - this.charLength = 2; - break; - } - - // 1110XXXX - if (i <= 2 && c >> 4 == 0x0E) { - this.charLength = 3; - break; - } - - // 11110XXX - if (i <= 3 && c >> 3 == 0x1E) { - this.charLength = 4; - break; - } - } - this.charReceived = i; -}; - -StringDecoder.prototype.end = function(buffer) { - var res = ''; - if (buffer && buffer.length) - res = this.write(buffer); - - if (this.charReceived) { - var cr = this.charReceived; - var buf = this.charBuffer; - var enc = this.encoding; - res += buf.slice(0, cr).toString(enc); - } - - return res; -}; - -function passThroughWrite(buffer) { - return buffer.toString(this.encoding); -} - -function utf16DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 2; - this.charLength = this.charReceived ? 2 : 0; +// 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 base64DetectIncompleteChar(buffer) { - this.charReceived = buffer.length % 3; - this.charLength = this.charReceived ? 3 : 0; +function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare } -},{"buffer":85}],87:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"base64-js":100,"buffer":103,"ieee754":402}],104:[function(require,module,exports){ module.exports = { "100": "Continue", "101": "Switching Protocols", @@ -12282,7 +11407,70 @@ module.exports = { "511": "Network Authentication Required" } -},{}],88:[function(require,module,exports){ +},{}],105:[function(require,module,exports){ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var callBind = require('./'); + +var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf')); + +module.exports = function callBoundIntrinsic(name, allowMissing) { + var intrinsic = GetIntrinsic(name, !!allowMissing); + if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { + return callBind(intrinsic); + } + return intrinsic; +}; + +},{"./":106,"get-intrinsic":392}],106:[function(require,module,exports){ +'use strict'; + +var bind = require('function-bind'); +var GetIntrinsic = require('get-intrinsic'); +var setFunctionLength = require('set-function-length'); + +var $TypeError = GetIntrinsic('%TypeError%'); +var $apply = GetIntrinsic('%Function.prototype.apply%'); +var $call = GetIntrinsic('%Function.prototype.call%'); +var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); + +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); +var $max = GetIntrinsic('%Math.max%'); + +if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + } catch (e) { + // IE 8 has a broken defineProperty + $defineProperty = null; + } +} + +module.exports = function callBind(originalFunction) { + if (typeof originalFunction !== 'function') { + throw new $TypeError('a function is required'); + } + var func = $reflectApply(bind, $call, arguments); + return setFunctionLength( + func, + 1 + $max(0, originalFunction.length - (arguments.length - 1)), + true + ); +}; + +var applyBind = function applyBind() { + return $reflectApply(bind, $apply, arguments); +}; + +if ($defineProperty) { + $defineProperty(module.exports, 'apply', { value: applyBind }); +} else { + module.exports.apply = applyBind; +} + +},{"function-bind":391,"get-intrinsic":392,"set-function-length":468}],107:[function(require,module,exports){ /*! * copy-to - index.js * Copyright(c) 2014 dead_horse @@ -12445,34 +11633,57 @@ function notDefined(obj, key) { && obj.__lookupSetter__(key) === undefined; } -},{}],89:[function(require,module,exports){ -module.exports = function (it) { - if (typeof it != 'function') { - throw TypeError(String(it) + ' is not a function'); - } return it; +},{}],108:[function(require,module,exports){ +'use strict'; +var isCallable = require('../internals/is-callable'); +var tryToString = require('../internals/try-to-string'); + +var $TypeError = TypeError; + +// `Assert: IsCallable(argument) is true` +module.exports = function (argument) { + if (isCallable(argument)) return argument; + throw new $TypeError(tryToString(argument) + ' is not a function'); }; -},{}],90:[function(require,module,exports){ -var isObject = require('../internals/is-object'); +},{"../internals/is-callable":203,"../internals/try-to-string":293}],109:[function(require,module,exports){ +'use strict'; +var isConstructor = require('../internals/is-constructor'); +var tryToString = require('../internals/try-to-string'); -module.exports = function (it) { - if (!isObject(it) && it !== null) { - throw TypeError("Can't set " + String(it) + ' as a prototype'); - } return it; +var $TypeError = TypeError; + +// `Assert: IsConstructor(argument) is true` +module.exports = function (argument) { + if (isConstructor(argument)) return argument; + throw new $TypeError(tryToString(argument) + ' is not a constructor'); +}; + +},{"../internals/is-constructor":204,"../internals/try-to-string":293}],110:[function(require,module,exports){ +'use strict'; +var isPossiblePrototype = require('../internals/is-possible-prototype'); + +var $String = String; +var $TypeError = TypeError; + +module.exports = function (argument) { + if (isPossiblePrototype(argument)) return argument; + throw new $TypeError("Can't set " + $String(argument) + ' as a prototype'); }; -},{"../internals/is-object":162}],91:[function(require,module,exports){ +},{"../internals/is-possible-prototype":209}],111:[function(require,module,exports){ +'use strict'; var wellKnownSymbol = require('../internals/well-known-symbol'); var create = require('../internals/object-create'); -var definePropertyModule = require('../internals/object-define-property'); +var defineProperty = require('../internals/object-define-property').f; var UNSCOPABLES = wellKnownSymbol('unscopables'); var ArrayPrototype = Array.prototype; // Array.prototype[@@unscopables] // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -if (ArrayPrototype[UNSCOPABLES] == undefined) { - definePropertyModule.f(ArrayPrototype, UNSCOPABLES, { +if (ArrayPrototype[UNSCOPABLES] === undefined) { + defineProperty(ArrayPrototype, UNSCOPABLES, { configurable: true, value: create(null) }); @@ -12483,7 +11694,7 @@ module.exports = function (key) { ArrayPrototype[UNSCOPABLES][key] = true; }; -},{"../internals/object-create":177,"../internals/object-define-property":179,"../internals/well-known-symbol":237}],92:[function(require,module,exports){ +},{"../internals/object-create":229,"../internals/object-define-property":231,"../internals/well-known-symbol":306}],112:[function(require,module,exports){ 'use strict'; var charAt = require('../internals/string-multibyte').charAt; @@ -12493,42 +11704,70 @@ module.exports = function (S, index, unicode) { return index + (unicode ? charAt(S, index).length : 1); }; -},{"../internals/string-multibyte":213}],93:[function(require,module,exports){ -module.exports = function (it, Constructor, name) { - if (!(it instanceof Constructor)) { - throw TypeError('Incorrect ' + (name ? name + ' ' : '') + 'invocation'); - } return it; +},{"../internals/string-multibyte":271}],113:[function(require,module,exports){ +'use strict'; +var isPrototypeOf = require('../internals/object-is-prototype-of'); + +var $TypeError = TypeError; + +module.exports = function (it, Prototype) { + if (isPrototypeOf(Prototype, it)) return it; + throw new $TypeError('Incorrect invocation'); }; -},{}],94:[function(require,module,exports){ +},{"../internals/object-is-prototype-of":238}],114:[function(require,module,exports){ +'use strict'; var isObject = require('../internals/is-object'); -module.exports = function (it) { - if (!isObject(it)) { - throw TypeError(String(it) + ' is not an object'); - } return it; +var $String = String; +var $TypeError = TypeError; + +// `Assert: Type(argument) is Object` +module.exports = function (argument) { + if (isObject(argument)) return argument; + throw new $TypeError($String(argument) + ' is not an object'); }; -},{"../internals/is-object":162}],95:[function(require,module,exports){ +},{"../internals/is-object":208}],115:[function(require,module,exports){ +'use strict'; // eslint-disable-next-line es/no-typed-arrays -- safe -module.exports = typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined'; +module.exports = typeof ArrayBuffer != 'undefined' && typeof DataView != 'undefined'; + +},{}],116:[function(require,module,exports){ +'use strict'; +// FF26- bug: ArrayBuffers are non-extensible, but Object.isExtensible does not report it +var fails = require('../internals/fails'); + +module.exports = fails(function () { + if (typeof ArrayBuffer == 'function') { + var buffer = new ArrayBuffer(8); + // eslint-disable-next-line es/no-object-isextensible, es/no-object-defineproperty -- safe + if (Object.isExtensible(buffer)) Object.defineProperty(buffer, 'a', { value: 8 }); + } +}); -},{}],96:[function(require,module,exports){ +},{"../internals/fails":171}],117:[function(require,module,exports){ 'use strict'; -var NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native'); +var NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-basic-detection'); var DESCRIPTORS = require('../internals/descriptors'); var global = require('../internals/global'); +var isCallable = require('../internals/is-callable'); var isObject = require('../internals/is-object'); -var has = require('../internals/has'); +var hasOwn = require('../internals/has-own-property'); var classof = require('../internals/classof'); +var tryToString = require('../internals/try-to-string'); var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var redefine = require('../internals/redefine'); -var defineProperty = require('../internals/object-define-property').f; +var defineBuiltIn = require('../internals/define-built-in'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); +var isPrototypeOf = require('../internals/object-is-prototype-of'); var getPrototypeOf = require('../internals/object-get-prototype-of'); var setPrototypeOf = require('../internals/object-set-prototype-of'); var wellKnownSymbol = require('../internals/well-known-symbol'); var uid = require('../internals/uid'); +var InternalStateModule = require('../internals/internal-state'); +var enforceInternalState = InternalStateModule.enforce; +var getInternalState = InternalStateModule.get; var Int8Array = global.Int8Array; var Int8ArrayPrototype = Int8Array && Int8Array.prototype; var Uint8ClampedArray = global.Uint8ClampedArray; @@ -12536,14 +11775,14 @@ var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototyp var TypedArray = Int8Array && getPrototypeOf(Int8Array); var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype); var ObjectPrototype = Object.prototype; -var isPrototypeOf = ObjectPrototype.isPrototypeOf; +var TypeError = global.TypeError; var TO_STRING_TAG = wellKnownSymbol('toStringTag'); var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG'); -var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR'); +var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor'; // Fixing native typed arrays in Opera Presto crashes the browser, see #595 var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera'; -var TYPED_ARRAY_TAG_REQIRED = false; +var TYPED_ARRAY_TAG_REQUIRED = false; var NAME, Constructor, Prototype; var TypedArrayConstructorsList = { @@ -12567,39 +11806,50 @@ var isView = function isView(it) { if (!isObject(it)) return false; var klass = classof(it); return klass === 'DataView' - || has(TypedArrayConstructorsList, klass) - || has(BigIntArrayConstructorsList, klass); + || hasOwn(TypedArrayConstructorsList, klass) + || hasOwn(BigIntArrayConstructorsList, klass); +}; + +var getTypedArrayConstructor = function (it) { + var proto = getPrototypeOf(it); + if (!isObject(proto)) return; + var state = getInternalState(proto); + return (state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR)) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto); }; var isTypedArray = function (it) { if (!isObject(it)) return false; var klass = classof(it); - return has(TypedArrayConstructorsList, klass) - || has(BigIntArrayConstructorsList, klass); + return hasOwn(TypedArrayConstructorsList, klass) + || hasOwn(BigIntArrayConstructorsList, klass); }; var aTypedArray = function (it) { if (isTypedArray(it)) return it; - throw TypeError('Target is not a typed array'); + throw new TypeError('Target is not a typed array'); }; var aTypedArrayConstructor = function (C) { - if (setPrototypeOf && !isPrototypeOf.call(TypedArray, C)) { - throw TypeError('Target is not a typed array constructor'); - } return C; + if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C))) return C; + throw new TypeError(tryToString(C) + ' is not a typed array constructor'); }; -var exportTypedArrayMethod = function (KEY, property, forced) { +var exportTypedArrayMethod = function (KEY, property, forced, options) { if (!DESCRIPTORS) return; if (forced) for (var ARRAY in TypedArrayConstructorsList) { var TypedArrayConstructor = global[ARRAY]; - if (TypedArrayConstructor && has(TypedArrayConstructor.prototype, KEY)) try { + if (TypedArrayConstructor && hasOwn(TypedArrayConstructor.prototype, KEY)) try { delete TypedArrayConstructor.prototype[KEY]; - } catch (error) { /* empty */ } + } catch (error) { + // old WebKit bug - some methods are non-configurable + try { + TypedArrayConstructor.prototype[KEY] = property; + } catch (error2) { /* empty */ } + } } if (!TypedArrayPrototype[KEY] || forced) { - redefine(TypedArrayPrototype, KEY, forced ? property - : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property); + defineBuiltIn(TypedArrayPrototype, KEY, forced ? property + : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property, options); } }; @@ -12609,21 +11859,21 @@ var exportTypedArrayStaticMethod = function (KEY, property, forced) { if (setPrototypeOf) { if (forced) for (ARRAY in TypedArrayConstructorsList) { TypedArrayConstructor = global[ARRAY]; - if (TypedArrayConstructor && has(TypedArrayConstructor, KEY)) try { + if (TypedArrayConstructor && hasOwn(TypedArrayConstructor, KEY)) try { delete TypedArrayConstructor[KEY]; } catch (error) { /* empty */ } } if (!TypedArray[KEY] || forced) { // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable try { - return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); + return defineBuiltIn(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property); } catch (error) { /* empty */ } } else return; } for (ARRAY in TypedArrayConstructorsList) { TypedArrayConstructor = global[ARRAY]; if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) { - redefine(TypedArrayConstructor, KEY, property); + defineBuiltIn(TypedArrayConstructor, KEY, property); } } }; @@ -12631,21 +11881,21 @@ var exportTypedArrayStaticMethod = function (KEY, property, forced) { for (NAME in TypedArrayConstructorsList) { Constructor = global[NAME]; Prototype = Constructor && Constructor.prototype; - if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor); + if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor; else NATIVE_ARRAY_BUFFER_VIEWS = false; } for (NAME in BigIntArrayConstructorsList) { Constructor = global[NAME]; Prototype = Constructor && Constructor.prototype; - if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor); + if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor; } // WebKit bug - typed arrays constructors prototype is Object.prototype -if (!NATIVE_ARRAY_BUFFER_VIEWS || typeof TypedArray != 'function' || TypedArray === Function.prototype) { +if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { // eslint-disable-next-line no-shadow -- safe TypedArray = function TypedArray() { - throw TypeError('Incorrect invocation'); + throw new TypeError('Incorrect invocation'); }; if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { if (global[NAME]) setPrototypeOf(global[NAME], TypedArray); @@ -12664,11 +11914,14 @@ if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype); } -if (DESCRIPTORS && !has(TypedArrayPrototype, TO_STRING_TAG)) { - TYPED_ARRAY_TAG_REQIRED = true; - defineProperty(TypedArrayPrototype, TO_STRING_TAG, { get: function () { - return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; - } }); +if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) { + TYPED_ARRAY_TAG_REQUIRED = true; + defineBuiltInAccessor(TypedArrayPrototype, TO_STRING_TAG, { + configurable: true, + get: function () { + return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined; + } + }); for (NAME in TypedArrayConstructorsList) if (global[NAME]) { createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME); } @@ -12676,52 +11929,64 @@ if (DESCRIPTORS && !has(TypedArrayPrototype, TO_STRING_TAG)) { module.exports = { NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS, - TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR, - TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG, + TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG, aTypedArray: aTypedArray, aTypedArrayConstructor: aTypedArrayConstructor, exportTypedArrayMethod: exportTypedArrayMethod, exportTypedArrayStaticMethod: exportTypedArrayStaticMethod, + getTypedArrayConstructor: getTypedArrayConstructor, isView: isView, isTypedArray: isTypedArray, TypedArray: TypedArray, TypedArrayPrototype: TypedArrayPrototype }; -},{"../internals/array-buffer-native":95,"../internals/classof":115,"../internals/create-non-enumerable-property":120,"../internals/descriptors":125,"../internals/global":147,"../internals/has":148,"../internals/is-object":162,"../internals/object-define-property":179,"../internals/object-get-prototype-of":184,"../internals/object-set-prototype-of":188,"../internals/redefine":197,"../internals/uid":234,"../internals/well-known-symbol":237}],97:[function(require,module,exports){ +},{"../internals/array-buffer-basic-detection":115,"../internals/classof":138,"../internals/create-non-enumerable-property":145,"../internals/define-built-in":149,"../internals/define-built-in-accessor":148,"../internals/descriptors":153,"../internals/global":188,"../internals/has-own-property":189,"../internals/internal-state":199,"../internals/is-callable":203,"../internals/is-object":208,"../internals/object-get-prototype-of":236,"../internals/object-is-prototype-of":238,"../internals/object-set-prototype-of":242,"../internals/try-to-string":293,"../internals/uid":299,"../internals/well-known-symbol":306}],118:[function(require,module,exports){ 'use strict'; var global = require('../internals/global'); +var uncurryThis = require('../internals/function-uncurry-this'); var DESCRIPTORS = require('../internals/descriptors'); -var NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native'); +var NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-basic-detection'); +var FunctionName = require('../internals/function-name'); var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var redefineAll = require('../internals/redefine-all'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); +var defineBuiltIns = require('../internals/define-built-ins'); var fails = require('../internals/fails'); var anInstance = require('../internals/an-instance'); -var toInteger = require('../internals/to-integer'); +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); var toLength = require('../internals/to-length'); var toIndex = require('../internals/to-index'); +var fround = require('../internals/math-fround'); var IEEE754 = require('../internals/ieee754'); var getPrototypeOf = require('../internals/object-get-prototype-of'); var setPrototypeOf = require('../internals/object-set-prototype-of'); -var getOwnPropertyNames = require('../internals/object-get-own-property-names').f; -var defineProperty = require('../internals/object-define-property').f; var arrayFill = require('../internals/array-fill'); +var arraySlice = require('../internals/array-slice'); +var inheritIfRequired = require('../internals/inherit-if-required'); +var copyConstructorProperties = require('../internals/copy-constructor-properties'); var setToStringTag = require('../internals/set-to-string-tag'); var InternalStateModule = require('../internals/internal-state'); -var getInternalState = InternalStateModule.get; -var setInternalState = InternalStateModule.set; +var PROPER_FUNCTION_NAME = FunctionName.PROPER; +var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE; var ARRAY_BUFFER = 'ArrayBuffer'; var DATA_VIEW = 'DataView'; var PROTOTYPE = 'prototype'; var WRONG_LENGTH = 'Wrong length'; var WRONG_INDEX = 'Wrong index'; +var getInternalArrayBufferState = InternalStateModule.getterFor(ARRAY_BUFFER); +var getInternalDataViewState = InternalStateModule.getterFor(DATA_VIEW); +var setInternalState = InternalStateModule.set; var NativeArrayBuffer = global[ARRAY_BUFFER]; var $ArrayBuffer = NativeArrayBuffer; +var ArrayBufferPrototype = $ArrayBuffer && $ArrayBuffer[PROTOTYPE]; var $DataView = global[DATA_VIEW]; -var $DataViewPrototype = $DataView && $DataView[PROTOTYPE]; +var DataViewPrototype = $DataView && $DataView[PROTOTYPE]; var ObjectPrototype = Object.prototype; +var Array = global.Array; var RangeError = global.RangeError; +var fill = uncurryThis(arrayFill); +var reverse = uncurryThis([].reverse); var packIEEE754 = IEEE754.pack; var unpackIEEE754 = IEEE754.unpack; @@ -12743,60 +12008,76 @@ var unpackInt32 = function (buffer) { }; var packFloat32 = function (number) { - return packIEEE754(number, 23, 4); + return packIEEE754(fround(number), 23, 4); }; var packFloat64 = function (number) { return packIEEE754(number, 52, 8); }; -var addGetter = function (Constructor, key) { - defineProperty(Constructor[PROTOTYPE], key, { get: function () { return getInternalState(this)[key]; } }); +var addGetter = function (Constructor, key, getInternalState) { + defineBuiltInAccessor(Constructor[PROTOTYPE], key, { + configurable: true, + get: function () { + return getInternalState(this)[key]; + } + }); }; var get = function (view, count, index, isLittleEndian) { + var store = getInternalDataViewState(view); var intIndex = toIndex(index); - var store = getInternalState(view); - if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX); - var bytes = getInternalState(store.buffer).bytes; + var boolIsLittleEndian = !!isLittleEndian; + if (intIndex + count > store.byteLength) throw new RangeError(WRONG_INDEX); + var bytes = store.bytes; var start = intIndex + store.byteOffset; - var pack = bytes.slice(start, start + count); - return isLittleEndian ? pack : pack.reverse(); + var pack = arraySlice(bytes, start, start + count); + return boolIsLittleEndian ? pack : reverse(pack); }; var set = function (view, count, index, conversion, value, isLittleEndian) { + var store = getInternalDataViewState(view); var intIndex = toIndex(index); - var store = getInternalState(view); - if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX); - var bytes = getInternalState(store.buffer).bytes; - var start = intIndex + store.byteOffset; var pack = conversion(+value); - for (var i = 0; i < count; i++) bytes[start + i] = pack[isLittleEndian ? i : count - i - 1]; + var boolIsLittleEndian = !!isLittleEndian; + if (intIndex + count > store.byteLength) throw new RangeError(WRONG_INDEX); + var bytes = store.bytes; + var start = intIndex + store.byteOffset; + for (var i = 0; i < count; i++) bytes[start + i] = pack[boolIsLittleEndian ? i : count - i - 1]; }; if (!NATIVE_ARRAY_BUFFER) { $ArrayBuffer = function ArrayBuffer(length) { - anInstance(this, $ArrayBuffer, ARRAY_BUFFER); + anInstance(this, ArrayBufferPrototype); var byteLength = toIndex(length); setInternalState(this, { - bytes: arrayFill.call(new Array(byteLength), 0), + type: ARRAY_BUFFER, + bytes: fill(Array(byteLength), 0), byteLength: byteLength }); - if (!DESCRIPTORS) this.byteLength = byteLength; + if (!DESCRIPTORS) { + this.byteLength = byteLength; + this.detached = false; + } }; + ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE]; + $DataView = function DataView(buffer, byteOffset, byteLength) { - anInstance(this, $DataView, DATA_VIEW); - anInstance(buffer, $ArrayBuffer, DATA_VIEW); - var bufferLength = getInternalState(buffer).byteLength; - var offset = toInteger(byteOffset); - if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset'); + anInstance(this, DataViewPrototype); + anInstance(buffer, ArrayBufferPrototype); + var bufferState = getInternalArrayBufferState(buffer); + var bufferLength = bufferState.byteLength; + var offset = toIntegerOrInfinity(byteOffset); + if (offset < 0 || offset > bufferLength) throw new RangeError('Wrong offset'); byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); - if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH); + if (offset + byteLength > bufferLength) throw new RangeError(WRONG_LENGTH); setInternalState(this, { + type: DATA_VIEW, buffer: buffer, byteLength: byteLength, - byteOffset: offset + byteOffset: offset, + bytes: bufferState.bytes }); if (!DESCRIPTORS) { this.buffer = buffer; @@ -12805,14 +12086,16 @@ if (!NATIVE_ARRAY_BUFFER) { } }; + DataViewPrototype = $DataView[PROTOTYPE]; + if (DESCRIPTORS) { - addGetter($ArrayBuffer, 'byteLength'); - addGetter($DataView, 'buffer'); - addGetter($DataView, 'byteLength'); - addGetter($DataView, 'byteOffset'); + addGetter($ArrayBuffer, 'byteLength', getInternalArrayBufferState); + addGetter($DataView, 'buffer', getInternalDataViewState); + addGetter($DataView, 'byteLength', getInternalDataViewState); + addGetter($DataView, 'byteOffset', getInternalDataViewState); } - redefineAll($DataView[PROTOTYPE], { + defineBuiltIns(DataViewPrototype, { getInt8: function getInt8(byteOffset) { return get(this, 1, byteOffset)[0] << 24 >> 24; }, @@ -12820,24 +12103,24 @@ if (!NATIVE_ARRAY_BUFFER) { return get(this, 1, byteOffset)[0]; }, getInt16: function getInt16(byteOffset /* , littleEndian */) { - var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); + var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); return (bytes[1] << 8 | bytes[0]) << 16 >> 16; }, getUint16: function getUint16(byteOffset /* , littleEndian */) { - var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : undefined); + var bytes = get(this, 2, byteOffset, arguments.length > 1 ? arguments[1] : false); return bytes[1] << 8 | bytes[0]; }, getInt32: function getInt32(byteOffset /* , littleEndian */) { - return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)); + return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)); }, getUint32: function getUint32(byteOffset /* , littleEndian */) { - return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined)) >>> 0; + return unpackInt32(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false)) >>> 0; }, getFloat32: function getFloat32(byteOffset /* , littleEndian */) { - return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 23); + return unpackIEEE754(get(this, 4, byteOffset, arguments.length > 1 ? arguments[1] : false), 23); }, getFloat64: function getFloat64(byteOffset /* , littleEndian */) { - return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : undefined), 52); + return unpackIEEE754(get(this, 8, byteOffset, arguments.length > 1 ? arguments[1] : false), 52); }, setInt8: function setInt8(byteOffset, value) { set(this, 1, byteOffset, packInt8, value); @@ -12846,25 +12129,26 @@ if (!NATIVE_ARRAY_BUFFER) { set(this, 1, byteOffset, packInt8, value); }, setInt16: function setInt16(byteOffset, value /* , littleEndian */) { - set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); + set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); }, setUint16: function setUint16(byteOffset, value /* , littleEndian */) { - set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : undefined); + set(this, 2, byteOffset, packInt16, value, arguments.length > 2 ? arguments[2] : false); }, setInt32: function setInt32(byteOffset, value /* , littleEndian */) { - set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); + set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); }, setUint32: function setUint32(byteOffset, value /* , littleEndian */) { - set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : undefined); + set(this, 4, byteOffset, packInt32, value, arguments.length > 2 ? arguments[2] : false); }, setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) { - set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : undefined); + set(this, 4, byteOffset, packFloat32, value, arguments.length > 2 ? arguments[2] : false); }, setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) { - set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : undefined); + set(this, 8, byteOffset, packFloat64, value, arguments.length > 2 ? arguments[2] : false); } }); } else { + var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER; /* eslint-disable no-new -- required for testing */ if (!fails(function () { NativeArrayBuffer(1); @@ -12874,38 +12158,39 @@ if (!NATIVE_ARRAY_BUFFER) { new NativeArrayBuffer(); new NativeArrayBuffer(1.5); new NativeArrayBuffer(NaN); - return NativeArrayBuffer.name != ARRAY_BUFFER; + return NativeArrayBuffer.length !== 1 || INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; })) { - /* eslint-enable no-new -- required for testing */ + /* eslint-enable no-new -- required for testing */ $ArrayBuffer = function ArrayBuffer(length) { - anInstance(this, $ArrayBuffer); - return new NativeArrayBuffer(toIndex(length)); + anInstance(this, ArrayBufferPrototype); + return inheritIfRequired(new NativeArrayBuffer(toIndex(length)), this, $ArrayBuffer); }; - var ArrayBufferPrototype = $ArrayBuffer[PROTOTYPE] = NativeArrayBuffer[PROTOTYPE]; - for (var keys = getOwnPropertyNames(NativeArrayBuffer), j = 0, key; keys.length > j;) { - if (!((key = keys[j++]) in $ArrayBuffer)) { - createNonEnumerableProperty($ArrayBuffer, key, NativeArrayBuffer[key]); - } - } + + $ArrayBuffer[PROTOTYPE] = ArrayBufferPrototype; + ArrayBufferPrototype.constructor = $ArrayBuffer; + + copyConstructorProperties($ArrayBuffer, NativeArrayBuffer); + } else if (INCORRECT_ARRAY_BUFFER_NAME && CONFIGURABLE_FUNCTION_NAME) { + createNonEnumerableProperty(NativeArrayBuffer, 'name', ARRAY_BUFFER); } // WebKit bug - the same parent prototype for typed arrays and data view - if (setPrototypeOf && getPrototypeOf($DataViewPrototype) !== ObjectPrototype) { - setPrototypeOf($DataViewPrototype, ObjectPrototype); + if (setPrototypeOf && getPrototypeOf(DataViewPrototype) !== ObjectPrototype) { + setPrototypeOf(DataViewPrototype, ObjectPrototype); } // iOS Safari 7.x bug var testView = new $DataView(new $ArrayBuffer(2)); - var $setInt8 = $DataViewPrototype.setInt8; + var $setInt8 = uncurryThis(DataViewPrototype.setInt8); testView.setInt8(0, 2147483648); testView.setInt8(1, 2147483649); - if (testView.getInt8(0) || !testView.getInt8(1)) redefineAll($DataViewPrototype, { + if (testView.getInt8(0) || !testView.getInt8(1)) defineBuiltIns(DataViewPrototype, { setInt8: function setInt8(byteOffset, value) { - $setInt8.call(this, byteOffset, value << 24 >> 24); + $setInt8(this, byteOffset, value << 24 >> 24); }, setUint8: function setUint8(byteOffset, value) { - $setInt8.call(this, byteOffset, value << 24 >> 24); + $setInt8(this, byteOffset, value << 24 >> 24); } }, { unsafe: true }); } @@ -12918,11 +12203,12 @@ module.exports = { DataView: $DataView }; -},{"../internals/an-instance":93,"../internals/array-buffer-native":95,"../internals/array-fill":99,"../internals/create-non-enumerable-property":120,"../internals/descriptors":125,"../internals/fails":140,"../internals/global":147,"../internals/ieee754":153,"../internals/internal-state":157,"../internals/object-define-property":179,"../internals/object-get-own-property-names":182,"../internals/object-get-prototype-of":184,"../internals/object-set-prototype-of":188,"../internals/redefine-all":196,"../internals/set-to-string-tag":208,"../internals/to-index":218,"../internals/to-integer":220,"../internals/to-length":221}],98:[function(require,module,exports){ +},{"../internals/an-instance":113,"../internals/array-buffer-basic-detection":115,"../internals/array-fill":120,"../internals/array-slice":131,"../internals/copy-constructor-properties":141,"../internals/create-non-enumerable-property":145,"../internals/define-built-in-accessor":148,"../internals/define-built-ins":150,"../internals/descriptors":153,"../internals/fails":171,"../internals/function-name":178,"../internals/function-uncurry-this":181,"../internals/global":188,"../internals/ieee754":194,"../internals/inherit-if-required":196,"../internals/internal-state":199,"../internals/math-fround":222,"../internals/object-get-prototype-of":236,"../internals/object-set-prototype-of":242,"../internals/set-to-string-tag":266,"../internals/to-index":281,"../internals/to-integer-or-infinity":283,"../internals/to-length":284}],119:[function(require,module,exports){ 'use strict'; var toObject = require('../internals/to-object'); var toAbsoluteIndex = require('../internals/to-absolute-index'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); +var deletePropertyOrThrow = require('../internals/delete-property-or-throw'); var min = Math.min; @@ -12931,7 +12217,7 @@ var min = Math.min; // eslint-disable-next-line es/no-array-prototype-copywithin -- safe module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) { var O = toObject(this); - var len = toLength(O.length); + var len = lengthOfArrayLike(O); var to = toAbsoluteIndex(target, len); var from = toAbsoluteIndex(start, len); var end = arguments.length > 2 ? arguments[2] : undefined; @@ -12944,23 +12230,23 @@ module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* } while (count-- > 0) { if (from in O) O[to] = O[from]; - else delete O[to]; + else deletePropertyOrThrow(O, to); to += inc; from += inc; } return O; }; -},{"../internals/to-absolute-index":217,"../internals/to-length":221,"../internals/to-object":222}],99:[function(require,module,exports){ +},{"../internals/delete-property-or-throw":152,"../internals/length-of-array-like":219,"../internals/to-absolute-index":279,"../internals/to-object":285}],120:[function(require,module,exports){ 'use strict'; var toObject = require('../internals/to-object'); var toAbsoluteIndex = require('../internals/to-absolute-index'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); // `Array.prototype.fill` method implementation // https://tc39.es/ecma262/#sec-array.prototype.fill module.exports = function fill(value /* , start = 0, end = @length */) { var O = toObject(this); - var length = toLength(O.length); + var length = lengthOfArrayLike(O); var argumentsLength = arguments.length; var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length); var end = argumentsLength > 2 ? arguments[2] : undefined; @@ -12969,7 +12255,7 @@ module.exports = function fill(value /* , start = 0, end = @length */) { return O; }; -},{"../internals/to-absolute-index":217,"../internals/to-length":221,"../internals/to-object":222}],100:[function(require,module,exports){ +},{"../internals/length-of-array-like":219,"../internals/to-absolute-index":279,"../internals/to-object":285}],121:[function(require,module,exports){ 'use strict'; var $forEach = require('../internals/array-iteration').forEach; var arrayMethodIsStrict = require('../internals/array-method-is-strict'); @@ -12983,50 +12269,57 @@ module.exports = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) { // eslint-disable-next-line es/no-array-prototype-foreach -- safe } : [].forEach; -},{"../internals/array-iteration":104,"../internals/array-method-is-strict":107}],101:[function(require,module,exports){ -module.exports = function (Constructor, list) { +},{"../internals/array-iteration":125,"../internals/array-method-is-strict":128}],122:[function(require,module,exports){ +'use strict'; +var lengthOfArrayLike = require('../internals/length-of-array-like'); + +module.exports = function (Constructor, list, $length) { var index = 0; - var length = list.length; + var length = arguments.length > 2 ? $length : lengthOfArrayLike(list); var result = new Constructor(length); while (length > index) result[index] = list[index++]; return result; }; -},{}],102:[function(require,module,exports){ +},{"../internals/length-of-array-like":219}],123:[function(require,module,exports){ 'use strict'; var bind = require('../internals/function-bind-context'); +var call = require('../internals/function-call'); var toObject = require('../internals/to-object'); var callWithSafeIterationClosing = require('../internals/call-with-safe-iteration-closing'); var isArrayIteratorMethod = require('../internals/is-array-iterator-method'); -var toLength = require('../internals/to-length'); +var isConstructor = require('../internals/is-constructor'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); var createProperty = require('../internals/create-property'); var getIterator = require('../internals/get-iterator'); var getIteratorMethod = require('../internals/get-iterator-method'); +var $Array = Array; + // `Array.from` method implementation // https://tc39.es/ecma262/#sec-array.from module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { var O = toObject(arrayLike); - var C = typeof this == 'function' ? this : Array; + var IS_CONSTRUCTOR = isConstructor(this); var argumentsLength = arguments.length; var mapfn = argumentsLength > 1 ? arguments[1] : undefined; var mapping = mapfn !== undefined; + if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined); var iteratorMethod = getIteratorMethod(O); var index = 0; var length, result, step, iterator, next, value; - if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2); // if the target is not iterable or it's an array with the default iterator - use a simple case - if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) { + if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) { iterator = getIterator(O, iteratorMethod); next = iterator.next; - result = new C(); - for (;!(step = next.call(iterator)).done; index++) { + result = IS_CONSTRUCTOR ? new this() : []; + for (;!(step = call(next, iterator)).done; index++) { value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value; createProperty(result, index, value); } } else { - length = toLength(O.length); - result = new C(length); + length = lengthOfArrayLike(O); + result = IS_CONSTRUCTOR ? new this(length) : $Array(length); for (;length > index; index++) { value = mapping ? mapfn(O[index], index) : O[index]; createProperty(result, index, value); @@ -13036,24 +12329,25 @@ module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undef return result; }; -},{"../internals/call-with-safe-iteration-closing":112,"../internals/create-property":122,"../internals/function-bind-context":142,"../internals/get-iterator":145,"../internals/get-iterator-method":144,"../internals/is-array-iterator-method":158,"../internals/to-length":221,"../internals/to-object":222}],103:[function(require,module,exports){ +},{"../internals/call-with-safe-iteration-closing":135,"../internals/create-property":147,"../internals/function-bind-context":175,"../internals/function-call":177,"../internals/get-iterator":184,"../internals/get-iterator-method":183,"../internals/is-array-iterator-method":200,"../internals/is-constructor":204,"../internals/length-of-array-like":219,"../internals/to-object":285}],124:[function(require,module,exports){ +'use strict'; var toIndexedObject = require('../internals/to-indexed-object'); -var toLength = require('../internals/to-length'); var toAbsoluteIndex = require('../internals/to-absolute-index'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); // `Array.prototype.{ indexOf, includes }` methods implementation var createMethod = function (IS_INCLUDES) { return function ($this, el, fromIndex) { var O = toIndexedObject($this); - var length = toLength(O.length); + var length = lengthOfArrayLike(O); var index = toAbsoluteIndex(fromIndex, length); var value; // Array#includes uses SameValueZero equality algorithm // eslint-disable-next-line no-self-compare -- NaN check - if (IS_INCLUDES && el != el) while (length > index) { + if (IS_INCLUDES && el !== el) while (length > index) { value = O[index++]; // eslint-disable-next-line no-self-compare -- NaN check - if (value != value) return true; + if (value !== value) return true; // Array#indexOf ignores holes, Array#includes - not } else for (;length > index; index++) { if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; @@ -13070,29 +12364,31 @@ module.exports = { indexOf: createMethod(false) }; -},{"../internals/to-absolute-index":217,"../internals/to-indexed-object":219,"../internals/to-length":221}],104:[function(require,module,exports){ +},{"../internals/length-of-array-like":219,"../internals/to-absolute-index":279,"../internals/to-indexed-object":282}],125:[function(require,module,exports){ +'use strict'; var bind = require('../internals/function-bind-context'); +var uncurryThis = require('../internals/function-uncurry-this'); var IndexedObject = require('../internals/indexed-object'); var toObject = require('../internals/to-object'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); var arraySpeciesCreate = require('../internals/array-species-create'); -var push = [].push; +var push = uncurryThis([].push); // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation var createMethod = function (TYPE) { - var IS_MAP = TYPE == 1; - var IS_FILTER = TYPE == 2; - var IS_SOME = TYPE == 3; - var IS_EVERY = TYPE == 4; - var IS_FIND_INDEX = TYPE == 6; - var IS_FILTER_REJECT = TYPE == 7; - var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; + var IS_MAP = TYPE === 1; + var IS_FILTER = TYPE === 2; + var IS_SOME = TYPE === 3; + var IS_EVERY = TYPE === 4; + var IS_FIND_INDEX = TYPE === 6; + var IS_FILTER_REJECT = TYPE === 7; + var NO_HOLES = TYPE === 5 || IS_FIND_INDEX; return function ($this, callbackfn, that, specificCreate) { var O = toObject($this); var self = IndexedObject(O); - var boundFunction = bind(callbackfn, that, 3); - var length = toLength(self.length); + var length = lengthOfArrayLike(self); + var boundFunction = bind(callbackfn, that); var index = 0; var create = specificCreate || arraySpeciesCreate; var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; @@ -13106,10 +12402,10 @@ var createMethod = function (TYPE) { case 3: return true; // some case 5: return value; // find case 6: return index; // findIndex - case 2: push.call(target, value); // filter + case 2: push(target, value); // filter } else switch (TYPE) { case 4: return false; // every - case 7: push.call(target, value); // filterReject + case 7: push(target, value); // filterReject } } } @@ -13144,12 +12440,13 @@ module.exports = { filterReject: createMethod(7) }; -},{"../internals/array-species-create":111,"../internals/function-bind-context":142,"../internals/indexed-object":154,"../internals/to-length":221,"../internals/to-object":222}],105:[function(require,module,exports){ +},{"../internals/array-species-create":134,"../internals/function-bind-context":175,"../internals/function-uncurry-this":181,"../internals/indexed-object":195,"../internals/length-of-array-like":219,"../internals/to-object":285}],126:[function(require,module,exports){ 'use strict'; /* eslint-disable es/no-array-prototype-lastindexof -- safe */ +var apply = require('../internals/function-apply'); var toIndexedObject = require('../internals/to-indexed-object'); -var toInteger = require('../internals/to-integer'); -var toLength = require('../internals/to-length'); +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); var arrayMethodIsStrict = require('../internals/array-method-is-strict'); var min = Math.min; @@ -13162,17 +12459,18 @@ var FORCED = NEGATIVE_ZERO || !STRICT_METHOD; // https://tc39.es/ecma262/#sec-array.prototype.lastindexof module.exports = FORCED ? function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) { // convert -0 to +0 - if (NEGATIVE_ZERO) return $lastIndexOf.apply(this, arguments) || 0; + if (NEGATIVE_ZERO) return apply($lastIndexOf, this, arguments) || 0; var O = toIndexedObject(this); - var length = toLength(O.length); + var length = lengthOfArrayLike(O); var index = length - 1; - if (arguments.length > 1) index = min(index, toInteger(arguments[1])); + if (arguments.length > 1) index = min(index, toIntegerOrInfinity(arguments[1])); if (index < 0) index = length + index; for (;index >= 0; index--) if (index in O && O[index] === searchElement) return index || 0; return -1; } : $lastIndexOf; -},{"../internals/array-method-is-strict":107,"../internals/to-indexed-object":219,"../internals/to-integer":220,"../internals/to-length":221}],106:[function(require,module,exports){ +},{"../internals/array-method-is-strict":128,"../internals/function-apply":174,"../internals/length-of-array-like":219,"../internals/to-indexed-object":282,"../internals/to-integer-or-infinity":283}],127:[function(require,module,exports){ +'use strict'; var fails = require('../internals/fails'); var wellKnownSymbol = require('../internals/well-known-symbol'); var V8_VERSION = require('../internals/engine-v8-version'); @@ -13193,31 +12491,34 @@ module.exports = function (METHOD_NAME) { }); }; -},{"../internals/engine-v8-version":136,"../internals/fails":140,"../internals/well-known-symbol":237}],107:[function(require,module,exports){ +},{"../internals/engine-v8-version":167,"../internals/fails":171,"../internals/well-known-symbol":306}],128:[function(require,module,exports){ 'use strict'; var fails = require('../internals/fails'); module.exports = function (METHOD_NAME, argument) { var method = [][METHOD_NAME]; return !!method && fails(function () { - // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing - method.call(null, argument || function () { throw 1; }, 1); + // eslint-disable-next-line no-useless-call -- required for testing + method.call(null, argument || function () { return 1; }, 1); }); }; -},{"../internals/fails":140}],108:[function(require,module,exports){ -var aFunction = require('../internals/a-function'); +},{"../internals/fails":171}],129:[function(require,module,exports){ +'use strict'; +var aCallable = require('../internals/a-callable'); var toObject = require('../internals/to-object'); var IndexedObject = require('../internals/indexed-object'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); + +var $TypeError = TypeError; // `Array.prototype.{ reduce, reduceRight }` methods implementation var createMethod = function (IS_RIGHT) { return function (that, callbackfn, argumentsLength, memo) { - aFunction(callbackfn); var O = toObject(that); var self = IndexedObject(O); - var length = toLength(O.length); + var length = lengthOfArrayLike(O); + aCallable(callbackfn); var index = IS_RIGHT ? length - 1 : 0; var i = IS_RIGHT ? -1 : 1; if (argumentsLength < 2) while (true) { @@ -13228,7 +12529,7 @@ var createMethod = function (IS_RIGHT) { } index += i; if (IS_RIGHT ? index < 0 : length <= index) { - throw TypeError('Reduce of empty array with no initial value'); + throw new $TypeError('Reduce of empty array with no initial value'); } } for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) { @@ -13247,59 +12548,94 @@ module.exports = { right: createMethod(true) }; -},{"../internals/a-function":89,"../internals/indexed-object":154,"../internals/to-length":221,"../internals/to-object":222}],109:[function(require,module,exports){ -// TODO: use something more complex like timsort? -var floor = Math.floor; +},{"../internals/a-callable":108,"../internals/indexed-object":195,"../internals/length-of-array-like":219,"../internals/to-object":285}],130:[function(require,module,exports){ +'use strict'; +var DESCRIPTORS = require('../internals/descriptors'); +var isArray = require('../internals/is-array'); -var mergeSort = function (array, comparefn) { - var length = array.length; - var middle = floor(length / 2); - return length < 8 ? insertionSort(array, comparefn) : merge( - mergeSort(array.slice(0, middle), comparefn), - mergeSort(array.slice(middle), comparefn), - comparefn - ); +var $TypeError = TypeError; +// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe +var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + +// Safari < 13 does not throw an error in this case +var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () { + // makes no sense without proper strict mode support + if (this !== undefined) return true; + try { + // eslint-disable-next-line es/no-object-defineproperty -- safe + Object.defineProperty([], 'length', { writable: false }).length = 1; + } catch (error) { + return error instanceof TypeError; + } +}(); + +module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) { + if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) { + throw new $TypeError('Cannot set read only .length'); + } return O.length = length; +} : function (O, length) { + return O.length = length; }; -var insertionSort = function (array, comparefn) { +},{"../internals/descriptors":153,"../internals/is-array":201}],131:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); + +module.exports = uncurryThis([].slice); + +},{"../internals/function-uncurry-this":181}],132:[function(require,module,exports){ +'use strict'; +var arraySlice = require('../internals/array-slice'); + +var floor = Math.floor; + +var sort = function (array, comparefn) { var length = array.length; - var i = 1; - var element, j; - while (i < length) { - j = i; - element = array[i]; - while (j && comparefn(array[j - 1], element) > 0) { - array[j] = array[--j]; - } - if (j !== i++) array[j] = element; - } return array; -}; + if (length < 8) { + // insertion sort + var i = 1; + var element, j; -var merge = function (left, right, comparefn) { - var llength = left.length; - var rlength = right.length; - var lindex = 0; - var rindex = 0; - var result = []; + while (i < length) { + j = i; + element = array[i]; + while (j && comparefn(array[j - 1], element) > 0) { + array[j] = array[--j]; + } + if (j !== i++) array[j] = element; + } + } else { + // merge sort + var middle = floor(length / 2); + var left = sort(arraySlice(array, 0, middle), comparefn); + var right = sort(arraySlice(array, middle), comparefn); + var llength = left.length; + var rlength = right.length; + var lindex = 0; + var rindex = 0; - while (lindex < llength || rindex < rlength) { - if (lindex < llength && rindex < rlength) { - result.push(comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]); - } else { - result.push(lindex < llength ? left[lindex++] : right[rindex++]); + while (lindex < llength || rindex < rlength) { + array[lindex + rindex] = (lindex < llength && rindex < rlength) + ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] + : lindex < llength ? left[lindex++] : right[rindex++]; } - } return result; + } + + return array; }; -module.exports = mergeSort; +module.exports = sort; -},{}],110:[function(require,module,exports){ -var isObject = require('../internals/is-object'); +},{"../internals/array-slice":131}],133:[function(require,module,exports){ +'use strict'; var isArray = require('../internals/is-array'); +var isConstructor = require('../internals/is-constructor'); +var isObject = require('../internals/is-object'); var wellKnownSymbol = require('../internals/well-known-symbol'); var SPECIES = wellKnownSymbol('species'); +var $Array = Array; // a part of `ArraySpeciesCreate` abstract operation // https://tc39.es/ecma262/#sec-arrayspeciescreate @@ -13308,15 +12644,16 @@ module.exports = function (originalArray) { if (isArray(originalArray)) { C = originalArray.constructor; // cross-realm fallback - if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; + if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined; else if (isObject(C)) { C = C[SPECIES]; if (C === null) C = undefined; } - } return C === undefined ? Array : C; + } return C === undefined ? $Array : C; }; -},{"../internals/is-array":159,"../internals/is-object":162,"../internals/well-known-symbol":237}],111:[function(require,module,exports){ +},{"../internals/is-array":201,"../internals/is-constructor":204,"../internals/is-object":208,"../internals/well-known-symbol":306}],134:[function(require,module,exports){ +'use strict'; var arraySpeciesConstructor = require('../internals/array-species-constructor'); // `ArraySpeciesCreate` abstract operation @@ -13325,7 +12662,8 @@ module.exports = function (originalArray, length) { return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); }; -},{"../internals/array-species-constructor":110}],112:[function(require,module,exports){ +},{"../internals/array-species-constructor":133}],135:[function(require,module,exports){ +'use strict'; var anObject = require('../internals/an-object'); var iteratorClose = require('../internals/iterator-close'); @@ -13338,7 +12676,8 @@ module.exports = function (iterator, fn, value, ENTRIES) { } }; -},{"../internals/an-object":94,"../internals/iterator-close":167}],113:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/iterator-close":214}],136:[function(require,module,exports){ +'use strict'; var wellKnownSymbol = require('../internals/well-known-symbol'); var ITERATOR = wellKnownSymbol('iterator'); @@ -13362,7 +12701,9 @@ try { } catch (error) { /* empty */ } module.exports = function (exec, SKIP_CLOSING) { - if (!SKIP_CLOSING && !SAFE_CLOSING) return false; + try { + if (!SKIP_CLOSING && !SAFE_CLOSING) return false; + } catch (error) { return false; } // workaround of old WebKit + `eval` bug var ITERATION_SUPPORT = false; try { var object = {}; @@ -13378,21 +12719,29 @@ module.exports = function (exec, SKIP_CLOSING) { return ITERATION_SUPPORT; }; -},{"../internals/well-known-symbol":237}],114:[function(require,module,exports){ -var toString = {}.toString; +},{"../internals/well-known-symbol":306}],137:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); + +var toString = uncurryThis({}.toString); +var stringSlice = uncurryThis(''.slice); module.exports = function (it) { - return toString.call(it).slice(8, -1); + return stringSlice(toString(it), 8, -1); }; -},{}],115:[function(require,module,exports){ +},{"../internals/function-uncurry-this":181}],138:[function(require,module,exports){ +'use strict'; var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support'); +var isCallable = require('../internals/is-callable'); var classofRaw = require('../internals/classof-raw'); var wellKnownSymbol = require('../internals/well-known-symbol'); var TO_STRING_TAG = wellKnownSymbol('toStringTag'); +var $Object = Object; + // ES3 wrong here -var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; +var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments'; // fallback for IE11 Script Access Denied error var tryGet = function (it, key) { @@ -13406,30 +12755,350 @@ module.exports = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) { var O, tag, result; return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case - : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag + : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag // builtinTag case : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback - : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result; + : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result; +}; + +},{"../internals/classof-raw":137,"../internals/is-callable":203,"../internals/to-string-tag-support":290,"../internals/well-known-symbol":306}],139:[function(require,module,exports){ +'use strict'; +var create = require('../internals/object-create'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); +var defineBuiltIns = require('../internals/define-built-ins'); +var bind = require('../internals/function-bind-context'); +var anInstance = require('../internals/an-instance'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); +var iterate = require('../internals/iterate'); +var defineIterator = require('../internals/iterator-define'); +var createIterResultObject = require('../internals/create-iter-result-object'); +var setSpecies = require('../internals/set-species'); +var DESCRIPTORS = require('../internals/descriptors'); +var fastKey = require('../internals/internal-metadata').fastKey; +var InternalStateModule = require('../internals/internal-state'); + +var setInternalState = InternalStateModule.set; +var internalStateGetterFor = InternalStateModule.getterFor; + +module.exports = { + getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) { + var Constructor = wrapper(function (that, iterable) { + anInstance(that, Prototype); + setInternalState(that, { + type: CONSTRUCTOR_NAME, + index: create(null), + first: undefined, + last: undefined, + size: 0 + }); + if (!DESCRIPTORS) that.size = 0; + if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); + }); + + var Prototype = Constructor.prototype; + + var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME); + + var define = function (that, key, value) { + var state = getInternalState(that); + var entry = getEntry(that, key); + var previous, index; + // change existing entry + if (entry) { + entry.value = value; + // create new entry + } else { + state.last = entry = { + index: index = fastKey(key, true), + key: key, + value: value, + previous: previous = state.last, + next: undefined, + removed: false + }; + if (!state.first) state.first = entry; + if (previous) previous.next = entry; + if (DESCRIPTORS) state.size++; + else that.size++; + // add to index + if (index !== 'F') state.index[index] = entry; + } return that; + }; + + var getEntry = function (that, key) { + var state = getInternalState(that); + // fast case + var index = fastKey(key); + var entry; + if (index !== 'F') return state.index[index]; + // frozen object case + for (entry = state.first; entry; entry = entry.next) { + if (entry.key === key) return entry; + } + }; + + defineBuiltIns(Prototype, { + // `{ Map, Set }.prototype.clear()` methods + // https://tc39.es/ecma262/#sec-map.prototype.clear + // https://tc39.es/ecma262/#sec-set.prototype.clear + clear: function clear() { + var that = this; + var state = getInternalState(that); + var entry = state.first; + while (entry) { + entry.removed = true; + if (entry.previous) entry.previous = entry.previous.next = undefined; + entry = entry.next; + } + state.first = state.last = undefined; + state.index = create(null); + if (DESCRIPTORS) state.size = 0; + else that.size = 0; + }, + // `{ Map, Set }.prototype.delete(key)` methods + // https://tc39.es/ecma262/#sec-map.prototype.delete + // https://tc39.es/ecma262/#sec-set.prototype.delete + 'delete': function (key) { + var that = this; + var state = getInternalState(that); + var entry = getEntry(that, key); + if (entry) { + var next = entry.next; + var prev = entry.previous; + delete state.index[entry.index]; + entry.removed = true; + if (prev) prev.next = next; + if (next) next.previous = prev; + if (state.first === entry) state.first = next; + if (state.last === entry) state.last = prev; + if (DESCRIPTORS) state.size--; + else that.size--; + } return !!entry; + }, + // `{ Map, Set }.prototype.forEach(callbackfn, thisArg = undefined)` methods + // https://tc39.es/ecma262/#sec-map.prototype.foreach + // https://tc39.es/ecma262/#sec-set.prototype.foreach + forEach: function forEach(callbackfn /* , that = undefined */) { + var state = getInternalState(this); + var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined); + var entry; + while (entry = entry ? entry.next : state.first) { + boundFunction(entry.value, entry.key, this); + // revert to the last existing entry + while (entry && entry.removed) entry = entry.previous; + } + }, + // `{ Map, Set}.prototype.has(key)` methods + // https://tc39.es/ecma262/#sec-map.prototype.has + // https://tc39.es/ecma262/#sec-set.prototype.has + has: function has(key) { + return !!getEntry(this, key); + } + }); + + defineBuiltIns(Prototype, IS_MAP ? { + // `Map.prototype.get(key)` method + // https://tc39.es/ecma262/#sec-map.prototype.get + get: function get(key) { + var entry = getEntry(this, key); + return entry && entry.value; + }, + // `Map.prototype.set(key, value)` method + // https://tc39.es/ecma262/#sec-map.prototype.set + set: function set(key, value) { + return define(this, key === 0 ? 0 : key, value); + } + } : { + // `Set.prototype.add(value)` method + // https://tc39.es/ecma262/#sec-set.prototype.add + add: function add(value) { + return define(this, value = value === 0 ? 0 : value, value); + } + }); + if (DESCRIPTORS) defineBuiltInAccessor(Prototype, 'size', { + configurable: true, + get: function () { + return getInternalState(this).size; + } + }); + return Constructor; + }, + setStrong: function (Constructor, CONSTRUCTOR_NAME, IS_MAP) { + var ITERATOR_NAME = CONSTRUCTOR_NAME + ' Iterator'; + var getInternalCollectionState = internalStateGetterFor(CONSTRUCTOR_NAME); + var getInternalIteratorState = internalStateGetterFor(ITERATOR_NAME); + // `{ Map, Set }.prototype.{ keys, values, entries, @@iterator }()` methods + // https://tc39.es/ecma262/#sec-map.prototype.entries + // https://tc39.es/ecma262/#sec-map.prototype.keys + // https://tc39.es/ecma262/#sec-map.prototype.values + // https://tc39.es/ecma262/#sec-map.prototype-@@iterator + // https://tc39.es/ecma262/#sec-set.prototype.entries + // https://tc39.es/ecma262/#sec-set.prototype.keys + // https://tc39.es/ecma262/#sec-set.prototype.values + // https://tc39.es/ecma262/#sec-set.prototype-@@iterator + defineIterator(Constructor, CONSTRUCTOR_NAME, function (iterated, kind) { + setInternalState(this, { + type: ITERATOR_NAME, + target: iterated, + state: getInternalCollectionState(iterated), + kind: kind, + last: undefined + }); + }, function () { + var state = getInternalIteratorState(this); + var kind = state.kind; + var entry = state.last; + // revert to the last existing entry + while (entry && entry.removed) entry = entry.previous; + // get next entry + if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) { + // or finish the iteration + state.target = undefined; + return createIterResultObject(undefined, true); + } + // return step by kind + if (kind === 'keys') return createIterResultObject(entry.key, false); + if (kind === 'values') return createIterResultObject(entry.value, false); + return createIterResultObject([entry.key, entry.value], false); + }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); + + // `{ Map, Set }.prototype[@@species]` accessors + // https://tc39.es/ecma262/#sec-get-map-@@species + // https://tc39.es/ecma262/#sec-get-set-@@species + setSpecies(CONSTRUCTOR_NAME); + } +}; + +},{"../internals/an-instance":113,"../internals/create-iter-result-object":144,"../internals/define-built-in-accessor":148,"../internals/define-built-ins":150,"../internals/descriptors":153,"../internals/function-bind-context":175,"../internals/internal-metadata":198,"../internals/internal-state":199,"../internals/is-null-or-undefined":207,"../internals/iterate":213,"../internals/iterator-define":216,"../internals/object-create":229,"../internals/set-species":265}],140:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var global = require('../internals/global'); +var uncurryThis = require('../internals/function-uncurry-this'); +var isForced = require('../internals/is-forced'); +var defineBuiltIn = require('../internals/define-built-in'); +var InternalMetadataModule = require('../internals/internal-metadata'); +var iterate = require('../internals/iterate'); +var anInstance = require('../internals/an-instance'); +var isCallable = require('../internals/is-callable'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); +var isObject = require('../internals/is-object'); +var fails = require('../internals/fails'); +var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration'); +var setToStringTag = require('../internals/set-to-string-tag'); +var inheritIfRequired = require('../internals/inherit-if-required'); + +module.exports = function (CONSTRUCTOR_NAME, wrapper, common) { + var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1; + var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1; + var ADDER = IS_MAP ? 'set' : 'add'; + var NativeConstructor = global[CONSTRUCTOR_NAME]; + var NativePrototype = NativeConstructor && NativeConstructor.prototype; + var Constructor = NativeConstructor; + var exported = {}; + + var fixMethod = function (KEY) { + var uncurriedNativeMethod = uncurryThis(NativePrototype[KEY]); + defineBuiltIn(NativePrototype, KEY, + KEY === 'add' ? function add(value) { + uncurriedNativeMethod(this, value === 0 ? 0 : value); + return this; + } : KEY === 'delete' ? function (key) { + return IS_WEAK && !isObject(key) ? false : uncurriedNativeMethod(this, key === 0 ? 0 : key); + } : KEY === 'get' ? function get(key) { + return IS_WEAK && !isObject(key) ? undefined : uncurriedNativeMethod(this, key === 0 ? 0 : key); + } : KEY === 'has' ? function has(key) { + return IS_WEAK && !isObject(key) ? false : uncurriedNativeMethod(this, key === 0 ? 0 : key); + } : function set(key, value) { + uncurriedNativeMethod(this, key === 0 ? 0 : key, value); + return this; + } + ); + }; + + var REPLACE = isForced( + CONSTRUCTOR_NAME, + !isCallable(NativeConstructor) || !(IS_WEAK || NativePrototype.forEach && !fails(function () { + new NativeConstructor().entries().next(); + })) + ); + + if (REPLACE) { + // create collection constructor + Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER); + InternalMetadataModule.enable(); + } else if (isForced(CONSTRUCTOR_NAME, true)) { + var instance = new Constructor(); + // early implementations not supports chaining + var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) !== instance; + // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false + var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); }); + // most early implementations doesn't supports iterables, most modern - not close it correctly + // eslint-disable-next-line no-new -- required for testing + var ACCEPT_ITERABLES = checkCorrectnessOfIteration(function (iterable) { new NativeConstructor(iterable); }); + // for early implementations -0 and +0 not the same + var BUGGY_ZERO = !IS_WEAK && fails(function () { + // V8 ~ Chromium 42- fails only with 5+ elements + var $instance = new NativeConstructor(); + var index = 5; + while (index--) $instance[ADDER](index, index); + return !$instance.has(-0); + }); + + if (!ACCEPT_ITERABLES) { + Constructor = wrapper(function (dummy, iterable) { + anInstance(dummy, NativePrototype); + var that = inheritIfRequired(new NativeConstructor(), dummy, Constructor); + if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP }); + return that; + }); + Constructor.prototype = NativePrototype; + NativePrototype.constructor = Constructor; + } + + if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { + fixMethod('delete'); + fixMethod('has'); + IS_MAP && fixMethod('get'); + } + + if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); + + // weak collections should not contains .clear method + if (IS_WEAK && NativePrototype.clear) delete NativePrototype.clear; + } + + exported[CONSTRUCTOR_NAME] = Constructor; + $({ global: true, constructor: true, forced: Constructor !== NativeConstructor }, exported); + + setToStringTag(Constructor, CONSTRUCTOR_NAME); + + if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP); + + return Constructor; }; -},{"../internals/classof-raw":114,"../internals/to-string-tag-support":227,"../internals/well-known-symbol":237}],116:[function(require,module,exports){ -var has = require('../internals/has'); +},{"../internals/an-instance":113,"../internals/check-correctness-of-iteration":136,"../internals/define-built-in":149,"../internals/export":170,"../internals/fails":171,"../internals/function-uncurry-this":181,"../internals/global":188,"../internals/inherit-if-required":196,"../internals/internal-metadata":198,"../internals/is-callable":203,"../internals/is-forced":205,"../internals/is-null-or-undefined":207,"../internals/is-object":208,"../internals/iterate":213,"../internals/set-to-string-tag":266}],141:[function(require,module,exports){ +'use strict'; +var hasOwn = require('../internals/has-own-property'); var ownKeys = require('../internals/own-keys'); var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor'); var definePropertyModule = require('../internals/object-define-property'); -module.exports = function (target, source) { +module.exports = function (target, source, exceptions) { var keys = ownKeys(source); var defineProperty = definePropertyModule.f; var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; for (var i = 0; i < keys.length; i++) { var key = keys[i]; - if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key)); + if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) { + defineProperty(target, key, getOwnPropertyDescriptor(source, key)); + } } }; -},{"../internals/has":148,"../internals/object-define-property":179,"../internals/object-get-own-property-descriptor":180,"../internals/own-keys":192}],117:[function(require,module,exports){ +},{"../internals/has-own-property":189,"../internals/object-define-property":231,"../internals/object-get-own-property-descriptor":232,"../internals/own-keys":246}],142:[function(require,module,exports){ +'use strict'; var wellKnownSymbol = require('../internals/well-known-symbol'); var MATCH = wellKnownSymbol('match'); @@ -13446,7 +13115,8 @@ module.exports = function (METHOD_NAME) { } return false; }; -},{"../internals/well-known-symbol":237}],118:[function(require,module,exports){ +},{"../internals/well-known-symbol":306}],143:[function(require,module,exports){ +'use strict'; var fails = require('../internals/fails'); module.exports = !fails(function () { @@ -13456,25 +13126,16 @@ module.exports = !fails(function () { return Object.getPrototypeOf(new F()) !== F.prototype; }); -},{"../internals/fails":140}],119:[function(require,module,exports){ +},{"../internals/fails":171}],144:[function(require,module,exports){ 'use strict'; -var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype; -var create = require('../internals/object-create'); -var createPropertyDescriptor = require('../internals/create-property-descriptor'); -var setToStringTag = require('../internals/set-to-string-tag'); -var Iterators = require('../internals/iterators'); - -var returnThis = function () { return this; }; - -module.exports = function (IteratorConstructor, NAME, next) { - var TO_STRING_TAG = NAME + ' Iterator'; - IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(1, next) }); - setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); - Iterators[TO_STRING_TAG] = returnThis; - return IteratorConstructor; +// `CreateIterResultObject` abstract operation +// https://tc39.es/ecma262/#sec-createiterresultobject +module.exports = function (value, done) { + return { value: value, done: done }; }; -},{"../internals/create-property-descriptor":121,"../internals/iterators":169,"../internals/iterators-core":168,"../internals/object-create":177,"../internals/set-to-string-tag":208}],120:[function(require,module,exports){ +},{}],145:[function(require,module,exports){ +'use strict'; var DESCRIPTORS = require('../internals/descriptors'); var definePropertyModule = require('../internals/object-define-property'); var createPropertyDescriptor = require('../internals/create-property-descriptor'); @@ -13486,7 +13147,8 @@ module.exports = DESCRIPTORS ? function (object, key, value) { return object; }; -},{"../internals/create-property-descriptor":121,"../internals/descriptors":125,"../internals/object-define-property":179}],121:[function(require,module,exports){ +},{"../internals/create-property-descriptor":146,"../internals/descriptors":153,"../internals/object-define-property":231}],146:[function(require,module,exports){ +'use strict'; module.exports = function (bitmap, value) { return { enumerable: !(bitmap & 1), @@ -13496,7 +13158,7 @@ module.exports = function (bitmap, value) { }; }; -},{}],122:[function(require,module,exports){ +},{}],147:[function(require,module,exports){ 'use strict'; var toPropertyKey = require('../internals/to-property-key'); var definePropertyModule = require('../internals/object-define-property'); @@ -13508,121 +13170,93 @@ module.exports = function (object, key, value) { else object[propertyKey] = value; }; -},{"../internals/create-property-descriptor":121,"../internals/object-define-property":179,"../internals/to-property-key":226}],123:[function(require,module,exports){ +},{"../internals/create-property-descriptor":146,"../internals/object-define-property":231,"../internals/to-property-key":289}],148:[function(require,module,exports){ 'use strict'; -var $ = require('../internals/export'); -var createIteratorConstructor = require('../internals/create-iterator-constructor'); -var getPrototypeOf = require('../internals/object-get-prototype-of'); -var setPrototypeOf = require('../internals/object-set-prototype-of'); -var setToStringTag = require('../internals/set-to-string-tag'); -var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var redefine = require('../internals/redefine'); -var wellKnownSymbol = require('../internals/well-known-symbol'); -var IS_PURE = require('../internals/is-pure'); -var Iterators = require('../internals/iterators'); -var IteratorsCore = require('../internals/iterators-core'); +var makeBuiltIn = require('../internals/make-built-in'); +var defineProperty = require('../internals/object-define-property'); -var IteratorPrototype = IteratorsCore.IteratorPrototype; -var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS; -var ITERATOR = wellKnownSymbol('iterator'); -var KEYS = 'keys'; -var VALUES = 'values'; -var ENTRIES = 'entries'; +module.exports = function (target, name, descriptor) { + if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true }); + if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true }); + return defineProperty.f(target, name, descriptor); +}; -var returnThis = function () { return this; }; +},{"../internals/make-built-in":220,"../internals/object-define-property":231}],149:[function(require,module,exports){ +'use strict'; +var isCallable = require('../internals/is-callable'); +var definePropertyModule = require('../internals/object-define-property'); +var makeBuiltIn = require('../internals/make-built-in'); +var defineGlobalProperty = require('../internals/define-global-property'); + +module.exports = function (O, key, value, options) { + if (!options) options = {}; + var simple = options.enumerable; + var name = options.name !== undefined ? options.name : key; + if (isCallable(value)) makeBuiltIn(value, name, options); + if (options.global) { + if (simple) O[key] = value; + else defineGlobalProperty(key, value); + } else { + try { + if (!options.unsafe) delete O[key]; + else if (O[key]) simple = true; + } catch (error) { /* empty */ } + if (simple) O[key] = value; + else definePropertyModule.f(O, key, { + value: value, + enumerable: false, + configurable: !options.nonConfigurable, + writable: !options.nonWritable + }); + } return O; +}; -module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { - createIteratorConstructor(IteratorConstructor, NAME, next); +},{"../internals/define-global-property":151,"../internals/is-callable":203,"../internals/make-built-in":220,"../internals/object-define-property":231}],150:[function(require,module,exports){ +'use strict'; +var defineBuiltIn = require('../internals/define-built-in'); - var getIterationMethod = function (KIND) { - if (KIND === DEFAULT && defaultIterator) return defaultIterator; - if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND]; - switch (KIND) { - case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; - case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; - case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; - } return function () { return new IteratorConstructor(this); }; - }; +module.exports = function (target, src, options) { + for (var key in src) defineBuiltIn(target, key, src[key], options); + return target; +}; - var TO_STRING_TAG = NAME + ' Iterator'; - var INCORRECT_VALUES_NAME = false; - var IterablePrototype = Iterable.prototype; - var nativeIterator = IterablePrototype[ITERATOR] - || IterablePrototype['@@iterator'] - || DEFAULT && IterablePrototype[DEFAULT]; - var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); - var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; - var CurrentIteratorPrototype, methods, KEY; +},{"../internals/define-built-in":149}],151:[function(require,module,exports){ +'use strict'; +var global = require('../internals/global'); - // fix native - if (anyNativeIterator) { - CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable())); - if (IteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { - if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) { - if (setPrototypeOf) { - setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype); - } else if (typeof CurrentIteratorPrototype[ITERATOR] != 'function') { - createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR, returnThis); - } - } - // Set @@toStringTag to native iterators - setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); - if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis; - } - } +// eslint-disable-next-line es/no-object-defineproperty -- safe +var defineProperty = Object.defineProperty; - // fix Array.prototype.{ values, @@iterator }.name in V8 / FF - if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { - INCORRECT_VALUES_NAME = true; - defaultIterator = function values() { return nativeIterator.call(this); }; - } +module.exports = function (key, value) { + try { + defineProperty(global, key, { value: value, configurable: true, writable: true }); + } catch (error) { + global[key] = value; + } return value; +}; - // define iterator - if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) { - createNonEnumerableProperty(IterablePrototype, ITERATOR, defaultIterator); - } - Iterators[NAME] = defaultIterator; +},{"../internals/global":188}],152:[function(require,module,exports){ +'use strict'; +var tryToString = require('../internals/try-to-string'); - // export additional methods - if (DEFAULT) { - methods = { - values: getIterationMethod(VALUES), - keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), - entries: getIterationMethod(ENTRIES) - }; - if (FORCED) for (KEY in methods) { - if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { - redefine(IterablePrototype, KEY, methods[KEY]); - } - } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); - } +var $TypeError = TypeError; - return methods; +module.exports = function (O, P) { + if (!delete O[P]) throw new $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O)); }; -},{"../internals/create-iterator-constructor":119,"../internals/create-non-enumerable-property":120,"../internals/export":139,"../internals/is-pure":163,"../internals/iterators":169,"../internals/iterators-core":168,"../internals/object-get-prototype-of":184,"../internals/object-set-prototype-of":188,"../internals/redefine":197,"../internals/set-to-string-tag":208,"../internals/well-known-symbol":237}],124:[function(require,module,exports){ -var path = require('../internals/path'); -var has = require('../internals/has'); -var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped'); -var defineProperty = require('../internals/object-define-property').f; - -module.exports = function (NAME) { - var Symbol = path.Symbol || (path.Symbol = {}); - if (!has(Symbol, NAME)) defineProperty(Symbol, NAME, { - value: wrappedWellKnownSymbolModule.f(NAME) - }); -}; - -},{"../internals/has":148,"../internals/object-define-property":179,"../internals/path":193,"../internals/well-known-symbol-wrapped":236}],125:[function(require,module,exports){ -var fails = require('../internals/fails'); +},{"../internals/try-to-string":293}],153:[function(require,module,exports){ +'use strict'; +var fails = require('../internals/fails'); // Detect IE8's incomplete defineProperty implementation module.exports = !fails(function () { // eslint-disable-next-line es/no-object-defineproperty -- required for testing - return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7; + return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7; }); -},{"../internals/fails":140}],126:[function(require,module,exports){ +},{"../internals/fails":171}],154:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); var isObject = require('../internals/is-object'); @@ -13634,7 +13268,18 @@ module.exports = function (it) { return EXISTS ? document.createElement(it) : {}; }; -},{"../internals/global":147,"../internals/is-object":162}],127:[function(require,module,exports){ +},{"../internals/global":188,"../internals/is-object":208}],155:[function(require,module,exports){ +'use strict'; +var $TypeError = TypeError; +var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991 + +module.exports = function (it) { + if (it > MAX_SAFE_INTEGER) throw $TypeError('Maximum allowed index exceeded'); + return it; +}; + +},{}],156:[function(require,module,exports){ +'use strict'; // iterable DOM collections // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods module.exports = { @@ -13671,49 +13316,76 @@ module.exports = { TouchList: 0 }; -},{}],128:[function(require,module,exports){ +},{}],157:[function(require,module,exports){ +'use strict'; +// in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList` +var documentCreateElement = require('../internals/document-create-element'); + +var classList = documentCreateElement('span').classList; +var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype; + +module.exports = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype; + +},{"../internals/document-create-element":154}],158:[function(require,module,exports){ +'use strict'; var userAgent = require('../internals/engine-user-agent'); var firefox = userAgent.match(/firefox\/(\d+)/i); module.exports = !!firefox && +firefox[1]; -},{"../internals/engine-user-agent":135}],129:[function(require,module,exports){ -module.exports = typeof window == 'object'; +},{"../internals/engine-user-agent":166}],159:[function(require,module,exports){ +'use strict'; +var IS_DENO = require('../internals/engine-is-deno'); +var IS_NODE = require('../internals/engine-is-node'); + +module.exports = !IS_DENO && !IS_NODE + && typeof window == 'object' + && typeof document == 'object'; + +},{"../internals/engine-is-deno":160,"../internals/engine-is-node":164}],160:[function(require,module,exports){ +'use strict'; +/* global Deno -- Deno case */ +module.exports = typeof Deno == 'object' && Deno && typeof Deno.version == 'object'; -},{}],130:[function(require,module,exports){ +},{}],161:[function(require,module,exports){ +'use strict'; var UA = require('../internals/engine-user-agent'); module.exports = /MSIE|Trident/.test(UA); -},{"../internals/engine-user-agent":135}],131:[function(require,module,exports){ +},{"../internals/engine-user-agent":166}],162:[function(require,module,exports){ +'use strict'; var userAgent = require('../internals/engine-user-agent'); -var global = require('../internals/global'); -module.exports = /ipad|iphone|ipod/i.test(userAgent) && global.Pebble !== undefined; +module.exports = /ipad|iphone|ipod/i.test(userAgent) && typeof Pebble != 'undefined'; -},{"../internals/engine-user-agent":135,"../internals/global":147}],132:[function(require,module,exports){ +},{"../internals/engine-user-agent":166}],163:[function(require,module,exports){ +'use strict'; var userAgent = require('../internals/engine-user-agent'); +// eslint-disable-next-line redos/no-vulnerable -- safe module.exports = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent); -},{"../internals/engine-user-agent":135}],133:[function(require,module,exports){ -var classof = require('../internals/classof-raw'); +},{"../internals/engine-user-agent":166}],164:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); +var classof = require('../internals/classof-raw'); -module.exports = classof(global.process) == 'process'; +module.exports = classof(global.process) === 'process'; -},{"../internals/classof-raw":114,"../internals/global":147}],134:[function(require,module,exports){ +},{"../internals/classof-raw":137,"../internals/global":188}],165:[function(require,module,exports){ +'use strict'; var userAgent = require('../internals/engine-user-agent'); module.exports = /web0s(?!.*chrome)/i.test(userAgent); -},{"../internals/engine-user-agent":135}],135:[function(require,module,exports){ -var getBuiltIn = require('../internals/get-built-in'); - -module.exports = getBuiltIn('navigator', 'userAgent') || ''; +},{"../internals/engine-user-agent":166}],166:[function(require,module,exports){ +'use strict'; +module.exports = typeof navigator != 'undefined' && String(navigator.userAgent) || ''; -},{"../internals/get-built-in":143}],136:[function(require,module,exports){ +},{}],167:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); var userAgent = require('../internals/engine-user-agent'); @@ -13725,25 +13397,33 @@ var match, version; if (v8) { match = v8.split('.'); - version = match[0] < 4 ? 1 : match[0] + match[1]; -} else if (userAgent) { + // in old Chrome, versions of V8 isn't V8 = Chrome / 10 + // but their correct versions are not interesting for us + version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); +} + +// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` +// so check `userAgent` even if `.v8` exists, but 0 +if (!version && userAgent) { match = userAgent.match(/Edge\/(\d+)/); if (!match || match[1] >= 74) { match = userAgent.match(/Chrome\/(\d+)/); - if (match) version = match[1]; + if (match) version = +match[1]; } } -module.exports = version && +version; +module.exports = version; -},{"../internals/engine-user-agent":135,"../internals/global":147}],137:[function(require,module,exports){ +},{"../internals/engine-user-agent":166,"../internals/global":188}],168:[function(require,module,exports){ +'use strict'; var userAgent = require('../internals/engine-user-agent'); var webkit = userAgent.match(/AppleWebKit\/(\d+)\./); module.exports = !!webkit && +webkit[1]; -},{"../internals/engine-user-agent":135}],138:[function(require,module,exports){ +},{"../internals/engine-user-agent":166}],169:[function(require,module,exports){ +'use strict'; // IE8- don't enum bug keys module.exports = [ 'constructor', @@ -13755,28 +13435,30 @@ module.exports = [ 'valueOf' ]; -},{}],139:[function(require,module,exports){ +},{}],170:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f; var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var redefine = require('../internals/redefine'); -var setGlobal = require('../internals/set-global'); +var defineBuiltIn = require('../internals/define-built-in'); +var defineGlobalProperty = require('../internals/define-global-property'); var copyConstructorProperties = require('../internals/copy-constructor-properties'); var isForced = require('../internals/is-forced'); /* - options.target - name of the target object - options.global - target is the global object - options.stat - export as static methods of target - options.proto - export as prototype methods of target - options.real - real prototype method for the `pure` version - options.forced - export even if the native feature is available - options.bind - bind methods to the target, required for the `pure` version - options.wrap - wrap constructors to preventing global pollution, required for the `pure` version - options.unsafe - use the simple assignment of property instead of delete + defineProperty - options.sham - add a flag to not completely full polyfills - options.enumerable - export as enumerable property - options.noTargetGet - prevent calling a getter on target + options.target - name of the target object + options.global - target is the global object + options.stat - export as static methods of target + options.proto - export as prototype methods of target + options.real - real prototype method for the `pure` version + options.forced - export even if the native feature is available + options.bind - bind methods to the target, required for the `pure` version + options.wrap - wrap constructors to preventing global pollution, required for the `pure` version + options.unsafe - use the simple assignment of property instead of delete + defineProperty + options.sham - add a flag to not completely full polyfills + options.enumerable - export as enumerable property + options.dontCallGetSet - prevent calling a getter on target + options.name - the .name of the function if it does not match the key */ module.exports = function (options, source) { var TARGET = options.target; @@ -13786,32 +13468,32 @@ module.exports = function (options, source) { if (GLOBAL) { target = global; } else if (STATIC) { - target = global[TARGET] || setGlobal(TARGET, {}); + target = global[TARGET] || defineGlobalProperty(TARGET, {}); } else { target = (global[TARGET] || {}).prototype; } if (target) for (key in source) { sourceProperty = source[key]; - if (options.noTargetGet) { + if (options.dontCallGetSet) { descriptor = getOwnPropertyDescriptor(target, key); targetProperty = descriptor && descriptor.value; } else targetProperty = target[key]; FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target if (!FORCED && targetProperty !== undefined) { - if (typeof sourceProperty === typeof targetProperty) continue; + if (typeof sourceProperty == typeof targetProperty) continue; copyConstructorProperties(sourceProperty, targetProperty); } // add a flag to not completely full polyfills if (options.sham || (targetProperty && targetProperty.sham)) { createNonEnumerableProperty(sourceProperty, 'sham', true); } - // extend global - redefine(target, key, sourceProperty, options); + defineBuiltIn(target, key, sourceProperty, options); } }; -},{"../internals/copy-constructor-properties":116,"../internals/create-non-enumerable-property":120,"../internals/global":147,"../internals/is-forced":160,"../internals/object-get-own-property-descriptor":180,"../internals/redefine":197,"../internals/set-global":206}],140:[function(require,module,exports){ +},{"../internals/copy-constructor-properties":141,"../internals/create-non-enumerable-property":145,"../internals/define-built-in":149,"../internals/define-global-property":151,"../internals/global":188,"../internals/is-forced":205,"../internals/object-get-own-property-descriptor":232}],171:[function(require,module,exports){ +'use strict'; module.exports = function (exec) { try { return !!exec(); @@ -13820,11 +13502,12 @@ module.exports = function (exec) { } }; -},{}],141:[function(require,module,exports){ +},{}],172:[function(require,module,exports){ 'use strict'; // TODO: Remove from `core-js@4` since it's moved to entry points require('../modules/es.regexp.exec'); -var redefine = require('../internals/redefine'); +var uncurryThis = require('../internals/function-uncurry-this-clause'); +var defineBuiltIn = require('../internals/define-built-in'); var regexpExec = require('../internals/regexp-exec'); var fails = require('../internals/fails'); var wellKnownSymbol = require('../internals/well-known-symbol'); @@ -13840,7 +13523,7 @@ module.exports = function (KEY, exec, FORCED, SHAM) { // String methods call symbol-named RegEp methods var O = {}; O[SYMBOL] = function () { return 7; }; - return ''[KEY](O) != 7; + return ''[KEY](O) !== 7; }); var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () { @@ -13861,7 +13544,10 @@ module.exports = function (KEY, exec, FORCED, SHAM) { re[SYMBOL] = /./[SYMBOL]; } - re.exec = function () { execCalled = true; return null; }; + re.exec = function () { + execCalled = true; + return null; + }; re[SYMBOL](''); return !execCalled; @@ -13872,94 +13558,245 @@ module.exports = function (KEY, exec, FORCED, SHAM) { !DELEGATES_TO_EXEC || FORCED ) { - var nativeRegExpMethod = /./[SYMBOL]; + var uncurriedNativeRegExpMethod = uncurryThis(/./[SYMBOL]); var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { + var uncurriedNativeMethod = uncurryThis(nativeMethod); var $exec = regexp.exec; if ($exec === regexpExec || $exec === RegExpPrototype.exec) { if (DELEGATES_TO_SYMBOL && !forceStringMethod) { // The native String method already delegates to @@method (this // polyfilled function), leasing to infinite recursion. // We avoid it by directly calling the native @@method method. - return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) }; + return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) }; } - return { done: true, value: nativeMethod.call(str, regexp, arg2) }; + return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) }; } return { done: false }; }); - redefine(String.prototype, KEY, methods[0]); - redefine(RegExpPrototype, SYMBOL, methods[1]); + defineBuiltIn(String.prototype, KEY, methods[0]); + defineBuiltIn(RegExpPrototype, SYMBOL, methods[1]); } if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true); }; -},{"../internals/create-non-enumerable-property":120,"../internals/fails":140,"../internals/redefine":197,"../internals/regexp-exec":199,"../internals/well-known-symbol":237,"../modules/es.regexp.exec":261}],142:[function(require,module,exports){ -var aFunction = require('../internals/a-function'); +},{"../internals/create-non-enumerable-property":145,"../internals/define-built-in":149,"../internals/fails":171,"../internals/function-uncurry-this-clause":180,"../internals/regexp-exec":256,"../internals/well-known-symbol":306,"../modules/es.regexp.exec":340}],173:[function(require,module,exports){ +'use strict'; +var fails = require('../internals/fails'); + +module.exports = !fails(function () { + // eslint-disable-next-line es/no-object-isextensible, es/no-object-preventextensions -- required for testing + return Object.isExtensible(Object.preventExtensions({})); +}); + +},{"../internals/fails":171}],174:[function(require,module,exports){ +'use strict'; +var NATIVE_BIND = require('../internals/function-bind-native'); + +var FunctionPrototype = Function.prototype; +var apply = FunctionPrototype.apply; +var call = FunctionPrototype.call; + +// eslint-disable-next-line es/no-reflect -- safe +module.exports = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () { + return call.apply(apply, arguments); +}); + +},{"../internals/function-bind-native":176}],175:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this-clause'); +var aCallable = require('../internals/a-callable'); +var NATIVE_BIND = require('../internals/function-bind-native'); + +var bind = uncurryThis(uncurryThis.bind); // optional / simple context binding -module.exports = function (fn, that, length) { - aFunction(fn); - if (that === undefined) return fn; - switch (length) { - case 0: return function () { - return fn.call(that); - }; - case 1: return function (a) { - return fn.call(that, a); - }; - case 2: return function (a, b) { - return fn.call(that, a, b); - }; - case 3: return function (a, b, c) { - return fn.call(that, a, b, c); - }; - } - return function (/* ...args */) { +module.exports = function (fn, that) { + aCallable(fn); + return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) { return fn.apply(that, arguments); }; }; -},{"../internals/a-function":89}],143:[function(require,module,exports){ +},{"../internals/a-callable":108,"../internals/function-bind-native":176,"../internals/function-uncurry-this-clause":180}],176:[function(require,module,exports){ +'use strict'; +var fails = require('../internals/fails'); + +module.exports = !fails(function () { + // eslint-disable-next-line es/no-function-prototype-bind -- safe + var test = (function () { /* empty */ }).bind(); + // eslint-disable-next-line no-prototype-builtins -- safe + return typeof test != 'function' || test.hasOwnProperty('prototype'); +}); + +},{"../internals/fails":171}],177:[function(require,module,exports){ +'use strict'; +var NATIVE_BIND = require('../internals/function-bind-native'); + +var call = Function.prototype.call; + +module.exports = NATIVE_BIND ? call.bind(call) : function () { + return call.apply(call, arguments); +}; + +},{"../internals/function-bind-native":176}],178:[function(require,module,exports){ +'use strict'; +var DESCRIPTORS = require('../internals/descriptors'); +var hasOwn = require('../internals/has-own-property'); + +var FunctionPrototype = Function.prototype; +// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe +var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor; + +var EXISTS = hasOwn(FunctionPrototype, 'name'); +// additional protection from minified / mangled / dropped function names +var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something'; +var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable)); + +module.exports = { + EXISTS: EXISTS, + PROPER: PROPER, + CONFIGURABLE: CONFIGURABLE +}; + +},{"../internals/descriptors":153,"../internals/has-own-property":189}],179:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); +var aCallable = require('../internals/a-callable'); + +module.exports = function (object, key, method) { + try { + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method])); + } catch (error) { /* empty */ } +}; + +},{"../internals/a-callable":108,"../internals/function-uncurry-this":181}],180:[function(require,module,exports){ +'use strict'; +var classofRaw = require('../internals/classof-raw'); +var uncurryThis = require('../internals/function-uncurry-this'); + +module.exports = function (fn) { + // Nashorn bug: + // https://github.com/zloirock/core-js/issues/1128 + // https://github.com/zloirock/core-js/issues/1130 + if (classofRaw(fn) === 'Function') return uncurryThis(fn); +}; + +},{"../internals/classof-raw":137,"../internals/function-uncurry-this":181}],181:[function(require,module,exports){ +'use strict'; +var NATIVE_BIND = require('../internals/function-bind-native'); + +var FunctionPrototype = Function.prototype; +var call = FunctionPrototype.call; +var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call); + +module.exports = NATIVE_BIND ? uncurryThisWithBind : function (fn) { + return function () { + return call.apply(fn, arguments); + }; +}; + +},{"../internals/function-bind-native":176}],182:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); +var isCallable = require('../internals/is-callable'); -var aFunction = function (variable) { - return typeof variable == 'function' ? variable : undefined; +var aFunction = function (argument) { + return isCallable(argument) ? argument : undefined; }; module.exports = function (namespace, method) { return arguments.length < 2 ? aFunction(global[namespace]) : global[namespace] && global[namespace][method]; }; -},{"../internals/global":147}],144:[function(require,module,exports){ +},{"../internals/global":188,"../internals/is-callable":203}],183:[function(require,module,exports){ +'use strict'; var classof = require('../internals/classof'); +var getMethod = require('../internals/get-method'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); var Iterators = require('../internals/iterators'); var wellKnownSymbol = require('../internals/well-known-symbol'); var ITERATOR = wellKnownSymbol('iterator'); module.exports = function (it) { - if (it != undefined) return it[ITERATOR] - || it['@@iterator'] + if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR) + || getMethod(it, '@@iterator') || Iterators[classof(it)]; }; -},{"../internals/classof":115,"../internals/iterators":169,"../internals/well-known-symbol":237}],145:[function(require,module,exports){ +},{"../internals/classof":138,"../internals/get-method":186,"../internals/is-null-or-undefined":207,"../internals/iterators":218,"../internals/well-known-symbol":306}],184:[function(require,module,exports){ +'use strict'; +var call = require('../internals/function-call'); +var aCallable = require('../internals/a-callable'); var anObject = require('../internals/an-object'); +var tryToString = require('../internals/try-to-string'); var getIteratorMethod = require('../internals/get-iterator-method'); -module.exports = function (it, usingIterator) { - var iteratorMethod = arguments.length < 2 ? getIteratorMethod(it) : usingIterator; - if (typeof iteratorMethod != 'function') { - throw TypeError(String(it) + ' is not iterable'); - } return anObject(iteratorMethod.call(it)); +var $TypeError = TypeError; + +module.exports = function (argument, usingIterator) { + var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; + if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument)); + throw new $TypeError(tryToString(argument) + ' is not iterable'); +}; + +},{"../internals/a-callable":108,"../internals/an-object":114,"../internals/function-call":177,"../internals/get-iterator-method":183,"../internals/try-to-string":293}],185:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); +var isArray = require('../internals/is-array'); +var isCallable = require('../internals/is-callable'); +var classof = require('../internals/classof-raw'); +var toString = require('../internals/to-string'); + +var push = uncurryThis([].push); + +module.exports = function (replacer) { + if (isCallable(replacer)) return replacer; + if (!isArray(replacer)) return; + var rawLength = replacer.length; + var keys = []; + for (var i = 0; i < rawLength; i++) { + var element = replacer[i]; + if (typeof element == 'string') push(keys, element); + else if (typeof element == 'number' || classof(element) === 'Number' || classof(element) === 'String') push(keys, toString(element)); + } + var keysLength = keys.length; + var root = true; + return function (key, value) { + if (root) { + root = false; + return value; + } + if (isArray(this)) return value; + for (var j = 0; j < keysLength; j++) if (keys[j] === key) return value; + }; +}; + +},{"../internals/classof-raw":137,"../internals/function-uncurry-this":181,"../internals/is-array":201,"../internals/is-callable":203,"../internals/to-string":291}],186:[function(require,module,exports){ +'use strict'; +var aCallable = require('../internals/a-callable'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); + +// `GetMethod` abstract operation +// https://tc39.es/ecma262/#sec-getmethod +module.exports = function (V, P) { + var func = V[P]; + return isNullOrUndefined(func) ? undefined : aCallable(func); }; -},{"../internals/an-object":94,"../internals/get-iterator-method":144}],146:[function(require,module,exports){ +},{"../internals/a-callable":108,"../internals/is-null-or-undefined":207}],187:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); var toObject = require('../internals/to-object'); var floor = Math.floor; -var replace = ''.replace; +var charAt = uncurryThis(''.charAt); +var replace = uncurryThis(''.replace); +var stringSlice = uncurryThis(''.slice); +// eslint-disable-next-line redos/no-vulnerable -- safe var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; @@ -13973,15 +13810,15 @@ module.exports = function (matched, str, position, captures, namedCaptures, repl namedCaptures = toObject(namedCaptures); symbols = SUBSTITUTION_SYMBOLS; } - return replace.call(replacement, symbols, function (match, ch) { + return replace(replacement, symbols, function (match, ch) { var capture; - switch (ch.charAt(0)) { + switch (charAt(ch, 0)) { case '$': return '$'; case '&': return matched; - case '`': return str.slice(0, position); - case "'": return str.slice(tailPos); + case '`': return stringSlice(str, 0, position); + case "'": return stringSlice(str, tailPos); case '<': - capture = namedCaptures[ch.slice(1, -1)]; + capture = namedCaptures[stringSlice(ch, 1, -1)]; break; default: // \d\d? var n = +ch; @@ -13989,7 +13826,7 @@ module.exports = function (matched, str, position, captures, namedCaptures, repl if (n > m) { var f = floor(n / 10); if (f === 0) return match; - if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1); + if (f <= m) return captures[f - 1] === undefined ? charAt(ch, 1) : captures[f - 1] + charAt(ch, 1); return match; } capture = captures[n - 1]; @@ -13998,10 +13835,11 @@ module.exports = function (matched, str, position, captures, namedCaptures, repl }); }; -},{"../internals/to-object":222}],147:[function(require,module,exports){ +},{"../internals/function-uncurry-this":181,"../internals/to-object":285}],188:[function(require,module,exports){ (function (global){(function (){ +'use strict'; var check = function (it) { - return it && it.Math == Math && it; + return it && it.Math === Math && it; }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 @@ -14012,52 +13850,62 @@ module.exports = // eslint-disable-next-line no-restricted-globals -- safe check(typeof self == 'object' && self) || check(typeof global == 'object' && global) || + check(typeof this == 'object' && this) || // eslint-disable-next-line no-new-func -- fallback (function () { return this; })() || Function('return this')(); }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],148:[function(require,module,exports){ +},{}],189:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); var toObject = require('../internals/to-object'); -var hasOwnProperty = {}.hasOwnProperty; +var hasOwnProperty = uncurryThis({}.hasOwnProperty); +// `HasOwnProperty` abstract operation +// https://tc39.es/ecma262/#sec-hasownproperty +// eslint-disable-next-line es/no-object-hasown -- safe module.exports = Object.hasOwn || function hasOwn(it, key) { - return hasOwnProperty.call(toObject(it), key); + return hasOwnProperty(toObject(it), key); }; -},{"../internals/to-object":222}],149:[function(require,module,exports){ +},{"../internals/function-uncurry-this":181,"../internals/to-object":285}],190:[function(require,module,exports){ +'use strict'; module.exports = {}; -},{}],150:[function(require,module,exports){ -var global = require('../internals/global'); - +},{}],191:[function(require,module,exports){ +'use strict'; module.exports = function (a, b) { - var console = global.console; - if (console && console.error) { + try { + // eslint-disable-next-line no-console -- safe arguments.length === 1 ? console.error(a) : console.error(a, b); - } + } catch (error) { /* empty */ } }; -},{"../internals/global":147}],151:[function(require,module,exports){ +},{}],192:[function(require,module,exports){ +'use strict'; var getBuiltIn = require('../internals/get-built-in'); module.exports = getBuiltIn('document', 'documentElement'); -},{"../internals/get-built-in":143}],152:[function(require,module,exports){ +},{"../internals/get-built-in":182}],193:[function(require,module,exports){ +'use strict'; var DESCRIPTORS = require('../internals/descriptors'); var fails = require('../internals/fails'); var createElement = require('../internals/document-create-element'); -// Thank's IE8 for his funny defineProperty +// Thanks to IE8 for its funny defineProperty module.exports = !DESCRIPTORS && !fails(function () { - // eslint-disable-next-line es/no-object-defineproperty -- requied for testing + // eslint-disable-next-line es/no-object-defineproperty -- required for testing return Object.defineProperty(createElement('div'), 'a', { get: function () { return 7; } - }).a != 7; + }).a !== 7; }); -},{"../internals/descriptors":125,"../internals/document-create-element":126,"../internals/fails":140}],153:[function(require,module,exports){ +},{"../internals/descriptors":153,"../internals/document-create-element":154,"../internals/fails":171}],194:[function(require,module,exports){ +'use strict'; // IEEE754 conversions based on https://github.com/feross/ieee754 +var $Array = Array; var abs = Math.abs; var pow = Math.pow; var floor = Math.floor; @@ -14065,7 +13913,7 @@ var log = Math.log; var LN2 = Math.LN2; var pack = function (number, mantissaLength, bytes) { - var buffer = new Array(bytes); + var buffer = $Array(bytes); var exponentLength = bytes * 8 - mantissaLength - 1; var eMax = (1 << exponentLength) - 1; var eBias = eMax >> 1; @@ -14075,13 +13923,14 @@ var pack = function (number, mantissaLength, bytes) { var exponent, mantissa, c; number = abs(number); // eslint-disable-next-line no-self-compare -- NaN check - if (number != number || number === Infinity) { + if (number !== number || number === Infinity) { // eslint-disable-next-line no-self-compare -- NaN check - mantissa = number != number ? 1 : 0; + mantissa = number !== number ? 1 : 0; exponent = eMax; } else { exponent = floor(log(number) / LN2); - if (number * (c = pow(2, -exponent)) < 1) { + c = pow(2, -exponent); + if (number * c < 1) { exponent--; c *= 2; } @@ -14099,16 +13948,24 @@ var pack = function (number, mantissaLength, bytes) { exponent = eMax; } else if (exponent + eBias >= 1) { mantissa = (number * c - 1) * pow(2, mantissaLength); - exponent = exponent + eBias; + exponent += eBias; } else { mantissa = number * pow(2, eBias - 1) * pow(2, mantissaLength); exponent = 0; } } - for (; mantissaLength >= 8; buffer[index++] = mantissa & 255, mantissa /= 256, mantissaLength -= 8); + while (mantissaLength >= 8) { + buffer[index++] = mantissa & 255; + mantissa /= 256; + mantissaLength -= 8; + } exponent = exponent << mantissaLength | mantissa; exponentLength += mantissaLength; - for (; exponentLength > 0; buffer[index++] = exponent & 255, exponent /= 256, exponentLength -= 8); + while (exponentLength > 0) { + buffer[index++] = exponent & 255; + exponent /= 256; + exponentLength -= 8; + } buffer[--index] |= sign * 128; return buffer; }; @@ -14124,18 +13981,24 @@ var unpack = function (buffer, mantissaLength) { var exponent = sign & 127; var mantissa; sign >>= 7; - for (; nBits > 0; exponent = exponent * 256 + buffer[index], index--, nBits -= 8); + while (nBits > 0) { + exponent = exponent * 256 + buffer[index--]; + nBits -= 8; + } mantissa = exponent & (1 << -nBits) - 1; exponent >>= -nBits; nBits += mantissaLength; - for (; nBits > 0; mantissa = mantissa * 256 + buffer[index], index--, nBits -= 8); + while (nBits > 0) { + mantissa = mantissa * 256 + buffer[index--]; + nBits -= 8; + } if (exponent === 0) { exponent = 1 - eBias; } else if (exponent === eMax) { return mantissa ? NaN : sign ? -Infinity : Infinity; } else { - mantissa = mantissa + pow(2, mantissaLength); - exponent = exponent - eBias; + mantissa += pow(2, mantissaLength); + exponent -= eBias; } return (sign ? -1 : 1) * mantissa * pow(2, exponent - mantissaLength); }; @@ -14144,22 +14007,27 @@ module.exports = { unpack: unpack }; -},{}],154:[function(require,module,exports){ +},{}],195:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); var fails = require('../internals/fails'); var classof = require('../internals/classof-raw'); -var split = ''.split; +var $Object = Object; +var split = uncurryThis(''.split); // fallback for non-array-like ES3 and non-enumerable old V8 strings module.exports = fails(function () { // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 // eslint-disable-next-line no-prototype-builtins -- safe - return !Object('z').propertyIsEnumerable(0); + return !$Object('z').propertyIsEnumerable(0); }) ? function (it) { - return classof(it) == 'String' ? split.call(it, '') : Object(it); -} : Object; + return classof(it) === 'String' ? split(it, '') : $Object(it); +} : $Object; -},{"../internals/classof-raw":114,"../internals/fails":140}],155:[function(require,module,exports){ +},{"../internals/classof-raw":137,"../internals/fails":171,"../internals/function-uncurry-this":181}],196:[function(require,module,exports){ +'use strict'; +var isCallable = require('../internals/is-callable'); var isObject = require('../internals/is-object'); var setPrototypeOf = require('../internals/object-set-prototype-of'); @@ -14170,7 +14038,7 @@ module.exports = function ($this, dummy, Wrapper) { // it can work only with native `setPrototypeOf` setPrototypeOf && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this - typeof (NewTarget = dummy.constructor) == 'function' && + isCallable(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype @@ -14178,31 +14046,128 @@ module.exports = function ($this, dummy, Wrapper) { return $this; }; -},{"../internals/is-object":162,"../internals/object-set-prototype-of":188}],156:[function(require,module,exports){ +},{"../internals/is-callable":203,"../internals/is-object":208,"../internals/object-set-prototype-of":242}],197:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); +var isCallable = require('../internals/is-callable'); var store = require('../internals/shared-store'); -var functionToString = Function.toString; +var functionToString = uncurryThis(Function.toString); // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper -if (typeof store.inspectSource != 'function') { +if (!isCallable(store.inspectSource)) { store.inspectSource = function (it) { - return functionToString.call(it); + return functionToString(it); }; } module.exports = store.inspectSource; -},{"../internals/shared-store":210}],157:[function(require,module,exports){ -var NATIVE_WEAK_MAP = require('../internals/native-weak-map'); +},{"../internals/function-uncurry-this":181,"../internals/is-callable":203,"../internals/shared-store":268}],198:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var uncurryThis = require('../internals/function-uncurry-this'); +var hiddenKeys = require('../internals/hidden-keys'); +var isObject = require('../internals/is-object'); +var hasOwn = require('../internals/has-own-property'); +var defineProperty = require('../internals/object-define-property').f; +var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names'); +var getOwnPropertyNamesExternalModule = require('../internals/object-get-own-property-names-external'); +var isExtensible = require('../internals/object-is-extensible'); +var uid = require('../internals/uid'); +var FREEZING = require('../internals/freezing'); + +var REQUIRED = false; +var METADATA = uid('meta'); +var id = 0; + +var setMetadata = function (it) { + defineProperty(it, METADATA, { value: { + objectID: 'O' + id++, // object ID + weakData: {} // weak collections IDs + } }); +}; + +var fastKey = function (it, create) { + // return a primitive with prefix + if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; + if (!hasOwn(it, METADATA)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return 'F'; + // not necessary to add metadata + if (!create) return 'E'; + // add missing metadata + setMetadata(it); + // return object ID + } return it[METADATA].objectID; +}; + +var getWeakData = function (it, create) { + if (!hasOwn(it, METADATA)) { + // can't set metadata to uncaught frozen object + if (!isExtensible(it)) return true; + // not necessary to add metadata + if (!create) return false; + // add missing metadata + setMetadata(it); + // return the store of weak collections IDs + } return it[METADATA].weakData; +}; + +// add metadata on freeze-family methods calling +var onFreeze = function (it) { + if (FREEZING && REQUIRED && isExtensible(it) && !hasOwn(it, METADATA)) setMetadata(it); + return it; +}; + +var enable = function () { + meta.enable = function () { /* empty */ }; + REQUIRED = true; + var getOwnPropertyNames = getOwnPropertyNamesModule.f; + var splice = uncurryThis([].splice); + var test = {}; + test[METADATA] = 1; + + // prevent exposing of metadata key + if (getOwnPropertyNames(test).length) { + getOwnPropertyNamesModule.f = function (it) { + var result = getOwnPropertyNames(it); + for (var i = 0, length = result.length; i < length; i++) { + if (result[i] === METADATA) { + splice(result, i, 1); + break; + } + } return result; + }; + + $({ target: 'Object', stat: true, forced: true }, { + getOwnPropertyNames: getOwnPropertyNamesExternalModule.f + }); + } +}; + +var meta = module.exports = { + enable: enable, + fastKey: fastKey, + getWeakData: getWeakData, + onFreeze: onFreeze +}; + +hiddenKeys[METADATA] = true; + +},{"../internals/export":170,"../internals/freezing":173,"../internals/function-uncurry-this":181,"../internals/has-own-property":189,"../internals/hidden-keys":190,"../internals/is-object":208,"../internals/object-define-property":231,"../internals/object-get-own-property-names":234,"../internals/object-get-own-property-names-external":233,"../internals/object-is-extensible":237,"../internals/uid":299}],199:[function(require,module,exports){ +'use strict'; +var NATIVE_WEAK_MAP = require('../internals/weak-map-basic-detection'); var global = require('../internals/global'); var isObject = require('../internals/is-object'); var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var objectHas = require('../internals/has'); +var hasOwn = require('../internals/has-own-property'); var shared = require('../internals/shared-store'); var sharedKey = require('../internals/shared-key'); var hiddenKeys = require('../internals/hidden-keys'); var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; +var TypeError = global.TypeError; var WeakMap = global.WeakMap; var set, get, has; @@ -14214,42 +14179,44 @@ var getterFor = function (TYPE) { return function (it) { var state; if (!isObject(it) || (state = get(it)).type !== TYPE) { - throw TypeError('Incompatible receiver, ' + TYPE + ' required'); + throw new TypeError('Incompatible receiver, ' + TYPE + ' required'); } return state; }; }; if (NATIVE_WEAK_MAP || shared.state) { var store = shared.state || (shared.state = new WeakMap()); - var wmget = store.get; - var wmhas = store.has; - var wmset = store.set; + /* eslint-disable no-self-assign -- prototype methods protection */ + store.get = store.get; + store.has = store.has; + store.set = store.set; + /* eslint-enable no-self-assign -- prototype methods protection */ set = function (it, metadata) { - if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); + if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); metadata.facade = it; - wmset.call(store, it, metadata); + store.set(it, metadata); return metadata; }; get = function (it) { - return wmget.call(store, it) || {}; + return store.get(it) || {}; }; has = function (it) { - return wmhas.call(store, it); + return store.has(it); }; } else { var STATE = sharedKey('state'); hiddenKeys[STATE] = true; set = function (it, metadata) { - if (objectHas(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); + if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); metadata.facade = it; createNonEnumerableProperty(it, STATE, metadata); return metadata; }; get = function (it) { - return objectHas(it, STATE) ? it[STATE] : {}; + return hasOwn(it, STATE) ? it[STATE] : {}; }; has = function (it) { - return objectHas(it, STATE); + return hasOwn(it, STATE); }; } @@ -14261,7 +14228,8 @@ module.exports = { getterFor: getterFor }; -},{"../internals/create-non-enumerable-property":120,"../internals/global":147,"../internals/has":148,"../internals/hidden-keys":149,"../internals/is-object":162,"../internals/native-weak-map":173,"../internals/shared-key":209,"../internals/shared-store":210}],158:[function(require,module,exports){ +},{"../internals/create-non-enumerable-property":145,"../internals/global":188,"../internals/has-own-property":189,"../internals/hidden-keys":190,"../internals/is-object":208,"../internals/shared-key":267,"../internals/shared-store":268,"../internals/weak-map-basic-detection":303}],200:[function(require,module,exports){ +'use strict'; var wellKnownSymbol = require('../internals/well-known-symbol'); var Iterators = require('../internals/iterators'); @@ -14273,26 +14241,107 @@ module.exports = function (it) { return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it); }; -},{"../internals/iterators":169,"../internals/well-known-symbol":237}],159:[function(require,module,exports){ +},{"../internals/iterators":218,"../internals/well-known-symbol":306}],201:[function(require,module,exports){ +'use strict'; var classof = require('../internals/classof-raw'); // `IsArray` abstract operation // https://tc39.es/ecma262/#sec-isarray // eslint-disable-next-line es/no-array-isarray -- safe -module.exports = Array.isArray || function isArray(arg) { - return classof(arg) == 'Array'; +module.exports = Array.isArray || function isArray(argument) { + return classof(argument) === 'Array'; +}; + +},{"../internals/classof-raw":137}],202:[function(require,module,exports){ +'use strict'; +var classof = require('../internals/classof'); + +module.exports = function (it) { + var klass = classof(it); + return klass === 'BigInt64Array' || klass === 'BigUint64Array'; +}; + +},{"../internals/classof":138}],203:[function(require,module,exports){ +'use strict'; +// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot +var documentAll = typeof document == 'object' && document.all; + +// `IsCallable` abstract operation +// https://tc39.es/ecma262/#sec-iscallable +// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing +module.exports = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) { + return typeof argument == 'function' || argument === documentAll; +} : function (argument) { + return typeof argument == 'function'; +}; + +},{}],204:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); +var fails = require('../internals/fails'); +var isCallable = require('../internals/is-callable'); +var classof = require('../internals/classof'); +var getBuiltIn = require('../internals/get-built-in'); +var inspectSource = require('../internals/inspect-source'); + +var noop = function () { /* empty */ }; +var empty = []; +var construct = getBuiltIn('Reflect', 'construct'); +var constructorRegExp = /^\s*(?:class|function)\b/; +var exec = uncurryThis(constructorRegExp.exec); +var INCORRECT_TO_STRING = !constructorRegExp.test(noop); + +var isConstructorModern = function isConstructor(argument) { + if (!isCallable(argument)) return false; + try { + construct(noop, empty, argument); + return true; + } catch (error) { + return false; + } +}; + +var isConstructorLegacy = function isConstructor(argument) { + if (!isCallable(argument)) return false; + switch (classof(argument)) { + case 'AsyncFunction': + case 'GeneratorFunction': + case 'AsyncGeneratorFunction': return false; + } + try { + // we can't check .prototype since constructors produced by .bind haven't it + // `Function#toString` throws on some built-it function in some legacy engines + // (for example, `DOMQuad` and similar in FF41-) + return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument)); + } catch (error) { + return true; + } }; -},{"../internals/classof-raw":114}],160:[function(require,module,exports){ +isConstructorLegacy.sham = true; + +// `IsConstructor` abstract operation +// https://tc39.es/ecma262/#sec-isconstructor +module.exports = !construct || fails(function () { + var called; + return isConstructorModern(isConstructorModern.call) + || !isConstructorModern(Object) + || !isConstructorModern(function () { called = true; }) + || called; +}) ? isConstructorLegacy : isConstructorModern; + +},{"../internals/classof":138,"../internals/fails":171,"../internals/function-uncurry-this":181,"../internals/get-built-in":182,"../internals/inspect-source":197,"../internals/is-callable":203}],205:[function(require,module,exports){ +'use strict'; var fails = require('../internals/fails'); +var isCallable = require('../internals/is-callable'); var replacement = /#|\.prototype\./; var isForced = function (feature, detection) { var value = data[normalize(feature)]; - return value == POLYFILL ? true - : value == NATIVE ? false - : typeof detection == 'function' ? fails(detection) + return value === POLYFILL ? true + : value === NATIVE ? false + : isCallable(detection) ? fails(detection) : !!detection; }; @@ -14306,26 +14355,49 @@ var POLYFILL = isForced.POLYFILL = 'P'; module.exports = isForced; -},{"../internals/fails":140}],161:[function(require,module,exports){ +},{"../internals/fails":171,"../internals/is-callable":203}],206:[function(require,module,exports){ +'use strict'; var isObject = require('../internals/is-object'); var floor = Math.floor; -// `Number.isInteger` method implementation -// https://tc39.es/ecma262/#sec-number.isinteger -module.exports = function isInteger(it) { +// `IsIntegralNumber` abstract operation +// https://tc39.es/ecma262/#sec-isintegralnumber +// eslint-disable-next-line es/no-number-isinteger -- safe +module.exports = Number.isInteger || function isInteger(it) { return !isObject(it) && isFinite(it) && floor(it) === it; }; -},{"../internals/is-object":162}],162:[function(require,module,exports){ +},{"../internals/is-object":208}],207:[function(require,module,exports){ +'use strict'; +// we can't use just `it == null` since of `document.all` special case +// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec +module.exports = function (it) { + return it === null || it === undefined; +}; + +},{}],208:[function(require,module,exports){ +'use strict'; +var isCallable = require('../internals/is-callable'); + module.exports = function (it) { - return typeof it === 'object' ? it !== null : typeof it === 'function'; + return typeof it == 'object' ? it !== null : isCallable(it); +}; + +},{"../internals/is-callable":203}],209:[function(require,module,exports){ +'use strict'; +var isObject = require('../internals/is-object'); + +module.exports = function (argument) { + return isObject(argument) || argument === null; }; -},{}],163:[function(require,module,exports){ +},{"../internals/is-object":208}],210:[function(require,module,exports){ +'use strict'; module.exports = false; -},{}],164:[function(require,module,exports){ +},{}],211:[function(require,module,exports){ +'use strict'; var isObject = require('../internals/is-object'); var classof = require('../internals/classof-raw'); var wellKnownSymbol = require('../internals/well-known-symbol'); @@ -14336,40 +14408,54 @@ var MATCH = wellKnownSymbol('match'); // https://tc39.es/ecma262/#sec-isregexp module.exports = function (it) { var isRegExp; - return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) == 'RegExp'); + return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof(it) === 'RegExp'); }; -},{"../internals/classof-raw":114,"../internals/is-object":162,"../internals/well-known-symbol":237}],165:[function(require,module,exports){ +},{"../internals/classof-raw":137,"../internals/is-object":208,"../internals/well-known-symbol":306}],212:[function(require,module,exports){ +'use strict'; var getBuiltIn = require('../internals/get-built-in'); +var isCallable = require('../internals/is-callable'); +var isPrototypeOf = require('../internals/object-is-prototype-of'); var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid'); +var $Object = Object; + module.exports = USE_SYMBOL_AS_UID ? function (it) { return typeof it == 'symbol'; } : function (it) { var $Symbol = getBuiltIn('Symbol'); - return typeof $Symbol == 'function' && Object(it) instanceof $Symbol; + return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it)); }; -},{"../internals/get-built-in":143,"../internals/use-symbol-as-uid":235}],166:[function(require,module,exports){ +},{"../internals/get-built-in":182,"../internals/is-callable":203,"../internals/object-is-prototype-of":238,"../internals/use-symbol-as-uid":300}],213:[function(require,module,exports){ +'use strict'; +var bind = require('../internals/function-bind-context'); +var call = require('../internals/function-call'); var anObject = require('../internals/an-object'); +var tryToString = require('../internals/try-to-string'); var isArrayIteratorMethod = require('../internals/is-array-iterator-method'); -var toLength = require('../internals/to-length'); -var bind = require('../internals/function-bind-context'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); +var isPrototypeOf = require('../internals/object-is-prototype-of'); var getIterator = require('../internals/get-iterator'); var getIteratorMethod = require('../internals/get-iterator-method'); var iteratorClose = require('../internals/iterator-close'); +var $TypeError = TypeError; + var Result = function (stopped, result) { this.stopped = stopped; this.result = result; }; +var ResultPrototype = Result.prototype; + module.exports = function (iterable, unboundFunction, options) { var that = options && options.that; var AS_ENTRIES = !!(options && options.AS_ENTRIES); + var IS_RECORD = !!(options && options.IS_RECORD); var IS_ITERATOR = !!(options && options.IS_ITERATOR); var INTERRUPTED = !!(options && options.INTERRUPTED); - var fn = bind(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED); + var fn = bind(unboundFunction, that); var iterator, iterFn, index, length, result, next, step; var stop = function (condition) { @@ -14384,45 +14470,50 @@ module.exports = function (iterable, unboundFunction, options) { } return INTERRUPTED ? fn(value, stop) : fn(value); }; - if (IS_ITERATOR) { + if (IS_RECORD) { + iterator = iterable.iterator; + } else if (IS_ITERATOR) { iterator = iterable; } else { iterFn = getIteratorMethod(iterable); - if (typeof iterFn != 'function') throw TypeError('Target is not iterable'); + if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators if (isArrayIteratorMethod(iterFn)) { - for (index = 0, length = toLength(iterable.length); length > index; index++) { + for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { result = callFn(iterable[index]); - if (result && result instanceof Result) return result; + if (result && isPrototypeOf(ResultPrototype, result)) return result; } return new Result(false); } iterator = getIterator(iterable, iterFn); } - next = iterator.next; - while (!(step = next.call(iterator)).done) { + next = IS_RECORD ? iterable.next : iterator.next; + while (!(step = call(next, iterator)).done) { try { result = callFn(step.value); } catch (error) { iteratorClose(iterator, 'throw', error); } - if (typeof result == 'object' && result && result instanceof Result) return result; + if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result; } return new Result(false); }; -},{"../internals/an-object":94,"../internals/function-bind-context":142,"../internals/get-iterator":145,"../internals/get-iterator-method":144,"../internals/is-array-iterator-method":158,"../internals/iterator-close":167,"../internals/to-length":221}],167:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/function-bind-context":175,"../internals/function-call":177,"../internals/get-iterator":184,"../internals/get-iterator-method":183,"../internals/is-array-iterator-method":200,"../internals/iterator-close":214,"../internals/length-of-array-like":219,"../internals/object-is-prototype-of":238,"../internals/try-to-string":293}],214:[function(require,module,exports){ +'use strict'; +var call = require('../internals/function-call'); var anObject = require('../internals/an-object'); +var getMethod = require('../internals/get-method'); module.exports = function (iterator, kind, value) { var innerResult, innerError; anObject(iterator); try { - innerResult = iterator['return']; - if (innerResult === undefined) { + innerResult = getMethod(iterator, 'return'); + if (!innerResult) { if (kind === 'throw') throw value; return value; } - innerResult = innerResult.call(iterator); + innerResult = call(innerResult, iterator); } catch (error) { innerError = true; innerResult = error; @@ -14433,27 +14524,149 @@ module.exports = function (iterator, kind, value) { return value; }; -},{"../internals/an-object":94}],168:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/function-call":177,"../internals/get-method":186}],215:[function(require,module,exports){ 'use strict'; -var fails = require('../internals/fails'); -var getPrototypeOf = require('../internals/object-get-prototype-of'); -var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var has = require('../internals/has'); -var wellKnownSymbol = require('../internals/well-known-symbol'); -var IS_PURE = require('../internals/is-pure'); - -var ITERATOR = wellKnownSymbol('iterator'); -var BUGGY_SAFARI_ITERATORS = false; +var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype; +var create = require('../internals/object-create'); +var createPropertyDescriptor = require('../internals/create-property-descriptor'); +var setToStringTag = require('../internals/set-to-string-tag'); +var Iterators = require('../internals/iterators'); var returnThis = function () { return this; }; -// `%IteratorPrototype%` object -// https://tc39.es/ecma262/#sec-%iteratorprototype%-object -var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; - -/* eslint-disable es/no-array-prototype-keys -- safe */ -if ([].keys) { - arrayIterator = [].keys(); +module.exports = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { + var TO_STRING_TAG = NAME + ' Iterator'; + IteratorConstructor.prototype = create(IteratorPrototype, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) }); + setToStringTag(IteratorConstructor, TO_STRING_TAG, false, true); + Iterators[TO_STRING_TAG] = returnThis; + return IteratorConstructor; +}; + +},{"../internals/create-property-descriptor":146,"../internals/iterators":218,"../internals/iterators-core":217,"../internals/object-create":229,"../internals/set-to-string-tag":266}],216:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var call = require('../internals/function-call'); +var IS_PURE = require('../internals/is-pure'); +var FunctionName = require('../internals/function-name'); +var isCallable = require('../internals/is-callable'); +var createIteratorConstructor = require('../internals/iterator-create-constructor'); +var getPrototypeOf = require('../internals/object-get-prototype-of'); +var setPrototypeOf = require('../internals/object-set-prototype-of'); +var setToStringTag = require('../internals/set-to-string-tag'); +var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); +var defineBuiltIn = require('../internals/define-built-in'); +var wellKnownSymbol = require('../internals/well-known-symbol'); +var Iterators = require('../internals/iterators'); +var IteratorsCore = require('../internals/iterators-core'); + +var PROPER_FUNCTION_NAME = FunctionName.PROPER; +var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE; +var IteratorPrototype = IteratorsCore.IteratorPrototype; +var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS; +var ITERATOR = wellKnownSymbol('iterator'); +var KEYS = 'keys'; +var VALUES = 'values'; +var ENTRIES = 'entries'; + +var returnThis = function () { return this; }; + +module.exports = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { + createIteratorConstructor(IteratorConstructor, NAME, next); + + var getIterationMethod = function (KIND) { + if (KIND === DEFAULT && defaultIterator) return defaultIterator; + if (!BUGGY_SAFARI_ITERATORS && KIND && KIND in IterablePrototype) return IterablePrototype[KIND]; + + switch (KIND) { + case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; + case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; + case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; + } + + return function () { return new IteratorConstructor(this); }; + }; + + var TO_STRING_TAG = NAME + ' Iterator'; + var INCORRECT_VALUES_NAME = false; + var IterablePrototype = Iterable.prototype; + var nativeIterator = IterablePrototype[ITERATOR] + || IterablePrototype['@@iterator'] + || DEFAULT && IterablePrototype[DEFAULT]; + var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); + var anyNativeIterator = NAME === 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; + var CurrentIteratorPrototype, methods, KEY; + + // fix native + if (anyNativeIterator) { + CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable())); + if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { + if (!IS_PURE && getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) { + if (setPrototypeOf) { + setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype); + } else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) { + defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis); + } + } + // Set @@toStringTag to native iterators + setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true, true); + if (IS_PURE) Iterators[TO_STRING_TAG] = returnThis; + } + } + + // fix Array.prototype.{ values, @@iterator }.name in V8 / FF + if (PROPER_FUNCTION_NAME && DEFAULT === VALUES && nativeIterator && nativeIterator.name !== VALUES) { + if (!IS_PURE && CONFIGURABLE_FUNCTION_NAME) { + createNonEnumerableProperty(IterablePrototype, 'name', VALUES); + } else { + INCORRECT_VALUES_NAME = true; + defaultIterator = function values() { return call(nativeIterator, this); }; + } + } + + // export additional methods + if (DEFAULT) { + methods = { + values: getIterationMethod(VALUES), + keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), + entries: getIterationMethod(ENTRIES) + }; + if (FORCED) for (KEY in methods) { + if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { + defineBuiltIn(IterablePrototype, KEY, methods[KEY]); + } + } else $({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); + } + + // define iterator + if ((!IS_PURE || FORCED) && IterablePrototype[ITERATOR] !== defaultIterator) { + defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT }); + } + Iterators[NAME] = defaultIterator; + + return methods; +}; + +},{"../internals/create-non-enumerable-property":145,"../internals/define-built-in":149,"../internals/export":170,"../internals/function-call":177,"../internals/function-name":178,"../internals/is-callable":203,"../internals/is-pure":210,"../internals/iterator-create-constructor":215,"../internals/iterators":218,"../internals/iterators-core":217,"../internals/object-get-prototype-of":236,"../internals/object-set-prototype-of":242,"../internals/set-to-string-tag":266,"../internals/well-known-symbol":306}],217:[function(require,module,exports){ +'use strict'; +var fails = require('../internals/fails'); +var isCallable = require('../internals/is-callable'); +var isObject = require('../internals/is-object'); +var create = require('../internals/object-create'); +var getPrototypeOf = require('../internals/object-get-prototype-of'); +var defineBuiltIn = require('../internals/define-built-in'); +var wellKnownSymbol = require('../internals/well-known-symbol'); +var IS_PURE = require('../internals/is-pure'); + +var ITERATOR = wellKnownSymbol('iterator'); +var BUGGY_SAFARI_ITERATORS = false; + +// `%IteratorPrototype%` object +// https://tc39.es/ecma262/#sec-%iteratorprototype%-object +var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator; + +/* eslint-disable es/no-array-prototype-keys -- safe */ +if ([].keys) { + arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next` if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true; else { @@ -14462,18 +14675,21 @@ if ([].keys) { } } -var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () { +var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () { var test = {}; // FF44- legacy iterators case return IteratorPrototype[ITERATOR].call(test) !== test; }); if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {}; +else if (IS_PURE) IteratorPrototype = create(IteratorPrototype); // `%IteratorPrototype%[@@iterator]()` method // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator -if ((!IS_PURE || NEW_ITERATOR_PROTOTYPE) && !has(IteratorPrototype, ITERATOR)) { - createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis); +if (!isCallable(IteratorPrototype[ITERATOR])) { + defineBuiltIn(IteratorPrototype, ITERATOR, function () { + return this; + }); } module.exports = { @@ -14481,12 +14697,146 @@ module.exports = { BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS }; -},{"../internals/create-non-enumerable-property":120,"../internals/fails":140,"../internals/has":148,"../internals/is-pure":163,"../internals/object-get-prototype-of":184,"../internals/well-known-symbol":237}],169:[function(require,module,exports){ -arguments[4][149][0].apply(exports,arguments) -},{"dup":149}],170:[function(require,module,exports){ +},{"../internals/define-built-in":149,"../internals/fails":171,"../internals/is-callable":203,"../internals/is-object":208,"../internals/is-pure":210,"../internals/object-create":229,"../internals/object-get-prototype-of":236,"../internals/well-known-symbol":306}],218:[function(require,module,exports){ +arguments[4][190][0].apply(exports,arguments) +},{"dup":190}],219:[function(require,module,exports){ +'use strict'; +var toLength = require('../internals/to-length'); + +// `LengthOfArrayLike` abstract operation +// https://tc39.es/ecma262/#sec-lengthofarraylike +module.exports = function (obj) { + return toLength(obj.length); +}; + +},{"../internals/to-length":284}],220:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); +var fails = require('../internals/fails'); +var isCallable = require('../internals/is-callable'); +var hasOwn = require('../internals/has-own-property'); +var DESCRIPTORS = require('../internals/descriptors'); +var CONFIGURABLE_FUNCTION_NAME = require('../internals/function-name').CONFIGURABLE; +var inspectSource = require('../internals/inspect-source'); +var InternalStateModule = require('../internals/internal-state'); + +var enforceInternalState = InternalStateModule.enforce; +var getInternalState = InternalStateModule.get; +var $String = String; +// eslint-disable-next-line es/no-object-defineproperty -- safe +var defineProperty = Object.defineProperty; +var stringSlice = uncurryThis(''.slice); +var replace = uncurryThis(''.replace); +var join = uncurryThis([].join); + +var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () { + return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8; +}); + +var TEMPLATE = String(String).split('String'); + +var makeBuiltIn = module.exports = function (value, name, options) { + if (stringSlice($String(name), 0, 7) === 'Symbol(') { + name = '[' + replace($String(name), /^Symbol\(([^)]*)\)/, '$1') + ']'; + } + if (options && options.getter) name = 'get ' + name; + if (options && options.setter) name = 'set ' + name; + if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) { + if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true }); + else value.name = name; + } + if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) { + defineProperty(value, 'length', { value: options.arity }); + } + try { + if (options && hasOwn(options, 'constructor') && options.constructor) { + if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false }); + // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable + } else if (value.prototype) value.prototype = undefined; + } catch (error) { /* empty */ } + var state = enforceInternalState(value); + if (!hasOwn(state, 'source')) { + state.source = join(TEMPLATE, typeof name == 'string' ? name : ''); + } return value; +}; + +// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative +// eslint-disable-next-line no-extend-native -- required +Function.prototype.toString = makeBuiltIn(function toString() { + return isCallable(this) && getInternalState(this).source || inspectSource(this); +}, 'toString'); + +},{"../internals/descriptors":153,"../internals/fails":171,"../internals/function-name":178,"../internals/function-uncurry-this":181,"../internals/has-own-property":189,"../internals/inspect-source":197,"../internals/internal-state":199,"../internals/is-callable":203}],221:[function(require,module,exports){ +'use strict'; +var sign = require('../internals/math-sign'); + +var abs = Math.abs; + +var EPSILON = 2.220446049250313e-16; // Number.EPSILON +var INVERSE_EPSILON = 1 / EPSILON; + +var roundTiesToEven = function (n) { + return n + INVERSE_EPSILON - INVERSE_EPSILON; +}; + +module.exports = function (x, FLOAT_EPSILON, FLOAT_MAX_VALUE, FLOAT_MIN_VALUE) { + var n = +x; + var absolute = abs(n); + var s = sign(n); + if (absolute < FLOAT_MIN_VALUE) return s * roundTiesToEven(absolute / FLOAT_MIN_VALUE / FLOAT_EPSILON) * FLOAT_MIN_VALUE * FLOAT_EPSILON; + var a = (1 + FLOAT_EPSILON / EPSILON) * absolute; + var result = a - (a - absolute); + // eslint-disable-next-line no-self-compare -- NaN check + if (result > FLOAT_MAX_VALUE || result !== result) return s * Infinity; + return s * result; +}; + +},{"../internals/math-sign":223}],222:[function(require,module,exports){ +'use strict'; +var floatRound = require('../internals/math-float-round'); + +var FLOAT32_EPSILON = 1.1920928955078125e-7; // 2 ** -23; +var FLOAT32_MAX_VALUE = 3.4028234663852886e+38; // 2 ** 128 - 2 ** 104 +var FLOAT32_MIN_VALUE = 1.1754943508222875e-38; // 2 ** -126; + +// `Math.fround` method implementation +// https://tc39.es/ecma262/#sec-math.fround +// eslint-disable-next-line es/no-math-fround -- safe +module.exports = Math.fround || function fround(x) { + return floatRound(x, FLOAT32_EPSILON, FLOAT32_MAX_VALUE, FLOAT32_MIN_VALUE); +}; + +},{"../internals/math-float-round":221}],223:[function(require,module,exports){ +'use strict'; +// `Math.sign` method implementation +// https://tc39.es/ecma262/#sec-math.sign +// eslint-disable-next-line es/no-math-sign -- safe +module.exports = Math.sign || function sign(x) { + var n = +x; + // eslint-disable-next-line no-self-compare -- NaN check + return n === 0 || n !== n ? n : n < 0 ? -1 : 1; +}; + +},{}],224:[function(require,module,exports){ +'use strict'; +var ceil = Math.ceil; +var floor = Math.floor; + +// `Math.trunc` method +// https://tc39.es/ecma262/#sec-math.trunc +// eslint-disable-next-line es/no-math-trunc -- safe +module.exports = Math.trunc || function trunc(x) { + var n = +x; + return (n > 0 ? floor : ceil)(n); +}; + +},{}],225:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); -var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f; +var safeGetBuiltIn = require('../internals/safe-get-built-in'); +var bind = require('../internals/function-bind-context'); var macrotask = require('../internals/task').set; +var Queue = require('../internals/queue'); var IS_IOS = require('../internals/engine-is-ios'); var IS_IOS_PEBBLE = require('../internals/engine-is-ios-pebble'); var IS_WEBOS_WEBKIT = require('../internals/engine-is-webos-webkit'); @@ -14496,28 +14846,22 @@ var MutationObserver = global.MutationObserver || global.WebKitMutationObserver; var document = global.document; var process = global.process; var Promise = global.Promise; -// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask` -var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask'); -var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value; - -var flush, head, last, notify, toggle, node, promise, then; +var microtask = safeGetBuiltIn('queueMicrotask'); +var notify, toggle, node, promise, then; // modern engines have queueMicrotask method -if (!queueMicrotask) { - flush = function () { +if (!microtask) { + var queue = new Queue(); + + var flush = function () { var parent, fn; if (IS_NODE && (parent = process.domain)) parent.exit(); - while (head) { - fn = head.fn; - head = head.next; - try { - fn(); - } catch (error) { - if (head) notify(); - else last = undefined; - throw error; - } - } last = undefined; + while (fn = queue.get()) try { + fn(); + } catch (error) { + if (queue.head) notify(); + throw error; + } if (parent) parent.enter(); }; @@ -14536,9 +14880,9 @@ if (!queueMicrotask) { promise = Promise.resolve(undefined); // workaround of WebKit ~ iOS Safari 10.1 bug promise.constructor = Promise; - then = promise.then; + then = bind(promise.then, promise); notify = function () { - then.call(promise, flush); + then(flush); }; // Node.js without promises } else if (IS_NODE) { @@ -14548,67 +14892,40 @@ if (!queueMicrotask) { // for other environments - macrotask based on: // - setImmediate // - MessageChannel - // - window.postMessag + // - window.postMessage // - onreadystatechange // - setTimeout } else { + // `webpack` dev server bug on IE global methods - use bind(fn, global) + macrotask = bind(macrotask, global); notify = function () { - // strange IE + webpack dev server bug - use .call(global) - macrotask.call(global, flush); + macrotask(flush); }; } -} - -module.exports = queueMicrotask || function (fn) { - var task = { fn: fn, next: undefined }; - if (last) last.next = task; - if (!head) { - head = task; - notify(); - } last = task; -}; - -},{"../internals/engine-is-ios":132,"../internals/engine-is-ios-pebble":131,"../internals/engine-is-node":133,"../internals/engine-is-webos-webkit":134,"../internals/global":147,"../internals/object-get-own-property-descriptor":180,"../internals/task":216}],171:[function(require,module,exports){ -var global = require('../internals/global'); - -module.exports = global.Promise; - -},{"../internals/global":147}],172:[function(require,module,exports){ -/* eslint-disable es/no-symbol -- required for testing */ -var V8_VERSION = require('../internals/engine-v8-version'); -var fails = require('../internals/fails'); - -// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing -module.exports = !!Object.getOwnPropertySymbols && !fails(function () { - var symbol = Symbol(); - // Chrome 38 Symbol has incorrect toString conversion - // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances - return !String(symbol) || !(Object(symbol) instanceof Symbol) || - // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances - !Symbol.sham && V8_VERSION && V8_VERSION < 41; -}); - -},{"../internals/engine-v8-version":136,"../internals/fails":140}],173:[function(require,module,exports){ -var global = require('../internals/global'); -var inspectSource = require('../internals/inspect-source'); -var WeakMap = global.WeakMap; + microtask = function (fn) { + if (!queue.head) notify(); + queue.add(fn); + }; +} -module.exports = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap)); +module.exports = microtask; -},{"../internals/global":147,"../internals/inspect-source":156}],174:[function(require,module,exports){ +},{"../internals/engine-is-ios":163,"../internals/engine-is-ios-pebble":162,"../internals/engine-is-node":164,"../internals/engine-is-webos-webkit":165,"../internals/function-bind-context":175,"../internals/global":188,"../internals/queue":254,"../internals/safe-get-built-in":263,"../internals/task":277}],226:[function(require,module,exports){ 'use strict'; -var aFunction = require('../internals/a-function'); +var aCallable = require('../internals/a-callable'); + +var $TypeError = TypeError; var PromiseCapability = function (C) { var resolve, reject; this.promise = new C(function ($$resolve, $$reject) { - if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); + if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor'); resolve = $$resolve; reject = $$reject; }); - this.resolve = aFunction(resolve); - this.reject = aFunction(reject); + this.resolve = aCallable(resolve); + this.reject = aCallable(reject); }; // `NewPromiseCapability` abstract operation @@ -14617,18 +14934,23 @@ module.exports.f = function (C) { return new PromiseCapability(C); }; -},{"../internals/a-function":89}],175:[function(require,module,exports){ +},{"../internals/a-callable":108}],227:[function(require,module,exports){ +'use strict'; var isRegExp = require('../internals/is-regexp'); +var $TypeError = TypeError; + module.exports = function (it) { if (isRegExp(it)) { - throw TypeError("The method doesn't accept regular expressions"); + throw new $TypeError("The method doesn't accept regular expressions"); } return it; }; -},{"../internals/is-regexp":164}],176:[function(require,module,exports){ +},{"../internals/is-regexp":211}],228:[function(require,module,exports){ 'use strict'; var DESCRIPTORS = require('../internals/descriptors'); +var uncurryThis = require('../internals/function-uncurry-this'); +var call = require('../internals/function-call'); var fails = require('../internals/fails'); var objectKeys = require('../internals/object-keys'); var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols'); @@ -14640,6 +14962,7 @@ var IndexedObject = require('../internals/indexed-object'); var $assign = Object.assign; // eslint-disable-next-line es/no-object-defineproperty -- required for testing var defineProperty = Object.defineProperty; +var concat = uncurryThis([].concat); // `Object.assign` method // https://tc39.es/ecma262/#sec-object.assign @@ -14658,11 +14981,11 @@ module.exports = !$assign || fails(function () { var A = {}; var B = {}; // eslint-disable-next-line es/no-symbol -- safe - var symbol = Symbol(); + var symbol = Symbol('assign detection'); var alphabet = 'abcdefghijklmnopqrst'; A[symbol] = 7; alphabet.split('').forEach(function (chr) { B[chr] = chr; }); - return $assign({}, A)[symbol] != 7 || objectKeys($assign({}, B)).join('') != alphabet; + return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet; }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length` var T = toObject(target); var argumentsLength = arguments.length; @@ -14671,21 +14994,22 @@ module.exports = !$assign || fails(function () { var propertyIsEnumerable = propertyIsEnumerableModule.f; while (argumentsLength > index) { var S = IndexedObject(arguments[index++]); - var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S); + var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S); var length = keys.length; var j = 0; var key; while (length > j) { key = keys[j++]; - if (!DESCRIPTORS || propertyIsEnumerable.call(S, key)) T[key] = S[key]; + if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key]; } } return T; } : $assign; -},{"../internals/descriptors":125,"../internals/fails":140,"../internals/indexed-object":154,"../internals/object-get-own-property-symbols":183,"../internals/object-keys":186,"../internals/object-property-is-enumerable":187,"../internals/to-object":222}],177:[function(require,module,exports){ +},{"../internals/descriptors":153,"../internals/fails":171,"../internals/function-call":177,"../internals/function-uncurry-this":181,"../internals/indexed-object":195,"../internals/object-get-own-property-symbols":235,"../internals/object-keys":240,"../internals/object-property-is-enumerable":241,"../internals/to-object":285}],229:[function(require,module,exports){ +'use strict'; /* global ActiveXObject -- old IE, WSH */ var anObject = require('../internals/an-object'); -var defineProperties = require('../internals/object-define-properties'); +var definePropertiesModule = require('../internals/object-define-properties'); var enumBugKeys = require('../internals/enum-bug-keys'); var hiddenKeys = require('../internals/hidden-keys'); var html = require('../internals/html'); @@ -14754,6 +15078,7 @@ hiddenKeys[IE_PROTO] = true; // `Object.create` method // https://tc39.es/ecma262/#sec-object.create +// eslint-disable-next-line es/no-object-create -- safe module.exports = Object.create || function create(O, Properties) { var result; if (O !== null) { @@ -14763,58 +15088,87 @@ module.exports = Object.create || function create(O, Properties) { // add "__proto__" for Object.getPrototypeOf polyfill result[IE_PROTO] = O; } else result = NullProtoObject(); - return Properties === undefined ? result : defineProperties(result, Properties); + return Properties === undefined ? result : definePropertiesModule.f(result, Properties); }; -},{"../internals/an-object":94,"../internals/document-create-element":126,"../internals/enum-bug-keys":138,"../internals/hidden-keys":149,"../internals/html":151,"../internals/object-define-properties":178,"../internals/shared-key":209}],178:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/document-create-element":154,"../internals/enum-bug-keys":169,"../internals/hidden-keys":190,"../internals/html":192,"../internals/object-define-properties":230,"../internals/shared-key":267}],230:[function(require,module,exports){ +'use strict'; var DESCRIPTORS = require('../internals/descriptors'); +var V8_PROTOTYPE_DEFINE_BUG = require('../internals/v8-prototype-define-bug'); var definePropertyModule = require('../internals/object-define-property'); var anObject = require('../internals/an-object'); +var toIndexedObject = require('../internals/to-indexed-object'); var objectKeys = require('../internals/object-keys'); // `Object.defineProperties` method // https://tc39.es/ecma262/#sec-object.defineproperties // eslint-disable-next-line es/no-object-defineproperties -- safe -module.exports = DESCRIPTORS ? Object.defineProperties : function defineProperties(O, Properties) { +exports.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) { anObject(O); + var props = toIndexedObject(Properties); var keys = objectKeys(Properties); var length = keys.length; var index = 0; var key; - while (length > index) definePropertyModule.f(O, key = keys[index++], Properties[key]); + while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]); return O; }; -},{"../internals/an-object":94,"../internals/descriptors":125,"../internals/object-define-property":179,"../internals/object-keys":186}],179:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/descriptors":153,"../internals/object-define-property":231,"../internals/object-keys":240,"../internals/to-indexed-object":282,"../internals/v8-prototype-define-bug":301}],231:[function(require,module,exports){ +'use strict'; var DESCRIPTORS = require('../internals/descriptors'); var IE8_DOM_DEFINE = require('../internals/ie8-dom-define'); +var V8_PROTOTYPE_DEFINE_BUG = require('../internals/v8-prototype-define-bug'); var anObject = require('../internals/an-object'); var toPropertyKey = require('../internals/to-property-key'); +var $TypeError = TypeError; // eslint-disable-next-line es/no-object-defineproperty -- safe var $defineProperty = Object.defineProperty; +// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe +var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +var ENUMERABLE = 'enumerable'; +var CONFIGURABLE = 'configurable'; +var WRITABLE = 'writable'; // `Object.defineProperty` method // https://tc39.es/ecma262/#sec-object.defineproperty -exports.f = DESCRIPTORS ? $defineProperty : function defineProperty(O, P, Attributes) { +exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) { + anObject(O); + P = toPropertyKey(P); + anObject(Attributes); + if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { + var current = $getOwnPropertyDescriptor(O, P); + if (current && current[WRITABLE]) { + O[P] = Attributes.value; + Attributes = { + configurable: CONFIGURABLE in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE], + enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], + writable: false + }; + } + } return $defineProperty(O, P, Attributes); +} : $defineProperty : function defineProperty(O, P, Attributes) { anObject(O); P = toPropertyKey(P); anObject(Attributes); if (IE8_DOM_DEFINE) try { return $defineProperty(O, P, Attributes); } catch (error) { /* empty */ } - if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported'); + if ('get' in Attributes || 'set' in Attributes) throw new $TypeError('Accessors not supported'); if ('value' in Attributes) O[P] = Attributes.value; return O; }; -},{"../internals/an-object":94,"../internals/descriptors":125,"../internals/ie8-dom-define":152,"../internals/to-property-key":226}],180:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/descriptors":153,"../internals/ie8-dom-define":193,"../internals/to-property-key":289,"../internals/v8-prototype-define-bug":301}],232:[function(require,module,exports){ +'use strict'; var DESCRIPTORS = require('../internals/descriptors'); +var call = require('../internals/function-call'); var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable'); var createPropertyDescriptor = require('../internals/create-property-descriptor'); var toIndexedObject = require('../internals/to-indexed-object'); var toPropertyKey = require('../internals/to-property-key'); -var has = require('../internals/has'); +var hasOwn = require('../internals/has-own-property'); var IE8_DOM_DEFINE = require('../internals/ie8-dom-define'); // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe @@ -14828,15 +15182,16 @@ exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDes if (IE8_DOM_DEFINE) try { return $getOwnPropertyDescriptor(O, P); } catch (error) { /* empty */ } - if (has(O, P)) return createPropertyDescriptor(!propertyIsEnumerableModule.f.call(O, P), O[P]); + if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]); }; -},{"../internals/create-property-descriptor":121,"../internals/descriptors":125,"../internals/has":148,"../internals/ie8-dom-define":152,"../internals/object-property-is-enumerable":187,"../internals/to-indexed-object":219,"../internals/to-property-key":226}],181:[function(require,module,exports){ +},{"../internals/create-property-descriptor":146,"../internals/descriptors":153,"../internals/function-call":177,"../internals/has-own-property":189,"../internals/ie8-dom-define":193,"../internals/object-property-is-enumerable":241,"../internals/to-indexed-object":282,"../internals/to-property-key":289}],233:[function(require,module,exports){ +'use strict'; /* eslint-disable es/no-object-getownpropertynames -- safe */ +var classof = require('../internals/classof-raw'); var toIndexedObject = require('../internals/to-indexed-object'); var $getOwnPropertyNames = require('../internals/object-get-own-property-names').f; - -var toString = {}.toString; +var arraySlice = require('../internals/array-slice'); var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : []; @@ -14845,18 +15200,19 @@ var getWindowNames = function (it) { try { return $getOwnPropertyNames(it); } catch (error) { - return windowNames.slice(); + return arraySlice(windowNames); } }; // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window module.exports.f = function getOwnPropertyNames(it) { - return windowNames && toString.call(it) == '[object Window]' + return windowNames && classof(it) === 'Window' ? getWindowNames(it) : $getOwnPropertyNames(toIndexedObject(it)); }; -},{"../internals/object-get-own-property-names":182,"../internals/to-indexed-object":219}],182:[function(require,module,exports){ +},{"../internals/array-slice":131,"../internals/classof-raw":137,"../internals/object-get-own-property-names":234,"../internals/to-indexed-object":282}],234:[function(require,module,exports){ +'use strict'; var internalObjectKeys = require('../internals/object-keys-internal'); var enumBugKeys = require('../internals/enum-bug-keys'); @@ -14869,50 +15225,85 @@ exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { return internalObjectKeys(O, hiddenKeys); }; -},{"../internals/enum-bug-keys":138,"../internals/object-keys-internal":185}],183:[function(require,module,exports){ +},{"../internals/enum-bug-keys":169,"../internals/object-keys-internal":239}],235:[function(require,module,exports){ +'use strict'; // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe exports.f = Object.getOwnPropertySymbols; -},{}],184:[function(require,module,exports){ -var has = require('../internals/has'); +},{}],236:[function(require,module,exports){ +'use strict'; +var hasOwn = require('../internals/has-own-property'); +var isCallable = require('../internals/is-callable'); var toObject = require('../internals/to-object'); var sharedKey = require('../internals/shared-key'); var CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter'); var IE_PROTO = sharedKey('IE_PROTO'); -var ObjectPrototype = Object.prototype; +var $Object = Object; +var ObjectPrototype = $Object.prototype; // `Object.getPrototypeOf` method // https://tc39.es/ecma262/#sec-object.getprototypeof // eslint-disable-next-line es/no-object-getprototypeof -- safe -module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) { - O = toObject(O); - if (has(O, IE_PROTO)) return O[IE_PROTO]; - if (typeof O.constructor == 'function' && O instanceof O.constructor) { - return O.constructor.prototype; - } return O instanceof Object ? ObjectPrototype : null; +module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) { + var object = toObject(O); + if (hasOwn(object, IE_PROTO)) return object[IE_PROTO]; + var constructor = object.constructor; + if (isCallable(constructor) && object instanceof constructor) { + return constructor.prototype; + } return object instanceof $Object ? ObjectPrototype : null; }; -},{"../internals/correct-prototype-getter":118,"../internals/has":148,"../internals/shared-key":209,"../internals/to-object":222}],185:[function(require,module,exports){ -var has = require('../internals/has'); +},{"../internals/correct-prototype-getter":143,"../internals/has-own-property":189,"../internals/is-callable":203,"../internals/shared-key":267,"../internals/to-object":285}],237:[function(require,module,exports){ +'use strict'; +var fails = require('../internals/fails'); +var isObject = require('../internals/is-object'); +var classof = require('../internals/classof-raw'); +var ARRAY_BUFFER_NON_EXTENSIBLE = require('../internals/array-buffer-non-extensible'); + +// eslint-disable-next-line es/no-object-isextensible -- safe +var $isExtensible = Object.isExtensible; +var FAILS_ON_PRIMITIVES = fails(function () { $isExtensible(1); }); + +// `Object.isExtensible` method +// https://tc39.es/ecma262/#sec-object.isextensible +module.exports = (FAILS_ON_PRIMITIVES || ARRAY_BUFFER_NON_EXTENSIBLE) ? function isExtensible(it) { + if (!isObject(it)) return false; + if (ARRAY_BUFFER_NON_EXTENSIBLE && classof(it) === 'ArrayBuffer') return false; + return $isExtensible ? $isExtensible(it) : true; +} : $isExtensible; + +},{"../internals/array-buffer-non-extensible":116,"../internals/classof-raw":137,"../internals/fails":171,"../internals/is-object":208}],238:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); + +module.exports = uncurryThis({}.isPrototypeOf); + +},{"../internals/function-uncurry-this":181}],239:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); +var hasOwn = require('../internals/has-own-property'); var toIndexedObject = require('../internals/to-indexed-object'); var indexOf = require('../internals/array-includes').indexOf; var hiddenKeys = require('../internals/hidden-keys'); +var push = uncurryThis([].push); + module.exports = function (object, names) { var O = toIndexedObject(object); var i = 0; var result = []; var key; - for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key); + for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key); // Don't enum bug & hidden keys - while (names.length > i) if (has(O, key = names[i++])) { - ~indexOf(result, key) || result.push(key); + while (names.length > i) if (hasOwn(O, key = names[i++])) { + ~indexOf(result, key) || push(result, key); } return result; }; -},{"../internals/array-includes":103,"../internals/has":148,"../internals/hidden-keys":149,"../internals/to-indexed-object":219}],186:[function(require,module,exports){ +},{"../internals/array-includes":124,"../internals/function-uncurry-this":181,"../internals/has-own-property":189,"../internals/hidden-keys":190,"../internals/to-indexed-object":282}],240:[function(require,module,exports){ +'use strict'; var internalObjectKeys = require('../internals/object-keys-internal'); var enumBugKeys = require('../internals/enum-bug-keys'); @@ -14923,7 +15314,7 @@ module.exports = Object.keys || function keys(O) { return internalObjectKeys(O, enumBugKeys); }; -},{"../internals/enum-bug-keys":138,"../internals/object-keys-internal":185}],187:[function(require,module,exports){ +},{"../internals/enum-bug-keys":169,"../internals/object-keys-internal":239}],241:[function(require,module,exports){ 'use strict'; var $propertyIsEnumerable = {}.propertyIsEnumerable; // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe @@ -14939,8 +15330,10 @@ exports.f = NASHORN_BUG ? function propertyIsEnumerable(V) { return !!descriptor && descriptor.enumerable; } : $propertyIsEnumerable; -},{}],188:[function(require,module,exports){ +},{}],242:[function(require,module,exports){ +'use strict'; /* eslint-disable no-proto -- safe */ +var uncurryThisAccessor = require('../internals/function-uncurry-this-accessor'); var anObject = require('../internals/an-object'); var aPossiblePrototype = require('../internals/a-possible-prototype'); @@ -14953,39 +15346,55 @@ module.exports = Object.setPrototypeOf || ('__proto__' in {} ? function () { var test = {}; var setter; try { - // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe - setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set; - setter.call(test, []); + setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set'); + setter(test, []); CORRECT_SETTER = test instanceof Array; } catch (error) { /* empty */ } return function setPrototypeOf(O, proto) { anObject(O); aPossiblePrototype(proto); - if (CORRECT_SETTER) setter.call(O, proto); + if (CORRECT_SETTER) setter(O, proto); else O.__proto__ = proto; return O; }; }() : undefined); -},{"../internals/a-possible-prototype":90,"../internals/an-object":94}],189:[function(require,module,exports){ +},{"../internals/a-possible-prototype":110,"../internals/an-object":114,"../internals/function-uncurry-this-accessor":179}],243:[function(require,module,exports){ +'use strict'; var DESCRIPTORS = require('../internals/descriptors'); +var fails = require('../internals/fails'); +var uncurryThis = require('../internals/function-uncurry-this'); +var objectGetPrototypeOf = require('../internals/object-get-prototype-of'); var objectKeys = require('../internals/object-keys'); var toIndexedObject = require('../internals/to-indexed-object'); -var propertyIsEnumerable = require('../internals/object-property-is-enumerable').f; +var $propertyIsEnumerable = require('../internals/object-property-is-enumerable').f; + +var propertyIsEnumerable = uncurryThis($propertyIsEnumerable); +var push = uncurryThis([].push); + +// in some IE versions, `propertyIsEnumerable` returns incorrect result on integer keys +// of `null` prototype objects +var IE_BUG = DESCRIPTORS && fails(function () { + // eslint-disable-next-line es/no-object-create -- safe + var O = Object.create(null); + O[2] = 2; + return !propertyIsEnumerable(O, 2); +}); // `Object.{ entries, values }` methods implementation var createMethod = function (TO_ENTRIES) { return function (it) { var O = toIndexedObject(it); var keys = objectKeys(O); + var IE_WORKAROUND = IE_BUG && objectGetPrototypeOf(O) === null; var length = keys.length; var i = 0; var result = []; var key; while (length > i) { key = keys[i++]; - if (!DESCRIPTORS || propertyIsEnumerable.call(O, key)) { - result.push(TO_ENTRIES ? [key, O[key]] : O[key]); + if (!DESCRIPTORS || (IE_WORKAROUND ? key in O : propertyIsEnumerable(O, key))) { + push(result, TO_ENTRIES ? [key, O[key]] : O[key]); } } return result; @@ -15001,7 +15410,7 @@ module.exports = { values: createMethod(false) }; -},{"../internals/descriptors":125,"../internals/object-keys":186,"../internals/object-property-is-enumerable":187,"../internals/to-indexed-object":219}],190:[function(require,module,exports){ +},{"../internals/descriptors":153,"../internals/fails":171,"../internals/function-uncurry-this":181,"../internals/object-get-prototype-of":236,"../internals/object-keys":240,"../internals/object-property-is-enumerable":241,"../internals/to-indexed-object":282}],244:[function(require,module,exports){ 'use strict'; var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support'); var classof = require('../internals/classof'); @@ -15012,38 +15421,49 @@ module.exports = TO_STRING_TAG_SUPPORT ? {}.toString : function toString() { return '[object ' + classof(this) + ']'; }; -},{"../internals/classof":115,"../internals/to-string-tag-support":227}],191:[function(require,module,exports){ +},{"../internals/classof":138,"../internals/to-string-tag-support":290}],245:[function(require,module,exports){ +'use strict'; +var call = require('../internals/function-call'); +var isCallable = require('../internals/is-callable'); var isObject = require('../internals/is-object'); +var $TypeError = TypeError; + // `OrdinaryToPrimitive` abstract operation // https://tc39.es/ecma262/#sec-ordinarytoprimitive module.exports = function (input, pref) { var fn, val; - if (pref === 'string' && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val; - if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val; - if (pref !== 'string' && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val; - throw TypeError("Can't convert object to primitive value"); + if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; + if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val; + if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; + throw new $TypeError("Can't convert object to primitive value"); }; -},{"../internals/is-object":162}],192:[function(require,module,exports){ +},{"../internals/function-call":177,"../internals/is-callable":203,"../internals/is-object":208}],246:[function(require,module,exports){ +'use strict'; var getBuiltIn = require('../internals/get-built-in'); +var uncurryThis = require('../internals/function-uncurry-this'); var getOwnPropertyNamesModule = require('../internals/object-get-own-property-names'); var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols'); var anObject = require('../internals/an-object'); +var concat = uncurryThis([].concat); + // all object keys, includes non-enumerable and symbols module.exports = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { var keys = getOwnPropertyNamesModule.f(anObject(it)); var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; - return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys; + return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; }; -},{"../internals/an-object":94,"../internals/get-built-in":143,"../internals/object-get-own-property-names":182,"../internals/object-get-own-property-symbols":183}],193:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/function-uncurry-this":181,"../internals/get-built-in":182,"../internals/object-get-own-property-names":234,"../internals/object-get-own-property-symbols":235}],247:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); module.exports = global; -},{"../internals/global":147}],194:[function(require,module,exports){ +},{"../internals/global":188}],248:[function(require,module,exports){ +'use strict'; module.exports = function (exec) { try { return { error: false, value: exec() }; @@ -15052,98 +15472,155 @@ module.exports = function (exec) { } }; -},{}],195:[function(require,module,exports){ -var anObject = require('../internals/an-object'); -var isObject = require('../internals/is-object'); -var newPromiseCapability = require('../internals/new-promise-capability'); - -module.exports = function (C, x) { - anObject(C); - if (isObject(x) && x.constructor === C) return x; +},{}],249:[function(require,module,exports){ +'use strict'; +var global = require('../internals/global'); +var NativePromiseConstructor = require('../internals/promise-native-constructor'); +var isCallable = require('../internals/is-callable'); +var isForced = require('../internals/is-forced'); +var inspectSource = require('../internals/inspect-source'); +var wellKnownSymbol = require('../internals/well-known-symbol'); +var IS_BROWSER = require('../internals/engine-is-browser'); +var IS_DENO = require('../internals/engine-is-deno'); +var IS_PURE = require('../internals/is-pure'); +var V8_VERSION = require('../internals/engine-v8-version'); + +var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype; +var SPECIES = wellKnownSymbol('species'); +var SUBCLASSING = false; +var NATIVE_PROMISE_REJECTION_EVENT = isCallable(global.PromiseRejectionEvent); + +var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () { + var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor); + var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor); + // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables + // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 + // We can't detect it synchronously, so just check versions + if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true; + // We need Promise#{ catch, finally } in the pure version for preventing prototype pollution + if (IS_PURE && !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true; + // We can't use @@species feature detection in V8 since it causes + // deoptimization and performance degradation + // https://github.com/zloirock/core-js/issues/679 + if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) { + // Detect correctness of subclassing with @@species support + var promise = new NativePromiseConstructor(function (resolve) { resolve(1); }); + var FakePromise = function (exec) { + exec(function () { /* empty */ }, function () { /* empty */ }); + }; + var constructor = promise.constructor = {}; + constructor[SPECIES] = FakePromise; + SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise; + if (!SUBCLASSING) return true; + // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test + } return !GLOBAL_CORE_JS_PROMISE && (IS_BROWSER || IS_DENO) && !NATIVE_PROMISE_REJECTION_EVENT; +}); + +module.exports = { + CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR, + REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT, + SUBCLASSING: SUBCLASSING +}; + +},{"../internals/engine-is-browser":159,"../internals/engine-is-deno":160,"../internals/engine-v8-version":167,"../internals/global":188,"../internals/inspect-source":197,"../internals/is-callable":203,"../internals/is-forced":205,"../internals/is-pure":210,"../internals/promise-native-constructor":250,"../internals/well-known-symbol":306}],250:[function(require,module,exports){ +'use strict'; +var global = require('../internals/global'); + +module.exports = global.Promise; + +},{"../internals/global":188}],251:[function(require,module,exports){ +'use strict'; +var anObject = require('../internals/an-object'); +var isObject = require('../internals/is-object'); +var newPromiseCapability = require('../internals/new-promise-capability'); + +module.exports = function (C, x) { + anObject(C); + if (isObject(x) && x.constructor === C) return x; var promiseCapability = newPromiseCapability.f(C); var resolve = promiseCapability.resolve; resolve(x); return promiseCapability.promise; }; -},{"../internals/an-object":94,"../internals/is-object":162,"../internals/new-promise-capability":174}],196:[function(require,module,exports){ -var redefine = require('../internals/redefine'); +},{"../internals/an-object":114,"../internals/is-object":208,"../internals/new-promise-capability":226}],252:[function(require,module,exports){ +'use strict'; +var NativePromiseConstructor = require('../internals/promise-native-constructor'); +var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration'); +var FORCED_PROMISE_CONSTRUCTOR = require('../internals/promise-constructor-detection').CONSTRUCTOR; -module.exports = function (target, src, options) { - for (var key in src) redefine(target, key, src[key], options); - return target; -}; +module.exports = FORCED_PROMISE_CONSTRUCTOR || !checkCorrectnessOfIteration(function (iterable) { + NativePromiseConstructor.all(iterable).then(undefined, function () { /* empty */ }); +}); -},{"../internals/redefine":197}],197:[function(require,module,exports){ -var global = require('../internals/global'); -var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var has = require('../internals/has'); -var setGlobal = require('../internals/set-global'); -var inspectSource = require('../internals/inspect-source'); -var InternalStateModule = require('../internals/internal-state'); +},{"../internals/check-correctness-of-iteration":136,"../internals/promise-constructor-detection":249,"../internals/promise-native-constructor":250}],253:[function(require,module,exports){ +'use strict'; +var defineProperty = require('../internals/object-define-property').f; -var getInternalState = InternalStateModule.get; -var enforceInternalState = InternalStateModule.enforce; -var TEMPLATE = String(String).split('String'); +module.exports = function (Target, Source, key) { + key in Target || defineProperty(Target, key, { + configurable: true, + get: function () { return Source[key]; }, + set: function (it) { Source[key] = it; } + }); +}; -(module.exports = function (O, key, value, options) { - var unsafe = options ? !!options.unsafe : false; - var simple = options ? !!options.enumerable : false; - var noTargetGet = options ? !!options.noTargetGet : false; - var state; - if (typeof value == 'function') { - if (typeof key == 'string' && !has(value, 'name')) { - createNonEnumerableProperty(value, 'name', key); - } - state = enforceInternalState(value); - if (!state.source) { - state.source = TEMPLATE.join(typeof key == 'string' ? key : ''); +},{"../internals/object-define-property":231}],254:[function(require,module,exports){ +'use strict'; +var Queue = function () { + this.head = null; + this.tail = null; +}; + +Queue.prototype = { + add: function (item) { + var entry = { item: item, next: null }; + var tail = this.tail; + if (tail) tail.next = entry; + else this.head = entry; + this.tail = entry; + }, + get: function () { + var entry = this.head; + if (entry) { + var next = this.head = entry.next; + if (next === null) this.tail = null; + return entry.item; } } - if (O === global) { - if (simple) O[key] = value; - else setGlobal(key, value); - return; - } else if (!unsafe) { - delete O[key]; - } else if (!noTargetGet && O[key]) { - simple = true; - } - if (simple) O[key] = value; - else createNonEnumerableProperty(O, key, value); -// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative -})(Function.prototype, 'toString', function toString() { - return typeof this == 'function' && getInternalState(this).source || inspectSource(this); -}); +}; + +module.exports = Queue; + +},{}],255:[function(require,module,exports){ +'use strict'; +var call = require('../internals/function-call'); +var anObject = require('../internals/an-object'); +var isCallable = require('../internals/is-callable'); +var classof = require('../internals/classof-raw'); +var regexpExec = require('../internals/regexp-exec'); -},{"../internals/create-non-enumerable-property":120,"../internals/global":147,"../internals/has":148,"../internals/inspect-source":156,"../internals/internal-state":157,"../internals/set-global":206}],198:[function(require,module,exports){ -var classof = require('./classof-raw'); -var regexpExec = require('./regexp-exec'); +var $TypeError = TypeError; // `RegExpExec` abstract operation // https://tc39.es/ecma262/#sec-regexpexec module.exports = function (R, S) { var exec = R.exec; - if (typeof exec === 'function') { - var result = exec.call(R, S); - if (typeof result !== 'object') { - throw TypeError('RegExp exec method returned something other than an Object or null'); - } + if (isCallable(exec)) { + var result = call(exec, R, S); + if (result !== null) anObject(result); return result; } - - if (classof(R) !== 'RegExp') { - throw TypeError('RegExp#exec called on incompatible receiver'); - } - - return regexpExec.call(R, S); + if (classof(R) === 'RegExp') return call(regexpExec, R, S); + throw new $TypeError('RegExp#exec called on incompatible receiver'); }; - -},{"./classof-raw":114,"./regexp-exec":199}],199:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/classof-raw":137,"../internals/function-call":177,"../internals/is-callable":203,"../internals/regexp-exec":256}],256:[function(require,module,exports){ 'use strict'; /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ /* eslint-disable regexp/no-useless-quantifier -- testing */ +var call = require('../internals/function-call'); +var uncurryThis = require('../internals/function-uncurry-this'); var toString = require('../internals/to-string'); var regexpFlags = require('../internals/regexp-flags'); var stickyHelpers = require('../internals/regexp-sticky-helpers'); @@ -15153,20 +15630,23 @@ var getInternalState = require('../internals/internal-state').get; var UNSUPPORTED_DOT_ALL = require('../internals/regexp-unsupported-dot-all'); var UNSUPPORTED_NCG = require('../internals/regexp-unsupported-ncg'); -var nativeExec = RegExp.prototype.exec; var nativeReplace = shared('native-string-replace', String.prototype.replace); - +var nativeExec = RegExp.prototype.exec; var patchedExec = nativeExec; +var charAt = uncurryThis(''.charAt); +var indexOf = uncurryThis(''.indexOf); +var replace = uncurryThis(''.replace); +var stringSlice = uncurryThis(''.slice); var UPDATES_LAST_INDEX_WRONG = (function () { var re1 = /a/; var re2 = /b*/g; - nativeExec.call(re1, 'a'); - nativeExec.call(re2, 'a'); + call(nativeExec, re1, 'a'); + call(nativeExec, re2, 'a'); return re1.lastIndex !== 0 || re2.lastIndex !== 0; })(); -var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET; +var UNSUPPORTED_Y = stickyHelpers.BROKEN_CARET; // nonparticipating capturing group, copied from es5-shim's String#split patch. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; @@ -15174,7 +15654,6 @@ var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG; if (PATCH) { - // eslint-disable-next-line max-statements -- TODO patchedExec = function exec(string) { var re = this; var state = getInternalState(re); @@ -15184,27 +15663,27 @@ if (PATCH) { if (raw) { raw.lastIndex = re.lastIndex; - result = patchedExec.call(raw, str); + result = call(patchedExec, raw, str); re.lastIndex = raw.lastIndex; return result; } var groups = state.groups; var sticky = UNSUPPORTED_Y && re.sticky; - var flags = regexpFlags.call(re); + var flags = call(regexpFlags, re); var source = re.source; var charsAdded = 0; var strCopy = str; if (sticky) { - flags = flags.replace('y', ''); - if (flags.indexOf('g') === -1) { + flags = replace(flags, 'y', ''); + if (indexOf(flags, 'g') === -1) { flags += 'g'; } - strCopy = str.slice(re.lastIndex); + strCopy = stringSlice(str, re.lastIndex); // Support anchored sticky behavior. - if (re.lastIndex > 0 && (!re.multiline || re.multiline && str.charAt(re.lastIndex - 1) !== '\n')) { + if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt(str, re.lastIndex - 1) !== '\n')) { source = '(?: ' + source + ')'; strCopy = ' ' + strCopy; charsAdded++; @@ -15219,12 +15698,12 @@ if (PATCH) { } if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; - match = nativeExec.call(sticky ? reCopy : re, strCopy); + match = call(nativeExec, sticky ? reCopy : re, strCopy); if (sticky) { if (match) { - match.input = match.input.slice(charsAdded); - match[0] = match[0].slice(charsAdded); + match.input = stringSlice(match.input, charsAdded); + match[0] = stringSlice(match[0], charsAdded); match.index = re.lastIndex; re.lastIndex += match[0].length; } else re.lastIndex = 0; @@ -15233,8 +15712,8 @@ if (PATCH) { } if (NPCG_INCLUDED && match && match.length > 1) { // Fix browsers whose `exec` methods don't consistently return `undefined` - // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/ - nativeReplace.call(match[0], reCopy, function () { + // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/ + call(nativeReplace, match[0], reCopy, function () { for (i = 1; i < arguments.length - 2; i++) { if (arguments[i] === undefined) match[i] = undefined; } @@ -15255,7 +15734,7 @@ if (PATCH) { module.exports = patchedExec; -},{"../internals/internal-state":157,"../internals/object-create":177,"../internals/regexp-flags":200,"../internals/regexp-sticky-helpers":201,"../internals/regexp-unsupported-dot-all":202,"../internals/regexp-unsupported-ncg":203,"../internals/shared":211,"../internals/to-string":228}],200:[function(require,module,exports){ +},{"../internals/function-call":177,"../internals/function-uncurry-this":181,"../internals/internal-state":199,"../internals/object-create":229,"../internals/regexp-flags":257,"../internals/regexp-sticky-helpers":259,"../internals/regexp-unsupported-dot-all":260,"../internals/regexp-unsupported-ncg":261,"../internals/shared":269,"../internals/to-string":291}],257:[function(require,module,exports){ 'use strict'; var anObject = require('../internals/an-object'); @@ -15264,37 +15743,68 @@ var anObject = require('../internals/an-object'); module.exports = function () { var that = anObject(this); var result = ''; + if (that.hasIndices) result += 'd'; if (that.global) result += 'g'; if (that.ignoreCase) result += 'i'; if (that.multiline) result += 'm'; if (that.dotAll) result += 's'; if (that.unicode) result += 'u'; + if (that.unicodeSets) result += 'v'; if (that.sticky) result += 'y'; return result; }; -},{"../internals/an-object":94}],201:[function(require,module,exports){ +},{"../internals/an-object":114}],258:[function(require,module,exports){ +'use strict'; +var call = require('../internals/function-call'); +var hasOwn = require('../internals/has-own-property'); +var isPrototypeOf = require('../internals/object-is-prototype-of'); +var regExpFlags = require('../internals/regexp-flags'); + +var RegExpPrototype = RegExp.prototype; + +module.exports = function (R) { + var flags = R.flags; + return flags === undefined && !('flags' in RegExpPrototype) && !hasOwn(R, 'flags') && isPrototypeOf(RegExpPrototype, R) + ? call(regExpFlags, R) : flags; +}; + +},{"../internals/function-call":177,"../internals/has-own-property":189,"../internals/object-is-prototype-of":238,"../internals/regexp-flags":257}],259:[function(require,module,exports){ +'use strict'; var fails = require('../internals/fails'); var global = require('../internals/global'); // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError var $RegExp = global.RegExp; -exports.UNSUPPORTED_Y = fails(function () { +var UNSUPPORTED_Y = fails(function () { var re = $RegExp('a', 'y'); re.lastIndex = 2; - return re.exec('abcd') != null; + return re.exec('abcd') !== null; +}); + +// UC Browser bug +// https://github.com/zloirock/core-js/issues/1008 +var MISSED_STICKY = UNSUPPORTED_Y || fails(function () { + return !$RegExp('a', 'y').sticky; }); -exports.BROKEN_CARET = fails(function () { +var BROKEN_CARET = UNSUPPORTED_Y || fails(function () { // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 var re = $RegExp('^r', 'gy'); re.lastIndex = 2; - return re.exec('str') != null; + return re.exec('str') !== null; }); -},{"../internals/fails":140,"../internals/global":147}],202:[function(require,module,exports){ -var fails = require('./fails'); +module.exports = { + BROKEN_CARET: BROKEN_CARET, + MISSED_STICKY: MISSED_STICKY, + UNSUPPORTED_Y: UNSUPPORTED_Y +}; + +},{"../internals/fails":171,"../internals/global":188}],260:[function(require,module,exports){ +'use strict'; +var fails = require('../internals/fails'); var global = require('../internals/global'); // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError @@ -15302,11 +15812,12 @@ var $RegExp = global.RegExp; module.exports = fails(function () { var re = $RegExp('.', 's'); - return !(re.dotAll && re.exec('\n') && re.flags === 's'); + return !(re.dotAll && re.test('\n') && re.flags === 's'); }); -},{"../internals/global":147,"./fails":140}],203:[function(require,module,exports){ -var fails = require('./fails'); +},{"../internals/fails":171,"../internals/global":188}],261:[function(require,module,exports){ +'use strict'; +var fails = require('../internals/fails'); var global = require('../internals/global'); // babel-minify and Closure Compiler transpiles RegExp('(?b)', 'g') -> /(?b)/g and it causes SyntaxError @@ -15318,39 +15829,48 @@ module.exports = fails(function () { 'b'.replace(re, '$c') !== 'bc'; }); -},{"../internals/global":147,"./fails":140}],204:[function(require,module,exports){ +},{"../internals/fails":171,"../internals/global":188}],262:[function(require,module,exports){ +'use strict'; +var isNullOrUndefined = require('../internals/is-null-or-undefined'); + +var $TypeError = TypeError; + // `RequireObjectCoercible` abstract operation // https://tc39.es/ecma262/#sec-requireobjectcoercible module.exports = function (it) { - if (it == undefined) throw TypeError("Can't call method on " + it); + if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it); return it; }; -},{}],205:[function(require,module,exports){ +},{"../internals/is-null-or-undefined":207}],263:[function(require,module,exports){ +'use strict'; +var global = require('../internals/global'); +var DESCRIPTORS = require('../internals/descriptors'); + +// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe +var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + +// Avoid NodeJS experimental warning +module.exports = function (name) { + if (!DESCRIPTORS) return global[name]; + var descriptor = getOwnPropertyDescriptor(global, name); + return descriptor && descriptor.value; +}; + +},{"../internals/descriptors":153,"../internals/global":188}],264:[function(require,module,exports){ +'use strict'; // `SameValue` abstract operation // https://tc39.es/ecma262/#sec-samevalue // eslint-disable-next-line es/no-object-is -- safe module.exports = Object.is || function is(x, y) { // eslint-disable-next-line no-self-compare -- NaN check - return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; -}; - -},{}],206:[function(require,module,exports){ -var global = require('../internals/global'); - -module.exports = function (key, value) { - try { - // eslint-disable-next-line es/no-object-defineproperty -- safe - Object.defineProperty(global, key, { value: value, configurable: true, writable: true }); - } catch (error) { - global[key] = value; - } return value; + return x === y ? x !== 0 || 1 / x === 1 / y : x !== x && y !== y; }; -},{"../internals/global":147}],207:[function(require,module,exports){ +},{}],265:[function(require,module,exports){ 'use strict'; var getBuiltIn = require('../internals/get-built-in'); -var definePropertyModule = require('../internals/object-define-property'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var wellKnownSymbol = require('../internals/well-known-symbol'); var DESCRIPTORS = require('../internals/descriptors'); @@ -15358,30 +15878,32 @@ var SPECIES = wellKnownSymbol('species'); module.exports = function (CONSTRUCTOR_NAME) { var Constructor = getBuiltIn(CONSTRUCTOR_NAME); - var defineProperty = definePropertyModule.f; if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) { - defineProperty(Constructor, SPECIES, { + defineBuiltInAccessor(Constructor, SPECIES, { configurable: true, get: function () { return this; } }); } }; -},{"../internals/descriptors":125,"../internals/get-built-in":143,"../internals/object-define-property":179,"../internals/well-known-symbol":237}],208:[function(require,module,exports){ +},{"../internals/define-built-in-accessor":148,"../internals/descriptors":153,"../internals/get-built-in":182,"../internals/well-known-symbol":306}],266:[function(require,module,exports){ +'use strict'; var defineProperty = require('../internals/object-define-property').f; -var has = require('../internals/has'); +var hasOwn = require('../internals/has-own-property'); var wellKnownSymbol = require('../internals/well-known-symbol'); var TO_STRING_TAG = wellKnownSymbol('toStringTag'); -module.exports = function (it, TAG, STATIC) { - if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) { - defineProperty(it, TO_STRING_TAG, { configurable: true, value: TAG }); +module.exports = function (target, TAG, STATIC) { + if (target && !STATIC) target = target.prototype; + if (target && !hasOwn(target, TO_STRING_TAG)) { + defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG }); } }; -},{"../internals/has":148,"../internals/object-define-property":179,"../internals/well-known-symbol":237}],209:[function(require,module,exports){ +},{"../internals/has-own-property":189,"../internals/object-define-property":231,"../internals/well-known-symbol":306}],267:[function(require,module,exports){ +'use strict'; var shared = require('../internals/shared'); var uid = require('../internals/uid'); @@ -15391,30 +15913,36 @@ module.exports = function (key) { return keys[key] || (keys[key] = uid(key)); }; -},{"../internals/shared":211,"../internals/uid":234}],210:[function(require,module,exports){ +},{"../internals/shared":269,"../internals/uid":299}],268:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); -var setGlobal = require('../internals/set-global'); +var defineGlobalProperty = require('../internals/define-global-property'); var SHARED = '__core-js_shared__'; -var store = global[SHARED] || setGlobal(SHARED, {}); +var store = global[SHARED] || defineGlobalProperty(SHARED, {}); module.exports = store; -},{"../internals/global":147,"../internals/set-global":206}],211:[function(require,module,exports){ +},{"../internals/define-global-property":151,"../internals/global":188}],269:[function(require,module,exports){ +'use strict'; var IS_PURE = require('../internals/is-pure'); var store = require('../internals/shared-store'); (module.exports = function (key, value) { return store[key] || (store[key] = value !== undefined ? value : {}); })('versions', []).push({ - version: '3.17.2', + version: '3.35.0', mode: IS_PURE ? 'pure' : 'global', - copyright: '© 2021 Denis Pushkarev (zloirock.ru)' + copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)', + license: 'https://github.com/zloirock/core-js/blob/v3.35.0/LICENSE', + source: 'https://github.com/zloirock/core-js' }); -},{"../internals/is-pure":163,"../internals/shared-store":210}],212:[function(require,module,exports){ +},{"../internals/is-pure":210,"../internals/shared-store":268}],270:[function(require,module,exports){ +'use strict'; var anObject = require('../internals/an-object'); -var aFunction = require('../internals/a-function'); +var aConstructor = require('../internals/a-constructor'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); var wellKnownSymbol = require('../internals/well-known-symbol'); var SPECIES = wellKnownSymbol('species'); @@ -15424,27 +15952,36 @@ var SPECIES = wellKnownSymbol('species'); module.exports = function (O, defaultConstructor) { var C = anObject(O).constructor; var S; - return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? defaultConstructor : aFunction(S); + return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S); }; -},{"../internals/a-function":89,"../internals/an-object":94,"../internals/well-known-symbol":237}],213:[function(require,module,exports){ -var toInteger = require('../internals/to-integer'); +},{"../internals/a-constructor":109,"../internals/an-object":114,"../internals/is-null-or-undefined":207,"../internals/well-known-symbol":306}],271:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); var toString = require('../internals/to-string'); var requireObjectCoercible = require('../internals/require-object-coercible'); -// `String.prototype.codePointAt` methods implementation +var charAt = uncurryThis(''.charAt); +var charCodeAt = uncurryThis(''.charCodeAt); +var stringSlice = uncurryThis(''.slice); + var createMethod = function (CONVERT_TO_STRING) { return function ($this, pos) { var S = toString(requireObjectCoercible($this)); - var position = toInteger(pos); + var position = toIntegerOrInfinity(pos); var size = S.length; var first, second; if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; - first = S.charCodeAt(position); + first = charCodeAt(S, position); return first < 0xD800 || first > 0xDBFF || position + 1 === size - || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF - ? CONVERT_TO_STRING ? S.charAt(position) : first - : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; + || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF + ? CONVERT_TO_STRING + ? charAt(S, position) + : first + : CONVERT_TO_STRING + ? stringSlice(S, position, position + 2) + : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; }; }; @@ -15457,7 +15994,9 @@ module.exports = { charAt: createMethod(true) }; -},{"../internals/require-object-coercible":204,"../internals/to-integer":220,"../internals/to-string":228}],214:[function(require,module,exports){ +},{"../internals/function-uncurry-this":181,"../internals/require-object-coercible":262,"../internals/to-integer-or-infinity":283,"../internals/to-string":291}],272:[function(require,module,exports){ +'use strict'; +var PROPER_FUNCTION_NAME = require('../internals/function-name').PROPER; var fails = require('../internals/fails'); var whitespaces = require('../internals/whitespaces'); @@ -15467,25 +16006,29 @@ var non = '\u200B\u0085\u180E'; // of whitespaces and has a correct name module.exports = function (METHOD_NAME) { return fails(function () { - return !!whitespaces[METHOD_NAME]() || non[METHOD_NAME]() != non || whitespaces[METHOD_NAME].name !== METHOD_NAME; + return !!whitespaces[METHOD_NAME]() + || non[METHOD_NAME]() !== non + || (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME); }); }; -},{"../internals/fails":140,"../internals/whitespaces":238}],215:[function(require,module,exports){ +},{"../internals/fails":171,"../internals/function-name":178,"../internals/whitespaces":307}],273:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); var requireObjectCoercible = require('../internals/require-object-coercible'); var toString = require('../internals/to-string'); var whitespaces = require('../internals/whitespaces'); -var whitespace = '[' + whitespaces + ']'; -var ltrim = RegExp('^' + whitespace + whitespace + '*'); -var rtrim = RegExp(whitespace + whitespace + '*$'); +var replace = uncurryThis(''.replace); +var ltrim = RegExp('^[' + whitespaces + ']+'); +var rtrim = RegExp('(^|[^' + whitespaces + '])[' + whitespaces + ']+$'); // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation var createMethod = function (TYPE) { return function ($this) { var string = toString(requireObjectCoercible($this)); - if (TYPE & 1) string = string.replace(ltrim, ''); - if (TYPE & 2) string = string.replace(rtrim, ''); + if (TYPE & 1) string = replace(string, ltrim, ''); + if (TYPE & 2) string = replace(string, rtrim, '$1'); return string; }; }; @@ -15502,33 +16045,91 @@ module.exports = { trim: createMethod(3) }; -},{"../internals/require-object-coercible":204,"../internals/to-string":228,"../internals/whitespaces":238}],216:[function(require,module,exports){ -var global = require('../internals/global'); +},{"../internals/function-uncurry-this":181,"../internals/require-object-coercible":262,"../internals/to-string":291,"../internals/whitespaces":307}],274:[function(require,module,exports){ +'use strict'; +/* eslint-disable es/no-symbol -- required for testing */ +var V8_VERSION = require('../internals/engine-v8-version'); var fails = require('../internals/fails'); +var global = require('../internals/global'); + +var $String = global.String; + +// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing +module.exports = !!Object.getOwnPropertySymbols && !fails(function () { + var symbol = Symbol('symbol detection'); + // Chrome 38 Symbol has incorrect toString conversion + // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances + // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will, + // of course, fail. + return !$String(symbol) || !(Object(symbol) instanceof Symbol) || + // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances + !Symbol.sham && V8_VERSION && V8_VERSION < 41; +}); + +},{"../internals/engine-v8-version":167,"../internals/fails":171,"../internals/global":188}],275:[function(require,module,exports){ +'use strict'; +var call = require('../internals/function-call'); +var getBuiltIn = require('../internals/get-built-in'); +var wellKnownSymbol = require('../internals/well-known-symbol'); +var defineBuiltIn = require('../internals/define-built-in'); + +module.exports = function () { + var Symbol = getBuiltIn('Symbol'); + var SymbolPrototype = Symbol && Symbol.prototype; + var valueOf = SymbolPrototype && SymbolPrototype.valueOf; + var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); + + if (SymbolPrototype && !SymbolPrototype[TO_PRIMITIVE]) { + // `Symbol.prototype[@@toPrimitive]` method + // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive + // eslint-disable-next-line no-unused-vars -- required for .length + defineBuiltIn(SymbolPrototype, TO_PRIMITIVE, function (hint) { + return call(valueOf, this); + }, { arity: 1 }); + } +}; + +},{"../internals/define-built-in":149,"../internals/function-call":177,"../internals/get-built-in":182,"../internals/well-known-symbol":306}],276:[function(require,module,exports){ +'use strict'; +var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection'); + +/* eslint-disable es/no-symbol -- safe */ +module.exports = NATIVE_SYMBOL && !!Symbol['for'] && !!Symbol.keyFor; + +},{"../internals/symbol-constructor-detection":274}],277:[function(require,module,exports){ +'use strict'; +var global = require('../internals/global'); +var apply = require('../internals/function-apply'); var bind = require('../internals/function-bind-context'); +var isCallable = require('../internals/is-callable'); +var hasOwn = require('../internals/has-own-property'); +var fails = require('../internals/fails'); var html = require('../internals/html'); +var arraySlice = require('../internals/array-slice'); var createElement = require('../internals/document-create-element'); +var validateArgumentsLength = require('../internals/validate-arguments-length'); var IS_IOS = require('../internals/engine-is-ios'); var IS_NODE = require('../internals/engine-is-node'); var set = global.setImmediate; var clear = global.clearImmediate; var process = global.process; -var MessageChannel = global.MessageChannel; var Dispatch = global.Dispatch; +var Function = global.Function; +var MessageChannel = global.MessageChannel; +var String = global.String; var counter = 0; var queue = {}; var ONREADYSTATECHANGE = 'onreadystatechange'; -var location, defer, channel, port; +var $location, defer, channel, port; -try { +fails(function () { // Deno throws a ReferenceError on `location` access without `--location` flag - location = global.location; -} catch (error) { /* empty */ } + $location = global.location; +}); var run = function (id) { - // eslint-disable-next-line no-prototype-builtins -- safe - if (queue.hasOwnProperty(id)) { + if (hasOwn(queue, id)) { var fn = queue[id]; delete queue[id]; fn(); @@ -15541,25 +16142,23 @@ var runner = function (id) { }; }; -var listener = function (event) { +var eventListener = function (event) { run(event.data); }; -var post = function (id) { +var globalPostMessageDefer = function (id) { // old engines have not location.origin - global.postMessage(String(id), location.protocol + '//' + location.host); + global.postMessage(String(id), $location.protocol + '//' + $location.host); }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: if (!set || !clear) { - set = function setImmediate(fn) { - var args = []; - var argumentsLength = arguments.length; - var i = 1; - while (argumentsLength > i) args.push(arguments[i++]); + set = function setImmediate(handler) { + validateArgumentsLength(arguments.length, 1); + var fn = isCallable(handler) ? handler : Function(handler); + var args = arraySlice(arguments, 1); queue[++counter] = function () { - // eslint-disable-next-line no-new-func -- spec requirement - (typeof fn == 'function' ? fn : Function(fn)).apply(undefined, args); + apply(fn, undefined, args); }; defer(counter); return counter; @@ -15582,19 +16181,19 @@ if (!set || !clear) { } else if (MessageChannel && !IS_IOS) { channel = new MessageChannel(); port = channel.port2; - channel.port1.onmessage = listener; - defer = bind(port.postMessage, port, 1); + channel.port1.onmessage = eventListener; + defer = bind(port.postMessage, port); // Browsers with postMessage, skip WebWorkers // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' } else if ( global.addEventListener && - typeof postMessage == 'function' && + isCallable(global.postMessage) && !global.importScripts && - location && location.protocol !== 'file:' && - !fails(post) + $location && $location.protocol !== 'file:' && + !fails(globalPostMessageDefer) ) { - defer = post; - global.addEventListener('message', listener, false); + defer = globalPostMessageDefer; + global.addEventListener('message', eventListener, false); // IE8- } else if (ONREADYSTATECHANGE in createElement('script')) { defer = function (id) { @@ -15616,8 +16215,17 @@ module.exports = { clear: clear }; -},{"../internals/document-create-element":126,"../internals/engine-is-ios":132,"../internals/engine-is-node":133,"../internals/fails":140,"../internals/function-bind-context":142,"../internals/global":147,"../internals/html":151}],217:[function(require,module,exports){ -var toInteger = require('../internals/to-integer'); +},{"../internals/array-slice":131,"../internals/document-create-element":154,"../internals/engine-is-ios":163,"../internals/engine-is-node":164,"../internals/fails":171,"../internals/function-apply":174,"../internals/function-bind-context":175,"../internals/global":188,"../internals/has-own-property":189,"../internals/html":192,"../internals/is-callable":203,"../internals/validate-arguments-length":302}],278:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); + +// `thisNumberValue` abstract operation +// https://tc39.es/ecma262/#sec-thisnumbervalue +module.exports = uncurryThis(1.0.valueOf); + +},{"../internals/function-uncurry-this":181}],279:[function(require,module,exports){ +'use strict'; +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); var max = Math.max; var min = Math.min; @@ -15626,25 +16234,44 @@ var min = Math.min; // Let integer be ? ToInteger(index). // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). module.exports = function (index, length) { - var integer = toInteger(index); + var integer = toIntegerOrInfinity(index); return integer < 0 ? max(integer + length, 0) : min(integer, length); }; -},{"../internals/to-integer":220}],218:[function(require,module,exports){ -var toInteger = require('../internals/to-integer'); +},{"../internals/to-integer-or-infinity":283}],280:[function(require,module,exports){ +'use strict'; +var toPrimitive = require('../internals/to-primitive'); + +var $TypeError = TypeError; + +// `ToBigInt` abstract operation +// https://tc39.es/ecma262/#sec-tobigint +module.exports = function (argument) { + var prim = toPrimitive(argument, 'number'); + if (typeof prim == 'number') throw new $TypeError("Can't convert number to bigint"); + // eslint-disable-next-line es/no-bigint -- safe + return BigInt(prim); +}; + +},{"../internals/to-primitive":288}],281:[function(require,module,exports){ +'use strict'; +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); var toLength = require('../internals/to-length'); +var $RangeError = RangeError; + // `ToIndex` abstract operation // https://tc39.es/ecma262/#sec-toindex module.exports = function (it) { if (it === undefined) return 0; - var number = toInteger(it); + var number = toIntegerOrInfinity(it); var length = toLength(number); - if (number !== length) throw RangeError('Wrong length or index'); + if (number !== length) throw new $RangeError('Wrong length or index'); return length; }; -},{"../internals/to-integer":220,"../internals/to-length":221}],219:[function(require,module,exports){ +},{"../internals/to-integer-or-infinity":283,"../internals/to-length":284}],282:[function(require,module,exports){ +'use strict'; // toObject with fallback for non-array-like ES3 strings var IndexedObject = require('../internals/indexed-object'); var requireObjectCoercible = require('../internals/require-object-coercible'); @@ -15653,79 +16280,96 @@ module.exports = function (it) { return IndexedObject(requireObjectCoercible(it)); }; -},{"../internals/indexed-object":154,"../internals/require-object-coercible":204}],220:[function(require,module,exports){ -var ceil = Math.ceil; -var floor = Math.floor; +},{"../internals/indexed-object":195,"../internals/require-object-coercible":262}],283:[function(require,module,exports){ +'use strict'; +var trunc = require('../internals/math-trunc'); -// `ToInteger` abstract operation -// https://tc39.es/ecma262/#sec-tointeger +// `ToIntegerOrInfinity` abstract operation +// https://tc39.es/ecma262/#sec-tointegerorinfinity module.exports = function (argument) { - return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument); + var number = +argument; + // eslint-disable-next-line no-self-compare -- NaN check + return number !== number || number === 0 ? 0 : trunc(number); }; -},{}],221:[function(require,module,exports){ -var toInteger = require('../internals/to-integer'); +},{"../internals/math-trunc":224}],284:[function(require,module,exports){ +'use strict'; +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); var min = Math.min; // `ToLength` abstract operation // https://tc39.es/ecma262/#sec-tolength module.exports = function (argument) { - return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 + return argument > 0 ? min(toIntegerOrInfinity(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 }; -},{"../internals/to-integer":220}],222:[function(require,module,exports){ +},{"../internals/to-integer-or-infinity":283}],285:[function(require,module,exports){ +'use strict'; var requireObjectCoercible = require('../internals/require-object-coercible'); +var $Object = Object; + // `ToObject` abstract operation // https://tc39.es/ecma262/#sec-toobject module.exports = function (argument) { - return Object(requireObjectCoercible(argument)); + return $Object(requireObjectCoercible(argument)); }; -},{"../internals/require-object-coercible":204}],223:[function(require,module,exports){ +},{"../internals/require-object-coercible":262}],286:[function(require,module,exports){ +'use strict'; var toPositiveInteger = require('../internals/to-positive-integer'); +var $RangeError = RangeError; + module.exports = function (it, BYTES) { var offset = toPositiveInteger(it); - if (offset % BYTES) throw RangeError('Wrong offset'); + if (offset % BYTES) throw new $RangeError('Wrong offset'); return offset; }; -},{"../internals/to-positive-integer":224}],224:[function(require,module,exports){ -var toInteger = require('../internals/to-integer'); +},{"../internals/to-positive-integer":287}],287:[function(require,module,exports){ +'use strict'; +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); + +var $RangeError = RangeError; module.exports = function (it) { - var result = toInteger(it); - if (result < 0) throw RangeError("The argument can't be less than 0"); + var result = toIntegerOrInfinity(it); + if (result < 0) throw new $RangeError("The argument can't be less than 0"); return result; }; -},{"../internals/to-integer":220}],225:[function(require,module,exports){ +},{"../internals/to-integer-or-infinity":283}],288:[function(require,module,exports){ +'use strict'; +var call = require('../internals/function-call'); var isObject = require('../internals/is-object'); var isSymbol = require('../internals/is-symbol'); +var getMethod = require('../internals/get-method'); var ordinaryToPrimitive = require('../internals/ordinary-to-primitive'); var wellKnownSymbol = require('../internals/well-known-symbol'); +var $TypeError = TypeError; var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); // `ToPrimitive` abstract operation // https://tc39.es/ecma262/#sec-toprimitive module.exports = function (input, pref) { if (!isObject(input) || isSymbol(input)) return input; - var exoticToPrim = input[TO_PRIMITIVE]; + var exoticToPrim = getMethod(input, TO_PRIMITIVE); var result; - if (exoticToPrim !== undefined) { + if (exoticToPrim) { if (pref === undefined) pref = 'default'; - result = exoticToPrim.call(input, pref); + result = call(exoticToPrim, input, pref); if (!isObject(result) || isSymbol(result)) return result; - throw TypeError("Can't convert object to primitive value"); + throw new $TypeError("Can't convert object to primitive value"); } if (pref === undefined) pref = 'number'; return ordinaryToPrimitive(input, pref); }; -},{"../internals/is-object":162,"../internals/is-symbol":165,"../internals/ordinary-to-primitive":191,"../internals/well-known-symbol":237}],226:[function(require,module,exports){ +},{"../internals/function-call":177,"../internals/get-method":186,"../internals/is-object":208,"../internals/is-symbol":212,"../internals/ordinary-to-primitive":245,"../internals/well-known-symbol":306}],289:[function(require,module,exports){ +'use strict'; var toPrimitive = require('../internals/to-primitive'); var isSymbol = require('../internals/is-symbol'); @@ -15733,10 +16377,11 @@ var isSymbol = require('../internals/is-symbol'); // https://tc39.es/ecma262/#sec-topropertykey module.exports = function (argument) { var key = toPrimitive(argument, 'string'); - return isSymbol(key) ? key : String(key); + return isSymbol(key) ? key : key + ''; }; -},{"../internals/is-symbol":165,"../internals/to-primitive":225}],227:[function(require,module,exports){ +},{"../internals/is-symbol":212,"../internals/to-primitive":288}],290:[function(require,module,exports){ +'use strict'; var wellKnownSymbol = require('../internals/well-known-symbol'); var TO_STRING_TAG = wellKnownSymbol('toStringTag'); @@ -15746,18 +16391,43 @@ test[TO_STRING_TAG] = 'z'; module.exports = String(test) === '[object z]'; -},{"../internals/well-known-symbol":237}],228:[function(require,module,exports){ -var isSymbol = require('../internals/is-symbol'); +},{"../internals/well-known-symbol":306}],291:[function(require,module,exports){ +'use strict'; +var classof = require('../internals/classof'); + +var $String = String; + +module.exports = function (argument) { + if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string'); + return $String(argument); +}; + +},{"../internals/classof":138}],292:[function(require,module,exports){ +'use strict'; +var round = Math.round; + +module.exports = function (it) { + var value = round(it); + return value < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; +}; + +},{}],293:[function(require,module,exports){ +'use strict'; +var $String = String; module.exports = function (argument) { - if (isSymbol(argument)) throw TypeError('Cannot convert a Symbol value to a string'); - return String(argument); + try { + return $String(argument); + } catch (error) { + return 'Object'; + } }; -},{"../internals/is-symbol":165}],229:[function(require,module,exports){ +},{}],294:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var global = require('../internals/global'); +var call = require('../internals/function-call'); var DESCRIPTORS = require('../internals/descriptors'); var TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS = require('../internals/typed-array-constructors-require-wrappers'); var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); @@ -15765,68 +16435,66 @@ var ArrayBufferModule = require('../internals/array-buffer'); var anInstance = require('../internals/an-instance'); var createPropertyDescriptor = require('../internals/create-property-descriptor'); var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var isInteger = require('../internals/is-integer'); +var isIntegralNumber = require('../internals/is-integral-number'); var toLength = require('../internals/to-length'); var toIndex = require('../internals/to-index'); var toOffset = require('../internals/to-offset'); +var toUint8Clamped = require('../internals/to-uint8-clamped'); var toPropertyKey = require('../internals/to-property-key'); -var has = require('../internals/has'); +var hasOwn = require('../internals/has-own-property'); var classof = require('../internals/classof'); var isObject = require('../internals/is-object'); var isSymbol = require('../internals/is-symbol'); var create = require('../internals/object-create'); +var isPrototypeOf = require('../internals/object-is-prototype-of'); var setPrototypeOf = require('../internals/object-set-prototype-of'); var getOwnPropertyNames = require('../internals/object-get-own-property-names').f; var typedArrayFrom = require('../internals/typed-array-from'); var forEach = require('../internals/array-iteration').forEach; var setSpecies = require('../internals/set-species'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var definePropertyModule = require('../internals/object-define-property'); var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor'); +var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list'); var InternalStateModule = require('../internals/internal-state'); var inheritIfRequired = require('../internals/inherit-if-required'); var getInternalState = InternalStateModule.get; var setInternalState = InternalStateModule.set; +var enforceInternalState = InternalStateModule.enforce; var nativeDefineProperty = definePropertyModule.f; var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; -var round = Math.round; var RangeError = global.RangeError; var ArrayBuffer = ArrayBufferModule.ArrayBuffer; +var ArrayBufferPrototype = ArrayBuffer.prototype; var DataView = ArrayBufferModule.DataView; var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS; -var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR; var TYPED_ARRAY_TAG = ArrayBufferViewCore.TYPED_ARRAY_TAG; var TypedArray = ArrayBufferViewCore.TypedArray; var TypedArrayPrototype = ArrayBufferViewCore.TypedArrayPrototype; -var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor; var isTypedArray = ArrayBufferViewCore.isTypedArray; var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT'; var WRONG_LENGTH = 'Wrong length'; -var fromList = function (C, list) { - var index = 0; - var length = list.length; - var result = new (aTypedArrayConstructor(C))(length); - while (length > index) result[index] = list[index++]; - return result; -}; - var addGetter = function (it, key) { - nativeDefineProperty(it, key, { get: function () { - return getInternalState(this)[key]; - } }); + defineBuiltInAccessor(it, key, { + configurable: true, + get: function () { + return getInternalState(this)[key]; + } + }); }; var isArrayBuffer = function (it) { var klass; - return it instanceof ArrayBuffer || (klass = classof(it)) == 'ArrayBuffer' || klass == 'SharedArrayBuffer'; + return isPrototypeOf(ArrayBufferPrototype, it) || (klass = classof(it)) === 'ArrayBuffer' || klass === 'SharedArrayBuffer'; }; var isTypedArrayIndex = function (target, key) { return isTypedArray(target) && !isSymbol(key) && key in target - && isInteger(+key) + && isIntegralNumber(+key) && key >= 0; }; @@ -15841,13 +16509,13 @@ var wrappedDefineProperty = function defineProperty(target, key, descriptor) { key = toPropertyKey(key); if (isTypedArrayIndex(target, key) && isObject(descriptor) - && has(descriptor, 'value') - && !has(descriptor, 'get') - && !has(descriptor, 'set') + && hasOwn(descriptor, 'value') + && !hasOwn(descriptor, 'get') + && !hasOwn(descriptor, 'set') // TODO: add validation descriptor w/o calling accessors && !descriptor.configurable - && (!has(descriptor, 'writable') || descriptor.writable) - && (!has(descriptor, 'enumerable') || descriptor.enumerable) + && (!hasOwn(descriptor, 'writable') || descriptor.writable) + && (!hasOwn(descriptor, 'enumerable') || descriptor.enumerable) ) { target[key] = descriptor.value; return target; @@ -15870,7 +16538,7 @@ if (DESCRIPTORS) { }); module.exports = function (TYPE, wrapper, CLAMPED) { - var BYTES = TYPE.match(/\d+$/)[0] / 8; + var BYTES = TYPE.match(/\d+/)[0] / 8; var CONSTRUCTOR_NAME = TYPE + (CLAMPED ? 'Clamped' : '') + 'Array'; var GETTER = 'get' + TYPE; var SETTER = 'set' + TYPE; @@ -15886,8 +16554,7 @@ if (DESCRIPTORS) { var setter = function (that, index, value) { var data = getInternalState(that); - if (CLAMPED) value = (value = round(value)) < 0 ? 0 : value > 0xFF ? 0xFF : value & 0xFF; - data.view[SETTER](index * BYTES + data.byteOffset, value, true); + data.view[SETTER](index * BYTES + data.byteOffset, CLAMPED ? toUint8Clamped(value) : value, true); }; var addElement = function (that, index) { @@ -15904,7 +16571,7 @@ if (DESCRIPTORS) { if (!NATIVE_ARRAY_BUFFER_VIEWS) { TypedArrayConstructor = wrapper(function (that, data, offset, $length) { - anInstance(that, TypedArrayConstructor, CONSTRUCTOR_NAME); + anInstance(that, TypedArrayConstructorPrototype); var index = 0; var byteOffset = 0; var buffer, byteLength, length; @@ -15917,18 +16584,18 @@ if (DESCRIPTORS) { byteOffset = toOffset(offset, BYTES); var $len = data.byteLength; if ($length === undefined) { - if ($len % BYTES) throw RangeError(WRONG_LENGTH); + if ($len % BYTES) throw new RangeError(WRONG_LENGTH); byteLength = $len - byteOffset; - if (byteLength < 0) throw RangeError(WRONG_LENGTH); + if (byteLength < 0) throw new RangeError(WRONG_LENGTH); } else { byteLength = toLength($length) * BYTES; - if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); + if (byteLength + byteOffset > $len) throw new RangeError(WRONG_LENGTH); } length = byteLength / BYTES; } else if (isTypedArray(data)) { - return fromList(TypedArrayConstructor, data); + return arrayFromConstructorAndList(TypedArrayConstructor, data); } else { - return typedArrayFrom.call(TypedArrayConstructor, data); + return call(typedArrayFrom, TypedArrayConstructor, data); } setInternalState(that, { buffer: buffer, @@ -15944,7 +16611,7 @@ if (DESCRIPTORS) { TypedArrayConstructorPrototype = TypedArrayConstructor.prototype = create(TypedArrayPrototype); } else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS) { TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) { - anInstance(dummy, TypedArrayConstructor, CONSTRUCTOR_NAME); + anInstance(dummy, TypedArrayConstructorPrototype); return inheritIfRequired(function () { if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data)); if (isArrayBuffer(data)) return $length !== undefined @@ -15952,8 +16619,8 @@ if (DESCRIPTORS) { : typedArrayOffset !== undefined ? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES)) : new NativeTypedArrayConstructor(data); - if (isTypedArray(data)) return fromList(TypedArrayConstructor, data); - return typedArrayFrom.call(TypedArrayConstructor, data); + if (isTypedArray(data)) return arrayFromConstructorAndList(TypedArrayConstructor, data); + return call(typedArrayFrom, TypedArrayConstructor, data); }(), dummy, TypedArrayConstructor); }); @@ -15970,17 +16637,17 @@ if (DESCRIPTORS) { createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor); } - createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor); + enforceInternalState(TypedArrayConstructorPrototype).TypedArrayConstructor = TypedArrayConstructor; if (TYPED_ARRAY_TAG) { createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME); } + var FORCED = TypedArrayConstructor !== NativeTypedArrayConstructor; + exported[CONSTRUCTOR_NAME] = TypedArrayConstructor; - $({ - global: true, forced: TypedArrayConstructor != NativeTypedArrayConstructor, sham: !NATIVE_ARRAY_BUFFER_VIEWS - }, exported); + $({ global: true, constructor: true, forced: FORCED, sham: !NATIVE_ARRAY_BUFFER_VIEWS }, exported); if (!(BYTES_PER_ELEMENT in TypedArrayConstructor)) { createNonEnumerableProperty(TypedArrayConstructor, BYTES_PER_ELEMENT, BYTES); @@ -15994,7 +16661,8 @@ if (DESCRIPTORS) { }; } else module.exports = function () { /* empty */ }; -},{"../internals/an-instance":93,"../internals/array-buffer":97,"../internals/array-buffer-view-core":96,"../internals/array-iteration":104,"../internals/classof":115,"../internals/create-non-enumerable-property":120,"../internals/create-property-descriptor":121,"../internals/descriptors":125,"../internals/export":139,"../internals/global":147,"../internals/has":148,"../internals/inherit-if-required":155,"../internals/internal-state":157,"../internals/is-integer":161,"../internals/is-object":162,"../internals/is-symbol":165,"../internals/object-create":177,"../internals/object-define-property":179,"../internals/object-get-own-property-descriptor":180,"../internals/object-get-own-property-names":182,"../internals/object-set-prototype-of":188,"../internals/set-species":207,"../internals/to-index":218,"../internals/to-length":221,"../internals/to-offset":223,"../internals/to-property-key":226,"../internals/typed-array-constructors-require-wrappers":230,"../internals/typed-array-from":232}],230:[function(require,module,exports){ +},{"../internals/an-instance":113,"../internals/array-buffer":118,"../internals/array-buffer-view-core":117,"../internals/array-from-constructor-and-list":122,"../internals/array-iteration":125,"../internals/classof":138,"../internals/create-non-enumerable-property":145,"../internals/create-property-descriptor":146,"../internals/define-built-in-accessor":148,"../internals/descriptors":153,"../internals/export":170,"../internals/function-call":177,"../internals/global":188,"../internals/has-own-property":189,"../internals/inherit-if-required":196,"../internals/internal-state":199,"../internals/is-integral-number":206,"../internals/is-object":208,"../internals/is-symbol":212,"../internals/object-create":229,"../internals/object-define-property":231,"../internals/object-get-own-property-descriptor":232,"../internals/object-get-own-property-names":234,"../internals/object-is-prototype-of":238,"../internals/object-set-prototype-of":242,"../internals/set-species":265,"../internals/to-index":281,"../internals/to-length":284,"../internals/to-offset":286,"../internals/to-property-key":289,"../internals/to-uint8-clamped":292,"../internals/typed-array-constructors-require-wrappers":295,"../internals/typed-array-from":297}],295:[function(require,module,exports){ +'use strict'; /* eslint-disable no-new -- required for testing */ var global = require('../internals/global'); var fails = require('../internals/fails'); @@ -16018,7 +16686,8 @@ module.exports = !NATIVE_ARRAY_BUFFER_VIEWS || !fails(function () { return new Int8Array(new ArrayBuffer(2), 1, undefined).length !== 1; }); -},{"../internals/array-buffer-view-core":96,"../internals/check-correctness-of-iteration":113,"../internals/fails":140,"../internals/global":147}],231:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/check-correctness-of-iteration":136,"../internals/fails":171,"../internals/global":188}],296:[function(require,module,exports){ +'use strict'; var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list'); var typedArraySpeciesConstructor = require('../internals/typed-array-species-constructor'); @@ -16026,103 +16695,166 @@ module.exports = function (instance, list) { return arrayFromConstructorAndList(typedArraySpeciesConstructor(instance), list); }; -},{"../internals/array-from-constructor-and-list":101,"../internals/typed-array-species-constructor":233}],232:[function(require,module,exports){ +},{"../internals/array-from-constructor-and-list":122,"../internals/typed-array-species-constructor":298}],297:[function(require,module,exports){ +'use strict'; +var bind = require('../internals/function-bind-context'); +var call = require('../internals/function-call'); +var aConstructor = require('../internals/a-constructor'); var toObject = require('../internals/to-object'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); var getIterator = require('../internals/get-iterator'); var getIteratorMethod = require('../internals/get-iterator-method'); var isArrayIteratorMethod = require('../internals/is-array-iterator-method'); -var bind = require('../internals/function-bind-context'); +var isBigIntArray = require('../internals/is-big-int-array'); var aTypedArrayConstructor = require('../internals/array-buffer-view-core').aTypedArrayConstructor; +var toBigInt = require('../internals/to-big-int'); module.exports = function from(source /* , mapfn, thisArg */) { + var C = aConstructor(this); var O = toObject(source); var argumentsLength = arguments.length; var mapfn = argumentsLength > 1 ? arguments[1] : undefined; var mapping = mapfn !== undefined; var iteratorMethod = getIteratorMethod(O); - var i, length, result, step, iterator, next; - if (iteratorMethod != undefined && !isArrayIteratorMethod(iteratorMethod)) { + var i, length, result, thisIsBigIntArray, value, step, iterator, next; + if (iteratorMethod && !isArrayIteratorMethod(iteratorMethod)) { iterator = getIterator(O, iteratorMethod); next = iterator.next; O = []; - while (!(step = next.call(iterator)).done) { + while (!(step = call(next, iterator)).done) { O.push(step.value); } } if (mapping && argumentsLength > 2) { - mapfn = bind(mapfn, arguments[2], 2); + mapfn = bind(mapfn, arguments[2]); } - length = toLength(O.length); - result = new (aTypedArrayConstructor(this))(length); + length = lengthOfArrayLike(O); + result = new (aTypedArrayConstructor(C))(length); + thisIsBigIntArray = isBigIntArray(result); for (i = 0; length > i; i++) { - result[i] = mapping ? mapfn(O[i], i) : O[i]; + value = mapping ? mapfn(O[i], i) : O[i]; + // FF30- typed arrays doesn't properly convert objects to typed array values + result[i] = thisIsBigIntArray ? toBigInt(value) : +value; } return result; }; -},{"../internals/array-buffer-view-core":96,"../internals/function-bind-context":142,"../internals/get-iterator":145,"../internals/get-iterator-method":144,"../internals/is-array-iterator-method":158,"../internals/to-length":221,"../internals/to-object":222}],233:[function(require,module,exports){ +},{"../internals/a-constructor":109,"../internals/array-buffer-view-core":117,"../internals/function-bind-context":175,"../internals/function-call":177,"../internals/get-iterator":184,"../internals/get-iterator-method":183,"../internals/is-array-iterator-method":200,"../internals/is-big-int-array":202,"../internals/length-of-array-like":219,"../internals/to-big-int":280,"../internals/to-object":285}],298:[function(require,module,exports){ +'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var speciesConstructor = require('../internals/species-constructor'); -var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR; var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor; +var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; // a part of `TypedArraySpeciesCreate` abstract operation // https://tc39.es/ecma262/#typedarray-species-create module.exports = function (originalArray) { - return aTypedArrayConstructor(speciesConstructor(originalArray, originalArray[TYPED_ARRAY_CONSTRUCTOR])); + return aTypedArrayConstructor(speciesConstructor(originalArray, getTypedArrayConstructor(originalArray))); }; -},{"../internals/array-buffer-view-core":96,"../internals/species-constructor":212}],234:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/species-constructor":270}],299:[function(require,module,exports){ +'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); + var id = 0; var postfix = Math.random(); +var toString = uncurryThis(1.0.toString); module.exports = function (key) { - return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36); + return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36); }; -},{}],235:[function(require,module,exports){ +},{"../internals/function-uncurry-this":181}],300:[function(require,module,exports){ +'use strict'; /* eslint-disable es/no-symbol -- required for testing */ -var NATIVE_SYMBOL = require('../internals/native-symbol'); +var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection'); module.exports = NATIVE_SYMBOL && !Symbol.sham && typeof Symbol.iterator == 'symbol'; -},{"../internals/native-symbol":172}],236:[function(require,module,exports){ -var wellKnownSymbol = require('../internals/well-known-symbol'); +},{"../internals/symbol-constructor-detection":274}],301:[function(require,module,exports){ +'use strict'; +var DESCRIPTORS = require('../internals/descriptors'); +var fails = require('../internals/fails'); -exports.f = wellKnownSymbol; +// V8 ~ Chrome 36- +// https://bugs.chromium.org/p/v8/issues/detail?id=3334 +module.exports = DESCRIPTORS && fails(function () { + // eslint-disable-next-line es/no-object-defineproperty -- required for testing + return Object.defineProperty(function () { /* empty */ }, 'prototype', { + value: 42, + writable: false + }).prototype !== 42; +}); -},{"../internals/well-known-symbol":237}],237:[function(require,module,exports){ -var global = require('../internals/global'); -var shared = require('../internals/shared'); -var has = require('../internals/has'); -var uid = require('../internals/uid'); -var NATIVE_SYMBOL = require('../internals/native-symbol'); -var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid'); +},{"../internals/descriptors":153,"../internals/fails":171}],302:[function(require,module,exports){ +'use strict'; +var $TypeError = TypeError; + +module.exports = function (passed, required) { + if (passed < required) throw new $TypeError('Not enough arguments'); + return passed; +}; + +},{}],303:[function(require,module,exports){ +'use strict'; +var global = require('../internals/global'); +var isCallable = require('../internals/is-callable'); + +var WeakMap = global.WeakMap; + +module.exports = isCallable(WeakMap) && /native code/.test(String(WeakMap)); + +},{"../internals/global":188,"../internals/is-callable":203}],304:[function(require,module,exports){ +'use strict'; +var path = require('../internals/path'); +var hasOwn = require('../internals/has-own-property'); +var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped'); +var defineProperty = require('../internals/object-define-property').f; + +module.exports = function (NAME) { + var Symbol = path.Symbol || (path.Symbol = {}); + if (!hasOwn(Symbol, NAME)) defineProperty(Symbol, NAME, { + value: wrappedWellKnownSymbolModule.f(NAME) + }); +}; + +},{"../internals/has-own-property":189,"../internals/object-define-property":231,"../internals/path":247,"../internals/well-known-symbol-wrapped":305}],305:[function(require,module,exports){ +'use strict'; +var wellKnownSymbol = require('../internals/well-known-symbol'); + +exports.f = wellKnownSymbol; + +},{"../internals/well-known-symbol":306}],306:[function(require,module,exports){ +'use strict'; +var global = require('../internals/global'); +var shared = require('../internals/shared'); +var hasOwn = require('../internals/has-own-property'); +var uid = require('../internals/uid'); +var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection'); +var USE_SYMBOL_AS_UID = require('../internals/use-symbol-as-uid'); -var WellKnownSymbolsStore = shared('wks'); var Symbol = global.Symbol; -var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol : Symbol && Symbol.withoutSetter || uid; +var WellKnownSymbolsStore = shared('wks'); +var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid; module.exports = function (name) { - if (!has(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL || typeof WellKnownSymbolsStore[name] == 'string')) { - if (NATIVE_SYMBOL && has(Symbol, name)) { - WellKnownSymbolsStore[name] = Symbol[name]; - } else { - WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name); - } + if (!hasOwn(WellKnownSymbolsStore, name)) { + WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name) + ? Symbol[name] + : createWellKnownSymbol('Symbol.' + name); } return WellKnownSymbolsStore[name]; }; -},{"../internals/global":147,"../internals/has":148,"../internals/native-symbol":172,"../internals/shared":211,"../internals/uid":234,"../internals/use-symbol-as-uid":235}],238:[function(require,module,exports){ +},{"../internals/global":188,"../internals/has-own-property":189,"../internals/shared":269,"../internals/symbol-constructor-detection":274,"../internals/uid":299,"../internals/use-symbol-as-uid":300}],307:[function(require,module,exports){ +'use strict'; // a string of all valid unicode whitespaces module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; -},{}],239:[function(require,module,exports){ +},{}],308:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var global = require('../internals/global'); @@ -16135,15 +16867,16 @@ var NativeArrayBuffer = global[ARRAY_BUFFER]; // `ArrayBuffer` constructor // https://tc39.es/ecma262/#sec-arraybuffer-constructor -$({ global: true, forced: NativeArrayBuffer !== ArrayBuffer }, { +$({ global: true, constructor: true, forced: NativeArrayBuffer !== ArrayBuffer }, { ArrayBuffer: ArrayBuffer }); setSpecies(ARRAY_BUFFER); -},{"../internals/array-buffer":97,"../internals/export":139,"../internals/global":147,"../internals/set-species":207}],240:[function(require,module,exports){ +},{"../internals/array-buffer":118,"../internals/export":170,"../internals/global":188,"../internals/set-species":265}],309:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); +var uncurryThis = require('../internals/function-uncurry-this-clause'); var fails = require('../internals/fails'); var ArrayBufferModule = require('../internals/array-buffer'); var anObject = require('../internals/an-object'); @@ -16153,7 +16886,10 @@ var speciesConstructor = require('../internals/species-constructor'); var ArrayBuffer = ArrayBufferModule.ArrayBuffer; var DataView = ArrayBufferModule.DataView; -var nativeArrayBufferSlice = ArrayBuffer.prototype.slice; +var DataViewPrototype = DataView.prototype; +var nativeArrayBufferSlice = uncurryThis(ArrayBuffer.prototype.slice); +var getUint8 = uncurryThis(DataViewPrototype.getUint8); +var setUint8 = uncurryThis(DataViewPrototype.setUint8); var INCORRECT_SLICE = fails(function () { return !new ArrayBuffer(2).slice(1, undefined).byteLength; @@ -16163,8 +16899,8 @@ var INCORRECT_SLICE = fails(function () { // https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice $({ target: 'ArrayBuffer', proto: true, unsafe: true, forced: INCORRECT_SLICE }, { slice: function slice(start, end) { - if (nativeArrayBufferSlice !== undefined && end === undefined) { - return nativeArrayBufferSlice.call(anObject(this), start); // FF fix + if (nativeArrayBufferSlice && end === undefined) { + return nativeArrayBufferSlice(anObject(this), start); // FF fix } var length = anObject(this).byteLength; var first = toAbsoluteIndex(start, length); @@ -16174,19 +16910,20 @@ $({ target: 'ArrayBuffer', proto: true, unsafe: true, forced: INCORRECT_SLICE }, var viewTarget = new DataView(result); var index = 0; while (first < fin) { - viewTarget.setUint8(index++, viewSource.getUint8(first++)); + setUint8(viewTarget, index++, getUint8(viewSource, first++)); } return result; } }); -},{"../internals/an-object":94,"../internals/array-buffer":97,"../internals/export":139,"../internals/fails":140,"../internals/species-constructor":212,"../internals/to-absolute-index":217,"../internals/to-length":221}],241:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/array-buffer":118,"../internals/export":170,"../internals/fails":171,"../internals/function-uncurry-this-clause":180,"../internals/species-constructor":270,"../internals/to-absolute-index":279,"../internals/to-length":284}],310:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var fails = require('../internals/fails'); var isArray = require('../internals/is-array'); var isObject = require('../internals/is-object'); var toObject = require('../internals/to-object'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); +var doesNotExceedSafeInteger = require('../internals/does-not-exceed-safe-integer'); var createProperty = require('../internals/create-property'); var arraySpeciesCreate = require('../internals/array-species-create'); var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support'); @@ -16194,8 +16931,6 @@ var wellKnownSymbol = require('../internals/well-known-symbol'); var V8_VERSION = require('../internals/engine-v8-version'); var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable'); -var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; -var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded'; // We can't use this feature detection in V8 since it causes // deoptimization and serious performance degradation @@ -16206,20 +16941,18 @@ var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () { return array.concat()[0] !== array; }); -var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat'); - var isConcatSpreadable = function (O) { if (!isObject(O)) return false; var spreadable = O[IS_CONCAT_SPREADABLE]; return spreadable !== undefined ? !!spreadable : isArray(O); }; -var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; +var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !arrayMethodHasSpeciesSupport('concat'); // `Array.prototype.concat` method // https://tc39.es/ecma262/#sec-array.prototype.concat // with adding support of @@isConcatSpreadable and @@species -$({ target: 'Array', proto: true, forced: FORCED }, { +$({ target: 'Array', proto: true, arity: 1, forced: FORCED }, { // eslint-disable-next-line no-unused-vars -- required for `.length` concat: function concat(arg) { var O = toObject(this); @@ -16229,11 +16962,11 @@ $({ target: 'Array', proto: true, forced: FORCED }, { for (i = -1, length = arguments.length; i < length; i++) { E = i === -1 ? O : arguments[i]; if (isConcatSpreadable(E)) { - len = toLength(E.length); - if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED); + len = lengthOfArrayLike(E); + doesNotExceedSafeInteger(n + len); for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]); } else { - if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED); + doesNotExceedSafeInteger(n + 1); createProperty(A, n++, E); } } @@ -16242,7 +16975,8 @@ $({ target: 'Array', proto: true, forced: FORCED }, { } }); -},{"../internals/array-method-has-species-support":106,"../internals/array-species-create":111,"../internals/create-property":122,"../internals/engine-v8-version":136,"../internals/export":139,"../internals/fails":140,"../internals/is-array":159,"../internals/is-object":162,"../internals/to-length":221,"../internals/to-object":222,"../internals/well-known-symbol":237}],242:[function(require,module,exports){ +},{"../internals/array-method-has-species-support":127,"../internals/array-species-create":134,"../internals/create-property":147,"../internals/does-not-exceed-safe-integer":155,"../internals/engine-v8-version":167,"../internals/export":170,"../internals/fails":171,"../internals/is-array":201,"../internals/is-object":208,"../internals/length-of-array-like":219,"../internals/to-object":285,"../internals/well-known-symbol":306}],311:[function(require,module,exports){ +'use strict'; var $ = require('../internals/export'); var fill = require('../internals/array-fill'); var addToUnscopables = require('../internals/add-to-unscopables'); @@ -16256,7 +16990,7 @@ $({ target: 'Array', proto: true }, { // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables addToUnscopables('fill'); -},{"../internals/add-to-unscopables":91,"../internals/array-fill":99,"../internals/export":139}],243:[function(require,module,exports){ +},{"../internals/add-to-unscopables":111,"../internals/array-fill":120,"../internals/export":170}],312:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var $filter = require('../internals/array-iteration').filter; @@ -16273,7 +17007,7 @@ $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { } }); -},{"../internals/array-iteration":104,"../internals/array-method-has-species-support":106,"../internals/export":139}],244:[function(require,module,exports){ +},{"../internals/array-iteration":125,"../internals/array-method-has-species-support":127,"../internals/export":170}],313:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var $find = require('../internals/array-iteration').find; @@ -16283,6 +17017,7 @@ var FIND = 'find'; var SKIPS_HOLES = true; // Shouldn't skip holes +// eslint-disable-next-line es/no-array-prototype-find -- testing if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; }); // `Array.prototype.find` method @@ -16296,7 +17031,8 @@ $({ target: 'Array', proto: true, forced: SKIPS_HOLES }, { // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables addToUnscopables(FIND); -},{"../internals/add-to-unscopables":91,"../internals/array-iteration":104,"../internals/export":139}],245:[function(require,module,exports){ +},{"../internals/add-to-unscopables":111,"../internals/array-iteration":125,"../internals/export":170}],314:[function(require,module,exports){ +'use strict'; var $ = require('../internals/export'); var from = require('../internals/array-from'); var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration'); @@ -16312,15 +17048,22 @@ $({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, { from: from }); -},{"../internals/array-from":102,"../internals/check-correctness-of-iteration":113,"../internals/export":139}],246:[function(require,module,exports){ +},{"../internals/array-from":123,"../internals/check-correctness-of-iteration":136,"../internals/export":170}],315:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var $includes = require('../internals/array-includes').includes; +var fails = require('../internals/fails'); var addToUnscopables = require('../internals/add-to-unscopables'); +// FF99+ bug +var BROKEN_ON_SPARSE = fails(function () { + // eslint-disable-next-line es/no-array-prototype-includes -- detection + return !Array(1).includes(); +}); + // `Array.prototype.includes` method // https://tc39.es/ecma262/#sec-array.prototype.includes -$({ target: 'Array', proto: true }, { +$({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, { includes: function includes(el /* , fromIndex = 0 */) { return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); } @@ -16329,13 +17072,17 @@ $({ target: 'Array', proto: true }, { // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables addToUnscopables('includes'); -},{"../internals/add-to-unscopables":91,"../internals/array-includes":103,"../internals/export":139}],247:[function(require,module,exports){ +},{"../internals/add-to-unscopables":111,"../internals/array-includes":124,"../internals/export":170,"../internals/fails":171}],316:[function(require,module,exports){ 'use strict'; var toIndexedObject = require('../internals/to-indexed-object'); var addToUnscopables = require('../internals/add-to-unscopables'); var Iterators = require('../internals/iterators'); var InternalStateModule = require('../internals/internal-state'); -var defineIterator = require('../internals/define-iterator'); +var defineProperty = require('../internals/object-define-property').f; +var defineIterator = require('../internals/iterator-define'); +var createIterResultObject = require('../internals/create-iter-result-object'); +var IS_PURE = require('../internals/is-pure'); +var DESCRIPTORS = require('../internals/descriptors'); var ARRAY_ITERATOR = 'Array Iterator'; var setInternalState = InternalStateModule.set; @@ -16363,48 +17110,54 @@ module.exports = defineIterator(Array, 'Array', function (iterated, kind) { }, function () { var state = getInternalState(this); var target = state.target; - var kind = state.kind; var index = state.index++; if (!target || index >= target.length) { state.target = undefined; - return { value: undefined, done: true }; + return createIterResultObject(undefined, true); } - if (kind == 'keys') return { value: index, done: false }; - if (kind == 'values') return { value: target[index], done: false }; - return { value: [index, target[index]], done: false }; + switch (state.kind) { + case 'keys': return createIterResultObject(index, false); + case 'values': return createIterResultObject(target[index], false); + } return createIterResultObject([index, target[index]], false); }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% // https://tc39.es/ecma262/#sec-createunmappedargumentsobject // https://tc39.es/ecma262/#sec-createmappedargumentsobject -Iterators.Arguments = Iterators.Array; +var values = Iterators.Arguments = Iterators.Array; // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables addToUnscopables('keys'); addToUnscopables('values'); addToUnscopables('entries'); -},{"../internals/add-to-unscopables":91,"../internals/define-iterator":123,"../internals/internal-state":157,"../internals/iterators":169,"../internals/to-indexed-object":219}],248:[function(require,module,exports){ +// V8 ~ Chrome 45- bug +if (!IS_PURE && DESCRIPTORS && values.name !== 'values') try { + defineProperty(values, 'name', { value: 'values' }); +} catch (error) { /* empty */ } + +},{"../internals/add-to-unscopables":111,"../internals/create-iter-result-object":144,"../internals/descriptors":153,"../internals/internal-state":199,"../internals/is-pure":210,"../internals/iterator-define":216,"../internals/iterators":218,"../internals/object-define-property":231,"../internals/to-indexed-object":282}],317:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); +var uncurryThis = require('../internals/function-uncurry-this'); var IndexedObject = require('../internals/indexed-object'); var toIndexedObject = require('../internals/to-indexed-object'); var arrayMethodIsStrict = require('../internals/array-method-is-strict'); -var nativeJoin = [].join; +var nativeJoin = uncurryThis([].join); -var ES3_STRINGS = IndexedObject != Object; -var STRICT_METHOD = arrayMethodIsStrict('join', ','); +var ES3_STRINGS = IndexedObject !== Object; +var FORCED = ES3_STRINGS || !arrayMethodIsStrict('join', ','); // `Array.prototype.join` method // https://tc39.es/ecma262/#sec-array.prototype.join -$({ target: 'Array', proto: true, forced: ES3_STRINGS || !STRICT_METHOD }, { +$({ target: 'Array', proto: true, forced: FORCED }, { join: function join(separator) { - return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator); + return nativeJoin(toIndexedObject(this), separator === undefined ? ',' : separator); } }); -},{"../internals/array-method-is-strict":107,"../internals/export":139,"../internals/indexed-object":154,"../internals/to-indexed-object":219}],249:[function(require,module,exports){ +},{"../internals/array-method-is-strict":128,"../internals/export":170,"../internals/function-uncurry-this":181,"../internals/indexed-object":195,"../internals/to-indexed-object":282}],318:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var $map = require('../internals/array-iteration').map; @@ -16421,22 +17174,24 @@ $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { } }); -},{"../internals/array-iteration":104,"../internals/array-method-has-species-support":106,"../internals/export":139}],250:[function(require,module,exports){ +},{"../internals/array-iteration":125,"../internals/array-method-has-species-support":127,"../internals/export":170}],319:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); -var isObject = require('../internals/is-object'); var isArray = require('../internals/is-array'); +var isConstructor = require('../internals/is-constructor'); +var isObject = require('../internals/is-object'); var toAbsoluteIndex = require('../internals/to-absolute-index'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); var toIndexedObject = require('../internals/to-indexed-object'); var createProperty = require('../internals/create-property'); var wellKnownSymbol = require('../internals/well-known-symbol'); var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support'); +var nativeSlice = require('../internals/array-slice'); var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice'); var SPECIES = wellKnownSymbol('species'); -var nativeSlice = [].slice; +var $Array = Array; var max = Math.max; // `Array.prototype.slice` method @@ -16445,7 +17200,7 @@ var max = Math.max; $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { slice: function slice(start, end) { var O = toIndexedObject(this); - var length = toLength(O.length); + var length = lengthOfArrayLike(O); var k = toAbsoluteIndex(start, length); var fin = toAbsoluteIndex(end === undefined ? length : end, length); // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible @@ -16453,29 +17208,31 @@ $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { if (isArray(O)) { Constructor = O.constructor; // cross-realm fallback - if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) { + if (isConstructor(Constructor) && (Constructor === $Array || isArray(Constructor.prototype))) { Constructor = undefined; } else if (isObject(Constructor)) { Constructor = Constructor[SPECIES]; if (Constructor === null) Constructor = undefined; } - if (Constructor === Array || Constructor === undefined) { - return nativeSlice.call(O, k, fin); + if (Constructor === $Array || Constructor === undefined) { + return nativeSlice(O, k, fin); } } - result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0)); + result = new (Constructor === undefined ? $Array : Constructor)(max(fin - k, 0)); for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]); result.length = n; return result; } }); -},{"../internals/array-method-has-species-support":106,"../internals/create-property":122,"../internals/export":139,"../internals/is-array":159,"../internals/is-object":162,"../internals/to-absolute-index":217,"../internals/to-indexed-object":219,"../internals/to-length":221,"../internals/well-known-symbol":237}],251:[function(require,module,exports){ +},{"../internals/array-method-has-species-support":127,"../internals/array-slice":131,"../internals/create-property":147,"../internals/export":170,"../internals/is-array":201,"../internals/is-constructor":204,"../internals/is-object":208,"../internals/length-of-array-like":219,"../internals/to-absolute-index":279,"../internals/to-indexed-object":282,"../internals/well-known-symbol":306}],320:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); -var aFunction = require('../internals/a-function'); +var uncurryThis = require('../internals/function-uncurry-this'); +var aCallable = require('../internals/a-callable'); var toObject = require('../internals/to-object'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); +var deletePropertyOrThrow = require('../internals/delete-property-or-throw'); var toString = require('../internals/to-string'); var fails = require('../internals/fails'); var internalSort = require('../internals/array-sort'); @@ -16486,7 +17243,8 @@ var V8 = require('../internals/engine-v8-version'); var WEBKIT = require('../internals/engine-webkit-version'); var test = []; -var nativeSort = test.sort; +var nativeSort = uncurryThis(test.sort); +var push = uncurryThis(test.push); // IE8- var FAILS_ON_UNDEFINED = fails(function () { @@ -16549,48 +17307,50 @@ var getSortCompare = function (comparefn) { // https://tc39.es/ecma262/#sec-array.prototype.sort $({ target: 'Array', proto: true, forced: FORCED }, { sort: function sort(comparefn) { - if (comparefn !== undefined) aFunction(comparefn); + if (comparefn !== undefined) aCallable(comparefn); var array = toObject(this); - if (STABLE_SORT) return comparefn === undefined ? nativeSort.call(array) : nativeSort.call(array, comparefn); + if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn); var items = []; - var arrayLength = toLength(array.length); + var arrayLength = lengthOfArrayLike(array); var itemsLength, index; for (index = 0; index < arrayLength; index++) { - if (index in array) items.push(array[index]); + if (index in array) push(items, array[index]); } - items = internalSort(items, getSortCompare(comparefn)); - itemsLength = items.length; + internalSort(items, getSortCompare(comparefn)); + + itemsLength = lengthOfArrayLike(items); index = 0; while (index < itemsLength) array[index] = items[index++]; - while (index < arrayLength) delete array[index++]; + while (index < arrayLength) deletePropertyOrThrow(array, index++); return array; } }); -},{"../internals/a-function":89,"../internals/array-method-is-strict":107,"../internals/array-sort":109,"../internals/engine-ff-version":128,"../internals/engine-is-ie-or-edge":130,"../internals/engine-v8-version":136,"../internals/engine-webkit-version":137,"../internals/export":139,"../internals/fails":140,"../internals/to-length":221,"../internals/to-object":222,"../internals/to-string":228}],252:[function(require,module,exports){ +},{"../internals/a-callable":108,"../internals/array-method-is-strict":128,"../internals/array-sort":132,"../internals/delete-property-or-throw":152,"../internals/engine-ff-version":158,"../internals/engine-is-ie-or-edge":161,"../internals/engine-v8-version":167,"../internals/engine-webkit-version":168,"../internals/export":170,"../internals/fails":171,"../internals/function-uncurry-this":181,"../internals/length-of-array-like":219,"../internals/to-object":285,"../internals/to-string":291}],321:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); -var toAbsoluteIndex = require('../internals/to-absolute-index'); -var toInteger = require('../internals/to-integer'); -var toLength = require('../internals/to-length'); var toObject = require('../internals/to-object'); +var toAbsoluteIndex = require('../internals/to-absolute-index'); +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); +var setArrayLength = require('../internals/array-set-length'); +var doesNotExceedSafeInteger = require('../internals/does-not-exceed-safe-integer'); var arraySpeciesCreate = require('../internals/array-species-create'); var createProperty = require('../internals/create-property'); +var deletePropertyOrThrow = require('../internals/delete-property-or-throw'); var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support'); var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice'); var max = Math.max; var min = Math.min; -var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; -var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; // `Array.prototype.splice` method // https://tc39.es/ecma262/#sec-array.prototype.splice @@ -16598,7 +17358,7 @@ var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded'; $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { splice: function splice(start, deleteCount /* , ...items */) { var O = toObject(this); - var len = toLength(O.length); + var len = lengthOfArrayLike(O); var actualStart = toAbsoluteIndex(start, len); var argumentsLength = arguments.length; var insertCount, actualDeleteCount, A, k, from, to; @@ -16609,11 +17369,9 @@ $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { actualDeleteCount = len - actualStart; } else { insertCount = argumentsLength - 2; - actualDeleteCount = min(max(toInteger(deleteCount), 0), len - actualStart); - } - if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) { - throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED); + actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart); } + doesNotExceedSafeInteger(len + insertCount - actualDeleteCount); A = arraySpeciesCreate(O, actualDeleteCount); for (k = 0; k < actualDeleteCount; k++) { from = actualStart + k; @@ -16625,42 +17383,46 @@ $({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { from = k + actualDeleteCount; to = k + insertCount; if (from in O) O[to] = O[from]; - else delete O[to]; + else deletePropertyOrThrow(O, to); } - for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1]; + for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1); } else if (insertCount > actualDeleteCount) { for (k = len - actualDeleteCount; k > actualStart; k--) { from = k + actualDeleteCount - 1; to = k + insertCount - 1; if (from in O) O[to] = O[from]; - else delete O[to]; + else deletePropertyOrThrow(O, to); } } for (k = 0; k < insertCount; k++) { O[k + actualStart] = arguments[k + 2]; } - O.length = len - actualDeleteCount + insertCount; + setArrayLength(O, len - actualDeleteCount + insertCount); return A; } }); -},{"../internals/array-method-has-species-support":106,"../internals/array-species-create":111,"../internals/create-property":122,"../internals/export":139,"../internals/to-absolute-index":217,"../internals/to-integer":220,"../internals/to-length":221,"../internals/to-object":222}],253:[function(require,module,exports){ +},{"../internals/array-method-has-species-support":127,"../internals/array-set-length":130,"../internals/array-species-create":134,"../internals/create-property":147,"../internals/delete-property-or-throw":152,"../internals/does-not-exceed-safe-integer":155,"../internals/export":170,"../internals/length-of-array-like":219,"../internals/to-absolute-index":279,"../internals/to-integer-or-infinity":283,"../internals/to-object":285}],322:[function(require,module,exports){ +'use strict'; var DESCRIPTORS = require('../internals/descriptors'); -var defineProperty = require('../internals/object-define-property').f; +var FUNCTION_NAME_EXISTS = require('../internals/function-name').EXISTS; +var uncurryThis = require('../internals/function-uncurry-this'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var FunctionPrototype = Function.prototype; -var FunctionPrototypeToString = FunctionPrototype.toString; -var nameRE = /^\s*function ([^ (]*)/; +var functionToString = uncurryThis(FunctionPrototype.toString); +var nameRE = /function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/; +var regExpExec = uncurryThis(nameRE.exec); var NAME = 'name'; // Function instances `.name` property // https://tc39.es/ecma262/#sec-function-instances-name -if (DESCRIPTORS && !(NAME in FunctionPrototype)) { - defineProperty(FunctionPrototype, NAME, { +if (DESCRIPTORS && !FUNCTION_NAME_EXISTS) { + defineBuiltInAccessor(FunctionPrototype, NAME, { configurable: true, get: function () { try { - return FunctionPrototypeToString.call(this).match(nameRE)[1]; + return regExpExec(nameRE, functionToString(this))[1]; } catch (error) { return ''; } @@ -16668,53 +17430,150 @@ if (DESCRIPTORS && !(NAME in FunctionPrototype)) { }); } -},{"../internals/descriptors":125,"../internals/object-define-property":179}],254:[function(require,module,exports){ +},{"../internals/define-built-in-accessor":148,"../internals/descriptors":153,"../internals/function-name":178,"../internals/function-uncurry-this":181}],323:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var getBuiltIn = require('../internals/get-built-in'); +var apply = require('../internals/function-apply'); +var call = require('../internals/function-call'); +var uncurryThis = require('../internals/function-uncurry-this'); +var fails = require('../internals/fails'); +var isCallable = require('../internals/is-callable'); +var isSymbol = require('../internals/is-symbol'); +var arraySlice = require('../internals/array-slice'); +var getReplacerFunction = require('../internals/get-json-replacer-function'); +var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection'); + +var $String = String; +var $stringify = getBuiltIn('JSON', 'stringify'); +var exec = uncurryThis(/./.exec); +var charAt = uncurryThis(''.charAt); +var charCodeAt = uncurryThis(''.charCodeAt); +var replace = uncurryThis(''.replace); +var numberToString = uncurryThis(1.0.toString); + +var tester = /[\uD800-\uDFFF]/g; +var low = /^[\uD800-\uDBFF]$/; +var hi = /^[\uDC00-\uDFFF]$/; + +var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () { + var symbol = getBuiltIn('Symbol')('stringify detection'); + // MS Edge converts symbol values to JSON as {} + return $stringify([symbol]) !== '[null]' + // WebKit converts symbol values to JSON as null + || $stringify({ a: symbol }) !== '{}' + // V8 throws on boxed symbols + || $stringify(Object(symbol)) !== '{}'; +}); + +// https://github.com/tc39/proposal-well-formed-stringify +var ILL_FORMED_UNICODE = fails(function () { + return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' + || $stringify('\uDEAD') !== '"\\udead"'; +}); + +var stringifyWithSymbolsFix = function (it, replacer) { + var args = arraySlice(arguments); + var $replacer = getReplacerFunction(replacer); + if (!isCallable($replacer) && (it === undefined || isSymbol(it))) return; // IE8 returns string on undefined + args[1] = function (key, value) { + // some old implementations (like WebKit) could pass numbers as keys + if (isCallable($replacer)) value = call($replacer, this, $String(key), value); + if (!isSymbol(value)) return value; + }; + return apply($stringify, null, args); +}; + +var fixIllFormed = function (match, offset, string) { + var prev = charAt(string, offset - 1); + var next = charAt(string, offset + 1); + if ((exec(low, match) && !exec(hi, next)) || (exec(hi, match) && !exec(low, prev))) { + return '\\u' + numberToString(charCodeAt(match, 0), 16); + } return match; +}; + +if ($stringify) { + // `JSON.stringify` method + // https://tc39.es/ecma262/#sec-json.stringify + $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + stringify: function stringify(it, replacer, space) { + var args = arraySlice(arguments); + var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args); + return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result; + } + }); +} + +},{"../internals/array-slice":131,"../internals/export":170,"../internals/fails":171,"../internals/function-apply":174,"../internals/function-call":177,"../internals/function-uncurry-this":181,"../internals/get-built-in":182,"../internals/get-json-replacer-function":185,"../internals/is-callable":203,"../internals/is-symbol":212,"../internals/symbol-constructor-detection":274}],324:[function(require,module,exports){ 'use strict'; +var $ = require('../internals/export'); +var IS_PURE = require('../internals/is-pure'); var DESCRIPTORS = require('../internals/descriptors'); var global = require('../internals/global'); +var path = require('../internals/path'); +var uncurryThis = require('../internals/function-uncurry-this'); var isForced = require('../internals/is-forced'); -var redefine = require('../internals/redefine'); -var has = require('../internals/has'); -var classof = require('../internals/classof-raw'); +var hasOwn = require('../internals/has-own-property'); var inheritIfRequired = require('../internals/inherit-if-required'); +var isPrototypeOf = require('../internals/object-is-prototype-of'); var isSymbol = require('../internals/is-symbol'); var toPrimitive = require('../internals/to-primitive'); var fails = require('../internals/fails'); -var create = require('../internals/object-create'); var getOwnPropertyNames = require('../internals/object-get-own-property-names').f; var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f; var defineProperty = require('../internals/object-define-property').f; +var thisNumberValue = require('../internals/this-number-value'); var trim = require('../internals/string-trim').trim; var NUMBER = 'Number'; var NativeNumber = global[NUMBER]; +var PureNumberNamespace = path[NUMBER]; var NumberPrototype = NativeNumber.prototype; +var TypeError = global.TypeError; +var stringSlice = uncurryThis(''.slice); +var charCodeAt = uncurryThis(''.charCodeAt); -// Opera ~12 has broken Object#toString -var BROKEN_CLASSOF = classof(create(NumberPrototype)) == NUMBER; +// `ToNumeric` abstract operation +// https://tc39.es/ecma262/#sec-tonumeric +var toNumeric = function (value) { + var primValue = toPrimitive(value, 'number'); + return typeof primValue == 'bigint' ? primValue : toNumber(primValue); +}; // `ToNumber` abstract operation // https://tc39.es/ecma262/#sec-tonumber var toNumber = function (argument) { - if (isSymbol(argument)) throw TypeError('Cannot convert a Symbol value to a number'); var it = toPrimitive(argument, 'number'); var first, third, radix, maxCode, digits, length, index, code; + if (isSymbol(it)) throw new TypeError('Cannot convert a Symbol value to a number'); if (typeof it == 'string' && it.length > 2) { it = trim(it); - first = it.charCodeAt(0); + first = charCodeAt(it, 0); if (first === 43 || first === 45) { - third = it.charCodeAt(2); + third = charCodeAt(it, 2); if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix } else if (first === 48) { - switch (it.charCodeAt(1)) { - case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i - case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i - default: return +it; + switch (charCodeAt(it, 1)) { + // fast equal of /^0b[01]+$/i + case 66: + case 98: + radix = 2; + maxCode = 49; + break; + // fast equal of /^0o[0-7]+$/i + case 79: + case 111: + radix = 8; + maxCode = 55; + break; + default: + return +it; } - digits = it.slice(2); + digits = stringSlice(it, 2); length = digits.length; for (index = 0; index < length; index++) { - code = digits.charCodeAt(index); + code = charCodeAt(digits, index); // parseInt parses a string to a first unavailable symbol // but ToNumber should return NaN if a string contains unavailable symbols if (code < 48 || code > maxCode) return NaN; @@ -16723,47 +17582,60 @@ var toNumber = function (argument) { } return +it; }; +var FORCED = isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1')); + +var calledWithNew = function (dummy) { + // includes check on 1..constructor(foo) case + return isPrototypeOf(NumberPrototype, dummy) && fails(function () { thisNumberValue(dummy); }); +}; + // `Number` constructor // https://tc39.es/ecma262/#sec-number-constructor -if (isForced(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) { - var NumberWrapper = function Number(value) { - var it = arguments.length < 1 ? 0 : value; - var dummy = this; - return dummy instanceof NumberWrapper - // check on 1..constructor(foo) case - && (BROKEN_CLASSOF ? fails(function () { NumberPrototype.valueOf.call(dummy); }) : classof(dummy) != NUMBER) - ? inheritIfRequired(new NativeNumber(toNumber(it)), dummy, NumberWrapper) : toNumber(it); - }; - for (var keys = DESCRIPTORS ? getOwnPropertyNames(NativeNumber) : ( +var NumberWrapper = function Number(value) { + var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value)); + return calledWithNew(this) ? inheritIfRequired(Object(n), this, NumberWrapper) : n; +}; + +NumberWrapper.prototype = NumberPrototype; +if (FORCED && !IS_PURE) NumberPrototype.constructor = NumberWrapper; + +$({ global: true, constructor: true, wrap: true, forced: FORCED }, { + Number: NumberWrapper +}); + +// Use `internal/copy-constructor-properties` helper in `core-js@4` +var copyConstructorProperties = function (target, source) { + for (var keys = DESCRIPTORS ? getOwnPropertyNames(source) : ( // ES3: 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + // ES2015 (in case, if modules with ES2015 Number statics required before): - 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + - 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,' + + 'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' + // ESNext 'fromString,range' ).split(','), j = 0, key; keys.length > j; j++) { - if (has(NativeNumber, key = keys[j]) && !has(NumberWrapper, key)) { - defineProperty(NumberWrapper, key, getOwnPropertyDescriptor(NativeNumber, key)); + if (hasOwn(source, key = keys[j]) && !hasOwn(target, key)) { + defineProperty(target, key, getOwnPropertyDescriptor(source, key)); } } - NumberWrapper.prototype = NumberPrototype; - NumberPrototype.constructor = NumberWrapper; - redefine(global, NUMBER, NumberWrapper); -} +}; + +if (IS_PURE && PureNumberNamespace) copyConstructorProperties(path[NUMBER], PureNumberNamespace); +if (FORCED || IS_PURE) copyConstructorProperties(path[NUMBER], NativeNumber); -},{"../internals/classof-raw":114,"../internals/descriptors":125,"../internals/fails":140,"../internals/global":147,"../internals/has":148,"../internals/inherit-if-required":155,"../internals/is-forced":160,"../internals/is-symbol":165,"../internals/object-create":177,"../internals/object-define-property":179,"../internals/object-get-own-property-descriptor":180,"../internals/object-get-own-property-names":182,"../internals/redefine":197,"../internals/string-trim":215,"../internals/to-primitive":225}],255:[function(require,module,exports){ +},{"../internals/descriptors":153,"../internals/export":170,"../internals/fails":171,"../internals/function-uncurry-this":181,"../internals/global":188,"../internals/has-own-property":189,"../internals/inherit-if-required":196,"../internals/is-forced":205,"../internals/is-pure":210,"../internals/is-symbol":212,"../internals/object-define-property":231,"../internals/object-get-own-property-descriptor":232,"../internals/object-get-own-property-names":234,"../internals/object-is-prototype-of":238,"../internals/path":247,"../internals/string-trim":273,"../internals/this-number-value":278,"../internals/to-primitive":288}],325:[function(require,module,exports){ +'use strict'; var $ = require('../internals/export'); var assign = require('../internals/object-assign'); // `Object.assign` method // https://tc39.es/ecma262/#sec-object.assign // eslint-disable-next-line es/no-object-assign -- required for testing -$({ target: 'Object', stat: true, forced: Object.assign !== assign }, { +$({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, { assign: assign }); -},{"../internals/export":139,"../internals/object-assign":176}],256:[function(require,module,exports){ +},{"../internals/export":170,"../internals/object-assign":228}],326:[function(require,module,exports){ +'use strict'; var $ = require('../internals/export'); var $entries = require('../internals/object-to-array').entries; @@ -16775,7 +17647,74 @@ $({ target: 'Object', stat: true }, { } }); -},{"../internals/export":139,"../internals/object-to-array":189}],257:[function(require,module,exports){ +},{"../internals/export":170,"../internals/object-to-array":243}],327:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var fails = require('../internals/fails'); +var toIndexedObject = require('../internals/to-indexed-object'); +var nativeGetOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f; +var DESCRIPTORS = require('../internals/descriptors'); + +var FORCED = !DESCRIPTORS || fails(function () { nativeGetOwnPropertyDescriptor(1); }); + +// `Object.getOwnPropertyDescriptor` method +// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor +$({ target: 'Object', stat: true, forced: FORCED, sham: !DESCRIPTORS }, { + getOwnPropertyDescriptor: function getOwnPropertyDescriptor(it, key) { + return nativeGetOwnPropertyDescriptor(toIndexedObject(it), key); + } +}); + +},{"../internals/descriptors":153,"../internals/export":170,"../internals/fails":171,"../internals/object-get-own-property-descriptor":232,"../internals/to-indexed-object":282}],328:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var DESCRIPTORS = require('../internals/descriptors'); +var ownKeys = require('../internals/own-keys'); +var toIndexedObject = require('../internals/to-indexed-object'); +var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor'); +var createProperty = require('../internals/create-property'); + +// `Object.getOwnPropertyDescriptors` method +// https://tc39.es/ecma262/#sec-object.getownpropertydescriptors +$({ target: 'Object', stat: true, sham: !DESCRIPTORS }, { + getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) { + var O = toIndexedObject(object); + var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; + var keys = ownKeys(O); + var result = {}; + var index = 0; + var key, descriptor; + while (keys.length > index) { + descriptor = getOwnPropertyDescriptor(O, key = keys[index++]); + if (descriptor !== undefined) createProperty(result, key, descriptor); + } + return result; + } +}); + +},{"../internals/create-property":147,"../internals/descriptors":153,"../internals/export":170,"../internals/object-get-own-property-descriptor":232,"../internals/own-keys":246,"../internals/to-indexed-object":282}],329:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection'); +var fails = require('../internals/fails'); +var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols'); +var toObject = require('../internals/to-object'); + +// V8 ~ Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives +// https://bugs.chromium.org/p/v8/issues/detail?id=3443 +var FORCED = !NATIVE_SYMBOL || fails(function () { getOwnPropertySymbolsModule.f(1); }); + +// `Object.getOwnPropertySymbols` method +// https://tc39.es/ecma262/#sec-object.getownpropertysymbols +$({ target: 'Object', stat: true, forced: FORCED }, { + getOwnPropertySymbols: function getOwnPropertySymbols(it) { + var $getOwnPropertySymbols = getOwnPropertySymbolsModule.f; + return $getOwnPropertySymbols ? $getOwnPropertySymbols(toObject(it)) : []; + } +}); + +},{"../internals/export":170,"../internals/fails":171,"../internals/object-get-own-property-symbols":235,"../internals/symbol-constructor-detection":274,"../internals/to-object":285}],330:[function(require,module,exports){ +'use strict'; var $ = require('../internals/export'); var toObject = require('../internals/to-object'); var nativeKeys = require('../internals/object-keys'); @@ -16791,64 +17730,129 @@ $({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES }, { } }); -},{"../internals/export":139,"../internals/fails":140,"../internals/object-keys":186,"../internals/to-object":222}],258:[function(require,module,exports){ +},{"../internals/export":170,"../internals/fails":171,"../internals/object-keys":240,"../internals/to-object":285}],331:[function(require,module,exports){ +'use strict'; var TO_STRING_TAG_SUPPORT = require('../internals/to-string-tag-support'); -var redefine = require('../internals/redefine'); +var defineBuiltIn = require('../internals/define-built-in'); var toString = require('../internals/object-to-string'); // `Object.prototype.toString` method // https://tc39.es/ecma262/#sec-object.prototype.tostring if (!TO_STRING_TAG_SUPPORT) { - redefine(Object.prototype, 'toString', toString, { unsafe: true }); + defineBuiltIn(Object.prototype, 'toString', toString, { unsafe: true }); } -},{"../internals/object-to-string":190,"../internals/redefine":197,"../internals/to-string-tag-support":227}],259:[function(require,module,exports){ +},{"../internals/define-built-in":149,"../internals/object-to-string":244,"../internals/to-string-tag-support":290}],332:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var call = require('../internals/function-call'); +var aCallable = require('../internals/a-callable'); +var newPromiseCapabilityModule = require('../internals/new-promise-capability'); +var perform = require('../internals/perform'); +var iterate = require('../internals/iterate'); +var PROMISE_STATICS_INCORRECT_ITERATION = require('../internals/promise-statics-incorrect-iteration'); + +// `Promise.all` method +// https://tc39.es/ecma262/#sec-promise.all +$({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, { + all: function all(iterable) { + var C = this; + var capability = newPromiseCapabilityModule.f(C); + var resolve = capability.resolve; + var reject = capability.reject; + var result = perform(function () { + var $promiseResolve = aCallable(C.resolve); + var values = []; + var counter = 0; + var remaining = 1; + iterate(iterable, function (promise) { + var index = counter++; + var alreadyCalled = false; + remaining++; + call($promiseResolve, C, promise).then(function (value) { + if (alreadyCalled) return; + alreadyCalled = true; + values[index] = value; + --remaining || resolve(values); + }, reject); + }); + --remaining || resolve(values); + }); + if (result.error) reject(result.value); + return capability.promise; + } +}); + +},{"../internals/a-callable":108,"../internals/export":170,"../internals/function-call":177,"../internals/iterate":213,"../internals/new-promise-capability":226,"../internals/perform":248,"../internals/promise-statics-incorrect-iteration":252}],333:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var IS_PURE = require('../internals/is-pure'); -var global = require('../internals/global'); +var FORCED_PROMISE_CONSTRUCTOR = require('../internals/promise-constructor-detection').CONSTRUCTOR; +var NativePromiseConstructor = require('../internals/promise-native-constructor'); var getBuiltIn = require('../internals/get-built-in'); -var NativePromise = require('../internals/native-promise-constructor'); -var redefine = require('../internals/redefine'); -var redefineAll = require('../internals/redefine-all'); +var isCallable = require('../internals/is-callable'); +var defineBuiltIn = require('../internals/define-built-in'); + +var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype; + +// `Promise.prototype.catch` method +// https://tc39.es/ecma262/#sec-promise.prototype.catch +$({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, { + 'catch': function (onRejected) { + return this.then(undefined, onRejected); + } +}); + +// makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then` +if (!IS_PURE && isCallable(NativePromiseConstructor)) { + var method = getBuiltIn('Promise').prototype['catch']; + if (NativePromisePrototype['catch'] !== method) { + defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true }); + } +} + +},{"../internals/define-built-in":149,"../internals/export":170,"../internals/get-built-in":182,"../internals/is-callable":203,"../internals/is-pure":210,"../internals/promise-constructor-detection":249,"../internals/promise-native-constructor":250}],334:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var IS_PURE = require('../internals/is-pure'); +var IS_NODE = require('../internals/engine-is-node'); +var global = require('../internals/global'); +var call = require('../internals/function-call'); +var defineBuiltIn = require('../internals/define-built-in'); var setPrototypeOf = require('../internals/object-set-prototype-of'); var setToStringTag = require('../internals/set-to-string-tag'); var setSpecies = require('../internals/set-species'); +var aCallable = require('../internals/a-callable'); +var isCallable = require('../internals/is-callable'); var isObject = require('../internals/is-object'); -var aFunction = require('../internals/a-function'); var anInstance = require('../internals/an-instance'); -var inspectSource = require('../internals/inspect-source'); -var iterate = require('../internals/iterate'); -var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration'); var speciesConstructor = require('../internals/species-constructor'); var task = require('../internals/task').set; var microtask = require('../internals/microtask'); -var promiseResolve = require('../internals/promise-resolve'); var hostReportErrors = require('../internals/host-report-errors'); -var newPromiseCapabilityModule = require('../internals/new-promise-capability'); var perform = require('../internals/perform'); +var Queue = require('../internals/queue'); var InternalStateModule = require('../internals/internal-state'); -var isForced = require('../internals/is-forced'); -var wellKnownSymbol = require('../internals/well-known-symbol'); -var IS_BROWSER = require('../internals/engine-is-browser'); -var IS_NODE = require('../internals/engine-is-node'); -var V8_VERSION = require('../internals/engine-v8-version'); +var NativePromiseConstructor = require('../internals/promise-native-constructor'); +var PromiseConstructorDetection = require('../internals/promise-constructor-detection'); +var newPromiseCapabilityModule = require('../internals/new-promise-capability'); -var SPECIES = wellKnownSymbol('species'); var PROMISE = 'Promise'; -var getInternalState = InternalStateModule.get; -var setInternalState = InternalStateModule.set; +var FORCED_PROMISE_CONSTRUCTOR = PromiseConstructorDetection.CONSTRUCTOR; +var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT; +var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING; var getInternalPromiseState = InternalStateModule.getterFor(PROMISE); -var NativePromisePrototype = NativePromise && NativePromise.prototype; -var PromiseConstructor = NativePromise; -var PromiseConstructorPrototype = NativePromisePrototype; +var setInternalState = InternalStateModule.set; +var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype; +var PromiseConstructor = NativePromiseConstructor; +var PromisePrototype = NativePromisePrototype; var TypeError = global.TypeError; var document = global.document; var process = global.process; var newPromiseCapability = newPromiseCapabilityModule.f; var newGenericPromiseCapability = newPromiseCapability; + var DISPATCH_EVENT = !!(document && document.createEvent && global.dispatchEvent); -var NATIVE_REJECTION_EVENT = typeof PromiseRejectionEvent == 'function'; var UNHANDLED_REJECTION = 'unhandledrejection'; var REJECTION_HANDLED = 'rejectionhandled'; var PENDING = 0; @@ -16856,88 +17860,59 @@ var FULFILLED = 1; var REJECTED = 2; var HANDLED = 1; var UNHANDLED = 2; -var SUBCLASSING = false; -var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen; - -var FORCED = isForced(PROMISE, function () { - var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(PromiseConstructor); - var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(PromiseConstructor); - // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables - // https://bugs.chromium.org/p/chromium/issues/detail?id=830565 - // We can't detect it synchronously, so just check versions - if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true; - // We need Promise#finally in the pure version for preventing prototype pollution - if (IS_PURE && !PromiseConstructorPrototype['finally']) return true; - // We can't use @@species feature detection in V8 since it causes - // deoptimization and performance degradation - // https://github.com/zloirock/core-js/issues/679 - if (V8_VERSION >= 51 && /native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) return false; - // Detect correctness of subclassing with @@species support - var promise = new PromiseConstructor(function (resolve) { resolve(1); }); - var FakePromise = function (exec) { - exec(function () { /* empty */ }, function () { /* empty */ }); - }; - var constructor = promise.constructor = {}; - constructor[SPECIES] = FakePromise; - SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise; - if (!SUBCLASSING) return true; - // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test - return !GLOBAL_CORE_JS_PROMISE && IS_BROWSER && !NATIVE_REJECTION_EVENT; -}); -var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) { - PromiseConstructor.all(iterable)['catch'](function () { /* empty */ }); -}); +var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen; // helpers var isThenable = function (it) { var then; - return isObject(it) && typeof (then = it.then) == 'function' ? then : false; + return isObject(it) && isCallable(then = it.then) ? then : false; +}; + +var callReaction = function (reaction, state) { + var value = state.value; + var ok = state.state === FULFILLED; + var handler = ok ? reaction.ok : reaction.fail; + var resolve = reaction.resolve; + var reject = reaction.reject; + var domain = reaction.domain; + var result, then, exited; + try { + if (handler) { + if (!ok) { + if (state.rejection === UNHANDLED) onHandleUnhandled(state); + state.rejection = HANDLED; + } + if (handler === true) result = value; + else { + if (domain) domain.enter(); + result = handler(value); // can throw + if (domain) { + domain.exit(); + exited = true; + } + } + if (result === reaction.promise) { + reject(new TypeError('Promise-chain cycle')); + } else if (then = isThenable(result)) { + call(then, result, resolve, reject); + } else resolve(result); + } else reject(value); + } catch (error) { + if (domain && !exited) domain.exit(); + reject(error); + } }; var notify = function (state, isReject) { if (state.notified) return; state.notified = true; - var chain = state.reactions; microtask(function () { - var value = state.value; - var ok = state.state == FULFILLED; - var index = 0; - // variable length - can't use forEach - while (chain.length > index) { - var reaction = chain[index++]; - var handler = ok ? reaction.ok : reaction.fail; - var resolve = reaction.resolve; - var reject = reaction.reject; - var domain = reaction.domain; - var result, then, exited; - try { - if (handler) { - if (!ok) { - if (state.rejection === UNHANDLED) onHandleUnhandled(state); - state.rejection = HANDLED; - } - if (handler === true) result = value; - else { - if (domain) domain.enter(); - result = handler(value); // can throw - if (domain) { - domain.exit(); - exited = true; - } - } - if (result === reaction.promise) { - reject(TypeError('Promise-chain cycle')); - } else if (then = isThenable(result)) { - then.call(result, resolve, reject); - } else resolve(result); - } else reject(value); - } catch (error) { - if (domain && !exited) domain.exit(); - reject(error); - } + var reactions = state.reactions; + var reaction; + while (reaction = reactions.get()) { + callReaction(reaction, state); } - state.reactions = []; state.notified = false; if (isReject && !state.rejection) onUnhandled(state); }); @@ -16952,12 +17927,12 @@ var dispatchEvent = function (name, promise, reason) { event.initEvent(name, false, true); global.dispatchEvent(event); } else event = { promise: promise, reason: reason }; - if (!NATIVE_REJECTION_EVENT && (handler = global['on' + name])) handler(event); + if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = global['on' + name])) handler(event); else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason); }; var onUnhandled = function (state) { - task.call(global, function () { + call(task, global, function () { var promise = state.facade; var value = state.value; var IS_UNHANDLED = isUnhandled(state); @@ -16980,7 +17955,7 @@ var isUnhandled = function (state) { }; var onHandleUnhandled = function (state) { - task.call(global, function () { + call(task, global, function () { var promise = state.facade; if (IS_NODE) { process.emit('rejectionHandled', promise); @@ -17008,13 +17983,13 @@ var internalResolve = function (state, value, unwrap) { state.done = true; if (unwrap) state = unwrap; try { - if (state.facade === value) throw TypeError("Promise can't be resolved itself"); + if (state.facade === value) throw new TypeError("Promise can't be resolved itself"); var then = isThenable(value); if (then) { microtask(function () { var wrapper = { done: false }; try { - then.call(value, + call(then, value, bind(internalResolve, wrapper, state), bind(internalReject, wrapper, state) ); @@ -17033,20 +18008,22 @@ var internalResolve = function (state, value, unwrap) { }; // constructor polyfill -if (FORCED) { +if (FORCED_PROMISE_CONSTRUCTOR) { // 25.4.3.1 Promise(executor) PromiseConstructor = function Promise(executor) { - anInstance(this, PromiseConstructor, PROMISE); - aFunction(executor); - Internal.call(this); - var state = getInternalState(this); + anInstance(this, PromisePrototype); + aCallable(executor); + call(Internal, this); + var state = getInternalPromiseState(this); try { executor(bind(internalResolve, state), bind(internalReject, state)); } catch (error) { internalReject(state, error); } }; - PromiseConstructorPrototype = PromiseConstructor.prototype; + + PromisePrototype = PromiseConstructor.prototype; + // eslint-disable-next-line no-unused-vars -- required for `.length` Internal = function Promise(executor) { setInternalState(this, { @@ -17054,60 +18031,55 @@ if (FORCED) { done: false, notified: false, parent: false, - reactions: [], + reactions: new Queue(), rejection: false, state: PENDING, value: undefined }); }; - Internal.prototype = redefineAll(PromiseConstructorPrototype, { - // `Promise.prototype.then` method - // https://tc39.es/ecma262/#sec-promise.prototype.then - then: function then(onFulfilled, onRejected) { - var state = getInternalPromiseState(this); - var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor)); - reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; - reaction.fail = typeof onRejected == 'function' && onRejected; - reaction.domain = IS_NODE ? process.domain : undefined; - state.parent = true; - state.reactions.push(reaction); - if (state.state != PENDING) notify(state, false); - return reaction.promise; - }, - // `Promise.prototype.catch` method - // https://tc39.es/ecma262/#sec-promise.prototype.catch - 'catch': function (onRejected) { - return this.then(undefined, onRejected); - } + + // `Promise.prototype.then` method + // https://tc39.es/ecma262/#sec-promise.prototype.then + Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) { + var state = getInternalPromiseState(this); + var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor)); + state.parent = true; + reaction.ok = isCallable(onFulfilled) ? onFulfilled : true; + reaction.fail = isCallable(onRejected) && onRejected; + reaction.domain = IS_NODE ? process.domain : undefined; + if (state.state === PENDING) state.reactions.add(reaction); + else microtask(function () { + callReaction(reaction, state); + }); + return reaction.promise; }); + OwnPromiseCapability = function () { var promise = new Internal(); - var state = getInternalState(promise); + var state = getInternalPromiseState(promise); this.promise = promise; this.resolve = bind(internalResolve, state); this.reject = bind(internalReject, state); }; + newPromiseCapabilityModule.f = newPromiseCapability = function (C) { return C === PromiseConstructor || C === PromiseWrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C); }; - if (!IS_PURE && typeof NativePromise == 'function' && NativePromisePrototype !== Object.prototype) { + if (!IS_PURE && isCallable(NativePromiseConstructor) && NativePromisePrototype !== Object.prototype) { nativeThen = NativePromisePrototype.then; - if (!SUBCLASSING) { + if (!NATIVE_PROMISE_SUBCLASSING) { // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs - redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) { + defineBuiltIn(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) { var that = this; return new PromiseConstructor(function (resolve, reject) { - nativeThen.call(that, resolve, reject); + call(nativeThen, that, resolve, reject); }).then(onFulfilled, onRejected); // https://github.com/zloirock/core-js/issues/640 }, { unsafe: true }); - - // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then` - redefine(NativePromisePrototype, 'catch', PromiseConstructorPrototype['catch'], { unsafe: true }); } // make `.constructor === Promise` work for native promise-based APIs @@ -17117,79 +18089,49 @@ if (FORCED) { // make `instanceof Promise` work for native promise-based APIs if (setPrototypeOf) { - setPrototypeOf(NativePromisePrototype, PromiseConstructorPrototype); + setPrototypeOf(NativePromisePrototype, PromisePrototype); } } } -$({ global: true, wrap: true, forced: FORCED }, { +$({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR }, { Promise: PromiseConstructor }); setToStringTag(PromiseConstructor, PROMISE, false, true); setSpecies(PROMISE); -PromiseWrapper = getBuiltIn(PROMISE); - -// statics -$({ target: PROMISE, stat: true, forced: FORCED }, { - // `Promise.reject` method - // https://tc39.es/ecma262/#sec-promise.reject - reject: function reject(r) { - var capability = newPromiseCapability(this); - capability.reject.call(undefined, r); - return capability.promise; - } -}); - -$({ target: PROMISE, stat: true, forced: IS_PURE || FORCED }, { - // `Promise.resolve` method - // https://tc39.es/ecma262/#sec-promise.resolve - resolve: function resolve(x) { - return promiseResolve(IS_PURE && this === PromiseWrapper ? PromiseConstructor : this, x); - } -}); +},{"../internals/a-callable":108,"../internals/an-instance":113,"../internals/define-built-in":149,"../internals/engine-is-node":164,"../internals/export":170,"../internals/function-call":177,"../internals/global":188,"../internals/host-report-errors":191,"../internals/internal-state":199,"../internals/is-callable":203,"../internals/is-object":208,"../internals/is-pure":210,"../internals/microtask":225,"../internals/new-promise-capability":226,"../internals/object-set-prototype-of":242,"../internals/perform":248,"../internals/promise-constructor-detection":249,"../internals/promise-native-constructor":250,"../internals/queue":254,"../internals/set-species":265,"../internals/set-to-string-tag":266,"../internals/species-constructor":270,"../internals/task":277}],335:[function(require,module,exports){ +'use strict'; +// TODO: Remove this module from `core-js@4` since it's split to modules listed below +require('../modules/es.promise.constructor'); +require('../modules/es.promise.all'); +require('../modules/es.promise.catch'); +require('../modules/es.promise.race'); +require('../modules/es.promise.reject'); +require('../modules/es.promise.resolve'); + +},{"../modules/es.promise.all":332,"../modules/es.promise.catch":333,"../modules/es.promise.constructor":334,"../modules/es.promise.race":336,"../modules/es.promise.reject":337,"../modules/es.promise.resolve":338}],336:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var call = require('../internals/function-call'); +var aCallable = require('../internals/a-callable'); +var newPromiseCapabilityModule = require('../internals/new-promise-capability'); +var perform = require('../internals/perform'); +var iterate = require('../internals/iterate'); +var PROMISE_STATICS_INCORRECT_ITERATION = require('../internals/promise-statics-incorrect-iteration'); -$({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, { - // `Promise.all` method - // https://tc39.es/ecma262/#sec-promise.all - all: function all(iterable) { - var C = this; - var capability = newPromiseCapability(C); - var resolve = capability.resolve; - var reject = capability.reject; - var result = perform(function () { - var $promiseResolve = aFunction(C.resolve); - var values = []; - var counter = 0; - var remaining = 1; - iterate(iterable, function (promise) { - var index = counter++; - var alreadyCalled = false; - values.push(undefined); - remaining++; - $promiseResolve.call(C, promise).then(function (value) { - if (alreadyCalled) return; - alreadyCalled = true; - values[index] = value; - --remaining || resolve(values); - }, reject); - }); - --remaining || resolve(values); - }); - if (result.error) reject(result.value); - return capability.promise; - }, - // `Promise.race` method - // https://tc39.es/ecma262/#sec-promise.race +// `Promise.race` method +// https://tc39.es/ecma262/#sec-promise.race +$({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, { race: function race(iterable) { var C = this; - var capability = newPromiseCapability(C); + var capability = newPromiseCapabilityModule.f(C); var reject = capability.reject; var result = perform(function () { - var $promiseResolve = aFunction(C.resolve); + var $promiseResolve = aCallable(C.resolve); iterate(iterable, function (promise) { - $promiseResolve.call(C, promise).then(capability.resolve, reject); + call($promiseResolve, C, promise).then(capability.resolve, reject); }); }); if (result.error) reject(result.value); @@ -17197,21 +18139,62 @@ $({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, { } }); -},{"../internals/a-function":89,"../internals/an-instance":93,"../internals/check-correctness-of-iteration":113,"../internals/engine-is-browser":129,"../internals/engine-is-node":133,"../internals/engine-v8-version":136,"../internals/export":139,"../internals/get-built-in":143,"../internals/global":147,"../internals/host-report-errors":150,"../internals/inspect-source":156,"../internals/internal-state":157,"../internals/is-forced":160,"../internals/is-object":162,"../internals/is-pure":163,"../internals/iterate":166,"../internals/microtask":170,"../internals/native-promise-constructor":171,"../internals/new-promise-capability":174,"../internals/object-set-prototype-of":188,"../internals/perform":194,"../internals/promise-resolve":195,"../internals/redefine":197,"../internals/redefine-all":196,"../internals/set-species":207,"../internals/set-to-string-tag":208,"../internals/species-constructor":212,"../internals/task":216,"../internals/well-known-symbol":237}],260:[function(require,module,exports){ +},{"../internals/a-callable":108,"../internals/export":170,"../internals/function-call":177,"../internals/iterate":213,"../internals/new-promise-capability":226,"../internals/perform":248,"../internals/promise-statics-incorrect-iteration":252}],337:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var newPromiseCapabilityModule = require('../internals/new-promise-capability'); +var FORCED_PROMISE_CONSTRUCTOR = require('../internals/promise-constructor-detection').CONSTRUCTOR; + +// `Promise.reject` method +// https://tc39.es/ecma262/#sec-promise.reject +$({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, { + reject: function reject(r) { + var capability = newPromiseCapabilityModule.f(this); + var capabilityReject = capability.reject; + capabilityReject(r); + return capability.promise; + } +}); + +},{"../internals/export":170,"../internals/new-promise-capability":226,"../internals/promise-constructor-detection":249}],338:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var getBuiltIn = require('../internals/get-built-in'); +var IS_PURE = require('../internals/is-pure'); +var NativePromiseConstructor = require('../internals/promise-native-constructor'); +var FORCED_PROMISE_CONSTRUCTOR = require('../internals/promise-constructor-detection').CONSTRUCTOR; +var promiseResolve = require('../internals/promise-resolve'); + +var PromiseConstructorWrapper = getBuiltIn('Promise'); +var CHECK_WRAPPER = IS_PURE && !FORCED_PROMISE_CONSTRUCTOR; + +// `Promise.resolve` method +// https://tc39.es/ecma262/#sec-promise.resolve +$({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR }, { + resolve: function resolve(x) { + return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? NativePromiseConstructor : this, x); + } +}); + +},{"../internals/export":170,"../internals/get-built-in":182,"../internals/is-pure":210,"../internals/promise-constructor-detection":249,"../internals/promise-native-constructor":250,"../internals/promise-resolve":251}],339:[function(require,module,exports){ +'use strict'; var DESCRIPTORS = require('../internals/descriptors'); var global = require('../internals/global'); +var uncurryThis = require('../internals/function-uncurry-this'); var isForced = require('../internals/is-forced'); var inheritIfRequired = require('../internals/inherit-if-required'); var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var defineProperty = require('../internals/object-define-property').f; +var create = require('../internals/object-create'); var getOwnPropertyNames = require('../internals/object-get-own-property-names').f; +var isPrototypeOf = require('../internals/object-is-prototype-of'); var isRegExp = require('../internals/is-regexp'); var toString = require('../internals/to-string'); -var getFlags = require('../internals/regexp-flags'); +var getRegExpFlags = require('../internals/regexp-get-flags'); var stickyHelpers = require('../internals/regexp-sticky-helpers'); -var redefine = require('../internals/redefine'); +var proxyAccessor = require('../internals/proxy-accessor'); +var defineBuiltIn = require('../internals/define-built-in'); var fails = require('../internals/fails'); -var has = require('../internals/has'); +var hasOwn = require('../internals/has-own-property'); var enforceInternalState = require('../internals/internal-state').enforce; var setSpecies = require('../internals/set-species'); var wellKnownSymbol = require('../internals/well-known-symbol'); @@ -17221,7 +18204,13 @@ var UNSUPPORTED_NCG = require('../internals/regexp-unsupported-ncg'); var MATCH = wellKnownSymbol('match'); var NativeRegExp = global.RegExp; var RegExpPrototype = NativeRegExp.prototype; -// TODO: Use only propper RegExpIdentifierName +var SyntaxError = global.SyntaxError; +var exec = uncurryThis(RegExpPrototype.exec); +var charAt = uncurryThis(''.charAt); +var replace = uncurryThis(''.replace); +var stringIndexOf = uncurryThis(''.indexOf); +var stringSlice = uncurryThis(''.slice); +// TODO: Use only proper RegExpIdentifierName var IS_NCG = /^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/; var re1 = /a/g; var re2 = /a/g; @@ -17229,13 +18218,14 @@ var re2 = /a/g; // "new" should create a new object, old webkit bug var CORRECT_NEW = new NativeRegExp(re1) !== re1; +var MISSED_STICKY = stickyHelpers.MISSED_STICKY; var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y; var BASE_FORCED = DESCRIPTORS && - (!CORRECT_NEW || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG || fails(function () { + (!CORRECT_NEW || MISSED_STICKY || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG || fails(function () { re2[MATCH] = false; // RegExp constructor can alter flags and IsRegExp works correct with @@match - return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i'; + return NativeRegExp(re1) !== re1 || NativeRegExp(re2) === re2 || String(NativeRegExp(re1, 'i')) !== '/a/i'; })); var handleDotAll = function (string) { @@ -17245,9 +18235,9 @@ var handleDotAll = function (string) { var brackets = false; var chr; for (; index <= length; index++) { - chr = string.charAt(index); + chr = charAt(string, index); if (chr === '\\') { - result += chr + string.charAt(++index); + result += chr + charAt(string, ++index); continue; } if (!brackets && chr === '.') { @@ -17267,16 +18257,16 @@ var handleNCG = function (string) { var index = 0; var result = ''; var named = []; - var names = {}; + var names = create(null); var brackets = false; var ncg = false; var groupid = 0; var groupname = ''; var chr; for (; index <= length; index++) { - chr = string.charAt(index); + chr = charAt(string, index); if (chr === '\\') { - chr = chr + string.charAt(++index); + chr += charAt(string, ++index); } else if (chr === ']') { brackets = false; } else if (!brackets) switch (true) { @@ -17284,7 +18274,7 @@ var handleNCG = function (string) { brackets = true; break; case chr === '(': - if (IS_NCG.test(string.slice(index + 1))) { + if (exec(IS_NCG, stringSlice(string, index + 1))) { index += 2; ncg = true; } @@ -17292,11 +18282,11 @@ var handleNCG = function (string) { groupid++; continue; case chr === '>' && ncg: - if (groupname === '' || has(names, groupname)) { + if (groupname === '' || hasOwn(names, groupname)) { throw new SyntaxError('Invalid capture group name'); } names[groupname] = true; - named.push([groupname, groupid]); + named[named.length] = [groupname, groupid]; ncg = false; groupname = ''; continue; @@ -17310,7 +18300,7 @@ var handleNCG = function (string) { // https://tc39.es/ecma262/#sec-regexp-constructor if (isForced('RegExp', BASE_FORCED)) { var RegExpWrapper = function RegExp(pattern, flags) { - var thisIsRegExp = this instanceof RegExpWrapper; + var thisIsRegExp = isPrototypeOf(RegExpPrototype, this); var patternIsRegExp = isRegExp(pattern); var flagsAreUndefined = flags === undefined; var groups = []; @@ -17321,9 +18311,9 @@ if (isForced('RegExp', BASE_FORCED)) { return pattern; } - if (patternIsRegExp || pattern instanceof RegExpWrapper) { + if (patternIsRegExp || isPrototypeOf(RegExpPrototype, pattern)) { pattern = pattern.source; - if (flagsAreUndefined) flags = 'flags' in rawPattern ? rawPattern.flags : getFlags.call(rawPattern); + if (flagsAreUndefined) flags = getRegExpFlags(rawPattern); } pattern = pattern === undefined ? '' : toString(pattern); @@ -17331,15 +18321,15 @@ if (isForced('RegExp', BASE_FORCED)) { rawPattern = pattern; if (UNSUPPORTED_DOT_ALL && 'dotAll' in re1) { - dotAll = !!flags && flags.indexOf('s') > -1; - if (dotAll) flags = flags.replace(/s/g, ''); + dotAll = !!flags && stringIndexOf(flags, 's') > -1; + if (dotAll) flags = replace(flags, /s/g, ''); } rawFlags = flags; - if (UNSUPPORTED_Y && 'sticky' in re1) { - sticky = !!flags && flags.indexOf('y') > -1; - if (sticky) flags = flags.replace(/y/g, ''); + if (MISSED_STICKY && 'sticky' in re1) { + sticky = !!flags && stringIndexOf(flags, 'y') > -1; + if (sticky && UNSUPPORTED_Y) flags = replace(flags, /y/g, ''); } if (UNSUPPORTED_NCG) { @@ -17368,27 +18358,19 @@ if (isForced('RegExp', BASE_FORCED)) { return result; }; - var proxy = function (key) { - key in RegExpWrapper || defineProperty(RegExpWrapper, key, { - configurable: true, - get: function () { return NativeRegExp[key]; }, - set: function (it) { NativeRegExp[key] = it; } - }); - }; - for (var keys = getOwnPropertyNames(NativeRegExp), index = 0; keys.length > index;) { - proxy(keys[index++]); + proxyAccessor(RegExpWrapper, NativeRegExp, keys[index++]); } RegExpPrototype.constructor = RegExpWrapper; RegExpWrapper.prototype = RegExpPrototype; - redefine(global, 'RegExp', RegExpWrapper); + defineBuiltIn(global, 'RegExp', RegExpWrapper, { constructor: true }); } // https://tc39.es/ecma262/#sec-get-regexp-@@species setSpecies('RegExp'); -},{"../internals/create-non-enumerable-property":120,"../internals/descriptors":125,"../internals/fails":140,"../internals/global":147,"../internals/has":148,"../internals/inherit-if-required":155,"../internals/internal-state":157,"../internals/is-forced":160,"../internals/is-regexp":164,"../internals/object-define-property":179,"../internals/object-get-own-property-names":182,"../internals/redefine":197,"../internals/regexp-flags":200,"../internals/regexp-sticky-helpers":201,"../internals/regexp-unsupported-dot-all":202,"../internals/regexp-unsupported-ncg":203,"../internals/set-species":207,"../internals/to-string":228,"../internals/well-known-symbol":237}],261:[function(require,module,exports){ +},{"../internals/create-non-enumerable-property":145,"../internals/define-built-in":149,"../internals/descriptors":153,"../internals/fails":171,"../internals/function-uncurry-this":181,"../internals/global":188,"../internals/has-own-property":189,"../internals/inherit-if-required":196,"../internals/internal-state":199,"../internals/is-forced":205,"../internals/is-regexp":211,"../internals/object-create":229,"../internals/object-get-own-property-names":234,"../internals/object-is-prototype-of":238,"../internals/proxy-accessor":253,"../internals/regexp-get-flags":258,"../internals/regexp-sticky-helpers":259,"../internals/regexp-unsupported-dot-all":260,"../internals/regexp-unsupported-ncg":261,"../internals/set-species":265,"../internals/to-string":291,"../internals/well-known-symbol":306}],340:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var exec = require('../internals/regexp-exec'); @@ -17399,57 +18381,80 @@ $({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, { exec: exec }); -},{"../internals/export":139,"../internals/regexp-exec":199}],262:[function(require,module,exports){ +},{"../internals/export":170,"../internals/regexp-exec":256}],341:[function(require,module,exports){ 'use strict'; -var redefine = require('../internals/redefine'); +var PROPER_FUNCTION_NAME = require('../internals/function-name').PROPER; +var defineBuiltIn = require('../internals/define-built-in'); var anObject = require('../internals/an-object'); var $toString = require('../internals/to-string'); var fails = require('../internals/fails'); -var flags = require('../internals/regexp-flags'); +var getRegExpFlags = require('../internals/regexp-get-flags'); var TO_STRING = 'toString'; var RegExpPrototype = RegExp.prototype; var nativeToString = RegExpPrototype[TO_STRING]; -var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; }); +var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; }); // FF44- RegExp#toString has a wrong name -var INCORRECT_NAME = nativeToString.name != TO_STRING; +var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING; // `RegExp.prototype.toString` method // https://tc39.es/ecma262/#sec-regexp.prototype.tostring if (NOT_GENERIC || INCORRECT_NAME) { - redefine(RegExp.prototype, TO_STRING, function toString() { + defineBuiltIn(RegExpPrototype, TO_STRING, function toString() { var R = anObject(this); - var p = $toString(R.source); - var rf = R.flags; - var f = $toString(rf === undefined && R instanceof RegExp && !('flags' in RegExpPrototype) ? flags.call(R) : rf); - return '/' + p + '/' + f; + var pattern = $toString(R.source); + var flags = $toString(getRegExpFlags(R)); + return '/' + pattern + '/' + flags; }, { unsafe: true }); } -},{"../internals/an-object":94,"../internals/fails":140,"../internals/redefine":197,"../internals/regexp-flags":200,"../internals/to-string":228}],263:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/define-built-in":149,"../internals/fails":171,"../internals/function-name":178,"../internals/regexp-get-flags":258,"../internals/to-string":291}],342:[function(require,module,exports){ +'use strict'; +var collection = require('../internals/collection'); +var collectionStrong = require('../internals/collection-strong'); + +// `Set` constructor +// https://tc39.es/ecma262/#sec-set-objects +collection('Set', function (init) { + return function Set() { return init(this, arguments.length ? arguments[0] : undefined); }; +}, collectionStrong); + +},{"../internals/collection":140,"../internals/collection-strong":139}],343:[function(require,module,exports){ +'use strict'; +// TODO: Remove this module from `core-js@4` since it's replaced to module below +require('../modules/es.set.constructor'); + +},{"../modules/es.set.constructor":342}],344:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); +var uncurryThis = require('../internals/function-uncurry-this'); var notARegExp = require('../internals/not-a-regexp'); var requireObjectCoercible = require('../internals/require-object-coercible'); var toString = require('../internals/to-string'); var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic'); +var stringIndexOf = uncurryThis(''.indexOf); + // `String.prototype.includes` method // https://tc39.es/ecma262/#sec-string.prototype.includes $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, { includes: function includes(searchString /* , position = 0 */) { - return !!~toString(requireObjectCoercible(this)) - .indexOf(toString(notARegExp(searchString)), arguments.length > 1 ? arguments[1] : undefined); + return !!~stringIndexOf( + toString(requireObjectCoercible(this)), + toString(notARegExp(searchString)), + arguments.length > 1 ? arguments[1] : undefined + ); } }); -},{"../internals/correct-is-regexp-logic":117,"../internals/export":139,"../internals/not-a-regexp":175,"../internals/require-object-coercible":204,"../internals/to-string":228}],264:[function(require,module,exports){ +},{"../internals/correct-is-regexp-logic":142,"../internals/export":170,"../internals/function-uncurry-this":181,"../internals/not-a-regexp":227,"../internals/require-object-coercible":262,"../internals/to-string":291}],345:[function(require,module,exports){ 'use strict'; var charAt = require('../internals/string-multibyte').charAt; var toString = require('../internals/to-string'); var InternalStateModule = require('../internals/internal-state'); -var defineIterator = require('../internals/define-iterator'); +var defineIterator = require('../internals/iterator-define'); +var createIterResultObject = require('../internals/create-iter-result-object'); var STRING_ITERATOR = 'String Iterator'; var setInternalState = InternalStateModule.set; @@ -17470,19 +18475,22 @@ defineIterator(String, 'String', function (iterated) { var string = state.string; var index = state.index; var point; - if (index >= string.length) return { value: undefined, done: true }; + if (index >= string.length) return createIterResultObject(undefined, true); point = charAt(string, index); state.index += point.length; - return { value: point, done: false }; + return createIterResultObject(point, false); }); -},{"../internals/define-iterator":123,"../internals/internal-state":157,"../internals/string-multibyte":213,"../internals/to-string":228}],265:[function(require,module,exports){ +},{"../internals/create-iter-result-object":144,"../internals/internal-state":199,"../internals/iterator-define":216,"../internals/string-multibyte":271,"../internals/to-string":291}],346:[function(require,module,exports){ 'use strict'; +var call = require('../internals/function-call'); var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic'); var anObject = require('../internals/an-object'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); var toLength = require('../internals/to-length'); var toString = require('../internals/to-string'); var requireObjectCoercible = require('../internals/require-object-coercible'); +var getMethod = require('../internals/get-method'); var advanceStringIndex = require('../internals/advance-string-index'); var regExpExec = require('../internals/regexp-exec-abstract'); @@ -17493,8 +18501,8 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa // https://tc39.es/ecma262/#sec-string.prototype.match function match(regexp) { var O = requireObjectCoercible(this); - var matcher = regexp == undefined ? undefined : regexp[MATCH]; - return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](toString(O)); + var matcher = isNullOrUndefined(regexp) ? undefined : getMethod(regexp, MATCH); + return matcher ? call(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString(O)); }, // `RegExp.prototype[@@match]` method // https://tc39.es/ecma262/#sec-regexp.prototype-@@match @@ -17523,16 +18531,22 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa ]; }); -},{"../internals/advance-string-index":92,"../internals/an-object":94,"../internals/fix-regexp-well-known-symbol-logic":141,"../internals/regexp-exec-abstract":198,"../internals/require-object-coercible":204,"../internals/to-length":221,"../internals/to-string":228}],266:[function(require,module,exports){ +},{"../internals/advance-string-index":112,"../internals/an-object":114,"../internals/fix-regexp-well-known-symbol-logic":172,"../internals/function-call":177,"../internals/get-method":186,"../internals/is-null-or-undefined":207,"../internals/regexp-exec-abstract":255,"../internals/require-object-coercible":262,"../internals/to-length":284,"../internals/to-string":291}],347:[function(require,module,exports){ 'use strict'; +var apply = require('../internals/function-apply'); +var call = require('../internals/function-call'); +var uncurryThis = require('../internals/function-uncurry-this'); var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic'); var fails = require('../internals/fails'); var anObject = require('../internals/an-object'); -var toInteger = require('../internals/to-integer'); +var isCallable = require('../internals/is-callable'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); +var toIntegerOrInfinity = require('../internals/to-integer-or-infinity'); var toLength = require('../internals/to-length'); var toString = require('../internals/to-string'); var requireObjectCoercible = require('../internals/require-object-coercible'); var advanceStringIndex = require('../internals/advance-string-index'); +var getMethod = require('../internals/get-method'); var getSubstitution = require('../internals/get-substitution'); var regExpExec = require('../internals/regexp-exec-abstract'); var wellKnownSymbol = require('../internals/well-known-symbol'); @@ -17540,6 +18554,10 @@ var wellKnownSymbol = require('../internals/well-known-symbol'); var REPLACE = wellKnownSymbol('replace'); var max = Math.max; var min = Math.min; +var concat = uncurryThis([].concat); +var push = uncurryThis([].push); +var stringIndexOf = uncurryThis(''.indexOf); +var stringSlice = uncurryThis(''.slice); var maybeToString = function (it) { return it === undefined ? it : String(it); @@ -17580,10 +18598,10 @@ fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNa // https://tc39.es/ecma262/#sec-string.prototype.replace function replace(searchValue, replaceValue) { var O = requireObjectCoercible(this); - var replacer = searchValue == undefined ? undefined : searchValue[REPLACE]; - return replacer !== undefined - ? replacer.call(searchValue, O, replaceValue) - : nativeReplace.call(toString(O), searchValue, replaceValue); + var replacer = isNullOrUndefined(searchValue) ? undefined : getMethod(searchValue, REPLACE); + return replacer + ? call(replacer, searchValue, O, replaceValue) + : call(nativeReplace, toString(O), searchValue, replaceValue); }, // `RegExp.prototype[@@replace]` method // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace @@ -17592,28 +18610,31 @@ fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNa var S = toString(string); if ( - typeof replaceValue === 'string' && - replaceValue.indexOf(UNSAFE_SUBSTITUTE) === -1 && - replaceValue.indexOf('$<') === -1 + typeof replaceValue == 'string' && + stringIndexOf(replaceValue, UNSAFE_SUBSTITUTE) === -1 && + stringIndexOf(replaceValue, '$<') === -1 ) { var res = maybeCallNative(nativeReplace, rx, S, replaceValue); if (res.done) return res.value; } - var functionalReplace = typeof replaceValue === 'function'; + var functionalReplace = isCallable(replaceValue); if (!functionalReplace) replaceValue = toString(replaceValue); var global = rx.global; + var fullUnicode; if (global) { - var fullUnicode = rx.unicode; + fullUnicode = rx.unicode; rx.lastIndex = 0; } + var results = []; + var result; while (true) { - var result = regExpExec(rx, S); + result = regExpExec(rx, S); if (result === null) break; - results.push(result); + push(results, result); if (!global) break; var matchStr = toString(result[0]); @@ -17626,39 +18647,44 @@ fixRegExpWellKnownSymbolLogic('replace', function (_, nativeReplace, maybeCallNa result = results[i]; var matched = toString(result[0]); - var position = max(min(toInteger(result.index), S.length), 0); + var position = max(min(toIntegerOrInfinity(result.index), S.length), 0); var captures = []; + var replacement; // NOTE: This is equivalent to // captures = result.slice(1).map(maybeToString) // but for some reason `nativeSlice.call(result, 1, result.length)` (called in // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. - for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j])); + for (var j = 1; j < result.length; j++) push(captures, maybeToString(result[j])); var namedCaptures = result.groups; if (functionalReplace) { - var replacerArgs = [matched].concat(captures, position, S); - if (namedCaptures !== undefined) replacerArgs.push(namedCaptures); - var replacement = toString(replaceValue.apply(undefined, replacerArgs)); + var replacerArgs = concat([matched], captures, position, S); + if (namedCaptures !== undefined) push(replacerArgs, namedCaptures); + replacement = toString(apply(replaceValue, undefined, replacerArgs)); } else { replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue); } if (position >= nextSourcePosition) { - accumulatedResult += S.slice(nextSourcePosition, position) + replacement; + accumulatedResult += stringSlice(S, nextSourcePosition, position) + replacement; nextSourcePosition = position + matched.length; } } - return accumulatedResult + S.slice(nextSourcePosition); + + return accumulatedResult + stringSlice(S, nextSourcePosition); } ]; }, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE); -},{"../internals/advance-string-index":92,"../internals/an-object":94,"../internals/fails":140,"../internals/fix-regexp-well-known-symbol-logic":141,"../internals/get-substitution":146,"../internals/regexp-exec-abstract":198,"../internals/require-object-coercible":204,"../internals/to-integer":220,"../internals/to-length":221,"../internals/to-string":228,"../internals/well-known-symbol":237}],267:[function(require,module,exports){ +},{"../internals/advance-string-index":112,"../internals/an-object":114,"../internals/fails":171,"../internals/fix-regexp-well-known-symbol-logic":172,"../internals/function-apply":174,"../internals/function-call":177,"../internals/function-uncurry-this":181,"../internals/get-method":186,"../internals/get-substitution":187,"../internals/is-callable":203,"../internals/is-null-or-undefined":207,"../internals/regexp-exec-abstract":255,"../internals/require-object-coercible":262,"../internals/to-integer-or-infinity":283,"../internals/to-length":284,"../internals/to-string":291,"../internals/well-known-symbol":306}],348:[function(require,module,exports){ 'use strict'; +var call = require('../internals/function-call'); var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic'); var anObject = require('../internals/an-object'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); var requireObjectCoercible = require('../internals/require-object-coercible'); var sameValue = require('../internals/same-value'); var toString = require('../internals/to-string'); +var getMethod = require('../internals/get-method'); var regExpExec = require('../internals/regexp-exec-abstract'); // @@search logic @@ -17668,8 +18694,8 @@ fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCal // https://tc39.es/ecma262/#sec-string.prototype.search function search(regexp) { var O = requireObjectCoercible(this); - var searcher = regexp == undefined ? undefined : regexp[SEARCH]; - return searcher !== undefined ? searcher.call(regexp, O) : new RegExp(regexp)[SEARCH](toString(O)); + var searcher = isNullOrUndefined(regexp) ? undefined : getMethod(regexp, SEARCH); + return searcher ? call(searcher, regexp, O) : new RegExp(regexp)[SEARCH](toString(O)); }, // `RegExp.prototype[@@search]` method // https://tc39.es/ecma262/#sec-regexp.prototype-@@search @@ -17689,25 +18715,34 @@ fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCal ]; }); -},{"../internals/an-object":94,"../internals/fix-regexp-well-known-symbol-logic":141,"../internals/regexp-exec-abstract":198,"../internals/require-object-coercible":204,"../internals/same-value":205,"../internals/to-string":228}],268:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/fix-regexp-well-known-symbol-logic":172,"../internals/function-call":177,"../internals/get-method":186,"../internals/is-null-or-undefined":207,"../internals/regexp-exec-abstract":255,"../internals/require-object-coercible":262,"../internals/same-value":264,"../internals/to-string":291}],349:[function(require,module,exports){ 'use strict'; +var apply = require('../internals/function-apply'); +var call = require('../internals/function-call'); +var uncurryThis = require('../internals/function-uncurry-this'); var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic'); -var isRegExp = require('../internals/is-regexp'); var anObject = require('../internals/an-object'); +var isNullOrUndefined = require('../internals/is-null-or-undefined'); +var isRegExp = require('../internals/is-regexp'); var requireObjectCoercible = require('../internals/require-object-coercible'); var speciesConstructor = require('../internals/species-constructor'); var advanceStringIndex = require('../internals/advance-string-index'); var toLength = require('../internals/to-length'); var toString = require('../internals/to-string'); +var getMethod = require('../internals/get-method'); +var arraySlice = require('../internals/array-slice'); var callRegExpExec = require('../internals/regexp-exec-abstract'); var regexpExec = require('../internals/regexp-exec'); var stickyHelpers = require('../internals/regexp-sticky-helpers'); var fails = require('../internals/fails'); var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y; -var arrayPush = [].push; -var min = Math.min; var MAX_UINT32 = 0xFFFFFFFF; +var min = Math.min; +var $push = [].push; +var exec = uncurryThis(/./.exec); +var push = uncurryThis($push); +var stringSlice = uncurryThis(''.slice); // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec // Weex JS has frozen built-in prototypes, so use try / catch wrapper @@ -17724,11 +18759,11 @@ var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () { fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) { var internalSplit; if ( - 'abbc'.split(/(b)*/)[1] == 'c' || + 'abbc'.split(/(b)*/)[1] === 'c' || // eslint-disable-next-line regexp/no-empty-group -- required for testing - 'test'.split(/(?:)/, -1).length != 4 || - 'ab'.split(/(?:ab)*/).length != 2 || - '.'.split(/(.?)(.?)/).length != 4 || + 'test'.split(/(?:)/, -1).length !== 4 || + 'ab'.split(/(?:ab)*/).length !== 2 || + '.'.split(/(.?)(.?)/).length !== 4 || // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing '.'.split(/()()/).length > 1 || ''.split(/.?/).length @@ -17741,7 +18776,7 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa if (separator === undefined) return [string]; // If `separator` is not a regex, use native split if (!isRegExp(separator)) { - return nativeSplit.call(string, separator, lim); + return call(nativeSplit, string, separator, lim); } var output = []; var flags = (separator.ignoreCase ? 'i' : '') + @@ -17752,11 +18787,11 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa // Make `global` and avoid `lastIndex` issues by working with a copy var separatorCopy = new RegExp(separator.source, flags + 'g'); var match, lastIndex, lastLength; - while (match = regexpExec.call(separatorCopy, string)) { + while (match = call(regexpExec, separatorCopy, string)) { lastIndex = separatorCopy.lastIndex; if (lastIndex > lastLastIndex) { - output.push(string.slice(lastLastIndex, match.index)); - if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1)); + push(output, stringSlice(string, lastLastIndex, match.index)); + if (match.length > 1 && match.index < string.length) apply($push, output, arraySlice(match, 1)); lastLength = match[0].length; lastLastIndex = lastIndex; if (output.length >= lim) break; @@ -17764,14 +18799,14 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop } if (lastLastIndex === string.length) { - if (lastLength || !separatorCopy.test('')) output.push(''); - } else output.push(string.slice(lastLastIndex)); - return output.length > lim ? output.slice(0, lim) : output; + if (lastLength || !exec(separatorCopy, '')) push(output, ''); + } else push(output, stringSlice(string, lastLastIndex)); + return output.length > lim ? arraySlice(output, 0, lim) : output; }; // Chakra, V8 } else if ('0'.split(undefined, 0).length) { internalSplit = function (separator, limit) { - return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit); + return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit); }; } else internalSplit = nativeSplit; @@ -17780,10 +18815,10 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa // https://tc39.es/ecma262/#sec-string.prototype.split function split(separator, limit) { var O = requireObjectCoercible(this); - var splitter = separator == undefined ? undefined : separator[SPLIT]; - return splitter !== undefined - ? splitter.call(separator, O, limit) - : internalSplit.call(toString(O), separator, limit); + var splitter = isNullOrUndefined(separator) ? undefined : getMethod(separator, SPLIT); + return splitter + ? call(splitter, separator, O, limit) + : call(internalSplit, toString(O), separator, limit); }, // `RegExp.prototype[@@split]` method // https://tc39.es/ecma262/#sec-regexp.prototype-@@split @@ -17816,7 +18851,7 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa var A = []; while (q < S.length) { splitter.lastIndex = UNSUPPORTED_Y ? 0 : q; - var z = callRegExpExec(splitter, UNSUPPORTED_Y ? S.slice(q) : S); + var z = callRegExpExec(splitter, UNSUPPORTED_Y ? stringSlice(S, q) : S); var e; if ( z === null || @@ -17824,22 +18859,56 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa ) { q = advanceStringIndex(S, q, unicodeMatching); } else { - A.push(S.slice(p, q)); + push(A, stringSlice(S, p, q)); if (A.length === lim) return A; for (var i = 1; i <= z.length - 1; i++) { - A.push(z[i]); + push(A, z[i]); if (A.length === lim) return A; } q = p = e; } } - A.push(S.slice(p)); + push(A, stringSlice(S, p)); return A; } ]; }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y); -},{"../internals/advance-string-index":92,"../internals/an-object":94,"../internals/fails":140,"../internals/fix-regexp-well-known-symbol-logic":141,"../internals/is-regexp":164,"../internals/regexp-exec":199,"../internals/regexp-exec-abstract":198,"../internals/regexp-sticky-helpers":201,"../internals/require-object-coercible":204,"../internals/species-constructor":212,"../internals/to-length":221,"../internals/to-string":228}],269:[function(require,module,exports){ +},{"../internals/advance-string-index":112,"../internals/an-object":114,"../internals/array-slice":131,"../internals/fails":171,"../internals/fix-regexp-well-known-symbol-logic":172,"../internals/function-apply":174,"../internals/function-call":177,"../internals/function-uncurry-this":181,"../internals/get-method":186,"../internals/is-null-or-undefined":207,"../internals/is-regexp":211,"../internals/regexp-exec":256,"../internals/regexp-exec-abstract":255,"../internals/regexp-sticky-helpers":259,"../internals/require-object-coercible":262,"../internals/species-constructor":270,"../internals/to-length":284,"../internals/to-string":291}],350:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var uncurryThis = require('../internals/function-uncurry-this-clause'); +var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f; +var toLength = require('../internals/to-length'); +var toString = require('../internals/to-string'); +var notARegExp = require('../internals/not-a-regexp'); +var requireObjectCoercible = require('../internals/require-object-coercible'); +var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic'); +var IS_PURE = require('../internals/is-pure'); + +var stringSlice = uncurryThis(''.slice); +var min = Math.min; + +var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith'); +// https://github.com/zloirock/core-js/pull/702 +var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () { + var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith'); + return descriptor && !descriptor.writable; +}(); + +// `String.prototype.startsWith` method +// https://tc39.es/ecma262/#sec-string.prototype.startswith +$({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, { + startsWith: function startsWith(searchString /* , position = 0 */) { + var that = toString(requireObjectCoercible(this)); + notARegExp(searchString); + var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length)); + var search = toString(searchString); + return stringSlice(that, index, index + search.length) === search; + } +}); + +},{"../internals/correct-is-regexp-logic":142,"../internals/export":170,"../internals/function-uncurry-this-clause":180,"../internals/is-pure":210,"../internals/not-a-regexp":227,"../internals/object-get-own-property-descriptor":232,"../internals/require-object-coercible":262,"../internals/to-length":284,"../internals/to-string":291}],351:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var $trim = require('../internals/string-trim').trim; @@ -17853,73 +18922,19 @@ $({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, { } }); -},{"../internals/export":139,"../internals/string-trim":215,"../internals/string-trim-forced":214}],270:[function(require,module,exports){ -// `Symbol.prototype.description` getter -// https://tc39.es/ecma262/#sec-symbol.prototype.description -'use strict'; -var $ = require('../internals/export'); -var DESCRIPTORS = require('../internals/descriptors'); -var global = require('../internals/global'); -var has = require('../internals/has'); -var isObject = require('../internals/is-object'); -var defineProperty = require('../internals/object-define-property').f; -var copyConstructorProperties = require('../internals/copy-constructor-properties'); - -var NativeSymbol = global.Symbol; - -if (DESCRIPTORS && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) || - // Safari 12 bug - NativeSymbol().description !== undefined -)) { - var EmptyStringDescriptionStore = {}; - // wrap Symbol constructor for correct work with undefined description - var SymbolWrapper = function Symbol() { - var description = arguments.length < 1 || arguments[0] === undefined ? undefined : String(arguments[0]); - var result = this instanceof SymbolWrapper - ? new NativeSymbol(description) - // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)' - : description === undefined ? NativeSymbol() : NativeSymbol(description); - if (description === '') EmptyStringDescriptionStore[result] = true; - return result; - }; - copyConstructorProperties(SymbolWrapper, NativeSymbol); - var symbolPrototype = SymbolWrapper.prototype = NativeSymbol.prototype; - symbolPrototype.constructor = SymbolWrapper; - - var symbolToString = symbolPrototype.toString; - var nativeSymbol = String(NativeSymbol('test')) == 'Symbol(test)'; - var regexp = /^Symbol\((.*)\)[^)]+$/; - defineProperty(symbolPrototype, 'description', { - configurable: true, - get: function description() { - var symbol = isObject(this) ? this.valueOf() : this; - var string = symbolToString.call(symbol); - if (has(EmptyStringDescriptionStore, symbol)) return ''; - var desc = nativeSymbol ? string.slice(7, -1) : string.replace(regexp, '$1'); - return desc === '' ? undefined : desc; - } - }); - - $({ global: true, forced: true }, { - Symbol: SymbolWrapper - }); -} - -},{"../internals/copy-constructor-properties":116,"../internals/descriptors":125,"../internals/export":139,"../internals/global":147,"../internals/has":148,"../internals/is-object":162,"../internals/object-define-property":179}],271:[function(require,module,exports){ +},{"../internals/export":170,"../internals/string-trim":273,"../internals/string-trim-forced":272}],352:[function(require,module,exports){ 'use strict'; var $ = require('../internals/export'); var global = require('../internals/global'); -var getBuiltIn = require('../internals/get-built-in'); +var call = require('../internals/function-call'); +var uncurryThis = require('../internals/function-uncurry-this'); var IS_PURE = require('../internals/is-pure'); var DESCRIPTORS = require('../internals/descriptors'); -var NATIVE_SYMBOL = require('../internals/native-symbol'); +var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection'); var fails = require('../internals/fails'); -var has = require('../internals/has'); -var isArray = require('../internals/is-array'); -var isObject = require('../internals/is-object'); -var isSymbol = require('../internals/is-symbol'); +var hasOwn = require('../internals/has-own-property'); +var isPrototypeOf = require('../internals/object-is-prototype-of'); var anObject = require('../internals/an-object'); -var toObject = require('../internals/to-object'); var toIndexedObject = require('../internals/to-indexed-object'); var toPropertyKey = require('../internals/to-property-key'); var $toString = require('../internals/to-string'); @@ -17931,16 +18946,18 @@ var getOwnPropertyNamesExternal = require('../internals/object-get-own-property- var getOwnPropertySymbolsModule = require('../internals/object-get-own-property-symbols'); var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor'); var definePropertyModule = require('../internals/object-define-property'); +var definePropertiesModule = require('../internals/object-define-properties'); var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable'); -var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -var redefine = require('../internals/redefine'); +var defineBuiltIn = require('../internals/define-built-in'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var shared = require('../internals/shared'); var sharedKey = require('../internals/shared-key'); var hiddenKeys = require('../internals/hidden-keys'); var uid = require('../internals/uid'); var wellKnownSymbol = require('../internals/well-known-symbol'); var wrappedWellKnownSymbolModule = require('../internals/well-known-symbol-wrapped'); -var defineWellKnownSymbol = require('../internals/define-well-known-symbol'); +var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); +var defineSymbolToPrimitive = require('../internals/symbol-define-to-primitive'); var setToStringTag = require('../internals/set-to-string-tag'); var InternalStateModule = require('../internals/internal-state'); var $forEach = require('../internals/array-iteration').forEach; @@ -17948,41 +18965,47 @@ var $forEach = require('../internals/array-iteration').forEach; var HIDDEN = sharedKey('hidden'); var SYMBOL = 'Symbol'; var PROTOTYPE = 'prototype'; -var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); + var setInternalState = InternalStateModule.set; var getInternalState = InternalStateModule.getterFor(SYMBOL); + var ObjectPrototype = Object[PROTOTYPE]; var $Symbol = global.Symbol; -var $stringify = getBuiltIn('JSON', 'stringify'); +var SymbolPrototype = $Symbol && $Symbol[PROTOTYPE]; +var RangeError = global.RangeError; +var TypeError = global.TypeError; +var QObject = global.QObject; var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; var nativeDefineProperty = definePropertyModule.f; var nativeGetOwnPropertyNames = getOwnPropertyNamesExternal.f; var nativePropertyIsEnumerable = propertyIsEnumerableModule.f; +var push = uncurryThis([].push); + var AllSymbols = shared('symbols'); var ObjectPrototypeSymbols = shared('op-symbols'); -var StringToSymbolRegistry = shared('string-to-symbol-registry'); -var SymbolToStringRegistry = shared('symbol-to-string-registry'); var WellKnownSymbolsStore = shared('wks'); -var QObject = global.QObject; + // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 var USE_SETTER = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 -var setSymbolDescriptor = DESCRIPTORS && fails(function () { - return nativeObjectCreate(nativeDefineProperty({}, 'a', { - get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; } - })).a != 7; -}) ? function (O, P, Attributes) { +var fallbackDefineProperty = function (O, P, Attributes) { var ObjectPrototypeDescriptor = nativeGetOwnPropertyDescriptor(ObjectPrototype, P); if (ObjectPrototypeDescriptor) delete ObjectPrototype[P]; nativeDefineProperty(O, P, Attributes); if (ObjectPrototypeDescriptor && O !== ObjectPrototype) { nativeDefineProperty(ObjectPrototype, P, ObjectPrototypeDescriptor); } -} : nativeDefineProperty; +}; + +var setSymbolDescriptor = DESCRIPTORS && fails(function () { + return nativeObjectCreate(nativeDefineProperty({}, 'a', { + get: function () { return nativeDefineProperty(this, 'a', { value: 7 }).a; } + })).a !== 7; +}) ? fallbackDefineProperty : nativeDefineProperty; var wrap = function (tag, description) { - var symbol = AllSymbols[tag] = nativeObjectCreate($Symbol[PROTOTYPE]); + var symbol = AllSymbols[tag] = nativeObjectCreate(SymbolPrototype); setInternalState(symbol, { type: SYMBOL, tag: tag, @@ -17997,12 +19020,12 @@ var $defineProperty = function defineProperty(O, P, Attributes) { anObject(O); var key = toPropertyKey(P); anObject(Attributes); - if (has(AllSymbols, key)) { + if (hasOwn(AllSymbols, key)) { if (!Attributes.enumerable) { - if (!has(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, {})); + if (!hasOwn(O, HIDDEN)) nativeDefineProperty(O, HIDDEN, createPropertyDescriptor(1, nativeObjectCreate(null))); O[HIDDEN][key] = true; } else { - if (has(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false; + if (hasOwn(O, HIDDEN) && O[HIDDEN][key]) O[HIDDEN][key] = false; Attributes = nativeObjectCreate(Attributes, { enumerable: createPropertyDescriptor(0, false) }); } return setSymbolDescriptor(O, key, Attributes); } return nativeDefineProperty(O, key, Attributes); @@ -18013,7 +19036,7 @@ var $defineProperties = function defineProperties(O, Properties) { var properties = toIndexedObject(Properties); var keys = objectKeys(properties).concat($getOwnPropertySymbols(properties)); $forEach(keys, function (key) { - if (!DESCRIPTORS || $propertyIsEnumerable.call(properties, key)) $defineProperty(O, key, properties[key]); + if (!DESCRIPTORS || call($propertyIsEnumerable, properties, key)) $defineProperty(O, key, properties[key]); }); return O; }; @@ -18024,17 +19047,18 @@ var $create = function create(O, Properties) { var $propertyIsEnumerable = function propertyIsEnumerable(V) { var P = toPropertyKey(V); - var enumerable = nativePropertyIsEnumerable.call(this, P); - if (this === ObjectPrototype && has(AllSymbols, P) && !has(ObjectPrototypeSymbols, P)) return false; - return enumerable || !has(this, P) || !has(AllSymbols, P) || has(this, HIDDEN) && this[HIDDEN][P] ? enumerable : true; + var enumerable = call(nativePropertyIsEnumerable, this, P); + if (this === ObjectPrototype && hasOwn(AllSymbols, P) && !hasOwn(ObjectPrototypeSymbols, P)) return false; + return enumerable || !hasOwn(this, P) || !hasOwn(AllSymbols, P) || hasOwn(this, HIDDEN) && this[HIDDEN][P] + ? enumerable : true; }; var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(O, P) { var it = toIndexedObject(O); var key = toPropertyKey(P); - if (it === ObjectPrototype && has(AllSymbols, key) && !has(ObjectPrototypeSymbols, key)) return; + if (it === ObjectPrototype && hasOwn(AllSymbols, key) && !hasOwn(ObjectPrototypeSymbols, key)) return; var descriptor = nativeGetOwnPropertyDescriptor(it, key); - if (descriptor && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) { + if (descriptor && hasOwn(AllSymbols, key) && !(hasOwn(it, HIDDEN) && it[HIDDEN][key])) { descriptor.enumerable = true; } return descriptor; @@ -18044,18 +19068,18 @@ var $getOwnPropertyNames = function getOwnPropertyNames(O) { var names = nativeGetOwnPropertyNames(toIndexedObject(O)); var result = []; $forEach(names, function (key) { - if (!has(AllSymbols, key) && !has(hiddenKeys, key)) result.push(key); + if (!hasOwn(AllSymbols, key) && !hasOwn(hiddenKeys, key)) push(result, key); }); return result; }; -var $getOwnPropertySymbols = function getOwnPropertySymbols(O) { +var $getOwnPropertySymbols = function (O) { var IS_OBJECT_PROTOTYPE = O === ObjectPrototype; var names = nativeGetOwnPropertyNames(IS_OBJECT_PROTOTYPE ? ObjectPrototypeSymbols : toIndexedObject(O)); var result = []; $forEach(names, function (key) { - if (has(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || has(ObjectPrototype, key))) { - result.push(AllSymbols[key]); + if (hasOwn(AllSymbols, key) && (!IS_OBJECT_PROTOTYPE || hasOwn(ObjectPrototype, key))) { + push(result, AllSymbols[key]); } }); return result; @@ -18065,28 +19089,38 @@ var $getOwnPropertySymbols = function getOwnPropertySymbols(O) { // https://tc39.es/ecma262/#sec-symbol-constructor if (!NATIVE_SYMBOL) { $Symbol = function Symbol() { - if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor'); + if (isPrototypeOf(SymbolPrototype, this)) throw new TypeError('Symbol is not a constructor'); var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]); var tag = uid(description); var setter = function (value) { - if (this === ObjectPrototype) setter.call(ObjectPrototypeSymbols, value); - if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; - setSymbolDescriptor(this, tag, createPropertyDescriptor(1, value)); + var $this = this === undefined ? global : this; + if ($this === ObjectPrototype) call(setter, ObjectPrototypeSymbols, value); + if (hasOwn($this, HIDDEN) && hasOwn($this[HIDDEN], tag)) $this[HIDDEN][tag] = false; + var descriptor = createPropertyDescriptor(1, value); + try { + setSymbolDescriptor($this, tag, descriptor); + } catch (error) { + if (!(error instanceof RangeError)) throw error; + fallbackDefineProperty($this, tag, descriptor); + } }; if (DESCRIPTORS && USE_SETTER) setSymbolDescriptor(ObjectPrototype, tag, { configurable: true, set: setter }); return wrap(tag, description); }; - redefine($Symbol[PROTOTYPE], 'toString', function toString() { + SymbolPrototype = $Symbol[PROTOTYPE]; + + defineBuiltIn(SymbolPrototype, 'toString', function toString() { return getInternalState(this).tag; }); - redefine($Symbol, 'withoutSetter', function (description) { + defineBuiltIn($Symbol, 'withoutSetter', function (description) { return wrap(uid(description), description); }); propertyIsEnumerableModule.f = $propertyIsEnumerable; definePropertyModule.f = $defineProperty; + definePropertiesModule.f = $defineProperties; getOwnPropertyDescriptorModule.f = $getOwnPropertyDescriptor; getOwnPropertyNamesModule.f = getOwnPropertyNamesExternal.f = $getOwnPropertyNames; getOwnPropertySymbolsModule.f = $getOwnPropertySymbols; @@ -18097,19 +19131,19 @@ if (!NATIVE_SYMBOL) { if (DESCRIPTORS) { // https://github.com/tc39/proposal-Symbol-description - nativeDefineProperty($Symbol[PROTOTYPE], 'description', { + defineBuiltInAccessor(SymbolPrototype, 'description', { configurable: true, get: function description() { return getInternalState(this).description; } }); if (!IS_PURE) { - redefine(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true }); + defineBuiltIn(ObjectPrototype, 'propertyIsEnumerable', $propertyIsEnumerable, { unsafe: true }); } } } -$({ global: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, { +$({ global: true, constructor: true, wrap: true, forced: !NATIVE_SYMBOL, sham: !NATIVE_SYMBOL }, { Symbol: $Symbol }); @@ -18118,22 +19152,6 @@ $forEach(objectKeys(WellKnownSymbolsStore), function (name) { }); $({ target: SYMBOL, stat: true, forced: !NATIVE_SYMBOL }, { - // `Symbol.for` method - // https://tc39.es/ecma262/#sec-symbol.for - 'for': function (key) { - var string = $toString(key); - if (has(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string]; - var symbol = $Symbol(string); - StringToSymbolRegistry[string] = symbol; - SymbolToStringRegistry[symbol] = string; - return symbol; - }, - // `Symbol.keyFor` method - // https://tc39.es/ecma262/#sec-symbol.keyfor - keyFor: function keyFor(sym) { - if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol'); - if (has(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym]; - }, useSetter: function () { USE_SETTER = true; }, useSimple: function () { USE_SETTER = false; } }); @@ -18156,78 +19174,159 @@ $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL, sham: !DESCRIPTORS }, $({ target: 'Object', stat: true, forced: !NATIVE_SYMBOL }, { // `Object.getOwnPropertyNames` method // https://tc39.es/ecma262/#sec-object.getownpropertynames - getOwnPropertyNames: $getOwnPropertyNames, - // `Object.getOwnPropertySymbols` method - // https://tc39.es/ecma262/#sec-object.getownpropertysymbols - getOwnPropertySymbols: $getOwnPropertySymbols -}); - -// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives -// https://bugs.chromium.org/p/v8/issues/detail?id=3443 -$({ target: 'Object', stat: true, forced: fails(function () { getOwnPropertySymbolsModule.f(1); }) }, { - getOwnPropertySymbols: function getOwnPropertySymbols(it) { - return getOwnPropertySymbolsModule.f(toObject(it)); - } + getOwnPropertyNames: $getOwnPropertyNames }); -// `JSON.stringify` method behavior with symbols -// https://tc39.es/ecma262/#sec-json.stringify -if ($stringify) { - var FORCED_JSON_STRINGIFY = !NATIVE_SYMBOL || fails(function () { - var symbol = $Symbol(); - // MS Edge converts symbol values to JSON as {} - return $stringify([symbol]) != '[null]' - // WebKit converts symbol values to JSON as null - || $stringify({ a: symbol }) != '{}' - // V8 throws on boxed symbols - || $stringify(Object(symbol)) != '{}'; - }); - - $({ target: 'JSON', stat: true, forced: FORCED_JSON_STRINGIFY }, { - // eslint-disable-next-line no-unused-vars -- required for `.length` - stringify: function stringify(it, replacer, space) { - var args = [it]; - var index = 1; - var $replacer; - while (arguments.length > index) args.push(arguments[index++]); - $replacer = replacer; - if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined - if (!isArray(replacer)) replacer = function (key, value) { - if (typeof $replacer == 'function') value = $replacer.call(this, key, value); - if (!isSymbol(value)) return value; - }; - args[1] = replacer; - return $stringify.apply(null, args); - } - }); -} - // `Symbol.prototype[@@toPrimitive]` method // https://tc39.es/ecma262/#sec-symbol.prototype-@@toprimitive -if (!$Symbol[PROTOTYPE][TO_PRIMITIVE]) { - createNonEnumerableProperty($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf); -} +defineSymbolToPrimitive(); + // `Symbol.prototype[@@toStringTag]` property // https://tc39.es/ecma262/#sec-symbol.prototype-@@tostringtag setToStringTag($Symbol, SYMBOL); hiddenKeys[HIDDEN] = true; -},{"../internals/an-object":94,"../internals/array-iteration":104,"../internals/create-non-enumerable-property":120,"../internals/create-property-descriptor":121,"../internals/define-well-known-symbol":124,"../internals/descriptors":125,"../internals/export":139,"../internals/fails":140,"../internals/get-built-in":143,"../internals/global":147,"../internals/has":148,"../internals/hidden-keys":149,"../internals/internal-state":157,"../internals/is-array":159,"../internals/is-object":162,"../internals/is-pure":163,"../internals/is-symbol":165,"../internals/native-symbol":172,"../internals/object-create":177,"../internals/object-define-property":179,"../internals/object-get-own-property-descriptor":180,"../internals/object-get-own-property-names":182,"../internals/object-get-own-property-names-external":181,"../internals/object-get-own-property-symbols":183,"../internals/object-keys":186,"../internals/object-property-is-enumerable":187,"../internals/redefine":197,"../internals/set-to-string-tag":208,"../internals/shared":211,"../internals/shared-key":209,"../internals/to-indexed-object":219,"../internals/to-object":222,"../internals/to-property-key":226,"../internals/to-string":228,"../internals/uid":234,"../internals/well-known-symbol":237,"../internals/well-known-symbol-wrapped":236}],272:[function(require,module,exports){ +},{"../internals/an-object":114,"../internals/array-iteration":125,"../internals/create-property-descriptor":146,"../internals/define-built-in":149,"../internals/define-built-in-accessor":148,"../internals/descriptors":153,"../internals/export":170,"../internals/fails":171,"../internals/function-call":177,"../internals/function-uncurry-this":181,"../internals/global":188,"../internals/has-own-property":189,"../internals/hidden-keys":190,"../internals/internal-state":199,"../internals/is-pure":210,"../internals/object-create":229,"../internals/object-define-properties":230,"../internals/object-define-property":231,"../internals/object-get-own-property-descriptor":232,"../internals/object-get-own-property-names":234,"../internals/object-get-own-property-names-external":233,"../internals/object-get-own-property-symbols":235,"../internals/object-is-prototype-of":238,"../internals/object-keys":240,"../internals/object-property-is-enumerable":241,"../internals/set-to-string-tag":266,"../internals/shared":269,"../internals/shared-key":267,"../internals/symbol-constructor-detection":274,"../internals/symbol-define-to-primitive":275,"../internals/to-indexed-object":282,"../internals/to-property-key":289,"../internals/to-string":291,"../internals/uid":299,"../internals/well-known-symbol":306,"../internals/well-known-symbol-define":304,"../internals/well-known-symbol-wrapped":305}],353:[function(require,module,exports){ +// `Symbol.prototype.description` getter +// https://tc39.es/ecma262/#sec-symbol.prototype.description +'use strict'; +var $ = require('../internals/export'); +var DESCRIPTORS = require('../internals/descriptors'); +var global = require('../internals/global'); +var uncurryThis = require('../internals/function-uncurry-this'); +var hasOwn = require('../internals/has-own-property'); +var isCallable = require('../internals/is-callable'); +var isPrototypeOf = require('../internals/object-is-prototype-of'); +var toString = require('../internals/to-string'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); +var copyConstructorProperties = require('../internals/copy-constructor-properties'); + +var NativeSymbol = global.Symbol; +var SymbolPrototype = NativeSymbol && NativeSymbol.prototype; + +if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototype) || + // Safari 12 bug + NativeSymbol().description !== undefined +)) { + var EmptyStringDescriptionStore = {}; + // wrap Symbol constructor for correct work with undefined description + var SymbolWrapper = function Symbol() { + var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString(arguments[0]); + var result = isPrototypeOf(SymbolPrototype, this) + ? new NativeSymbol(description) + // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)' + : description === undefined ? NativeSymbol() : NativeSymbol(description); + if (description === '') EmptyStringDescriptionStore[result] = true; + return result; + }; + + copyConstructorProperties(SymbolWrapper, NativeSymbol); + SymbolWrapper.prototype = SymbolPrototype; + SymbolPrototype.constructor = SymbolWrapper; + + var NATIVE_SYMBOL = String(NativeSymbol('description detection')) === 'Symbol(description detection)'; + var thisSymbolValue = uncurryThis(SymbolPrototype.valueOf); + var symbolDescriptiveString = uncurryThis(SymbolPrototype.toString); + var regexp = /^Symbol\((.*)\)[^)]+$/; + var replace = uncurryThis(''.replace); + var stringSlice = uncurryThis(''.slice); + + defineBuiltInAccessor(SymbolPrototype, 'description', { + configurable: true, + get: function description() { + var symbol = thisSymbolValue(this); + if (hasOwn(EmptyStringDescriptionStore, symbol)) return ''; + var string = symbolDescriptiveString(symbol); + var desc = NATIVE_SYMBOL ? stringSlice(string, 7, -1) : replace(string, regexp, '$1'); + return desc === '' ? undefined : desc; + } + }); + + $({ global: true, constructor: true, forced: true }, { + Symbol: SymbolWrapper + }); +} + +},{"../internals/copy-constructor-properties":141,"../internals/define-built-in-accessor":148,"../internals/descriptors":153,"../internals/export":170,"../internals/function-uncurry-this":181,"../internals/global":188,"../internals/has-own-property":189,"../internals/is-callable":203,"../internals/object-is-prototype-of":238,"../internals/to-string":291}],354:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var getBuiltIn = require('../internals/get-built-in'); +var hasOwn = require('../internals/has-own-property'); +var toString = require('../internals/to-string'); +var shared = require('../internals/shared'); +var NATIVE_SYMBOL_REGISTRY = require('../internals/symbol-registry-detection'); + +var StringToSymbolRegistry = shared('string-to-symbol-registry'); +var SymbolToStringRegistry = shared('symbol-to-string-registry'); + +// `Symbol.for` method +// https://tc39.es/ecma262/#sec-symbol.for +$({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, { + 'for': function (key) { + var string = toString(key); + if (hasOwn(StringToSymbolRegistry, string)) return StringToSymbolRegistry[string]; + var symbol = getBuiltIn('Symbol')(string); + StringToSymbolRegistry[string] = symbol; + SymbolToStringRegistry[symbol] = string; + return symbol; + } +}); + +},{"../internals/export":170,"../internals/get-built-in":182,"../internals/has-own-property":189,"../internals/shared":269,"../internals/symbol-registry-detection":276,"../internals/to-string":291}],355:[function(require,module,exports){ +'use strict'; +var defineWellKnownSymbol = require('../internals/well-known-symbol-define'); + +// `Symbol.iterator` well-known symbol +// https://tc39.es/ecma262/#sec-symbol.iterator +defineWellKnownSymbol('iterator'); + +},{"../internals/well-known-symbol-define":304}],356:[function(require,module,exports){ +'use strict'; +// TODO: Remove this module from `core-js@4` since it's split to modules listed below +require('../modules/es.symbol.constructor'); +require('../modules/es.symbol.for'); +require('../modules/es.symbol.key-for'); +require('../modules/es.json.stringify'); +require('../modules/es.object.get-own-property-symbols'); + +},{"../modules/es.json.stringify":323,"../modules/es.object.get-own-property-symbols":329,"../modules/es.symbol.constructor":352,"../modules/es.symbol.for":354,"../modules/es.symbol.key-for":357}],357:[function(require,module,exports){ +'use strict'; +var $ = require('../internals/export'); +var hasOwn = require('../internals/has-own-property'); +var isSymbol = require('../internals/is-symbol'); +var tryToString = require('../internals/try-to-string'); +var shared = require('../internals/shared'); +var NATIVE_SYMBOL_REGISTRY = require('../internals/symbol-registry-detection'); + +var SymbolToStringRegistry = shared('symbol-to-string-registry'); + +// `Symbol.keyFor` method +// https://tc39.es/ecma262/#sec-symbol.keyfor +$({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, { + keyFor: function keyFor(sym) { + if (!isSymbol(sym)) throw new TypeError(tryToString(sym) + ' is not a symbol'); + if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym]; + } +}); + +},{"../internals/export":170,"../internals/has-own-property":189,"../internals/is-symbol":212,"../internals/shared":269,"../internals/symbol-registry-detection":276,"../internals/try-to-string":293}],358:[function(require,module,exports){ 'use strict'; +var uncurryThis = require('../internals/function-uncurry-this'); var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); -var $copyWithin = require('../internals/array-copy-within'); +var $ArrayCopyWithin = require('../internals/array-copy-within'); +var u$ArrayCopyWithin = uncurryThis($ArrayCopyWithin); var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.copyWithin` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin exportTypedArrayMethod('copyWithin', function copyWithin(target, start /* , end */) { - return $copyWithin.call(aTypedArray(this), target, start, arguments.length > 2 ? arguments[2] : undefined); + return u$ArrayCopyWithin(aTypedArray(this), target, start, arguments.length > 2 ? arguments[2] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-copy-within":98}],273:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-copy-within":119,"../internals/function-uncurry-this":181}],359:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $every = require('../internals/array-iteration').every; @@ -18241,22 +19340,38 @@ exportTypedArrayMethod('every', function every(callbackfn /* , thisArg */) { return $every(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-iteration":104}],274:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-iteration":125}],360:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $fill = require('../internals/array-fill'); +var toBigInt = require('../internals/to-big-int'); +var classof = require('../internals/classof'); +var call = require('../internals/function-call'); +var uncurryThis = require('../internals/function-uncurry-this'); +var fails = require('../internals/fails'); var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; +var slice = uncurryThis(''.slice); + +// V8 ~ Chrome < 59, Safari < 14.1, FF < 55, Edge <=18 +var CONVERSION_BUG = fails(function () { + var count = 0; + // eslint-disable-next-line es/no-typed-arrays -- safe + new Int8Array(2).fill({ valueOf: function () { return count++; } }); + return count !== 1; +}); // `%TypedArray%.prototype.fill` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.fill -// eslint-disable-next-line no-unused-vars -- required for `.length` exportTypedArrayMethod('fill', function fill(value /* , start, end */) { - return $fill.apply(aTypedArray(this), arguments); -}); + var length = arguments.length; + aTypedArray(this); + var actualValue = slice(classof(this), 0, 3) === 'Big' ? toBigInt(value) : +value; + return call($fill, this, actualValue, length > 1 ? arguments[1] : undefined, length > 2 ? arguments[2] : undefined); +}, CONVERSION_BUG); -},{"../internals/array-buffer-view-core":96,"../internals/array-fill":99}],275:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-fill":120,"../internals/classof":138,"../internals/fails":171,"../internals/function-call":177,"../internals/function-uncurry-this":181,"../internals/to-big-int":280}],361:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $filter = require('../internals/array-iteration').filter; @@ -18272,7 +19387,7 @@ exportTypedArrayMethod('filter', function filter(callbackfn /* , thisArg */) { return fromSpeciesAndList(this, list); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-iteration":104,"../internals/typed-array-from-species-and-list":231}],276:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-iteration":125,"../internals/typed-array-from-species-and-list":296}],362:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $findIndex = require('../internals/array-iteration').findIndex; @@ -18286,7 +19401,7 @@ exportTypedArrayMethod('findIndex', function findIndex(predicate /* , thisArg */ return $findIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-iteration":104}],277:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-iteration":125}],363:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $find = require('../internals/array-iteration').find; @@ -18300,7 +19415,7 @@ exportTypedArrayMethod('find', function find(predicate /* , thisArg */) { return $find(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-iteration":104}],278:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-iteration":125}],364:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $forEach = require('../internals/array-iteration').forEach; @@ -18314,7 +19429,7 @@ exportTypedArrayMethod('forEach', function forEach(callbackfn /* , thisArg */) { $forEach(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-iteration":104}],279:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-iteration":125}],365:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $includes = require('../internals/array-includes').includes; @@ -18328,7 +19443,7 @@ exportTypedArrayMethod('includes', function includes(searchElement /* , fromInde return $includes(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-includes":103}],280:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-includes":124}],366:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $indexOf = require('../internals/array-includes').indexOf; @@ -18342,64 +19457,73 @@ exportTypedArrayMethod('indexOf', function indexOf(searchElement /* , fromIndex return $indexOf(aTypedArray(this), searchElement, arguments.length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-includes":103}],281:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-includes":124}],367:[function(require,module,exports){ 'use strict'; var global = require('../internals/global'); +var fails = require('../internals/fails'); +var uncurryThis = require('../internals/function-uncurry-this'); var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var ArrayIterators = require('../modules/es.array.iterator'); var wellKnownSymbol = require('../internals/well-known-symbol'); var ITERATOR = wellKnownSymbol('iterator'); var Uint8Array = global.Uint8Array; -var arrayValues = ArrayIterators.values; -var arrayKeys = ArrayIterators.keys; -var arrayEntries = ArrayIterators.entries; +var arrayValues = uncurryThis(ArrayIterators.values); +var arrayKeys = uncurryThis(ArrayIterators.keys); +var arrayEntries = uncurryThis(ArrayIterators.entries); var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; -var nativeTypedArrayIterator = Uint8Array && Uint8Array.prototype[ITERATOR]; +var TypedArrayPrototype = Uint8Array && Uint8Array.prototype; + +var GENERIC = !fails(function () { + TypedArrayPrototype[ITERATOR].call([1]); +}); -var CORRECT_ITER_NAME = !!nativeTypedArrayIterator - && (nativeTypedArrayIterator.name == 'values' || nativeTypedArrayIterator.name == undefined); +var ITERATOR_IS_VALUES = !!TypedArrayPrototype + && TypedArrayPrototype.values + && TypedArrayPrototype[ITERATOR] === TypedArrayPrototype.values + && TypedArrayPrototype.values.name === 'values'; var typedArrayValues = function values() { - return arrayValues.call(aTypedArray(this)); + return arrayValues(aTypedArray(this)); }; // `%TypedArray%.prototype.entries` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries exportTypedArrayMethod('entries', function entries() { - return arrayEntries.call(aTypedArray(this)); -}); + return arrayEntries(aTypedArray(this)); +}, GENERIC); // `%TypedArray%.prototype.keys` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys exportTypedArrayMethod('keys', function keys() { - return arrayKeys.call(aTypedArray(this)); -}); + return arrayKeys(aTypedArray(this)); +}, GENERIC); // `%TypedArray%.prototype.values` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.values -exportTypedArrayMethod('values', typedArrayValues, !CORRECT_ITER_NAME); +exportTypedArrayMethod('values', typedArrayValues, GENERIC || !ITERATOR_IS_VALUES, { name: 'values' }); // `%TypedArray%.prototype[@@iterator]` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype-@@iterator -exportTypedArrayMethod(ITERATOR, typedArrayValues, !CORRECT_ITER_NAME); +exportTypedArrayMethod(ITERATOR, typedArrayValues, GENERIC || !ITERATOR_IS_VALUES, { name: 'values' }); -},{"../internals/array-buffer-view-core":96,"../internals/global":147,"../internals/well-known-symbol":237,"../modules/es.array.iterator":247}],282:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/fails":171,"../internals/function-uncurry-this":181,"../internals/global":188,"../internals/well-known-symbol":306,"../modules/es.array.iterator":316}],368:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); +var uncurryThis = require('../internals/function-uncurry-this'); var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; -var $join = [].join; +var $join = uncurryThis([].join); // `%TypedArray%.prototype.join` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.join -// eslint-disable-next-line no-unused-vars -- required for `.length` exportTypedArrayMethod('join', function join(separator) { - return $join.apply(aTypedArray(this), arguments); + return $join(aTypedArray(this), separator); }); -},{"../internals/array-buffer-view-core":96}],283:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/function-uncurry-this":181}],369:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); +var apply = require('../internals/function-apply'); var $lastIndexOf = require('../internals/array-last-index-of'); var aTypedArray = ArrayBufferViewCore.aTypedArray; @@ -18407,12 +19531,12 @@ var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.lastIndexOf` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.lastindexof -// eslint-disable-next-line no-unused-vars -- required for `.length` exportTypedArrayMethod('lastIndexOf', function lastIndexOf(searchElement /* , fromIndex */) { - return $lastIndexOf.apply(aTypedArray(this), arguments); + var length = arguments.length; + return apply($lastIndexOf, aTypedArray(this), length > 1 ? [searchElement, arguments[1]] : [searchElement]); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-last-index-of":105}],284:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-last-index-of":126,"../internals/function-apply":174}],370:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $map = require('../internals/array-iteration').map; @@ -18429,7 +19553,7 @@ exportTypedArrayMethod('map', function map(mapfn /* , thisArg */) { }); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-iteration":104,"../internals/typed-array-species-constructor":233}],285:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-iteration":125,"../internals/typed-array-species-constructor":298}],371:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $reduceRight = require('../internals/array-reduce').right; @@ -18437,13 +19561,14 @@ var $reduceRight = require('../internals/array-reduce').right; var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; -// `%TypedArray%.prototype.reduceRicht` method +// `%TypedArray%.prototype.reduceRight` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduceright exportTypedArrayMethod('reduceRight', function reduceRight(callbackfn /* , initialValue */) { - return $reduceRight(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); + var length = arguments.length; + return $reduceRight(aTypedArray(this), callbackfn, length, length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-reduce":108}],286:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-reduce":129}],372:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $reduce = require('../internals/array-reduce').left; @@ -18454,10 +19579,11 @@ var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; // `%TypedArray%.prototype.reduce` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce exportTypedArrayMethod('reduce', function reduce(callbackfn /* , initialValue */) { - return $reduce(aTypedArray(this), callbackfn, arguments.length, arguments.length > 1 ? arguments[1] : undefined); + var length = arguments.length; + return $reduce(aTypedArray(this), callbackfn, length, length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-reduce":108}],287:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-reduce":129}],373:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); @@ -18480,20 +19606,36 @@ exportTypedArrayMethod('reverse', function reverse() { } return that; }); -},{"../internals/array-buffer-view-core":96}],288:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117}],374:[function(require,module,exports){ 'use strict'; +var global = require('../internals/global'); +var call = require('../internals/function-call'); var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); -var toLength = require('../internals/to-length'); +var lengthOfArrayLike = require('../internals/length-of-array-like'); var toOffset = require('../internals/to-offset'); -var toObject = require('../internals/to-object'); +var toIndexedObject = require('../internals/to-object'); var fails = require('../internals/fails'); +var RangeError = global.RangeError; +var Int8Array = global.Int8Array; +var Int8ArrayPrototype = Int8Array && Int8Array.prototype; +var $set = Int8ArrayPrototype && Int8ArrayPrototype.set; var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; -var FORCED = fails(function () { +var WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS = !fails(function () { // eslint-disable-next-line es/no-typed-arrays -- required for testing - new Int8Array(1).set({}); + var array = new Uint8ClampedArray(2); + call($set, array, { length: 1, 0: 3 }, 1); + return array[1] !== 3; +}); + +// https://bugs.chromium.org/p/v8/issues/detail?id=11294 and other +var TO_OBJECT_BUG = WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS && ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS && fails(function () { + var array = new Int8Array(2); + array.set(1); + array.set('2', 1); + return array[0] !== 0 || array[1] !== 2; }); // `%TypedArray%.prototype.set` method @@ -18501,23 +19643,24 @@ var FORCED = fails(function () { exportTypedArrayMethod('set', function set(arrayLike /* , offset */) { aTypedArray(this); var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1); + var src = toIndexedObject(arrayLike); + if (WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS) return call($set, this, src, offset); var length = this.length; - var src = toObject(arrayLike); - var len = toLength(src.length); + var len = lengthOfArrayLike(src); var index = 0; - if (len + offset > length) throw RangeError('Wrong length'); + if (len + offset > length) throw new RangeError('Wrong length'); while (index < len) this[offset + index] = src[index++]; -}, FORCED); +}, !WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG); -},{"../internals/array-buffer-view-core":96,"../internals/fails":140,"../internals/to-length":221,"../internals/to-object":222,"../internals/to-offset":223}],289:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/fails":171,"../internals/function-call":177,"../internals/global":188,"../internals/length-of-array-like":219,"../internals/to-object":285,"../internals/to-offset":286}],375:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var typedArraySpeciesConstructor = require('../internals/typed-array-species-constructor'); var fails = require('../internals/fails'); +var arraySlice = require('../internals/array-slice'); var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; -var $slice = [].slice; var FORCED = fails(function () { // eslint-disable-next-line es/no-typed-arrays -- required for testing @@ -18527,7 +19670,7 @@ var FORCED = fails(function () { // `%TypedArray%.prototype.slice` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice exportTypedArrayMethod('slice', function slice(start, end) { - var list = $slice.call(aTypedArray(this), start, end); + var list = arraySlice(aTypedArray(this), start, end); var C = typedArraySpeciesConstructor(this); var index = 0; var length = list.length; @@ -18536,7 +19679,7 @@ exportTypedArrayMethod('slice', function slice(start, end) { return result; }, FORCED); -},{"../internals/array-buffer-view-core":96,"../internals/fails":140,"../internals/typed-array-species-constructor":233}],290:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-slice":131,"../internals/fails":171,"../internals/typed-array-species-constructor":298}],376:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var $some = require('../internals/array-iteration').some; @@ -18550,14 +19693,14 @@ exportTypedArrayMethod('some', function some(callbackfn /* , thisArg */) { return $some(aTypedArray(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined); }); -},{"../internals/array-buffer-view-core":96,"../internals/array-iteration":104}],291:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-iteration":125}],377:[function(require,module,exports){ 'use strict'; -var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var global = require('../internals/global'); +var uncurryThis = require('../internals/function-uncurry-this-clause'); var fails = require('../internals/fails'); -var aFunction = require('../internals/a-function'); -var toLength = require('../internals/to-length'); +var aCallable = require('../internals/a-callable'); var internalSort = require('../internals/array-sort'); +var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var FF = require('../internals/engine-ff-version'); var IE_OR_EDGE = require('../internals/engine-is-ie-or-edge'); var V8 = require('../internals/engine-v8-version'); @@ -18566,14 +19709,14 @@ var WEBKIT = require('../internals/engine-webkit-version'); var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; var Uint16Array = global.Uint16Array; -var nativeSort = Uint16Array && Uint16Array.prototype.sort; +var nativeSort = Uint16Array && uncurryThis(Uint16Array.prototype.sort); // WebKit -var ACCEPT_INCORRECT_ARGUMENTS = !!nativeSort && !fails(function () { - var array = new Uint16Array(2); - array.sort(null); - array.sort({}); -}); +var ACCEPT_INCORRECT_ARGUMENTS = !!nativeSort && !(fails(function () { + nativeSort(new Uint16Array(2), null); +}) && fails(function () { + nativeSort(new Uint16Array(2), {}); +})); var STABLE_SORT = !!nativeSort && !fails(function () { // feature detection can be too slow, so check engines versions @@ -18592,7 +19735,7 @@ var STABLE_SORT = !!nativeSort && !fails(function () { expected[index] = index - 2 * mod + 3; } - array.sort(function (a, b) { + nativeSort(array, function (a, b) { return (a / 4 | 0) - (b / 4 | 0); }); @@ -18616,29 +19759,13 @@ var getSortCompare = function (comparefn) { // `%TypedArray%.prototype.sort` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort exportTypedArrayMethod('sort', function sort(comparefn) { - var array = this; - if (comparefn !== undefined) aFunction(comparefn); - if (STABLE_SORT) return nativeSort.call(array, comparefn); - - aTypedArray(array); - var arrayLength = toLength(array.length); - var items = Array(arrayLength); - var index; - - for (index = 0; index < arrayLength; index++) { - items[index] = array[index]; - } - - items = internalSort(array, getSortCompare(comparefn)); - - for (index = 0; index < arrayLength; index++) { - array[index] = items[index]; - } + if (comparefn !== undefined) aCallable(comparefn); + if (STABLE_SORT) return nativeSort(this, comparefn); - return array; + return internalSort(aTypedArray(this), getSortCompare(comparefn)); }, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS); -},{"../internals/a-function":89,"../internals/array-buffer-view-core":96,"../internals/array-sort":109,"../internals/engine-ff-version":128,"../internals/engine-is-ie-or-edge":130,"../internals/engine-v8-version":136,"../internals/engine-webkit-version":137,"../internals/fails":140,"../internals/global":147,"../internals/to-length":221}],292:[function(require,module,exports){ +},{"../internals/a-callable":108,"../internals/array-buffer-view-core":117,"../internals/array-sort":132,"../internals/engine-ff-version":158,"../internals/engine-is-ie-or-edge":161,"../internals/engine-v8-version":167,"../internals/engine-webkit-version":168,"../internals/fails":171,"../internals/function-uncurry-this-clause":180,"../internals/global":188}],378:[function(require,module,exports){ 'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var toLength = require('../internals/to-length'); @@ -18662,17 +19789,18 @@ exportTypedArrayMethod('subarray', function subarray(begin, end) { ); }); -},{"../internals/array-buffer-view-core":96,"../internals/to-absolute-index":217,"../internals/to-length":221,"../internals/typed-array-species-constructor":233}],293:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/to-absolute-index":279,"../internals/to-length":284,"../internals/typed-array-species-constructor":298}],379:[function(require,module,exports){ 'use strict'; var global = require('../internals/global'); +var apply = require('../internals/function-apply'); var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var fails = require('../internals/fails'); +var arraySlice = require('../internals/array-slice'); var Int8Array = global.Int8Array; var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; var $toLocaleString = [].toLocaleString; -var $slice = [].slice; // iOS Safari 6.x fails here var TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () { @@ -18680,7 +19808,7 @@ var TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () { }); var FORCED = fails(function () { - return [1, 2].toLocaleString() != new Int8Array([1, 2]).toLocaleString(); + return [1, 2].toLocaleString() !== new Int8Array([1, 2]).toLocaleString(); }) || !fails(function () { Int8Array.prototype.toLocaleString.call([1, 2]); }); @@ -18688,33 +19816,39 @@ var FORCED = fails(function () { // `%TypedArray%.prototype.toLocaleString` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tolocalestring exportTypedArrayMethod('toLocaleString', function toLocaleString() { - return $toLocaleString.apply(TO_LOCALE_STRING_BUG ? $slice.call(aTypedArray(this)) : aTypedArray(this), arguments); + return apply( + $toLocaleString, + TO_LOCALE_STRING_BUG ? arraySlice(aTypedArray(this)) : aTypedArray(this), + arraySlice(arguments) + ); }, FORCED); -},{"../internals/array-buffer-view-core":96,"../internals/fails":140,"../internals/global":147}],294:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/array-slice":131,"../internals/fails":171,"../internals/function-apply":174,"../internals/global":188}],380:[function(require,module,exports){ 'use strict'; var exportTypedArrayMethod = require('../internals/array-buffer-view-core').exportTypedArrayMethod; var fails = require('../internals/fails'); var global = require('../internals/global'); +var uncurryThis = require('../internals/function-uncurry-this'); var Uint8Array = global.Uint8Array; var Uint8ArrayPrototype = Uint8Array && Uint8Array.prototype || {}; var arrayToString = [].toString; -var arrayJoin = [].join; +var join = uncurryThis([].join); if (fails(function () { arrayToString.call({}); })) { arrayToString = function toString() { - return arrayJoin.call(this); + return join(this); }; } -var IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString != arrayToString; +var IS_NOT_ARRAY_METHOD = Uint8ArrayPrototype.toString !== arrayToString; // `%TypedArray%.prototype.toString` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring exportTypedArrayMethod('toString', arrayToString, IS_NOT_ARRAY_METHOD); -},{"../internals/array-buffer-view-core":96,"../internals/fails":140,"../internals/global":147}],295:[function(require,module,exports){ +},{"../internals/array-buffer-view-core":117,"../internals/fails":171,"../internals/function-uncurry-this":181,"../internals/global":188}],381:[function(require,module,exports){ +'use strict'; var createTypedArrayConstructor = require('../internals/typed-array-constructor'); // `Uint8Array` constructor @@ -18725,37 +19859,45 @@ createTypedArrayConstructor('Uint8', function (init) { }; }); -},{"../internals/typed-array-constructor":229}],296:[function(require,module,exports){ +},{"../internals/typed-array-constructor":294}],382:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); var DOMIterables = require('../internals/dom-iterables'); +var DOMTokenListPrototype = require('../internals/dom-token-list-prototype'); var forEach = require('../internals/array-for-each'); var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); -for (var COLLECTION_NAME in DOMIterables) { - var Collection = global[COLLECTION_NAME]; - var CollectionPrototype = Collection && Collection.prototype; +var handlePrototype = function (CollectionPrototype) { // some Chrome versions have non-configurable methods on DOMTokenList if (CollectionPrototype && CollectionPrototype.forEach !== forEach) try { createNonEnumerableProperty(CollectionPrototype, 'forEach', forEach); } catch (error) { CollectionPrototype.forEach = forEach; } +}; + +for (var COLLECTION_NAME in DOMIterables) { + if (DOMIterables[COLLECTION_NAME]) { + handlePrototype(global[COLLECTION_NAME] && global[COLLECTION_NAME].prototype); + } } -},{"../internals/array-for-each":100,"../internals/create-non-enumerable-property":120,"../internals/dom-iterables":127,"../internals/global":147}],297:[function(require,module,exports){ +handlePrototype(DOMTokenListPrototype); + +},{"../internals/array-for-each":121,"../internals/create-non-enumerable-property":145,"../internals/dom-iterables":156,"../internals/dom-token-list-prototype":157,"../internals/global":188}],383:[function(require,module,exports){ +'use strict'; var global = require('../internals/global'); var DOMIterables = require('../internals/dom-iterables'); +var DOMTokenListPrototype = require('../internals/dom-token-list-prototype'); var ArrayIteratorMethods = require('../modules/es.array.iterator'); var createNonEnumerableProperty = require('../internals/create-non-enumerable-property'); +var setToStringTag = require('../internals/set-to-string-tag'); var wellKnownSymbol = require('../internals/well-known-symbol'); var ITERATOR = wellKnownSymbol('iterator'); -var TO_STRING_TAG = wellKnownSymbol('toStringTag'); var ArrayValues = ArrayIteratorMethods.values; -for (var COLLECTION_NAME in DOMIterables) { - var Collection = global[COLLECTION_NAME]; - var CollectionPrototype = Collection && Collection.prototype; +var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) { if (CollectionPrototype) { // some Chrome versions have non-configurable methods on DOMTokenList if (CollectionPrototype[ITERATOR] !== ArrayValues) try { @@ -18763,9 +19905,7 @@ for (var COLLECTION_NAME in DOMIterables) { } catch (error) { CollectionPrototype[ITERATOR] = ArrayValues; } - if (!CollectionPrototype[TO_STRING_TAG]) { - createNonEnumerableProperty(CollectionPrototype, TO_STRING_TAG, COLLECTION_NAME); - } + setToStringTag(CollectionPrototype, COLLECTION_NAME, true); if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) { // some Chrome versions have non-configurable methods on DOMTokenList if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try { @@ -18775,9 +19915,15 @@ for (var COLLECTION_NAME in DOMIterables) { } } } +}; + +for (var COLLECTION_NAME in DOMIterables) { + handlePrototype(global[COLLECTION_NAME] && global[COLLECTION_NAME].prototype, COLLECTION_NAME); } -},{"../internals/create-non-enumerable-property":120,"../internals/dom-iterables":127,"../internals/global":147,"../internals/well-known-symbol":237,"../modules/es.array.iterator":247}],298:[function(require,module,exports){ +handlePrototype(DOMTokenListPrototype, 'DOMTokenList'); + +},{"../internals/create-non-enumerable-property":145,"../internals/dom-iterables":156,"../internals/dom-token-list-prototype":157,"../internals/global":188,"../internals/set-to-string-tag":266,"../internals/well-known-symbol":306,"../modules/es.array.iterator":316}],384:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -18886,7 +20032,7 @@ function objectToString(o) { return Object.prototype.toString.call(o); } -},{"buffer":85}],299:[function(require,module,exports){ +},{"buffer":103}],385:[function(require,module,exports){ /* * Date Format 1.2.3 * (c) 2007-2009 Steven Levithan @@ -19114,7 +20260,77 @@ function kindOf(val) { } })(this); -},{}],300:[function(require,module,exports){ +},{}],386:[function(require,module,exports){ +'use strict'; + +var hasPropertyDescriptors = require('has-property-descriptors')(); + +var GetIntrinsic = require('get-intrinsic'); + +var $defineProperty = hasPropertyDescriptors && GetIntrinsic('%Object.defineProperty%', true); +if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + } catch (e) { + // IE 8 has a broken defineProperty + $defineProperty = false; + } +} + +var $SyntaxError = GetIntrinsic('%SyntaxError%'); +var $TypeError = GetIntrinsic('%TypeError%'); + +var gopd = require('gopd'); + +/** @type {(obj: Record, property: PropertyKey, value: unknown, nonEnumerable?: boolean | null, nonWritable?: boolean | null, nonConfigurable?: boolean | null, loose?: boolean) => void} */ +module.exports = function defineDataProperty( + obj, + property, + value +) { + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) { + throw new $TypeError('`obj` must be an object or a function`'); + } + if (typeof property !== 'string' && typeof property !== 'symbol') { + throw new $TypeError('`property` must be a string or a symbol`'); + } + if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) { + throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null'); + } + if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) { + throw new $TypeError('`nonWritable`, if provided, must be a boolean or null'); + } + if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) { + throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null'); + } + if (arguments.length > 6 && typeof arguments[6] !== 'boolean') { + throw new $TypeError('`loose`, if provided, must be a boolean'); + } + + var nonEnumerable = arguments.length > 3 ? arguments[3] : null; + var nonWritable = arguments.length > 4 ? arguments[4] : null; + var nonConfigurable = arguments.length > 5 ? arguments[5] : null; + var loose = arguments.length > 6 ? arguments[6] : false; + + /* @type {false | TypedPropertyDescriptor} */ + var desc = !!gopd && gopd(obj, property); + + if ($defineProperty) { + $defineProperty(obj, property, { + configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable, + enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable, + value: value, + writable: nonWritable === null && desc ? desc.writable : !nonWritable + }); + } else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) { + // must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable + obj[property] = value; // eslint-disable-line no-param-reassign + } else { + throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.'); + } +}; + +},{"get-intrinsic":392,"gopd":393,"has-property-descriptors":394}],387:[function(require,module,exports){ /*! * escape-html * Copyright(c) 2012-2013 TJ Holowaychuk @@ -19194,7 +20410,7 @@ function escapeHtml(string) { : html; } -},{}],301:[function(require,module,exports){ +},{}],388:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -19216,341 +20432,1207 @@ function escapeHtml(string) { // 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() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; + 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. -EventEmitter.defaultMaxListeners = 10; +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(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); +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; }; -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; +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'); - if (!this._events) - this._events = {}; + 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 (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } + 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 } - handler = this._events[type]; + var handler = events[type]; - if (isUndefined(handler)) + if (handler === undefined) return false; - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); + 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; }; -EventEmitter.prototype.addListener = function(type, listener) { +function _addListener(target, type, listener, prepend) { var m; + var events; + var existing; - if (!isFunction(listener)) - throw TypeError('listener must be a function'); + checkListener(listener); - if (!this._events) - this._events = {}; + 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); - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(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 (!this._events[type]) + if (existing === undefined) { // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; + 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 { - m = EventEmitter.defaultMaxListeners; + existing.push(listener); } - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } + // 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 this; + return target; +} + +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); }; EventEmitter.prototype.on = EventEmitter.prototype.addListener; -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; - if (!fired) { - fired = true; - listener.apply(this, arguments); - } +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); } +} - g.listener = listener; - this.on(type, g); +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; }; -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; +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; - if (!isFunction(listener)) - throw TypeError('listener must be a function'); + checkListener(listener); - if (!this._events || !this._events[type]) - return this; + events = this._events; + if (events === undefined) + return this; - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; + 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); } - } - if (position < 0) return this; + }; - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; - return this; -}; + events = this._events; + if (events === undefined) + return this; -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; + // 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; + } - if (!this._events) - 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; + } - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } + listeners = events[type]; - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } + 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; + }; - listeners = this._events[type]; +function _listeners(target, type, unwrap) { + var events = target._events; - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; + if (events === undefined) + return []; - return this; + 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.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; +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 = function(type) { - if (this._events) { - var evlistener = this._events[type]; +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; - if (isFunction(evlistener)) + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { return 1; - else if (evlistener) + } else if (evlistener !== undefined) { return evlistener.length; + } } + return 0; -}; +} -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; }; -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; +function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; } -function isObject(arg) { - return typeof arg === 'object' && arg !== null; +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); } -function isUndefined(arg) { - return arg === void 0; +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; } -},{}],302:[function(require,module,exports){ -var http = require('http'); +function once(emitter, name) { + return new Promise(function (resolve, reject) { + function errorListener(err) { + emitter.removeListener(name, resolver); + reject(err); + } -var https = module.exports; + function resolver() { + if (typeof emitter.removeListener === 'function') { + emitter.removeListener('error', errorListener); + } + resolve([].slice.call(arguments)); + }; -for (var key in http) { - if (http.hasOwnProperty(key)) https[key] = http[key]; -}; + eventTargetAgnosticAddListener(emitter, name, resolver, { once: true }); + if (name !== 'error') { + addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true }); + } + }); +} -https.request = function (params, cb) { - if (!params) params = {}; - params.scheme = 'https'; - params.protocol = 'https:'; - return http.request.call(this, params, cb); +function addErrorHandlerIfEventEmitter(emitter, handler, flags) { + if (typeof emitter.on === 'function') { + eventTargetAgnosticAddListener(emitter, 'error', handler, flags); + } } -},{"http":400}],303:[function(require,module,exports){ -/*! - * humanize-ms - index.js - * Copyright(c) 2014 dead_horse - * MIT Licensed - */ +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); + } +} +},{}],389:[function(require,module,exports){ 'use strict'; -/** - * Module dependencies. - */ +var isCallable = require('is-callable'); -var util = require('util'); -var ms = require('ms'); +var toStr = Object.prototype.toString; +var hasOwnProperty = Object.prototype.hasOwnProperty; -module.exports = function (t) { - if (typeof t === 'number') return t; - var r = ms(t); - if (r === undefined) { - var err = new Error(util.format('humanize-ms(%j) result undefined', t)); - console.warn(err.stack); - } - return r; +var forEachArray = function forEachArray(array, iterator, receiver) { + for (var i = 0, len = array.length; i < len; i++) { + if (hasOwnProperty.call(array, i)) { + if (receiver == null) { + iterator(array[i], i, array); + } else { + iterator.call(receiver, array[i], i, array); + } + } + } }; -},{"ms":319,"util":352}],304:[function(require,module,exports){ -/*! 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] +var forEachString = function forEachString(string, iterator, receiver) { + for (var i = 0, len = string.length; i < len; i++) { + // no such thing as a sparse string. + if (receiver == null) { + iterator(string.charAt(i), i, string); + } else { + iterator.call(receiver, string.charAt(i), i, string); + } + } +}; + +var forEachObject = function forEachObject(object, iterator, receiver) { + for (var k in object) { + if (hasOwnProperty.call(object, k)) { + if (receiver == null) { + iterator(object[k], k, object); + } else { + iterator.call(receiver, object[k], k, object); + } + } + } +}; + +var forEach = function forEach(list, iterator, thisArg) { + if (!isCallable(iterator)) { + throw new TypeError('iterator must be a function'); + } + + var receiver; + if (arguments.length >= 3) { + receiver = thisArg; + } + + if (toStr.call(list) === '[object Array]') { + forEachArray(list, iterator, receiver); + } else if (typeof list === 'string') { + forEachString(list, iterator, receiver); + } else { + forEachObject(list, iterator, receiver); + } +}; + +module.exports = forEach; + +},{"is-callable":412}],390:[function(require,module,exports){ +'use strict'; + +/* eslint no-invalid-this: 1 */ + +var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; +var toStr = Object.prototype.toString; +var max = Math.max; +var funcType = '[object Function]'; + +var concatty = function concatty(a, b) { + var arr = []; + + for (var i = 0; i < a.length; i += 1) { + arr[i] = a[i]; + } + for (var j = 0; j < b.length; j += 1) { + arr[j + a.length] = b[j]; + } + + return arr; +}; + +var slicy = function slicy(arrLike, offset) { + var arr = []; + for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) { + arr[j] = arrLike[i]; + } + return arr; +}; + +var joiny = function (arr, joiner) { + var str = ''; + for (var i = 0; i < arr.length; i += 1) { + str += arr[i]; + if (i + 1 < arr.length) { + str += joiner; + } + } + return str; +}; + +module.exports = function bind(that) { + var target = this; + if (typeof target !== 'function' || toStr.apply(target) !== funcType) { + throw new TypeError(ERROR_MESSAGE + target); + } + var args = slicy(arguments, 1); + + var bound; + var binder = function () { + if (this instanceof bound) { + var result = target.apply( + this, + concatty(args, arguments) + ); + if (Object(result) === result) { + return result; + } + return this; + } + return target.apply( + that, + concatty(args, arguments) + ); + + }; + + var boundLength = max(0, target.length - args.length); + var boundArgs = []; + for (var i = 0; i < boundLength; i++) { + boundArgs[i] = '$' + i; + } + + bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder); + + if (target.prototype) { + var Empty = function Empty() {}; + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + Empty.prototype = null; + } + + return bound; +}; + +},{}],391:[function(require,module,exports){ +'use strict'; + +var implementation = require('./implementation'); + +module.exports = Function.prototype.bind || implementation; + +},{"./implementation":390}],392:[function(require,module,exports){ +'use strict'; + +var undefined; + +var $SyntaxError = SyntaxError; +var $Function = Function; +var $TypeError = TypeError; + +// eslint-disable-next-line consistent-return +var getEvalledConstructor = function (expressionSyntax) { + try { + return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')(); + } catch (e) {} +}; + +var $gOPD = Object.getOwnPropertyDescriptor; +if ($gOPD) { + try { + $gOPD({}, ''); + } catch (e) { + $gOPD = null; // this is IE 8, which has a broken gOPD + } +} + +var throwTypeError = function () { + throw new $TypeError(); +}; +var ThrowTypeError = $gOPD + ? (function () { + try { + // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties + arguments.callee; // IE 8 does not throw here + return throwTypeError; + } catch (calleeThrows) { + try { + // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '') + return $gOPD(arguments, 'callee').get; + } catch (gOPDthrows) { + return throwTypeError; + } + } + }()) + : throwTypeError; + +var hasSymbols = require('has-symbols')(); +var hasProto = require('has-proto')(); + +var getProto = Object.getPrototypeOf || ( + hasProto + ? function (x) { return x.__proto__; } // eslint-disable-line no-proto + : null +); + +var needsEval = {}; + +var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined : getProto(Uint8Array); + +var INTRINSICS = { + '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError, + '%Array%': Array, + '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer, + '%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined, + '%AsyncFromSyncIteratorPrototype%': undefined, + '%AsyncFunction%': needsEval, + '%AsyncGenerator%': needsEval, + '%AsyncGeneratorFunction%': needsEval, + '%AsyncIteratorPrototype%': needsEval, + '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics, + '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt, + '%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined : BigInt64Array, + '%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined : BigUint64Array, + '%Boolean%': Boolean, + '%DataView%': typeof DataView === 'undefined' ? undefined : DataView, + '%Date%': Date, + '%decodeURI%': decodeURI, + '%decodeURIComponent%': decodeURIComponent, + '%encodeURI%': encodeURI, + '%encodeURIComponent%': encodeURIComponent, + '%Error%': Error, + '%eval%': eval, // eslint-disable-line no-eval + '%EvalError%': EvalError, + '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array, + '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array, + '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry, + '%Function%': $Function, + '%GeneratorFunction%': needsEval, + '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array, + '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array, + '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array, + '%isFinite%': isFinite, + '%isNaN%': isNaN, + '%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined, + '%JSON%': typeof JSON === 'object' ? JSON : undefined, + '%Map%': typeof Map === 'undefined' ? undefined : Map, + '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Map()[Symbol.iterator]()), + '%Math%': Math, + '%Number%': Number, + '%Object%': Object, + '%parseFloat%': parseFloat, + '%parseInt%': parseInt, + '%Promise%': typeof Promise === 'undefined' ? undefined : Promise, + '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy, + '%RangeError%': RangeError, + '%ReferenceError%': ReferenceError, + '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect, + '%RegExp%': RegExp, + '%Set%': typeof Set === 'undefined' ? undefined : Set, + '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined : getProto(new Set()[Symbol.iterator]()), + '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer, + '%String%': String, + '%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined, + '%Symbol%': hasSymbols ? Symbol : undefined, + '%SyntaxError%': $SyntaxError, + '%ThrowTypeError%': ThrowTypeError, + '%TypedArray%': TypedArray, + '%TypeError%': $TypeError, + '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array, + '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray, + '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array, + '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array, + '%URIError%': URIError, + '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap, + '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef, + '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet +}; + +if (getProto) { + try { + null.error; // eslint-disable-line no-unused-expressions + } catch (e) { + // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229 + var errorProto = getProto(getProto(e)); + INTRINSICS['%Error.prototype%'] = errorProto; + } +} + +var doEval = function doEval(name) { + var value; + if (name === '%AsyncFunction%') { + value = getEvalledConstructor('async function () {}'); + } else if (name === '%GeneratorFunction%') { + value = getEvalledConstructor('function* () {}'); + } else if (name === '%AsyncGeneratorFunction%') { + value = getEvalledConstructor('async function* () {}'); + } else if (name === '%AsyncGenerator%') { + var fn = doEval('%AsyncGeneratorFunction%'); + if (fn) { + value = fn.prototype; + } + } else if (name === '%AsyncIteratorPrototype%') { + var gen = doEval('%AsyncGenerator%'); + if (gen && getProto) { + value = getProto(gen.prototype); + } + } + + INTRINSICS[name] = value; + + return value; +}; + +var LEGACY_ALIASES = { + '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'], + '%ArrayPrototype%': ['Array', 'prototype'], + '%ArrayProto_entries%': ['Array', 'prototype', 'entries'], + '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'], + '%ArrayProto_keys%': ['Array', 'prototype', 'keys'], + '%ArrayProto_values%': ['Array', 'prototype', 'values'], + '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'], + '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'], + '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'], + '%BooleanPrototype%': ['Boolean', 'prototype'], + '%DataViewPrototype%': ['DataView', 'prototype'], + '%DatePrototype%': ['Date', 'prototype'], + '%ErrorPrototype%': ['Error', 'prototype'], + '%EvalErrorPrototype%': ['EvalError', 'prototype'], + '%Float32ArrayPrototype%': ['Float32Array', 'prototype'], + '%Float64ArrayPrototype%': ['Float64Array', 'prototype'], + '%FunctionPrototype%': ['Function', 'prototype'], + '%Generator%': ['GeneratorFunction', 'prototype'], + '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'], + '%Int8ArrayPrototype%': ['Int8Array', 'prototype'], + '%Int16ArrayPrototype%': ['Int16Array', 'prototype'], + '%Int32ArrayPrototype%': ['Int32Array', 'prototype'], + '%JSONParse%': ['JSON', 'parse'], + '%JSONStringify%': ['JSON', 'stringify'], + '%MapPrototype%': ['Map', 'prototype'], + '%NumberPrototype%': ['Number', 'prototype'], + '%ObjectPrototype%': ['Object', 'prototype'], + '%ObjProto_toString%': ['Object', 'prototype', 'toString'], + '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'], + '%PromisePrototype%': ['Promise', 'prototype'], + '%PromiseProto_then%': ['Promise', 'prototype', 'then'], + '%Promise_all%': ['Promise', 'all'], + '%Promise_reject%': ['Promise', 'reject'], + '%Promise_resolve%': ['Promise', 'resolve'], + '%RangeErrorPrototype%': ['RangeError', 'prototype'], + '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'], + '%RegExpPrototype%': ['RegExp', 'prototype'], + '%SetPrototype%': ['Set', 'prototype'], + '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'], + '%StringPrototype%': ['String', 'prototype'], + '%SymbolPrototype%': ['Symbol', 'prototype'], + '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'], + '%TypedArrayPrototype%': ['TypedArray', 'prototype'], + '%TypeErrorPrototype%': ['TypeError', 'prototype'], + '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'], + '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'], + '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'], + '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'], + '%URIErrorPrototype%': ['URIError', 'prototype'], + '%WeakMapPrototype%': ['WeakMap', 'prototype'], + '%WeakSetPrototype%': ['WeakSet', 'prototype'] +}; + +var bind = require('function-bind'); +var hasOwn = require('hasown'); +var $concat = bind.call(Function.call, Array.prototype.concat); +var $spliceApply = bind.call(Function.apply, Array.prototype.splice); +var $replace = bind.call(Function.call, String.prototype.replace); +var $strSlice = bind.call(Function.call, String.prototype.slice); +var $exec = bind.call(Function.call, RegExp.prototype.exec); + +/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */ +var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; +var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */ +var stringToPath = function stringToPath(string) { + var first = $strSlice(string, 0, 1); + var last = $strSlice(string, -1); + if (first === '%' && last !== '%') { + throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`'); + } else if (last === '%' && first !== '%') { + throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`'); + } + var result = []; + $replace(string, rePropName, function (match, number, quote, subString) { + result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match; + }); + return result; +}; +/* end adaptation */ + +var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) { + var intrinsicName = name; + var alias; + if (hasOwn(LEGACY_ALIASES, intrinsicName)) { + alias = LEGACY_ALIASES[intrinsicName]; + intrinsicName = '%' + alias[0] + '%'; + } + + if (hasOwn(INTRINSICS, intrinsicName)) { + var value = INTRINSICS[intrinsicName]; + if (value === needsEval) { + value = doEval(intrinsicName); + } + if (typeof value === 'undefined' && !allowMissing) { + throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!'); + } + + return { + alias: alias, + name: intrinsicName, + value: value + }; + } + + throw new $SyntaxError('intrinsic ' + name + ' does not exist!'); +}; + +module.exports = function GetIntrinsic(name, allowMissing) { + if (typeof name !== 'string' || name.length === 0) { + throw new $TypeError('intrinsic name must be a non-empty string'); + } + if (arguments.length > 1 && typeof allowMissing !== 'boolean') { + throw new $TypeError('"allowMissing" argument must be a boolean'); + } + + if ($exec(/^%?[^%]*%?$/, name) === null) { + throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name'); + } + var parts = stringToPath(name); + var intrinsicBaseName = parts.length > 0 ? parts[0] : ''; + + var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing); + var intrinsicRealName = intrinsic.name; + var value = intrinsic.value; + var skipFurtherCaching = false; + + var alias = intrinsic.alias; + if (alias) { + intrinsicBaseName = alias[0]; + $spliceApply(parts, $concat([0, 1], alias)); + } + + for (var i = 1, isOwn = true; i < parts.length; i += 1) { + var part = parts[i]; + var first = $strSlice(part, 0, 1); + var last = $strSlice(part, -1); + if ( + ( + (first === '"' || first === "'" || first === '`') + || (last === '"' || last === "'" || last === '`') + ) + && first !== last + ) { + throw new $SyntaxError('property names with quotes must have matching quotes'); + } + if (part === 'constructor' || !isOwn) { + skipFurtherCaching = true; + } + + intrinsicBaseName += '.' + part; + intrinsicRealName = '%' + intrinsicBaseName + '%'; + + if (hasOwn(INTRINSICS, intrinsicRealName)) { + value = INTRINSICS[intrinsicRealName]; + } else if (value != null) { + if (!(part in value)) { + if (!allowMissing) { + throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.'); + } + return void undefined; + } + if ($gOPD && (i + 1) >= parts.length) { + var desc = $gOPD(value, part); + isOwn = !!desc; + + // By convention, when a data property is converted to an accessor + // property to emulate a data property that does not suffer from + // the override mistake, that accessor's getter is marked with + // an `originalValue` property. Here, when we detect this, we + // uphold the illusion by pretending to see that original data + // property, i.e., returning the value rather than the getter + // itself. + if (isOwn && 'get' in desc && !('originalValue' in desc.get)) { + value = desc.get; + } else { + value = value[part]; + } + } else { + isOwn = hasOwn(value, part); + value = value[part]; + } + + if (isOwn && !skipFurtherCaching) { + INTRINSICS[intrinsicRealName] = value; + } + } + } + return value; +}; + +},{"function-bind":391,"has-proto":395,"has-symbols":396,"hasown":399}],393:[function(require,module,exports){ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); + +if ($gOPD) { + try { + $gOPD([], 'length'); + } catch (e) { + // IE 8 has a broken gOPD + $gOPD = null; + } +} + +module.exports = $gOPD; + +},{"get-intrinsic":392}],394:[function(require,module,exports){ +'use strict'; + +var GetIntrinsic = require('get-intrinsic'); + +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); + +var hasPropertyDescriptors = function hasPropertyDescriptors() { + if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + return true; + } catch (e) { + // IE 8 has a broken defineProperty + return false; + } + } + return false; +}; + +hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() { + // node v0.6 has a bug where array lengths can be Set but not Defined + if (!hasPropertyDescriptors()) { + return null; + } + try { + return $defineProperty([], 'length', { value: 1 }).length !== 1; + } catch (e) { + // In Firefox 4-22, defining length on an array throws an exception. + return true; + } +}; + +module.exports = hasPropertyDescriptors; + +},{"get-intrinsic":392}],395:[function(require,module,exports){ +'use strict'; + +var test = { + foo: {} +}; + +var $Object = Object; + +module.exports = function hasProto() { + return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object); +}; + +},{}],396:[function(require,module,exports){ +'use strict'; + +var origSymbol = typeof Symbol !== 'undefined' && Symbol; +var hasSymbolSham = require('./shams'); + +module.exports = function hasNativeSymbols() { + if (typeof origSymbol !== 'function') { return false; } + if (typeof Symbol !== 'function') { return false; } + if (typeof origSymbol('foo') !== 'symbol') { return false; } + if (typeof Symbol('bar') !== 'symbol') { return false; } + + return hasSymbolSham(); +}; + +},{"./shams":397}],397:[function(require,module,exports){ +'use strict'; + +/* eslint complexity: [2, 18], max-statements: [2, 33] */ +module.exports = function hasSymbols() { + if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } + if (typeof Symbol.iterator === 'symbol') { return true; } + + var obj = {}; + var sym = Symbol('test'); + var symObj = Object(sym); + if (typeof sym === 'string') { return false; } + + if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; } + if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; } + + // temp disabled per https://github.com/ljharb/object.assign/issues/17 + // if (sym instanceof Symbol) { return false; } + // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4 + // if (!(symObj instanceof Symbol)) { return false; } + + // if (typeof Symbol.prototype.toString !== 'function') { return false; } + // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; } + + var symVal = 42; + obj[sym] = symVal; + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop + if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } + + if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } + + var syms = Object.getOwnPropertySymbols(obj); + if (syms.length !== 1 || syms[0] !== sym) { return false; } + + if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } + + if (typeof Object.getOwnPropertyDescriptor === 'function') { + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); + if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } + } + + return true; +}; + +},{}],398:[function(require,module,exports){ +'use strict'; + +var hasSymbols = require('has-symbols/shams'); + +module.exports = function hasToStringTagShams() { + return hasSymbols() && !!Symbol.toStringTag; +}; + +},{"has-symbols/shams":397}],399:[function(require,module,exports){ +'use strict'; + +var call = Function.prototype.call; +var $hasOwn = Object.prototype.hasOwnProperty; +var bind = require('function-bind'); + +/** @type {(o: {}, p: PropertyKey) => p is keyof o} */ +module.exports = bind.call(call, $hasOwn); + +},{"function-bind":391}],400:[function(require,module,exports){ +var http = require('http') +var url = require('url') + +var https = module.exports + +for (var key in http) { + if (http.hasOwnProperty(key)) https[key] = http[key] +} + +https.request = function (params, cb) { + params = validateParams(params) + return http.request.call(this, params, cb) +} + +https.get = function (params, cb) { + params = validateParams(params) + return http.get.call(this, params, cb) +} + +function validateParams (params) { + if (typeof params === 'string') { + params = url.parse(params) + } + if (!params.protocol) { + params.protocol = 'https:' + } + if (params.protocol !== 'https:') { + throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"') + } + return params +} + +},{"http":541,"url":545}],401:[function(require,module,exports){ +/*! + * humanize-ms - index.js + * Copyright(c) 2014 dead_horse + * MIT Licensed + */ + +'use strict'; + +/** + * Module dependencies. + */ + +var util = require('util'); +var ms = require('ms'); + +module.exports = function (t) { + if (typeof t === 'number') return t; + var r = ms(t); + if (r === undefined) { + var err = new Error(util.format('humanize-ms(%j) result undefined', t)); + console.warn(err.stack); + } + return r; +}; + +},{"ms":434,"util":491}],402:[function(require,module,exports){ +/*! 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 @@ -19627,7 +21709,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],305:[function(require,module,exports){ +},{}],403:[function(require,module,exports){ 'use strict'; var types = [ require('./nextTick'), @@ -19726,7 +21808,7 @@ function immediate(task) { } } -},{"./messageChannel":306,"./mutation.js":307,"./nextTick":84,"./queueMicrotask":308,"./stateChange":309,"./timeout":310}],306:[function(require,module,exports){ +},{"./messageChannel":404,"./mutation.js":405,"./nextTick":102,"./queueMicrotask":406,"./stateChange":407,"./timeout":408}],404:[function(require,module,exports){ (function (global){(function (){ 'use strict'; @@ -19747,7 +21829,7 @@ exports.install = function (func) { }; }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],307:[function(require,module,exports){ +},{}],405:[function(require,module,exports){ (function (global){(function (){ 'use strict'; //based off rsvp https://github.com/tildeio/rsvp.js @@ -19772,7 +21854,7 @@ exports.install = function (handle) { }; }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],308:[function(require,module,exports){ +},{}],406:[function(require,module,exports){ (function (global){(function (){ 'use strict'; exports.test = function () { @@ -19786,7 +21868,7 @@ exports.install = function (func) { }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],309:[function(require,module,exports){ +},{}],407:[function(require,module,exports){ (function (global){(function (){ 'use strict'; @@ -19813,7 +21895,7 @@ exports.install = function (handle) { }; }; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],310:[function(require,module,exports){ +},{}],408:[function(require,module,exports){ 'use strict'; exports.test = function () { return true; @@ -19824,7 +21906,7 @@ exports.install = function (t) { setTimeout(t, 0); }; }; -},{}],311:[function(require,module,exports){ +},{}],409:[function(require,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -19853,7 +21935,42 @@ if (typeof Object.create === 'function') { } } -},{}],312:[function(require,module,exports){ +},{}],410:[function(require,module,exports){ +'use strict'; + +var hasToStringTag = require('has-tostringtag/shams')(); +var callBound = require('call-bind/callBound'); + +var $toString = callBound('Object.prototype.toString'); + +var isStandardArguments = function isArguments(value) { + if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) { + return false; + } + return $toString(value) === '[object Arguments]'; +}; + +var isLegacyArguments = function isArguments(value) { + if (isStandardArguments(value)) { + return true; + } + return value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + $toString(value) !== '[object Array]' && + $toString(value.callee) === '[object Function]'; +}; + +var supportsStandardArguments = (function () { + return isStandardArguments(arguments); +}()); + +isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests + +module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments; + +},{"call-bind/callBound":105,"has-tostringtag/shams":398}],411:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -19876,18 +21993,163 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],313:[function(require,module,exports){ -var toString = {}.toString; +},{}],412:[function(require,module,exports){ +'use strict'; -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; +var fnToStr = Function.prototype.toString; +var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply; +var badArrayLike; +var isCallableMarker; +if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') { + try { + badArrayLike = Object.defineProperty({}, 'length', { + get: function () { + throw isCallableMarker; + } + }); + isCallableMarker = {}; + // eslint-disable-next-line no-throw-literal + reflectApply(function () { throw 42; }, null, badArrayLike); + } catch (_) { + if (_ !== isCallableMarker) { + reflectApply = null; + } + } +} else { + reflectApply = null; +} + +var constructorRegex = /^\s*class\b/; +var isES6ClassFn = function isES6ClassFunction(value) { + try { + var fnStr = fnToStr.call(value); + return constructorRegex.test(fnStr); + } catch (e) { + return false; // not a function + } }; -},{}],314:[function(require,module,exports){ -(function (global){(function (){ -/* - * base64.js - * +var tryFunctionObject = function tryFunctionToStr(value) { + try { + if (isES6ClassFn(value)) { return false; } + fnToStr.call(value); + return true; + } catch (e) { + return false; + } +}; +var toStr = Object.prototype.toString; +var objectClass = '[object Object]'; +var fnClass = '[object Function]'; +var genClass = '[object GeneratorFunction]'; +var ddaClass = '[object HTMLAllCollection]'; // IE 11 +var ddaClass2 = '[object HTML document.all class]'; +var ddaClass3 = '[object HTMLCollection]'; // IE 9-10 +var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag` + +var isIE68 = !(0 in [,]); // eslint-disable-line no-sparse-arrays, comma-spacing + +var isDDA = function isDocumentDotAll() { return false; }; +if (typeof document === 'object') { + // Firefox 3 canonicalizes DDA to undefined when it's not accessed directly + var all = document.all; + if (toStr.call(all) === toStr.call(document.all)) { + isDDA = function isDocumentDotAll(value) { + /* globals document: false */ + // in IE 6-8, typeof document.all is "object" and it's truthy + if ((isIE68 || !value) && (typeof value === 'undefined' || typeof value === 'object')) { + try { + var str = toStr.call(value); + return ( + str === ddaClass + || str === ddaClass2 + || str === ddaClass3 // opera 12.16 + || str === objectClass // IE 6-8 + ) && value('') == null; // eslint-disable-line eqeqeq + } catch (e) { /**/ } + } + return false; + }; + } +} + +module.exports = reflectApply + ? function isCallable(value) { + if (isDDA(value)) { return true; } + if (!value) { return false; } + if (typeof value !== 'function' && typeof value !== 'object') { return false; } + try { + reflectApply(value, null, badArrayLike); + } catch (e) { + if (e !== isCallableMarker) { return false; } + } + return !isES6ClassFn(value) && tryFunctionObject(value); + } + : function isCallable(value) { + if (isDDA(value)) { return true; } + if (!value) { return false; } + if (typeof value !== 'function' && typeof value !== 'object') { return false; } + if (hasToStringTag) { return tryFunctionObject(value); } + if (isES6ClassFn(value)) { return false; } + var strClass = toStr.call(value); + if (strClass !== fnClass && strClass !== genClass && !(/^\[object HTML/).test(strClass)) { return false; } + return tryFunctionObject(value); + }; + +},{}],413:[function(require,module,exports){ +'use strict'; + +var toStr = Object.prototype.toString; +var fnToStr = Function.prototype.toString; +var isFnRegex = /^\s*(?:function)?\*/; +var hasToStringTag = require('has-tostringtag/shams')(); +var getProto = Object.getPrototypeOf; +var getGeneratorFunc = function () { // eslint-disable-line consistent-return + if (!hasToStringTag) { + return false; + } + try { + return Function('return function*() {}')(); + } catch (e) { + } +}; +var GeneratorFunction; + +module.exports = function isGeneratorFunction(fn) { + if (typeof fn !== 'function') { + return false; + } + if (isFnRegex.test(fnToStr.call(fn))) { + return true; + } + if (!hasToStringTag) { + var str = toStr.call(fn); + return str === '[object GeneratorFunction]'; + } + if (!getProto) { + return false; + } + if (typeof GeneratorFunction === 'undefined') { + var generatorFunc = getGeneratorFunc(); + GeneratorFunction = generatorFunc ? getProto(generatorFunc) : false; + } + return getProto(fn) === GeneratorFunction; +}; + +},{"has-tostringtag/shams":398}],414:[function(require,module,exports){ +'use strict'; + +var whichTypedArray = require('which-typed-array'); + +module.exports = function isTypedArray(value) { + return !!whichTypedArray(value); +}; + +},{"which-typed-array":492}],415:[function(require,module,exports){ +(function (global){(function (){ +/* + * base64.js + * * Licensed under the BSD 3-Clause License. * http://opensource.org/licenses/BSD-3-Clause * @@ -20117,7 +22379,383 @@ module.exports = Array.isArray || function (arr) { })); }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],315:[function(require,module,exports){ +},{}],416:[function(require,module,exports){ +var root = require('./_root'); + +/** Built-in value references. */ +var Symbol = root.Symbol; + +module.exports = Symbol; + +},{"./_root":423}],417:[function(require,module,exports){ +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +module.exports = arrayMap; + +},{}],418:[function(require,module,exports){ +var Symbol = require('./_Symbol'), + getRawTag = require('./_getRawTag'), + objectToString = require('./_objectToString'); + +/** `Object#toString` result references. */ +var nullTag = '[object Null]', + undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +module.exports = baseGetTag; + +},{"./_Symbol":416,"./_getRawTag":421,"./_objectToString":422}],419:[function(require,module,exports){ +var Symbol = require('./_Symbol'), + arrayMap = require('./_arrayMap'), + isArray = require('./isArray'), + isSymbol = require('./isSymbol'); + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +module.exports = baseToString; + +},{"./_Symbol":416,"./_arrayMap":417,"./isArray":424,"./isSymbol":428}],420:[function(require,module,exports){ +(function (global){(function (){ +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +module.exports = freeGlobal; + +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],421:[function(require,module,exports){ +var Symbol = require('./_Symbol'); + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag = Symbol ? Symbol.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag), + tag = value[symToStringTag]; + + try { + value[symToStringTag] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag] = tag; + } else { + delete value[symToStringTag]; + } + } + return result; +} + +module.exports = getRawTag; + +},{"./_Symbol":416}],422:[function(require,module,exports){ +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString.call(value); +} + +module.exports = objectToString; + +},{}],423:[function(require,module,exports){ +var freeGlobal = require('./_freeGlobal'); + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +module.exports = root; + +},{"./_freeGlobal":420}],424:[function(require,module,exports){ +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +module.exports = isArray; + +},{}],425:[function(require,module,exports){ +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +module.exports = isObject; + +},{}],426:[function(require,module,exports){ +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +module.exports = isObjectLike; + +},{}],427:[function(require,module,exports){ +var baseGetTag = require('./_baseGetTag'), + isArray = require('./isArray'), + isObjectLike = require('./isObjectLike'); + +/** `Object#toString` result references. */ +var stringTag = '[object String]'; + +/** + * Checks if `value` is classified as a `String` primitive or object. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a string, else `false`. + * @example + * + * _.isString('abc'); + * // => true + * + * _.isString(1); + * // => false + */ +function isString(value) { + return typeof value == 'string' || + (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); +} + +module.exports = isString; + +},{"./_baseGetTag":418,"./isArray":424,"./isObjectLike":426}],428:[function(require,module,exports){ +var baseGetTag = require('./_baseGetTag'), + isObjectLike = require('./isObjectLike'); + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag); +} + +module.exports = isSymbol; + +},{"./_baseGetTag":418,"./isObjectLike":426}],429:[function(require,module,exports){ +var baseToString = require('./_baseToString'); + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString(value) { + return value == null ? '' : baseToString(value); +} + +module.exports = toString; + +},{"./_baseToString":419}],430:[function(require,module,exports){ /*! * merge-descriptors * Copyright(c) 2014 Jonathan Ong @@ -20151,7 +22789,7 @@ var hasOwnProperty = Object.prototype.hasOwnProperty * @public */ -function merge(dest, src, redefine) { +function merge (dest, src, redefine) { if (!dest) { throw new TypeError('argument dest is required') } @@ -20165,9 +22803,9 @@ function merge(dest, src, redefine) { redefine = true } - Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) { + Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName (name) { if (!redefine && hasOwnProperty.call(dest, name)) { - // Skip desriptor + // Skip descriptor return } @@ -20179,35 +22817,29 @@ function merge(dest, src, redefine) { return dest } -},{}],316:[function(require,module,exports){ +},{}],431:[function(require,module,exports){ 'use strict'; + /** * @param typeMap [Object] Map of MIME type -> Array[extensions] * @param ... */ - require("core-js/modules/es.array.map.js"); - require("core-js/modules/es.regexp.exec.js"); - require("core-js/modules/es.string.replace.js"); - require("core-js/modules/es.regexp.constructor.js"); - require("core-js/modules/es.regexp.to-string.js"); - function Mime() { this._types = Object.create(null); this._extensions = Object.create(null); - for (var i = 0; i < arguments.length; i++) { this.define(arguments[i]); } - this.define = this.define.bind(this); this.getType = this.getType.bind(this); this.getExtension = this.getExtension.bind(this); } + /** * Define mimetype -> extension mappings. Each key is a mime-type that maps * to an array of extensions associated with the type. The first extension is @@ -20227,42 +22859,37 @@ function Mime() { * @param map (Object) type definitions * @param force (Boolean) if true, force overriding of existing definitions */ - - Mime.prototype.define = function (typeMap, force) { for (var type in typeMap) { var extensions = typeMap[type].map(function (t) { return t.toLowerCase(); }); type = type.toLowerCase(); - for (var i = 0; i < extensions.length; i++) { - var ext = extensions[i]; // '*' prefix = not the preferred type for this extension. So fixup the - // extension, and skip it. + var ext = extensions[i]; + // '*' prefix = not the preferred type for this extension. So fixup the + // extension, and skip it. if (ext[0] === '*') { continue; } - if (!force && ext in this._types) { throw new Error('Attempt to change mapping for "' + ext + '" extension from "' + this._types[ext] + '" to "' + type + '". Pass `force=true` to allow this, otherwise remove "' + ext + '" from the list of extensions for "' + type + '".'); } - this._types[ext] = type; - } // Use first extension as default - + } + // Use first extension as default if (force || !this._extensions[type]) { var _ext = extensions[0]; this._extensions[type] = _ext[0] !== '*' ? _ext : _ext.substr(1); } } }; + /** * Lookup a mime type based on extension */ - - Mime.prototype.getType = function (path) { path = String(path); var last = path.replace(/^.*[/\\]/, '').toLowerCase(); @@ -20271,26 +22898,23 @@ Mime.prototype.getType = function (path) { var hasDot = ext.length < last.length - 1; return (hasDot || !hasPath) && this._types[ext] || null; }; + /** * Return file extension associated with a mime type */ - - Mime.prototype.getExtension = function (type) { type = /^\s*([^;\s]*)/.test(type) && RegExp.$1; return type && this._extensions[type.toLowerCase()] || null; }; - module.exports = Mime; -},{"core-js/modules/es.array.map.js":249,"core-js/modules/es.regexp.constructor.js":260,"core-js/modules/es.regexp.exec.js":261,"core-js/modules/es.regexp.to-string.js":262,"core-js/modules/es.string.replace.js":266}],317:[function(require,module,exports){ +},{"core-js/modules/es.array.map.js":318,"core-js/modules/es.regexp.constructor.js":339,"core-js/modules/es.regexp.exec.js":340,"core-js/modules/es.regexp.to-string.js":341,"core-js/modules/es.string.replace.js":347}],432:[function(require,module,exports){ 'use strict'; var Mime = require('./Mime'); - module.exports = new Mime(require('./types/standard')); -},{"./Mime":316,"./types/standard":318}],318:[function(require,module,exports){ +},{"./Mime":431,"./types/standard":433}],433:[function(require,module,exports){ "use strict"; module.exports = { @@ -20318,11 +22942,12 @@ module.exports = { "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], - "application/ecmascript": ["ecma", "es"], + "application/ecmascript": ["es", "ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], + "application/express": ["exp"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], @@ -20363,8 +22988,6 @@ module.exports = { "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["mp4s", "m4p"], - "application/mrb-consumer+xml": ["*xdf"], - "application/mrb-publish+xml": ["*xdf"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], @@ -20378,7 +23001,7 @@ module.exports = { "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], - "application/patch-ops-error+xml": ["*xer"], + "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-signature": ["asc", "sig"], @@ -20437,6 +23060,7 @@ module.exports = { "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], + "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], @@ -20452,7 +23076,6 @@ module.exports = { "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], - "application/xcap-error+xml": ["xer"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xhtml+xml": ["xhtml", "xht"], @@ -20542,6 +23165,9 @@ module.exports = { "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], + "model/step+xml": ["stpx"], + "model/step+zip": ["stpz"], + "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], @@ -20595,7 +23221,7 @@ module.exports = { "video/webm": ["webm"] }; -},{}],319:[function(require,module,exports){ +},{}],434:[function(require,module,exports){ /** * Helpers. */ @@ -20621,7 +23247,7 @@ var y = d * 365.25; * @api public */ -module.exports = function (val, options) { +module.exports = function(val, options) { options = options || {}; var type = typeof val; if (type === 'string' && val.length > 0) { @@ -20759,411 +23385,1356 @@ function plural(ms, msAbs, n, name) { return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } -},{}],320:[function(require,module,exports){ -/* -object-assign -(c) Sindre Sorhus -@license MIT -*/ +},{}],435:[function(require,module,exports){ +(function (global){(function (){ +var hasMap = typeof Map === 'function' && Map.prototype; +var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null; +var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null; +var mapForEach = hasMap && Map.prototype.forEach; +var hasSet = typeof Set === 'function' && Set.prototype; +var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null; +var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null; +var setForEach = hasSet && Set.prototype.forEach; +var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype; +var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null; +var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype; +var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null; +var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype; +var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null; +var booleanValueOf = Boolean.prototype.valueOf; +var objectToString = Object.prototype.toString; +var functionToString = Function.prototype.toString; +var $match = String.prototype.match; +var $slice = String.prototype.slice; +var $replace = String.prototype.replace; +var $toUpperCase = String.prototype.toUpperCase; +var $toLowerCase = String.prototype.toLowerCase; +var $test = RegExp.prototype.test; +var $concat = Array.prototype.concat; +var $join = Array.prototype.join; +var $arrSlice = Array.prototype.slice; +var $floor = Math.floor; +var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null; +var gOPS = Object.getOwnPropertySymbols; +var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null; +var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object'; +// ie, `has-tostringtag/shams +var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol') + ? Symbol.toStringTag + : null; +var isEnumerable = Object.prototype.propertyIsEnumerable; + +var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ( + [].__proto__ === Array.prototype // eslint-disable-line no-proto + ? function (O) { + return O.__proto__; // eslint-disable-line no-proto + } + : null +); -'use strict'; -/* eslint-disable no-unused-vars */ -var getOwnPropertySymbols = Object.getOwnPropertySymbols; -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; +function addNumericSeparator(num, str) { + if ( + num === Infinity + || num === -Infinity + || num !== num + || (num && num > -1000 && num < 1000) + || $test.call(/e/, str) + ) { + return str; + } + var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g; + if (typeof num === 'number') { + var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num) + if (int !== num) { + var intStr = String(int); + var dec = $slice.call(str, intStr.length + 1); + return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, ''); + } + } + return $replace.call(str, sepRegex, '$&_'); +} -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } +var utilInspect = require('./util.inspect'); +var inspectCustom = utilInspect.custom; +var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null; - return Object(val); -} +module.exports = function inspect_(obj, options, depth, seen) { + var opts = options || {}; -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } + if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) { + throw new TypeError('option "quoteStyle" must be "single" or "double"'); + } + if ( + has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number' + ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity + : opts.maxStringLength !== null + ) + ) { + throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`'); + } + var customInspect = has(opts, 'customInspect') ? opts.customInspect : true; + if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') { + throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`'); + } - // Detect buggy property enumeration order in older V8 versions. + if ( + has(opts, 'indent') + && opts.indent !== null + && opts.indent !== '\t' + && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0) + ) { + throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`'); + } + if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') { + throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`'); + } + var numericSeparator = opts.numericSeparator; - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } + if (typeof obj === 'undefined') { + return 'undefined'; + } + if (obj === null) { + return 'null'; + } + if (typeof obj === 'boolean') { + return obj ? 'true' : 'false'; + } - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } + if (typeof obj === 'string') { + return inspectString(obj, opts); + } + if (typeof obj === 'number') { + if (obj === 0) { + return Infinity / obj > 0 ? '0' : '-0'; + } + var str = String(obj); + return numericSeparator ? addNumericSeparator(obj, str) : str; + } + if (typeof obj === 'bigint') { + var bigIntStr = String(obj) + 'n'; + return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr; + } - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } + var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth; + if (typeof depth === 'undefined') { depth = 0; } + if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') { + return isArray(obj) ? '[Array]' : '[Object]'; + } - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } -} + var indent = getIndent(opts, depth); -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } + if (typeof seen === 'undefined') { + seen = []; + } else if (indexOf(seen, obj) >= 0) { + return '[Circular]'; + } - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } + function inspect(value, from, noIndent) { + if (from) { + seen = $arrSlice.call(seen); + seen.push(from); + } + if (noIndent) { + var newOpts = { + depth: opts.depth + }; + if (has(opts, 'quoteStyle')) { + newOpts.quoteStyle = opts.quoteStyle; + } + return inspect_(value, newOpts, depth + 1, seen); + } + return inspect_(value, opts, depth + 1, seen); + } - return to; + if (typeof obj === 'function' && !isRegExp(obj)) { // in older engines, regexes are callable + var name = nameOf(obj); + var keys = arrObjKeys(obj, inspect); + return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : ''); + } + if (isSymbol(obj)) { + var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj); + return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString; + } + if (isElement(obj)) { + var s = '<' + $toLowerCase.call(String(obj.nodeName)); + var attrs = obj.attributes || []; + for (var i = 0; i < attrs.length; i++) { + s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts); + } + s += '>'; + if (obj.childNodes && obj.childNodes.length) { s += '...'; } + s += ''; + return s; + } + if (isArray(obj)) { + if (obj.length === 0) { return '[]'; } + var xs = arrObjKeys(obj, inspect); + if (indent && !singleLineValues(xs)) { + return '[' + indentedJoin(xs, indent) + ']'; + } + return '[ ' + $join.call(xs, ', ') + ' ]'; + } + if (isError(obj)) { + var parts = arrObjKeys(obj, inspect); + if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) { + return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }'; + } + if (parts.length === 0) { return '[' + String(obj) + ']'; } + return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }'; + } + if (typeof obj === 'object' && customInspect) { + if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) { + return utilInspect(obj, { depth: maxDepth - depth }); + } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') { + return obj.inspect(); + } + } + if (isMap(obj)) { + var mapParts = []; + if (mapForEach) { + mapForEach.call(obj, function (value, key) { + mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj)); + }); + } + return collectionOf('Map', mapSize.call(obj), mapParts, indent); + } + if (isSet(obj)) { + var setParts = []; + if (setForEach) { + setForEach.call(obj, function (value) { + setParts.push(inspect(value, obj)); + }); + } + return collectionOf('Set', setSize.call(obj), setParts, indent); + } + if (isWeakMap(obj)) { + return weakCollectionOf('WeakMap'); + } + if (isWeakSet(obj)) { + return weakCollectionOf('WeakSet'); + } + if (isWeakRef(obj)) { + return weakCollectionOf('WeakRef'); + } + if (isNumber(obj)) { + return markBoxed(inspect(Number(obj))); + } + if (isBigInt(obj)) { + return markBoxed(inspect(bigIntValueOf.call(obj))); + } + if (isBoolean(obj)) { + return markBoxed(booleanValueOf.call(obj)); + } + if (isString(obj)) { + return markBoxed(inspect(String(obj))); + } + // note: in IE 8, sometimes `global !== window` but both are the prototypes of each other + /* eslint-env browser */ + if (typeof window !== 'undefined' && obj === window) { + return '{ [object Window] }'; + } + if (obj === global) { + return '{ [object globalThis] }'; + } + if (!isDate(obj) && !isRegExp(obj)) { + var ys = arrObjKeys(obj, inspect); + var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object; + var protoTag = obj instanceof Object ? '' : 'null prototype'; + var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : ''; + var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : ''; + var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : ''); + if (ys.length === 0) { return tag + '{}'; } + if (indent) { + return tag + '{' + indentedJoin(ys, indent) + '}'; + } + return tag + '{ ' + $join.call(ys, ', ') + ' }'; + } + return String(obj); }; -},{}],321:[function(require,module,exports){ -(function (process){(function (){ -// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1, -// backported and transplited with Babel, with backwards-compat fixes +function wrapQuotes(s, defaultStyle, opts) { + var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'"; + return quoteChar + s + quoteChar; +} -// 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. +function quote(s) { + return $replace.call(String(s), /"/g, '"'); +} -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length - 1; i >= 0; i--) { - var last = parts[i]; - if (last === '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; +function isArray(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); } +function isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); } +function isRegExp(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); } +function isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); } +function isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); } +function isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); } +function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); } + +// Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives +function isSymbol(obj) { + if (hasShammedSymbols) { + return obj && typeof obj === 'object' && obj instanceof Symbol; } - } + if (typeof obj === 'symbol') { + return true; + } + if (!obj || typeof obj !== 'object' || !symToString) { + return false; + } + try { + symToString.call(obj); + return true; + } catch (e) {} + return false; +} - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); +function isBigInt(obj) { + if (!obj || typeof obj !== 'object' || !bigIntValueOf) { + return false; } - } + try { + bigIntValueOf.call(obj); + return true; + } catch (e) {} + return false; +} - return parts; +var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; }; +function has(obj, key) { + return hasOwn.call(obj, key); } -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { - var resolvedPath = '', - resolvedAbsolute = false; +function toStr(obj) { + return objectToString.call(obj); +} - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) ? arguments[i] : process.cwd(); +function nameOf(f) { + if (f.name) { return f.name; } + var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/); + if (m) { return m[1]; } + return null; +} - // Skip empty and invalid entries - if (typeof path !== 'string') { - throw new TypeError('Arguments to path.resolve must be strings'); - } else if (!path) { - continue; +function indexOf(xs, x) { + if (xs.indexOf) { return xs.indexOf(x); } + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) { return i; } } + return -1; +} - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; - } +function isMap(x) { + if (!mapSize || !x || typeof x !== 'object') { + return false; + } + try { + mapSize.call(x); + try { + setSize.call(x); + } catch (s) { + return true; + } + return x instanceof Map; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +} + +function isWeakMap(x) { + if (!weakMapHas || !x || typeof x !== 'object') { + return false; + } + try { + weakMapHas.call(x, weakMapHas); + try { + weakSetHas.call(x, weakSetHas); + } catch (s) { + return true; + } + return x instanceof WeakMap; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +} - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) +function isWeakRef(x) { + if (!weakRefDeref || !x || typeof x !== 'object') { + return false; + } + try { + weakRefDeref.call(x); + return true; + } catch (e) {} + return false; +} - // Normalize the path - resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); +function isSet(x) { + if (!setSize || !x || typeof x !== 'object') { + return false; + } + try { + setSize.call(x); + try { + mapSize.call(x); + } catch (m) { + return true; + } + return x instanceof Set; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +} - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; +function isWeakSet(x) { + if (!weakSetHas || !x || typeof x !== 'object') { + return false; + } + try { + weakSetHas.call(x, weakSetHas); + try { + weakMapHas.call(x, weakMapHas); + } catch (s) { + return true; + } + return x instanceof WeakSet; // core-js workaround, pre-v2.5.0 + } catch (e) {} + return false; +} -// path.normalize(path) -// posix version -exports.normalize = function(path) { - var isAbsolute = exports.isAbsolute(path), - trailingSlash = substr(path, -1) === '/'; +function isElement(x) { + if (!x || typeof x !== 'object') { return false; } + if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) { + return true; + } + return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function'; +} - // Normalize the path - path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); +function inspectString(str, opts) { + if (str.length > opts.maxStringLength) { + var remaining = str.length - opts.maxStringLength; + var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : ''); + return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer; + } + // eslint-disable-next-line no-control-regex + var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte); + return wrapQuotes(s, 'single', opts); +} - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } +function lowbyte(c) { + var n = c.charCodeAt(0); + var x = { + 8: 'b', + 9: 't', + 10: 'n', + 12: 'f', + 13: 'r' + }[n]; + if (x) { return '\\' + x; } + return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16)); +} - return (isAbsolute ? '/' : '') + path; -}; +function markBoxed(str) { + return 'Object(' + str + ')'; +} -// posix version -exports.isAbsolute = function(path) { - return path.charAt(0) === '/'; -}; +function weakCollectionOf(type) { + return type + ' { ? }'; +} + +function collectionOf(type, size, entries, indent) { + var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', '); + return type + ' (' + size + ') {' + joinedEntries + '}'; +} -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - if (typeof p !== 'string') { - throw new TypeError('Arguments to path.join must be strings'); +function singleLineValues(xs) { + for (var i = 0; i < xs.length; i++) { + if (indexOf(xs[i], '\n') >= 0) { + return false; + } } - return p; - }).join('/')); -}; + return true; +} +function getIndent(opts, depth) { + var baseIndent; + if (opts.indent === '\t') { + baseIndent = '\t'; + } else if (typeof opts.indent === 'number' && opts.indent > 0) { + baseIndent = $join.call(Array(opts.indent + 1), ' '); + } else { + return null; + } + return { + base: baseIndent, + prev: $join.call(Array(depth + 1), baseIndent) + }; +} -// path.relative(from, to) -// posix version -exports.relative = function(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); +function indentedJoin(xs, indent) { + if (xs.length === 0) { return ''; } + var lineJoiner = '\n' + indent.prev + indent.base; + return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev; +} - function trim(arr) { - var start = 0; - for (; start < arr.length; start++) { - if (arr[start] !== '') break; +function arrObjKeys(obj, inspect) { + var isArr = isArray(obj); + var xs = []; + if (isArr) { + xs.length = obj.length; + for (var i = 0; i < obj.length; i++) { + xs[i] = has(obj, i) ? inspect(obj[i], obj) : ''; + } + } + var syms = typeof gOPS === 'function' ? gOPS(obj) : []; + var symMap; + if (hasShammedSymbols) { + symMap = {}; + for (var k = 0; k < syms.length; k++) { + symMap['$' + syms[k]] = syms[k]; + } } - var end = arr.length - 1; - for (; end >= 0; end--) { - if (arr[end] !== '') break; + for (var key in obj) { // eslint-disable-line no-restricted-syntax + if (!has(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue + if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue + if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) { + // this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section + continue; // eslint-disable-line no-restricted-syntax, no-continue + } else if ($test.call(/[^\w$]/, key)) { + xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj)); + } else { + xs.push(key + ': ' + inspect(obj[key], obj)); + } + } + if (typeof gOPS === 'function') { + for (var j = 0; j < syms.length; j++) { + if (isEnumerable.call(obj, syms[j])) { + xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj)); + } + } } + return xs; +} - if (start > end) return []; - return arr.slice(start, end - start + 1); - } +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./util.inspect":102}],436:[function(require,module,exports){ +'use strict'; + +var keysShim; +if (!Object.keys) { + // modified from https://github.com/es-shims/es5-shim + var has = Object.prototype.hasOwnProperty; + var toStr = Object.prototype.toString; + var isArgs = require('./isArguments'); // eslint-disable-line global-require + var isEnumerable = Object.prototype.propertyIsEnumerable; + var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); + var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); + var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ]; + var equalsConstructorPrototype = function (o) { + var ctor = o.constructor; + return ctor && ctor.prototype === o; + }; + var excludedKeys = { + $applicationCache: true, + $console: true, + $external: true, + $frame: true, + $frameElement: true, + $frames: true, + $innerHeight: true, + $innerWidth: true, + $onmozfullscreenchange: true, + $onmozfullscreenerror: true, + $outerHeight: true, + $outerWidth: true, + $pageXOffset: true, + $pageYOffset: true, + $parent: true, + $scrollLeft: true, + $scrollTop: true, + $scrollX: true, + $scrollY: true, + $self: true, + $webkitIndexedDB: true, + $webkitStorageInfo: true, + $window: true + }; + var hasAutomationEqualityBug = (function () { + /* global window */ + if (typeof window === 'undefined') { return false; } + for (var k in window) { + try { + if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { + try { + equalsConstructorPrototype(window[k]); + } catch (e) { + return true; + } + } + } catch (e) { + return true; + } + } + return false; + }()); + var equalsConstructorPrototypeIfNotBuggy = function (o) { + /* global window */ + if (typeof window === 'undefined' || !hasAutomationEqualityBug) { + return equalsConstructorPrototype(o); + } + try { + return equalsConstructorPrototype(o); + } catch (e) { + return false; + } + }; - var fromParts = trim(from.split('/')); - var toParts = trim(to.split('/')); + keysShim = function keys(object) { + var isObject = object !== null && typeof object === 'object'; + var isFunction = toStr.call(object) === '[object Function]'; + var isArguments = isArgs(object); + var isString = isObject && toStr.call(object) === '[object String]'; + var theKeys = []; - var length = Math.min(fromParts.length, toParts.length); - var samePartsLength = length; - for (var i = 0; i < length; i++) { - if (fromParts[i] !== toParts[i]) { - samePartsLength = i; - break; - } - } + if (!isObject && !isFunction && !isArguments) { + throw new TypeError('Object.keys called on a non-object'); + } - var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { - outputParts.push('..'); - } + var skipProto = hasProtoEnumBug && isFunction; + if (isString && object.length > 0 && !has.call(object, 0)) { + for (var i = 0; i < object.length; ++i) { + theKeys.push(String(i)); + } + } - outputParts = outputParts.concat(toParts.slice(samePartsLength)); + if (isArguments && object.length > 0) { + for (var j = 0; j < object.length; ++j) { + theKeys.push(String(j)); + } + } else { + for (var name in object) { + if (!(skipProto && name === 'prototype') && has.call(object, name)) { + theKeys.push(String(name)); + } + } + } - return outputParts.join('/'); -}; + if (hasDontEnumBug) { + var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); -exports.sep = '/'; -exports.delimiter = ':'; + for (var k = 0; k < dontEnums.length; ++k) { + if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { + theKeys.push(dontEnums[k]); + } + } + } + return theKeys; + }; +} +module.exports = keysShim; -exports.dirname = function (path) { - if (typeof path !== 'string') path = path + ''; - if (path.length === 0) return '.'; - var code = path.charCodeAt(0); - var hasRoot = code === 47 /*/*/; - var end = -1; - var matchedSlash = true; - for (var i = path.length - 1; i >= 1; --i) { - code = path.charCodeAt(i); - if (code === 47 /*/*/) { - if (!matchedSlash) { - end = i; - break; - } - } else { - // We saw the first non-path separator - matchedSlash = false; - } - } +},{"./isArguments":438}],437:[function(require,module,exports){ +'use strict'; - if (end === -1) return hasRoot ? '/' : '.'; - if (hasRoot && end === 1) { - // return '//'; - // Backwards-compat fix: - return '/'; - } - return path.slice(0, end); +var slice = Array.prototype.slice; +var isArgs = require('./isArguments'); + +var origKeys = Object.keys; +var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation'); + +var originalKeys = Object.keys; + +keysShim.shim = function shimObjectKeys() { + if (Object.keys) { + var keysWorksWithArguments = (function () { + // Safari 5.0 bug + var args = Object.keys(arguments); + return args && args.length === arguments.length; + }(1, 2)); + if (!keysWorksWithArguments) { + Object.keys = function keys(object) { // eslint-disable-line func-name-matching + if (isArgs(object)) { + return originalKeys(slice.call(object)); + } + return originalKeys(object); + }; + } + } else { + Object.keys = keysShim; + } + return Object.keys || keysShim; }; -function basename(path) { - if (typeof path !== 'string') path = path + ''; +module.exports = keysShim; - var start = 0; - var end = -1; - var matchedSlash = true; - var i; +},{"./implementation":436,"./isArguments":438}],438:[function(require,module,exports){ +'use strict'; - for (i = path.length - 1; i >= 0; --i) { - if (path.charCodeAt(i) === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - start = i + 1; - break; - } - } else if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // path component - matchedSlash = false; - end = i + 1; - } - } +var toStr = Object.prototype.toString; + +module.exports = function isArguments(value) { + var str = toStr.call(value); + var isArgs = str === '[object Arguments]'; + if (!isArgs) { + isArgs = str !== '[object Array]' && + value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + toStr.call(value.callee) === '[object Function]'; + } + return isArgs; +}; - if (end === -1) return ''; - return path.slice(start, end); -} +},{}],439:[function(require,module,exports){ +'use strict'; -// Uses a mixed approach for backwards-compatibility, as ext behavior changed -// in new Node.js versions, so only basename() above is backported here -exports.basename = function (path, ext) { - var f = basename(path); - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; +// modified from https://github.com/es-shims/es6-shim +var objectKeys = require('object-keys'); +var hasSymbols = require('has-symbols/shams')(); +var callBound = require('call-bind/callBound'); +var toObject = Object; +var $push = callBound('Array.prototype.push'); +var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable'); +var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null; + +// eslint-disable-next-line no-unused-vars +module.exports = function assign(target, source1) { + if (target == null) { throw new TypeError('target must be an object'); } + var to = toObject(target); // step 1 + if (arguments.length === 1) { + return to; // step 2 + } + for (var s = 1; s < arguments.length; ++s) { + var from = toObject(arguments[s]); // step 3.a.i + + // step 3.a.ii: + var keys = objectKeys(from); + var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols); + if (getSymbols) { + var syms = getSymbols(from); + for (var j = 0; j < syms.length; ++j) { + var key = syms[j]; + if ($propIsEnumerable(from, key)) { + $push(keys, key); + } + } + } -exports.extname = function (path) { - if (typeof path !== 'string') path = path + ''; - var startDot = -1; - var startPart = 0; - var end = -1; - var matchedSlash = true; - // Track the state of characters (if any) we see before our first dot and - // after any path separator we find - var preDotState = 0; - for (var i = path.length - 1; i >= 0; --i) { - var code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // extension - matchedSlash = false; - end = i + 1; - } - if (code === 46 /*.*/) { - // If this is our first dot, mark it as the start of our extension - if (startDot === -1) - startDot = i; - else if (preDotState !== 1) - preDotState = 1; - } else if (startDot !== -1) { - // We saw a non-dot and non-path separator before our dot, so we should - // have a good chance at having a non-empty extension - preDotState = -1; - } - } - - if (startDot === -1 || end === -1 || - // We saw a non-dot character immediately before the dot - preDotState === 0 || - // The (right-most) trimmed path component is exactly '..' - preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - return ''; - } - return path.slice(startDot, end); + // step 3.a.iii: + for (var i = 0; i < keys.length; ++i) { + var nextKey = keys[i]; + if ($propIsEnumerable(from, nextKey)) { // step 3.a.iii.2 + var propValue = from[nextKey]; // step 3.a.iii.2.a + to[nextKey] = propValue; // step 3.a.iii.2.b + } + } + } + + return to; // step 4 }; -function filter (xs, f) { - if (xs.filter) return xs.filter(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - if (f(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} +},{"call-bind/callBound":105,"has-symbols/shams":397,"object-keys":437}],440:[function(require,module,exports){ +'use strict'; -// String.prototype.substr - negative index don't work in IE8 -var substr = 'ab'.substr(-1) === 'b' - ? function (str, start, len) { return str.substr(start, len) } - : function (str, start, len) { - if (start < 0) start = str.length + start; - return str.substr(start, len); - } -; +var implementation = require('./implementation'); -}).call(this)}).call(this,require('_process')) -},{"_process":399}],322:[function(require,module,exports){ -(function (global){(function (){ -/*! - * Platform.js v1.3.6 - * Copyright 2014-2020 Benjamin Tan - * Copyright 2011-2013 John-David Dalton - * Available under MIT license +var lacksProperEnumerationOrder = function () { + if (!Object.assign) { + return false; + } + /* + * v8, specifically in node 4.x, has a bug with incorrect property enumeration order + * note: this does not detect the bug unless there's 20 characters + */ + var str = 'abcdefghijklmnopqrst'; + var letters = str.split(''); + var map = {}; + for (var i = 0; i < letters.length; ++i) { + map[letters[i]] = letters[i]; + } + var obj = Object.assign({}, map); + var actual = ''; + for (var k in obj) { + actual += k; + } + return str !== actual; +}; + +var assignHasPendingExceptions = function () { + if (!Object.assign || !Object.preventExtensions) { + return false; + } + /* + * Firefox 37 still has "pending exception" logic in its Object.assign implementation, + * which is 72% slower than our shim, and Firefox 40's native implementation. + */ + var thrower = Object.preventExtensions({ 1: 2 }); + try { + Object.assign(thrower, 'xy'); + } catch (e) { + return thrower[1] === 'y'; + } + return false; +}; + +module.exports = function getPolyfill() { + if (!Object.assign) { + return implementation; + } + if (lacksProperEnumerationOrder()) { + return implementation; + } + if (assignHasPendingExceptions()) { + return implementation; + } + return Object.assign; +}; + +},{"./implementation":439}],441:[function(require,module,exports){ +(function (process){(function (){ +// 'path' module extracted from Node.js v8.11.1 (only the posix part) +// transplited with Babel + +// 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'; + +function assertPath(path) { + if (typeof path !== 'string') { + throw new TypeError('Path must be a string. Received ' + JSON.stringify(path)); + } +} + +// Resolves . and .. elements in a path with directory names +function normalizeStringPosix(path, allowAboveRoot) { + var res = ''; + var lastSegmentLength = 0; + var lastSlash = -1; + var dots = 0; + var code; + for (var i = 0; i <= path.length; ++i) { + if (i < path.length) + code = path.charCodeAt(i); + else if (code === 47 /*/*/) + break; + else + code = 47 /*/*/; + if (code === 47 /*/*/) { + if (lastSlash === i - 1 || dots === 1) { + // NOOP + } else if (lastSlash !== i - 1 && dots === 2) { + if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) { + if (res.length > 2) { + var lastSlashIndex = res.lastIndexOf('/'); + if (lastSlashIndex !== res.length - 1) { + if (lastSlashIndex === -1) { + res = ''; + lastSegmentLength = 0; + } else { + res = res.slice(0, lastSlashIndex); + lastSegmentLength = res.length - 1 - res.lastIndexOf('/'); + } + lastSlash = i; + dots = 0; + continue; + } + } else if (res.length === 2 || res.length === 1) { + res = ''; + lastSegmentLength = 0; + lastSlash = i; + dots = 0; + continue; + } + } + if (allowAboveRoot) { + if (res.length > 0) + res += '/..'; + else + res = '..'; + lastSegmentLength = 2; + } + } else { + if (res.length > 0) + res += '/' + path.slice(lastSlash + 1, i); + else + res = path.slice(lastSlash + 1, i); + lastSegmentLength = i - lastSlash - 1; + } + lastSlash = i; + dots = 0; + } else if (code === 46 /*.*/ && dots !== -1) { + ++dots; + } else { + dots = -1; + } + } + return res; +} + +function _format(sep, pathObject) { + var dir = pathObject.dir || pathObject.root; + var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || ''); + if (!dir) { + return base; + } + if (dir === pathObject.root) { + return dir + base; + } + return dir + sep + base; +} + +var posix = { + // path.resolve([from ...], to) + resolve: function resolve() { + var resolvedPath = ''; + var resolvedAbsolute = false; + var cwd; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path; + if (i >= 0) + path = arguments[i]; + else { + if (cwd === undefined) + cwd = process.cwd(); + path = cwd; + } + + assertPath(path); + + // Skip empty entries + if (path.length === 0) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); + + if (resolvedAbsolute) { + if (resolvedPath.length > 0) + return '/' + resolvedPath; + else + return '/'; + } else if (resolvedPath.length > 0) { + return resolvedPath; + } else { + return '.'; + } + }, + + normalize: function normalize(path) { + assertPath(path); + + if (path.length === 0) return '.'; + + var isAbsolute = path.charCodeAt(0) === 47 /*/*/; + var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/; + + // Normalize the path + path = normalizeStringPosix(path, !isAbsolute); + + if (path.length === 0 && !isAbsolute) path = '.'; + if (path.length > 0 && trailingSeparator) path += '/'; + + if (isAbsolute) return '/' + path; + return path; + }, + + isAbsolute: function isAbsolute(path) { + assertPath(path); + return path.length > 0 && path.charCodeAt(0) === 47 /*/*/; + }, + + join: function join() { + if (arguments.length === 0) + return '.'; + var joined; + for (var i = 0; i < arguments.length; ++i) { + var arg = arguments[i]; + assertPath(arg); + if (arg.length > 0) { + if (joined === undefined) + joined = arg; + else + joined += '/' + arg; + } + } + if (joined === undefined) + return '.'; + return posix.normalize(joined); + }, + + relative: function relative(from, to) { + assertPath(from); + assertPath(to); + + if (from === to) return ''; + + from = posix.resolve(from); + to = posix.resolve(to); + + if (from === to) return ''; + + // Trim any leading backslashes + var fromStart = 1; + for (; fromStart < from.length; ++fromStart) { + if (from.charCodeAt(fromStart) !== 47 /*/*/) + break; + } + var fromEnd = from.length; + var fromLen = fromEnd - fromStart; + + // Trim any leading backslashes + var toStart = 1; + for (; toStart < to.length; ++toStart) { + if (to.charCodeAt(toStart) !== 47 /*/*/) + break; + } + var toEnd = to.length; + var toLen = toEnd - toStart; + + // Compare paths to find the longest common path from root + var length = fromLen < toLen ? fromLen : toLen; + var lastCommonSep = -1; + var i = 0; + for (; i <= length; ++i) { + if (i === length) { + if (toLen > length) { + if (to.charCodeAt(toStart + i) === 47 /*/*/) { + // We get here if `from` is the exact base path for `to`. + // For example: from='/foo/bar'; to='/foo/bar/baz' + return to.slice(toStart + i + 1); + } else if (i === 0) { + // We get here if `from` is the root + // For example: from='/'; to='/foo' + return to.slice(toStart + i); + } + } else if (fromLen > length) { + if (from.charCodeAt(fromStart + i) === 47 /*/*/) { + // We get here if `to` is the exact base path for `from`. + // For example: from='/foo/bar/baz'; to='/foo/bar' + lastCommonSep = i; + } else if (i === 0) { + // We get here if `to` is the root. + // For example: from='/foo'; to='/' + lastCommonSep = 0; + } + } + break; + } + var fromCode = from.charCodeAt(fromStart + i); + var toCode = to.charCodeAt(toStart + i); + if (fromCode !== toCode) + break; + else if (fromCode === 47 /*/*/) + lastCommonSep = i; + } + + var out = ''; + // Generate the relative path based on the path difference between `to` + // and `from` + for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) { + if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) { + if (out.length === 0) + out += '..'; + else + out += '/..'; + } + } + + // Lastly, append the rest of the destination (`to`) path that comes after + // the common path parts + if (out.length > 0) + return out + to.slice(toStart + lastCommonSep); + else { + toStart += lastCommonSep; + if (to.charCodeAt(toStart) === 47 /*/*/) + ++toStart; + return to.slice(toStart); + } + }, + + _makeLong: function _makeLong(path) { + return path; + }, + + dirname: function dirname(path) { + assertPath(path); + if (path.length === 0) return '.'; + var code = path.charCodeAt(0); + var hasRoot = code === 47 /*/*/; + var end = -1; + var matchedSlash = true; + for (var i = path.length - 1; i >= 1; --i) { + code = path.charCodeAt(i); + if (code === 47 /*/*/) { + if (!matchedSlash) { + end = i; + break; + } + } else { + // We saw the first non-path separator + matchedSlash = false; + } + } + + if (end === -1) return hasRoot ? '/' : '.'; + if (hasRoot && end === 1) return '//'; + return path.slice(0, end); + }, + + basename: function basename(path, ext) { + if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string'); + assertPath(path); + + var start = 0; + var end = -1; + var matchedSlash = true; + var i; + + if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { + if (ext.length === path.length && ext === path) return ''; + var extIdx = ext.length - 1; + var firstNonSlashEnd = -1; + for (i = path.length - 1; i >= 0; --i) { + var code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + start = i + 1; + break; + } + } else { + if (firstNonSlashEnd === -1) { + // We saw the first non-path separator, remember this index in case + // we need it if the extension ends up not matching + matchedSlash = false; + firstNonSlashEnd = i + 1; + } + if (extIdx >= 0) { + // Try to match the explicit extension + if (code === ext.charCodeAt(extIdx)) { + if (--extIdx === -1) { + // We matched the extension, so mark this as the end of our path + // component + end = i; + } + } else { + // Extension does not match, so our result is the entire path + // component + extIdx = -1; + end = firstNonSlashEnd; + } + } + } + } + + if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length; + return path.slice(start, end); + } else { + for (i = path.length - 1; i >= 0; --i) { + if (path.charCodeAt(i) === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + start = i + 1; + break; + } + } else if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // path component + matchedSlash = false; + end = i + 1; + } + } + + if (end === -1) return ''; + return path.slice(start, end); + } + }, + + extname: function extname(path) { + assertPath(path); + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + // Track the state of characters (if any) we see before our first dot and + // after any path separator we find + var preDotState = 0; + for (var i = path.length - 1; i >= 0; --i) { + var code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // extension + matchedSlash = false; + end = i + 1; + } + if (code === 46 /*.*/) { + // If this is our first dot, mark it as the start of our extension + if (startDot === -1) + startDot = i; + else if (preDotState !== 1) + preDotState = 1; + } else if (startDot !== -1) { + // We saw a non-dot and non-path separator before our dot, so we should + // have a good chance at having a non-empty extension + preDotState = -1; + } + } + + if (startDot === -1 || end === -1 || + // We saw a non-dot character immediately before the dot + preDotState === 0 || + // The (right-most) trimmed path component is exactly '..' + preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + return ''; + } + return path.slice(startDot, end); + }, + + format: function format(pathObject) { + if (pathObject === null || typeof pathObject !== 'object') { + throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return _format('/', pathObject); + }, + + parse: function parse(path) { + assertPath(path); + + var ret = { root: '', dir: '', base: '', ext: '', name: '' }; + if (path.length === 0) return ret; + var code = path.charCodeAt(0); + var isAbsolute = code === 47 /*/*/; + var start; + if (isAbsolute) { + ret.root = '/'; + start = 1; + } else { + start = 0; + } + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + var i = path.length - 1; + + // Track the state of characters (if any) we see before our first dot and + // after any path separator we find + var preDotState = 0; + + // Get non-dir info + for (; i >= start; --i) { + code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // extension + matchedSlash = false; + end = i + 1; + } + if (code === 46 /*.*/) { + // If this is our first dot, mark it as the start of our extension + if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1; + } else if (startDot !== -1) { + // We saw a non-dot and non-path separator before our dot, so we should + // have a good chance at having a non-empty extension + preDotState = -1; + } + } + + if (startDot === -1 || end === -1 || + // We saw a non-dot character immediately before the dot + preDotState === 0 || + // The (right-most) trimmed path component is exactly '..' + preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + if (end !== -1) { + if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end); + } + } else { + if (startPart === 0 && isAbsolute) { + ret.name = path.slice(1, startDot); + ret.base = path.slice(1, end); + } else { + ret.name = path.slice(startPart, startDot); + ret.base = path.slice(startPart, end); + } + ret.ext = path.slice(startDot, end); + } + + if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/'; + + return ret; + }, + + sep: '/', + delimiter: ':', + win32: null, + posix: null +}; + +posix.posix = posix; + +module.exports = posix; + +}).call(this)}).call(this,require('_process')) +},{"_process":540}],442:[function(require,module,exports){ +(function (global){(function (){ +/*! + * Platform.js v1.3.6 + * Copyright 2014-2020 Benjamin Tan + * Copyright 2011-2013 John-David Dalton + * Available under MIT license */ ;(function() { 'use strict'; @@ -22421,7 +25992,7 @@ var substr = 'ab'.substr(-1) === 'b' }.call(this)); }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],323:[function(require,module,exports){ +},{}],443:[function(require,module,exports){ (function (process){(function (){ 'use strict'; @@ -22470,7 +26041,7 @@ function nextTick(fn, arg1, arg2, arg3) { }).call(this)}).call(this,require('_process')) -},{"_process":399}],324:[function(require,module,exports){ +},{"_process":540}],444:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -22656,7 +26227,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],325:[function(require,module,exports){ +},{}],445:[function(require,module,exports){ (function (global){(function (){ /*! https://mths.be/punycode v1.4.1 by @mathias */ ;(function(root) { @@ -23193,322 +26764,888 @@ process.umask = function() { return 0; }; }(this)); }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],326:[function(require,module,exports){ -// 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. +},{}],446:[function(require,module,exports){ +'use strict'; + +var replace = String.prototype.replace; +var percentTwenties = /%20/g; + +var Format = { + RFC1738: 'RFC1738', + RFC3986: 'RFC3986' +}; + +module.exports = { + 'default': Format.RFC3986, + formatters: { + RFC1738: function (value) { + return replace.call(value, percentTwenties, '+'); + }, + RFC3986: function (value) { + return String(value); + } + }, + RFC1738: Format.RFC1738, + RFC3986: Format.RFC3986 +}; +},{}],447:[function(require,module,exports){ 'use strict'; -// If obj.hasOwnProperty has been overridden, then calling -// obj.hasOwnProperty(prop) will break. -// See: https://github.com/joyent/node/issues/1707 -function hasOwnProperty(obj, prop) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} +var stringify = require('./stringify'); +var parse = require('./parse'); +var formats = require('./formats'); -module.exports = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; - var obj = {}; +module.exports = { + formats: formats, + parse: parse, + stringify: stringify +}; - if (typeof qs !== 'string' || qs.length === 0) { - return obj; - } +},{"./formats":446,"./parse":448,"./stringify":449}],448:[function(require,module,exports){ +'use strict'; - var regexp = /\+/g; - qs = qs.split(sep); +var utils = require('./utils'); + +var has = Object.prototype.hasOwnProperty; +var isArray = Array.isArray; + +var defaults = { + allowDots: false, + allowPrototypes: false, + allowSparse: false, + arrayLimit: 20, + charset: 'utf-8', + charsetSentinel: false, + comma: false, + decoder: utils.decode, + delimiter: '&', + depth: 5, + ignoreQueryPrefix: false, + interpretNumericEntities: false, + parameterLimit: 1000, + parseArrays: true, + plainObjects: false, + strictNullHandling: false +}; + +var interpretNumericEntities = function (str) { + return str.replace(/&#(\d+);/g, function ($0, numberStr) { + return String.fromCharCode(parseInt(numberStr, 10)); + }); +}; - var maxKeys = 1000; - if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; - } +var parseArrayValue = function (val, options) { + if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) { + return val.split(','); + } - var len = qs.length; - // maxKeys <= 0 means that we should not limit keys count - if (maxKeys > 0 && len > maxKeys) { - len = maxKeys; - } + return val; +}; - for (var i = 0; i < len; ++i) { - var x = qs[i].replace(regexp, '%20'), - idx = x.indexOf(eq), - kstr, vstr, k, v; +// This is what browsers will submit when the ✓ character occurs in an +// application/x-www-form-urlencoded body and the encoding of the page containing +// the form is iso-8859-1, or when the submitted form has an accept-charset +// attribute of iso-8859-1. Presumably also with other charsets that do not contain +// the ✓ character, such as us-ascii. +var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓') - if (idx >= 0) { - kstr = x.substr(0, idx); - vstr = x.substr(idx + 1); - } else { - kstr = x; - vstr = ''; - } +// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded. +var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓') - k = decodeURIComponent(kstr); - v = decodeURIComponent(vstr); +var parseValues = function parseQueryStringValues(str, options) { + var obj = { __proto__: null }; - if (!hasOwnProperty(obj, k)) { - obj[k] = v; - } else if (isArray(obj[k])) { - obj[k].push(v); - } else { - obj[k] = [obj[k], v]; - } - } + var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; + var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; + var parts = cleanStr.split(options.delimiter, limit); + var skipIndex = -1; // Keep track of where the utf8 sentinel was found + var i; - return obj; -}; + var charset = options.charset; + if (options.charsetSentinel) { + for (i = 0; i < parts.length; ++i) { + if (parts[i].indexOf('utf8=') === 0) { + if (parts[i] === charsetSentinel) { + charset = 'utf-8'; + } else if (parts[i] === isoSentinel) { + charset = 'iso-8859-1'; + } + skipIndex = i; + i = parts.length; // The eslint settings do not allow break; + } + } + } -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; -}; + for (i = 0; i < parts.length; ++i) { + if (i === skipIndex) { + continue; + } + var part = parts[i]; -},{}],327:[function(require,module,exports){ -// 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 bracketEqualsPos = part.indexOf(']='); + var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; -'use strict'; + var key, val; + if (pos === -1) { + key = options.decoder(part, defaults.decoder, charset, 'key'); + val = options.strictNullHandling ? null : ''; + } else { + key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key'); + val = utils.maybeMap( + parseArrayValue(part.slice(pos + 1), options), + function (encodedVal) { + return options.decoder(encodedVal, defaults.decoder, charset, 'value'); + } + ); + } -var stringifyPrimitive = function(v) { - switch (typeof v) { - case 'string': - return v; + if (val && options.interpretNumericEntities && charset === 'iso-8859-1') { + val = interpretNumericEntities(val); + } - case 'boolean': - return v ? 'true' : 'false'; + if (part.indexOf('[]=') > -1) { + val = isArray(val) ? [val] : val; + } - case 'number': - return isFinite(v) ? v : ''; + if (has.call(obj, key)) { + obj[key] = utils.combine(obj[key], val); + } else { + obj[key] = val; + } + } - default: - return ''; - } + return obj; }; -module.exports = function(obj, sep, eq, name) { - sep = sep || '&'; - eq = eq || '='; - if (obj === null) { - obj = undefined; - } +var parseObject = function (chain, val, options, valuesParsed) { + var leaf = valuesParsed ? val : parseArrayValue(val, options); - if (typeof obj === 'object') { - return map(objectKeys(obj), function(k) { - var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; - if (isArray(obj[k])) { - return map(obj[k], function(v) { - return ks + encodeURIComponent(stringifyPrimitive(v)); - }).join(sep); - } else { - return ks + encodeURIComponent(stringifyPrimitive(obj[k])); - } - }).join(sep); + for (var i = chain.length - 1; i >= 0; --i) { + var obj; + var root = chain[i]; - } + if (root === '[]' && options.parseArrays) { + obj = [].concat(leaf); + } else { + obj = options.plainObjects ? Object.create(null) : {}; + var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; + var index = parseInt(cleanRoot, 10); + if (!options.parseArrays && cleanRoot === '') { + obj = { 0: leaf }; + } else if ( + !isNaN(index) + && root !== cleanRoot + && String(index) === cleanRoot + && index >= 0 + && (options.parseArrays && index <= options.arrayLimit) + ) { + obj = []; + obj[index] = leaf; + } else if (cleanRoot !== '__proto__') { + obj[cleanRoot] = leaf; + } + } - if (!name) return ''; - return encodeURIComponent(stringifyPrimitive(name)) + eq + - encodeURIComponent(stringifyPrimitive(obj)); -}; + leaf = obj; + } -var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; + return leaf; }; -function map (xs, f) { - if (xs.map) return xs.map(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - res.push(f(xs[i], i)); - } - return res; -} +var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) { + if (!givenKey) { + return; + } -var objectKeys = Object.keys || function (obj) { - var res = []; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); - } - return res; -}; + // Transform dot notation to bracket notation + var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; -},{}],328:[function(require,module,exports){ -'use strict'; + // The regex chunks -exports.decode = exports.parse = require('./decode'); -exports.encode = exports.stringify = require('./encode'); + var brackets = /(\[[^[\]]*])/; + var child = /(\[[^[\]]*])/g; -},{"./decode":326,"./encode":327}],329:[function(require,module,exports){ -module.exports = require('./lib/_stream_duplex.js'); + // Get the parent -},{"./lib/_stream_duplex.js":330}],330:[function(require,module,exports){ -// 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 segment = options.depth > 0 && brackets.exec(key); + var parent = segment ? key.slice(0, segment.index) : key; -// a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototypal inheritance, this class -// prototypally inherits from Readable, and then parasitically from -// Writable. + // Stash the parent if it exists -'use strict'; + var keys = []; + if (parent) { + // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties + if (!options.plainObjects && has.call(Object.prototype, parent)) { + if (!options.allowPrototypes) { + return; + } + } -/**/ + keys.push(parent); + } -var pna = require('process-nextick-args'); -/**/ + // Loop through children appending to the array until we hit depth -/**/ -var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) { - keys.push(key); - }return keys; -}; -/**/ + var i = 0; + while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) { + i += 1; + if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { + if (!options.allowPrototypes) { + return; + } + } + keys.push(segment[1]); + } -module.exports = Duplex; + // If there's a remainder, just add whatever is left -/**/ -var util = Object.create(require('core-util-is')); -util.inherits = require('inherits'); -/**/ + if (segment) { + keys.push('[' + key.slice(segment.index) + ']'); + } -var Readable = require('./_stream_readable'); -var Writable = require('./_stream_writable'); + return parseObject(keys, val, options, valuesParsed); +}; -util.inherits(Duplex, Readable); +var normalizeParseOptions = function normalizeParseOptions(opts) { + if (!opts) { + return defaults; + } -{ - // avoid scope creep, the keys array can then be collected - var keys = objectKeys(Writable.prototype); - for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; - } -} + if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { + throw new TypeError('Decoder has to be a function.'); + } -function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options); + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { + throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); + } + var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; - Readable.call(this, options); - Writable.call(this, options); + return { + allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, + allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, + allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse, + arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, + charset: charset, + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, + comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, + decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, + delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, + // eslint-disable-next-line no-implicit-coercion, no-extra-parens + depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth, + ignoreQueryPrefix: opts.ignoreQueryPrefix === true, + interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, + parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, + parseArrays: opts.parseArrays !== false, + plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling + }; +}; - if (options && options.readable === false) this.readable = false; +module.exports = function (str, opts) { + var options = normalizeParseOptions(opts); - if (options && options.writable === false) this.writable = false; + if (str === '' || str === null || typeof str === 'undefined') { + return options.plainObjects ? Object.create(null) : {}; + } - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + var tempObj = typeof str === 'string' ? parseValues(str, options) : str; + var obj = options.plainObjects ? Object.create(null) : {}; - this.once('end', onend); -} + // Iterate over the keys and setup the new object -Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._writableState.highWaterMark; - } -}); + var keys = Object.keys(tempObj); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string'); + obj = utils.merge(obj, newObj, options); + } -// the no-half-open enforcer -function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; + if (options.allowSparse === true) { + return obj; + } - // no more data can be written. - // But allow more writes to happen in this tick. - pna.nextTick(onEndNT, this); -} + return utils.compact(obj); +}; -function onEndNT(self) { - self.end(); -} +},{"./utils":450}],449:[function(require,module,exports){ +'use strict'; -Object.defineProperty(Duplex.prototype, 'destroyed', { - get: function () { - if (this._readableState === undefined || this._writableState === undefined) { - return false; +var getSideChannel = require('side-channel'); +var utils = require('./utils'); +var formats = require('./formats'); +var has = Object.prototype.hasOwnProperty; + +var arrayPrefixGenerators = { + brackets: function brackets(prefix) { + return prefix + '[]'; + }, + comma: 'comma', + indices: function indices(prefix, key) { + return prefix + '[' + key + ']'; + }, + repeat: function repeat(prefix) { + return prefix; + } +}; + +var isArray = Array.isArray; +var push = Array.prototype.push; +var pushToArray = function (arr, valueOrArray) { + push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); +}; + +var toISO = Date.prototype.toISOString; + +var defaultFormat = formats['default']; +var defaults = { + addQueryPrefix: false, + allowDots: false, + charset: 'utf-8', + charsetSentinel: false, + delimiter: '&', + encode: true, + encoder: utils.encode, + encodeValuesOnly: false, + format: defaultFormat, + formatter: formats.formatters[defaultFormat], + // deprecated + indices: false, + serializeDate: function serializeDate(date) { + return toISO.call(date); + }, + skipNulls: false, + strictNullHandling: false +}; + +var isNonNullishPrimitive = function isNonNullishPrimitive(v) { + return typeof v === 'string' + || typeof v === 'number' + || typeof v === 'boolean' + || typeof v === 'symbol' + || typeof v === 'bigint'; +}; + +var sentinel = {}; + +var stringify = function stringify( + object, + prefix, + generateArrayPrefix, + commaRoundTrip, + strictNullHandling, + skipNulls, + encoder, + filter, + sort, + allowDots, + serializeDate, + format, + formatter, + encodeValuesOnly, + charset, + sideChannel +) { + var obj = object; + + var tmpSc = sideChannel; + var step = 0; + var findFlag = false; + while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) { + // Where object last appeared in the ref tree + var pos = tmpSc.get(object); + step += 1; + if (typeof pos !== 'undefined') { + if (pos === step) { + throw new RangeError('Cyclic object value'); + } else { + findFlag = true; // Break while + } + } + if (typeof tmpSc.get(sentinel) === 'undefined') { + step = 0; + } } - return this._readableState.destroyed && this._writableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (this._readableState === undefined || this._writableState === undefined) { - return; + + if (typeof filter === 'function') { + obj = filter(prefix, obj); + } else if (obj instanceof Date) { + obj = serializeDate(obj); + } else if (generateArrayPrefix === 'comma' && isArray(obj)) { + obj = utils.maybeMap(obj, function (value) { + if (value instanceof Date) { + return serializeDate(value); + } + return value; + }); } - // backward compatibility, the user is explicitly - // managing destroyed - this._readableState.destroyed = value; - this._writableState.destroyed = value; - } -}); + if (obj === null) { + if (strictNullHandling) { + return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix; + } -Duplex.prototype._destroy = function (err, cb) { - this.push(null); - this.end(); + obj = ''; + } - pna.nextTick(cb, err); -}; -},{"./_stream_readable":332,"./_stream_writable":334,"core-util-is":298,"inherits":311,"process-nextick-args":323}],331:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. + if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) { + if (encoder) { + var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format); + return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))]; + } + return [formatter(prefix) + '=' + formatter(String(obj))]; + } + + var values = []; + + if (typeof obj === 'undefined') { + return values; + } + + var objKeys; + if (generateArrayPrefix === 'comma' && isArray(obj)) { + // we need to join elements in + if (encodeValuesOnly && encoder) { + obj = utils.maybeMap(obj, encoder); + } + objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }]; + } else if (isArray(filter)) { + objKeys = filter; + } else { + var keys = Object.keys(obj); + objKeys = sort ? keys.sort(sort) : keys; + } + + var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix; + + for (var j = 0; j < objKeys.length; ++j) { + var key = objKeys[j]; + var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key]; + + if (skipNulls && value === null) { + continue; + } + + var keyPrefix = isArray(obj) + ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix + : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']'); + + sideChannel.set(object, step); + var valueSideChannel = getSideChannel(); + valueSideChannel.set(sentinel, sideChannel); + pushToArray(values, stringify( + value, + keyPrefix, + generateArrayPrefix, + commaRoundTrip, + strictNullHandling, + skipNulls, + generateArrayPrefix === 'comma' && encodeValuesOnly && isArray(obj) ? null : encoder, + filter, + sort, + allowDots, + serializeDate, + format, + formatter, + encodeValuesOnly, + charset, + valueSideChannel + )); + } + + return values; +}; + +var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { + if (!opts) { + return defaults; + } + + if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + + var charset = opts.charset || defaults.charset; + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { + throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); + } + + var format = formats['default']; + if (typeof opts.format !== 'undefined') { + if (!has.call(formats.formatters, opts.format)) { + throw new TypeError('Unknown format option provided.'); + } + format = opts.format; + } + var formatter = formats.formatters[format]; + + var filter = defaults.filter; + if (typeof opts.filter === 'function' || isArray(opts.filter)) { + filter = opts.filter; + } + + return { + addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, + allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, + charset: charset, + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, + delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, + encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, + encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, + encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, + filter: filter, + format: format, + formatter: formatter, + serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, + skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, + sort: typeof opts.sort === 'function' ? opts.sort : null, + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling + }; +}; + +module.exports = function (object, opts) { + var obj = object; + var options = normalizeStringifyOptions(opts); + + var objKeys; + var filter; + + if (typeof options.filter === 'function') { + filter = options.filter; + obj = filter('', obj); + } else if (isArray(options.filter)) { + filter = options.filter; + objKeys = filter; + } + + var keys = []; + + if (typeof obj !== 'object' || obj === null) { + return ''; + } + + var arrayFormat; + if (opts && opts.arrayFormat in arrayPrefixGenerators) { + arrayFormat = opts.arrayFormat; + } else if (opts && 'indices' in opts) { + arrayFormat = opts.indices ? 'indices' : 'repeat'; + } else { + arrayFormat = 'indices'; + } + + var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; + if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') { + throw new TypeError('`commaRoundTrip` must be a boolean, or absent'); + } + var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip; + + if (!objKeys) { + objKeys = Object.keys(obj); + } + + if (options.sort) { + objKeys.sort(options.sort); + } + + var sideChannel = getSideChannel(); + for (var i = 0; i < objKeys.length; ++i) { + var key = objKeys[i]; + + if (options.skipNulls && obj[key] === null) { + continue; + } + pushToArray(keys, stringify( + obj[key], + key, + generateArrayPrefix, + commaRoundTrip, + options.strictNullHandling, + options.skipNulls, + options.encode ? options.encoder : null, + options.filter, + options.sort, + options.allowDots, + options.serializeDate, + options.format, + options.formatter, + options.encodeValuesOnly, + options.charset, + sideChannel + )); + } + + var joined = keys.join(options.delimiter); + var prefix = options.addQueryPrefix === true ? '?' : ''; + + if (options.charsetSentinel) { + if (options.charset === 'iso-8859-1') { + // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark + prefix += 'utf8=%26%2310003%3B&'; + } else { + // encodeURIComponent('✓') + prefix += 'utf8=%E2%9C%93&'; + } + } + + return joined.length > 0 ? prefix + joined : ''; +}; + +},{"./formats":446,"./utils":450,"side-channel":469}],450:[function(require,module,exports){ +'use strict'; + +var formats = require('./formats'); + +var has = Object.prototype.hasOwnProperty; +var isArray = Array.isArray; + +var hexTable = (function () { + var array = []; + for (var i = 0; i < 256; ++i) { + array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); + } + + return array; +}()); + +var compactQueue = function compactQueue(queue) { + while (queue.length > 1) { + var item = queue.pop(); + var obj = item.obj[item.prop]; + + if (isArray(obj)) { + var compacted = []; + + for (var j = 0; j < obj.length; ++j) { + if (typeof obj[j] !== 'undefined') { + compacted.push(obj[j]); + } + } + + item.obj[item.prop] = compacted; + } + } +}; + +var arrayToObject = function arrayToObject(source, options) { + var obj = options && options.plainObjects ? Object.create(null) : {}; + for (var i = 0; i < source.length; ++i) { + if (typeof source[i] !== 'undefined') { + obj[i] = source[i]; + } + } + + return obj; +}; + +var merge = function merge(target, source, options) { + /* eslint no-param-reassign: 0 */ + if (!source) { + return target; + } + + if (typeof source !== 'object') { + if (isArray(target)) { + target.push(source); + } else if (target && typeof target === 'object') { + if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { + target[source] = true; + } + } else { + return [target, source]; + } + + return target; + } + + if (!target || typeof target !== 'object') { + return [target].concat(source); + } + + var mergeTarget = target; + if (isArray(target) && !isArray(source)) { + mergeTarget = arrayToObject(target, options); + } + + if (isArray(target) && isArray(source)) { + source.forEach(function (item, i) { + if (has.call(target, i)) { + var targetItem = target[i]; + if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { + target[i] = merge(targetItem, item, options); + } else { + target.push(item); + } + } else { + target[i] = item; + } + }); + return target; + } + + return Object.keys(source).reduce(function (acc, key) { + var value = source[key]; + + if (has.call(acc, key)) { + acc[key] = merge(acc[key], value, options); + } else { + acc[key] = value; + } + return acc; + }, mergeTarget); +}; + +var assign = function assignSingleSource(target, source) { + return Object.keys(source).reduce(function (acc, key) { + acc[key] = source[key]; + return acc; + }, target); +}; + +var decode = function (str, decoder, charset) { + var strWithoutPlus = str.replace(/\+/g, ' '); + if (charset === 'iso-8859-1') { + // unescape never throws, no try...catch needed: + return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); + } + // utf-8 + try { + return decodeURIComponent(strWithoutPlus); + } catch (e) { + return strWithoutPlus; + } +}; + +var encode = function encode(str, defaultEncoder, charset, kind, format) { + // This code was originally written by Brian White (mscdex) for the io.js core querystring library. + // It has been adapted here for stricter adherence to RFC 3986 + if (str.length === 0) { + return str; + } + + var string = str; + if (typeof str === 'symbol') { + string = Symbol.prototype.toString.call(str); + } else if (typeof str !== 'string') { + string = String(str); + } + + if (charset === 'iso-8859-1') { + return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { + return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; + }); + } + + var out = ''; + for (var i = 0; i < string.length; ++i) { + var c = string.charCodeAt(i); + + if ( + c === 0x2D // - + || c === 0x2E // . + || c === 0x5F // _ + || c === 0x7E // ~ + || (c >= 0x30 && c <= 0x39) // 0-9 + || (c >= 0x41 && c <= 0x5A) // a-z + || (c >= 0x61 && c <= 0x7A) // A-Z + || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( ) + ) { + out += string.charAt(i); + continue; + } + + if (c < 0x80) { + out = out + hexTable[c]; + continue; + } + + if (c < 0x800) { + out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + if (c < 0xD800 || c >= 0xE000) { + out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + i += 1; + c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); + /* eslint operator-linebreak: [2, "before"] */ + out += hexTable[0xF0 | (c >> 18)] + + hexTable[0x80 | ((c >> 12) & 0x3F)] + + hexTable[0x80 | ((c >> 6) & 0x3F)] + + hexTable[0x80 | (c & 0x3F)]; + } + + return out; +}; + +var compact = function compact(value) { + var queue = [{ obj: { o: value }, prop: 'o' }]; + var refs = []; + + for (var i = 0; i < queue.length; ++i) { + var item = queue[i]; + var obj = item.obj[item.prop]; + + var keys = Object.keys(obj); + for (var j = 0; j < keys.length; ++j) { + var key = keys[j]; + var val = obj[key]; + if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { + queue.push({ obj: obj, prop: key }); + refs.push(val); + } + } + } + + compactQueue(queue); + + return value; +}; + +var isRegExp = function isRegExp(obj) { + return Object.prototype.toString.call(obj) === '[object RegExp]'; +}; + +var isBuffer = function isBuffer(obj) { + if (!obj || typeof obj !== 'object') { + return false; + } + + return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); +}; + +var combine = function combine(a, b) { + return [].concat(a, b); +}; + +var maybeMap = function maybeMap(val, fn) { + if (isArray(val)) { + var mapped = []; + for (var i = 0; i < val.length; i += 1) { + mapped.push(fn(val[i])); + } + return mapped; + } + return fn(val); +}; + +module.exports = { + arrayToObject: arrayToObject, + assign: assign, + combine: combine, + compact: compact, + decode: decode, + encode: encode, + isBuffer: isBuffer, + isRegExp: isRegExp, + maybeMap: maybeMap, + merge: merge +}; + +},{"./formats":446}],451:[function(require,module,exports){ +// 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 @@ -23529,34 +27666,71 @@ Duplex.prototype._destroy = function (err, cb) { // 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'; -module.exports = PassThrough; +// If obj.hasOwnProperty has been overridden, then calling +// obj.hasOwnProperty(prop) will break. +// See: https://github.com/joyent/node/issues/1707 +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} -var Transform = require('./_stream_transform'); +module.exports = function(qs, sep, eq, options) { + sep = sep || '&'; + eq = eq || '='; + var obj = {}; -/**/ -var util = Object.create(require('core-util-is')); -util.inherits = require('inherits'); -/**/ + if (typeof qs !== 'string' || qs.length === 0) { + return obj; + } -util.inherits(PassThrough, Transform); + var regexp = /\+/g; + qs = qs.split(sep); -function PassThrough(options) { - if (!(this instanceof PassThrough)) return new PassThrough(options); + var maxKeys = 1000; + if (options && typeof options.maxKeys === 'number') { + maxKeys = options.maxKeys; + } - Transform.call(this, options); -} + var len = qs.length; + // maxKeys <= 0 means that we should not limit keys count + if (maxKeys > 0 && len > maxKeys) { + len = maxKeys; + } -PassThrough.prototype._transform = function (chunk, encoding, cb) { - cb(null, chunk); + for (var i = 0; i < len; ++i) { + var x = qs[i].replace(regexp, '%20'), + idx = x.indexOf(eq), + kstr, vstr, k, v; + + if (idx >= 0) { + kstr = x.substr(0, idx); + vstr = x.substr(idx + 1); + } else { + kstr = x; + vstr = ''; + } + + k = decodeURIComponent(kstr); + v = decodeURIComponent(vstr); + + if (!hasOwnProperty(obj, k)) { + obj[k] = v; + } else if (isArray(obj[k])) { + obj[k].push(v); + } else { + obj[k] = [obj[k], v]; + } + } + + return obj; }; -},{"./_stream_transform":333,"core-util-is":298,"inherits":311}],332:[function(require,module,exports){ -(function (process,global){(function (){ + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + +},{}],452:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -23580,2841 +27754,2355 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { 'use strict'; -/**/ - -var pna = require('process-nextick-args'); -/**/ +var stringifyPrimitive = function(v) { + switch (typeof v) { + case 'string': + return v; -module.exports = Readable; + case 'boolean': + return v ? 'true' : 'false'; -/**/ -var isArray = require('isarray'); -/**/ + case 'number': + return isFinite(v) ? v : ''; -/**/ -var Duplex; -/**/ - -Readable.ReadableState = ReadableState; - -/**/ -var EE = require('events').EventEmitter; - -var EElistenerCount = function (emitter, type) { - return emitter.listeners(type).length; + default: + return ''; + } }; -/**/ -/**/ -var Stream = require('./internal/streams/stream'); -/**/ +module.exports = function(obj, sep, eq, name) { + sep = sep || '&'; + eq = eq || '='; + if (obj === null) { + obj = undefined; + } -/**/ + if (typeof obj === 'object') { + return map(objectKeys(obj), function(k) { + var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; + if (isArray(obj[k])) { + return map(obj[k], function(v) { + return ks + encodeURIComponent(stringifyPrimitive(v)); + }).join(sep); + } else { + return ks + encodeURIComponent(stringifyPrimitive(obj[k])); + } + }).join(sep); -var Buffer = require('safe-buffer').Buffer; -var OurUint8Array = global.Uint8Array || function () {}; -function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); -} -function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; -} + } -/**/ + if (!name) return ''; + return encodeURIComponent(stringifyPrimitive(name)) + eq + + encodeURIComponent(stringifyPrimitive(obj)); +}; -/**/ -var util = Object.create(require('core-util-is')); -util.inherits = require('inherits'); -/**/ +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; -/**/ -var debugUtil = require('util'); -var debug = void 0; -if (debugUtil && debugUtil.debuglog) { - debug = debugUtil.debuglog('stream'); -} else { - debug = function () {}; +function map (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f(xs[i], i)); + } + return res; } -/**/ - -var BufferList = require('./internal/streams/BufferList'); -var destroyImpl = require('./internal/streams/destroy'); -var StringDecoder; -util.inherits(Readable, Stream); +var objectKeys = Object.keys || function (obj) { + var res = []; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); + } + return res; +}; -var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; +},{}],453:[function(require,module,exports){ +'use strict'; -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); +exports.decode = exports.parse = require('./decode'); +exports.encode = exports.stringify = require('./encode'); - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; -} +},{"./decode":451,"./encode":452}],454:[function(require,module,exports){ +// 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. -function ReadableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. - options = options || {}; +'use strict'; - // 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. - var isDuplex = stream instanceof 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.objectMode; +var pna = require('process-nextick-args'); +/**/ - if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ - // the point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var readableHwm = options.readableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; +module.exports = Duplex; - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); - // 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 = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; +util.inherits(Duplex, Readable); - // 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; +{ + // avoid scope creep, the keys array can then be collected + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} - // 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; +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); - // has it been destroyed - this.destroyed = false; + Readable.call(this, options); + Writable.call(this, options); - // 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.defaultEncoding || 'utf8'; + if (options && options.readable === false) this.readable = false; - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; + if (options && options.writable === false) this.writable = false; - // if true, a maybeReadMore has been scheduled - this.readingMore = false; + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } + this.once('end', onend); } -function Readable(options) { - Duplex = Duplex || require('./_stream_duplex'); - - if (!(this instanceof Readable)) return new Readable(options); - - this._readableState = new ReadableState(options, this); - - // legacy - this.readable = true; +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); - if (options) { - if (typeof options.read === 'function') this._read = options.read; +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; - if (typeof options.destroy === 'function') this._destroy = options.destroy; - } + // no more data can be written. + // But allow more writes to happen in this tick. + pna.nextTick(onEndNT, this); +} - Stream.call(this); +function onEndNT(self) { + self.end(); } -Object.defineProperty(Readable.prototype, 'destroyed', { +Object.defineProperty(Duplex.prototype, 'destroyed', { get: function () { - if (this._readableState === undefined) { + if (this._readableState === undefined || this._writableState === undefined) { return false; } - return this._readableState.destroyed; + return this._readableState.destroyed && this._writableState.destroyed; }, set: function (value) { // we ignore the value if the stream // has not been initialized yet - if (!this._readableState) { + if (this._readableState === undefined || this._writableState === undefined) { return; } // backward compatibility, the user is explicitly // managing destroyed this._readableState.destroyed = value; + this._writableState.destroyed = value; } }); -Readable.prototype.destroy = destroyImpl.destroy; -Readable.prototype._undestroy = destroyImpl.undestroy; -Readable.prototype._destroy = function (err, cb) { +Duplex.prototype._destroy = function (err, cb) { this.push(null); - cb(err); + this.end(); + + pna.nextTick(cb, err); }; +},{"./_stream_readable":456,"./_stream_writable":458,"core-util-is":384,"inherits":409,"process-nextick-args":443}],455:[function(require,module,exports){ +// 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. -// 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) { - var state = this._readableState; - var skipChunkCheck; +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. - if (!state.objectMode) { - if (typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = Buffer.from(chunk, encoding); - encoding = ''; - } - skipChunkCheck = true; - } - } else { - skipChunkCheck = true; - } +'use strict'; - return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); -}; +module.exports = PassThrough; -// Unshift should *always* be something directly out of read() -Readable.prototype.unshift = function (chunk) { - return readableAddChunk(this, chunk, null, true, false); -}; +var Transform = require('./_stream_transform'); -function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { - var state = stream._readableState; - if (chunk === null) { - state.reading = false; - onEofChunk(stream, state); - } else { - var er; - if (!skipChunkCheck) er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { - chunk = _uint8ArrayToBuffer(chunk); - } +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ - if (addToFront) { - if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); - } else if (state.ended) { - stream.emit('error', new Error('stream.push() after EOF')); - } 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; - } - } +util.inherits(PassThrough, Transform); - return needMoreData(state); +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); } -function addChunk(stream, state, chunk, addToFront) { - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":457,"core-util-is":384,"inherits":409}],456:[function(require,module,exports){ +(function (process,global){(function (){ +// 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. - if (state.needReadable) emitReadable(stream); - } - maybeReadMore(stream, state); -} +'use strict'; -function chunkInvalid(state, chunk) { - var er; - if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; -} +/**/ -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); -} +var pna = require('process-nextick-args'); +/**/ -Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; -}; +module.exports = Readable; -// backwards compatibility. -Readable.prototype.setEncoding = function (enc) { - if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; -}; +/**/ +var isArray = require('isarray'); +/**/ -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; -function computeNewHighWaterMark(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 to prevent increasing hwm excessively in - // tiny amounts - n--; - n |= n >>> 1; - n |= n >>> 2; - n |= n >>> 4; - n |= n >>> 8; - n |= n >>> 16; - n++; - } - return n; -} +/**/ +var Duplex; +/**/ -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function howMuchToRead(n, state) { - if (n <= 0 || state.length === 0 && state.ended) return 0; - if (state.objectMode) return 1; - if (n !== n) { - // Only flow one buffer at a time - if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } - // If we're asking for more than the current hwm, then raise the hwm. - if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; - // Don't have enough - if (!state.ended) { - state.needReadable = true; - return 0; - } - return state.length; -} +Readable.ReadableState = ReadableState; -// you can override either this method, or the async _read(n) below. -Readable.prototype.read = function (n) { - debug('read', n); - n = parseInt(n, 10); - var state = this._readableState; - var nOrig = n; +/**/ +var EE = require('events').EventEmitter; - if (n !== 0) state.emittedReadable = false; +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ - // if we're doing read(0) to trigger a readable event, but we - // already have a bunch of data in the buffer, then just trigger - // the 'readable' event and move on. - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { - debug('read: emitReadable', state.length, state.ended); - if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); - return null; - } +/**/ +var Stream = require('./internal/streams/stream'); +/**/ - 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; - } +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} - // 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. - var doRead = state.needReadable; - debug('need readable', doRead); +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ - // 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); - } +/**/ +var debugUtil = require('util'); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ - // however, if we've ended, then there's no point, and if we're already - // reading, then it's unnecessary. - if (state.ended || state.reading) { - doRead = false; - debug('reading or ended', 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 - this._read(state.highWaterMark); - state.sync = false; - // If _read pushed data synchronously, then `reading` will be false, - // and we need to re-evaluate how much data we can return to the user. - if (!state.reading) n = howMuchToRead(nOrig, state); - } +var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); +var StringDecoder; - var ret; - if (n > 0) ret = fromList(n, state);else ret = null; +util.inherits(Readable, Stream); - if (ret === null) { - state.needReadable = true; - n = 0; - } else { - state.length -= n; - } +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; - 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; +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); - // If we tried to read() past the EOF, then emit end on the next tick. - if (nOrig !== n && state.ended) endReadable(this); - } + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} - if (ret !== null) this.emit('data', ret); +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); - return ret; -}; + options = options || {}; -function onEofChunk(stream, state) { - if (state.ended) return; - if (state.decoder) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) { - state.buffer.push(chunk); - state.length += state.objectMode ? 1 : chunk.length; - } - } - state.ended = true; + // 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. + var isDuplex = stream instanceof Duplex; - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); -} + // 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.objectMode; -// 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) { - var state = stream._readableState; - state.needReadable = false; - if (!state.emittedReadable) { - debug('emitReadable', state.flowing); - state.emittedReadable = true; - if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); - } -} + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; -function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); -} + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; -// 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.readingMore = true; - pna.nextTick(maybeReadMore_, stream, state); - } -} + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; -function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { - debug('maybeReadMore read 0'); - stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break;else len = state.length; - } - state.readingMore = false; -} + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); -// 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) { - this.emit('error', new Error('_read() is not implemented')); -}; + // 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 = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; -Readable.prototype.pipe = function (dest, pipeOpts) { - var src = this; - var state = this._readableState; + // 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; - switch (state.pipesCount) { - case 0: - state.pipes = dest; - break; - case 1: - state.pipes = [state.pipes, dest]; - break; - default: - state.pipes.push(dest); - break; - } - state.pipesCount += 1; - debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + // 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; - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + // has it been destroyed + this.destroyed = false; - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + // 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.defaultEncoding || 'utf8'; - dest.on('unpipe', onunpipe); - function onunpipe(readable, unpipeInfo) { - debug('onunpipe'); - if (readable === src) { - if (unpipeInfo && unpipeInfo.hasUnpiped === false) { - unpipeInfo.hasUnpiped = true; - cleanup(); - } - } - } + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; - function onend() { - debug('onend'); - dest.end(); + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; } +} - // 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. - var ondrain = pipeOnDrain(src); - dest.on('drain', ondrain); +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); - var cleanedUp = false; - function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken - dest.removeListener('close', onclose); - dest.removeListener('finish', onfinish); - 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 (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); - } + if (!(this instanceof Readable)) return new Readable(options); - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; - src.on('data', ondata); - function ondata(chunk) { - debug('ondata'); - increasedAwaitDrain = false; - var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { - // If the user unpiped during `dest.write()`, it is possible - // to get stuck in a permanently paused state if that write - // also returned false. - // => Check whether `dest` is still a piping destination. - if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; - } - src.pause(); - } - } + this._readableState = new ReadableState(options, this); - // 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 (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); - } + // legacy + this.readable = true; - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); + if (options) { + if (typeof options.read === 'function') this._read = options.read; - // 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(); + if (typeof options.destroy === 'function') this._destroy = options.destroy; } - dest.once('finish', onfinish); - function unpipe() { - debug('unpipe'); - src.unpipe(dest); - } + Stream.call(this); +} - // tell the dest that it's being piped to - dest.emit('pipe', src); +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } - // start the flow if it hasn't been started already. - if (!state.flowing) { - debug('pipe resume'); - src.resume(); + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; } +}); - return dest; +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); }; -function pipeOnDrain(src) { - return function () { - var state = src._readableState; - debug('pipeOnDrain', state.awaitDrain); - if (state.awaitDrain) state.awaitDrain--; - if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { - state.flowing = true; - flow(src); - } - }; -} - -Readable.prototype.unpipe = function (dest) { +// 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) { var state = this._readableState; - var unpipeInfo = { hasUnpiped: false }; - - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) return this; - - // just one destination. most common case. - if (state.pipesCount === 1) { - // passed in one, but it's not the right one. - if (dest && dest !== state.pipes) return this; - - if (!dest) dest = state.pipes; - - // got a match. - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; - if (dest) dest.emit('unpipe', this, unpipeInfo); - return this; - } - - // slow case. multiple pipe destinations. - - if (!dest) { - // remove all. - var dests = state.pipes; - var len = state.pipesCount; - state.pipes = null; - state.pipesCount = 0; - state.flowing = false; + var skipChunkCheck; - for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this, unpipeInfo); - }return this; + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; } - // try to find the right one. - var index = indexOf(state.pipes, dest); - if (index === -1) return this; - - state.pipes.splice(index, 1); - state.pipesCount -= 1; - if (state.pipesCount === 1) state.pipes = state.pipes[0]; - - dest.emit('unpipe', this, unpipeInfo); + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; - return this; +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); }; -// set up data events if they are asked for -// Ensure readable listeners eventually get something -Readable.prototype.on = function (ev, fn) { - var res = Stream.prototype.on.call(this, ev, fn); +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } - if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); - } else if (ev === 'readable') { - var state = this._readableState; - if (!state.endEmitted && !state.readableListening) { - state.readableListening = state.needReadable = true; - state.emittedReadable = false; - if (!state.reading) { - pna.nextTick(nReadingNextTick, this); - } else if (state.length) { - emitReadable(this); + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } 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; } } - return res; -}; -Readable.prototype.addListener = Readable.prototype.on; - -function nReadingNextTick(self) { - debug('readable nexttick read 0'); - self.read(0); + return needMoreData(state); } -// 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 () { - var state = this._readableState; - if (!state.flowing) { - debug('resume'); - state.flowing = true; - resume(this, state); - } - return this; -}; +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); -function resume(stream, state) { - if (!state.resumeScheduled) { - state.resumeScheduled = true; - pna.nextTick(resume_, stream, state); + if (state.needReadable) emitReadable(stream); } + maybeReadMore(stream, state); } -function resume_(stream, state) { - if (!state.reading) { - debug('resume read 0'); - stream.read(0); +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); } + return er; +} - state.resumeScheduled = false; - state.awaitDrain = 0; - stream.emit('resume'); - flow(stream); - if (state.flowing && !state.reading) stream.read(0); +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); } -Readable.prototype.pause = function () { - debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { - debug('pause'); - this._readableState.flowing = false; - this.emit('pause'); - } +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; return this; }; -function flow(stream) { - var state = stream._readableState; - debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; } -// 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) { - var _this = this; +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); var state = this._readableState; - var paused = false; + var nOrig = n; - stream.on('end', function () { - debug('wrapped end'); - if (state.decoder && !state.ended) { - var chunk = state.decoder.end(); - if (chunk && chunk.length) _this.push(chunk); - } + if (n !== 0) state.emittedReadable = false; - _this.push(null); - }); + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } - stream.on('data', function (chunk) { - debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); + n = howMuchToRead(n, state); - // don't skip over falsy values in objectMode - if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + // if 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; + } - var ret = _this.push(chunk); - if (!ret) { - paused = true; - stream.pause(); - } - }); + // 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. - // proxy all the other methods. - // important when wrapping filters and duplexes. - for (var i in stream) { - if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function (method) { - return function () { - return stream[method].apply(stream, arguments); - }; - }(i); - } + // if we need a readable event, then we need to do some reading. + var 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); } - // proxy certain important events. - for (var n = 0; n < kProxyEvents.length; n++) { - stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', 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 + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); } - // when we try to consume some more bytes, simply unpause the - // underlying stream. - this._read = function (n) { - debug('wrapped _read', n); - if (paused) { - paused = false; - stream.resume(); - } - }; + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; - return this; -}; + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } -Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._readableState.highWaterMark; + 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); } -}); -// exposed for testing purposes only. -Readable._fromList = fromList; + if (ret !== null) this.emit('data', ret); -// 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; + return ret; +}; - var ret; - if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { - // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); - state.buffer.clear(); - } else { - // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } } + state.ended = true; - return ret; + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); } -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); - } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); +// 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) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); } - return ret; } -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); } -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = Buffer.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; +// 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.readingMore = true; + pna.nextTick(maybeReadMore_, stream, state); } - list.length -= c; - return ret; } -function endReadable(stream) { - var state = stream._readableState; - - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); - - if (!state.endEmitted) { - state.ended = true; - pna.nextTick(endReadableNT, state, stream); +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; } + state.readingMore = false; } -function endReadableNT(state, stream) { - // Check that we didn't get one last unshift. - if (!state.endEmitted && state.length === 0) { - state.endEmitted = true; - stream.readable = false; - stream.emit('end'); - } -} +// 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) { + this.emit('error', new Error('_read() is not implemented')); +}; -function indexOf(xs, x) { - for (var i = 0, l = xs.length; i < l; i++) { - if (xs[i] === x) return i; - } - return -1; -} -}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":330,"./internal/streams/BufferList":335,"./internal/streams/destroy":336,"./internal/streams/stream":337,"_process":399,"core-util-is":298,"events":301,"inherits":311,"isarray":313,"process-nextick-args":323,"safe-buffer":343,"string_decoder/":346,"util":84}],333:[function(require,module,exports){ -// 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. +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; -// 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. + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); -'use strict'; + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; -module.exports = Transform; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); -var Duplex = require('./_stream_duplex'); + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } -/**/ -var util = Object.create(require('core-util-is')); -util.inherits = require('inherits'); -/**/ + function onend() { + debug('onend'); + dest.end(); + } -util.inherits(Transform, Duplex); + // 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. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); -function afterTransform(er, data) { - var ts = this._transformState; - ts.transforming = false; + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); - var cb = ts.writecb; + cleanedUp = true; - if (!cb) { - return this.emit('error', new Error('write callback called multiple times')); + // 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 (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } - ts.writechunk = null; - ts.writecb = null; + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } - if (data != null) // single equals check for both `null` and `undefined` - this.push(data); + // 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 (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } - cb(er); + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); - var rs = this._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - this._read(rs.highWaterMark); + // 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 Transform(options) { - if (!(this instanceof Transform)) return new Transform(options); + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } - Duplex.call(this, options); + // tell the dest that it's being piped to + dest.emit('pipe', src); - this._transformState = { - afterTransform: afterTransform.bind(this), - needTransform: false, - transforming: false, - writecb: null, - writechunk: null, - writeencoding: null + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } }; +} - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; - // 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; + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; - if (options) { - if (typeof options.transform === 'function') this._transform = options.transform; + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; - if (typeof options.flush === 'function') this._flush = options.flush; + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; } - // When the writable side finishes, then flush out anything remaining. - this.on('prefinish', prefinish); -} + // slow case. multiple pipe destinations. -function prefinish() { - var _this = this; + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; - if (typeof this._flush === 'function') { - this._flush(function (er, data) { - done(_this, er, data); - }); - } else { - done(this, null, null); + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, { hasUnpiped: false }); + }return this; } -} -Transform.prototype.push = function (chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); -}; + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; -// This is the part where you do stuff! -// override this function in implementation classes. -// 'chunk' is an input chunk. -// -// Call `push(newChunk)` to pass along transformed output -// to the readable side. You may call 'push' zero or more times. -// -// Call `cb(err)` when you are done with this chunk. If you pass -// an error, then that'll put the hurt on the whole operation. If you -// never call cb(), then you'll never get another chunk. -Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); -}; + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; -Transform.prototype._write = function (chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); - } + dest.emit('unpipe', this, unpipeInfo); + + return this; }; -// Doesn't matter what the args are here. -// _transform does all the work. -// That we got here means that the readable side wants more data. -Transform.prototype._read = function (n) { - var ts = this._transformState; +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + pna.nextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); + } + } } + + return res; }; +Readable.prototype.addListener = Readable.prototype.on; -Transform.prototype._destroy = function (err, cb) { - var _this2 = this; +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} - Duplex.prototype._destroy.call(this, err, function (err2) { - cb(err2); - _this2.emit('close'); - }); +// 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 () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; }; -function done(stream, er, data) { - if (er) return stream.emit('error', er); - - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + pna.nextTick(resume_, stream, state); + } +} - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } - if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} - return stream.push(null); +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} } -},{"./_stream_duplex":330,"core-util-is":298,"inherits":311}],334:[function(require,module,exports){ -(function (process,global,setImmediate){(function (){ -// 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. +// 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) { + var _this = this; -'use strict'; + var state = this._readableState; + var paused = false; -/**/ + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } -var pna = require('process-nextick-args'); -/**/ + _this.push(null); + }); -module.exports = Writable; + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); -/* */ -function WriteReq(chunk, encoding, cb) { - this.chunk = chunk; - this.encoding = encoding; - this.callback = cb; - this.next = null; -} + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; -// It seems a linked list but it is not -// there will be only 2 of these for each stream -function CorkedRequest(state) { - var _this = this; + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); - this.next = null; - this.entry = null; - this.finish = function () { - onCorkedFinish(_this, state); - }; -} -/* */ + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } -/**/ -var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; -/**/ + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } -/**/ -var Duplex; -/**/ + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; -Writable.WritableState = WritableState; + return this; +}; -/**/ -var util = Object.create(require('core-util-is')); -util.inherits = require('inherits'); -/**/ +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._readableState.highWaterMark; + } +}); -/**/ -var internalUtil = { - deprecate: require('util-deprecate') -}; -/**/ +// exposed for testing purposes only. +Readable._fromList = fromList; -/**/ -var Stream = require('./internal/streams/stream'); -/**/ +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; -/**/ + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } -var Buffer = require('safe-buffer').Buffer; -var OurUint8Array = global.Uint8Array || function () {}; -function _uint8ArrayToBuffer(chunk) { - return Buffer.from(chunk); -} -function _isUint8Array(obj) { - return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; + return ret; } -/**/ +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} -var destroyImpl = require('./internal/streams/destroy'); +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} -util.inherits(Writable, Stream); +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} -function nop() {} +function endReadable(stream) { + var state = stream._readableState; -function WritableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); - options = options || {}; + if (!state.endEmitted) { + state.ended = true; + pna.nextTick(endReadableNT, state, stream); + } +} - // 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. - var isDuplex = stream instanceof Duplex; +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} - // object stream flag to indicate whether or not this stream - // contains buffers or objects. - this.objectMode = !!options.objectMode; +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":454,"./internal/streams/BufferList":459,"./internal/streams/destroy":460,"./internal/streams/stream":461,"_process":540,"core-util-is":384,"events":388,"inherits":409,"isarray":462,"process-nextick-args":443,"safe-buffer":463,"string_decoder/":464,"util":102}],457:[function(require,module,exports){ +// 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. - if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; +// 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. - // the point at which write() starts returning false - // Note: 0 is a valid value, means that we always return false if - // the entire buffer is not flushed immediately on write() - var hwm = options.highWaterMark; - var writableHwm = options.writableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; +'use strict'; - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; +module.exports = Transform; - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); +var Duplex = require('./_stream_duplex'); - // if _final has been called - this.finalCalled = false; +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ - // 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; +util.inherits(Transform, Duplex); - // has it been destroyed - this.destroyed = false; +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = 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. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; + var cb = ts.writecb; - // 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.defaultEncoding || 'utf8'; + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); + } - // 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; + ts.writechunk = null; + ts.writecb = null; - // a flag to see when we're in the middle of a write. - this.writing = false; + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); - // when true all writes will be buffered until .uncork() call - this.corked = 0; + cb(er); - // 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; + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} - // 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; +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); - // the callback that's passed to _write(chunk,cb) - this.onwrite = function (er) { - onwrite(stream, er); - }; + Duplex.call(this, options); - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; - // the amount that is being written when _write is called. - this.writelen = 0; + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; - this.bufferedRequest = null; - this.lastBufferedRequest = null; + // 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; - // number of pending user-supplied write callbacks - // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; - // emit prefinish if the only thing we're waiting for is _write cbs - // This is relevant for synchronous Transform streams - this.prefinished = false; + if (typeof options.flush === 'function') this._flush = options.flush; + } - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); +} - // count buffered requests - this.bufferedRequestCount = 0; +function prefinish() { + var _this = this; - // allocate the first CorkedRequest, there is always - // one allocated and free to use, and we maintain at most two - this.corkedRequestsFree = new CorkedRequest(this); + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } } -WritableState.prototype.getBuffer = function getBuffer() { - var current = this.bufferedRequest; - var out = []; - while (current) { - out.push(current); - current = current.next; - } - return out; +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); }; -(function () { - try { - Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function () { - return this.getBuffer(); - }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') - }); - } catch (_) {} -})(); +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; -// Test _writableState for inheritance to account for Duplex streams, -// whose prototype chain only points to Readable. -var realHasInstance; -if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { - realHasInstance = Function.prototype[Symbol.hasInstance]; - Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { - if (realHasInstance.call(this, object)) return true; - if (this !== Writable) return false; - - return object && object._writableState instanceof WritableState; - } - }); -} else { - realHasInstance = function (object) { - return object instanceof this; - }; -} - -function Writable(options) { - Duplex = Duplex || require('./_stream_duplex'); +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; - // Writable ctor is applied to Duplexes, too. - // `realHasInstance` is necessary because using plain `instanceof` - // would return false, as no `_writableState` property is attached. +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; - // Trying to use the custom `instanceof` for Writable here will also break the - // Node.js LazyTransform implementation, which has a non-trivial getter for - // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; } +}; - this._writableState = new WritableState(options, this); +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; - // legacy. - this.writable = true; + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; - if (options) { - if (typeof options.write === 'function') this._write = options.write; +function done(stream, er, data) { + if (er) return stream.emit('error', er); - if (typeof options.writev === 'function') this._writev = options.writev; + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); - if (typeof options.destroy === 'function') this._destroy = options.destroy; + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - if (typeof options.final === 'function') this._final = options.final; - } + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); - Stream.call(this); + return stream.push(null); } +},{"./_stream_duplex":454,"core-util-is":384,"inherits":409}],458:[function(require,module,exports){ +(function (process,global,setImmediate){(function (){ +// 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. -// Otherwise people can pipe Writable streams, which is just wrong. -Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); -}; +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. -function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - pna.nextTick(cb, er); -} +'use strict'; -// Checks that a user-supplied chunk is valid, especially for the particular -// mode the stream is in. Currently this means that `null` is never accepted -// and undefined/non-string values are only allowed in object mode. -function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; +/**/ - if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - if (er) { - stream.emit('error', er); - pna.nextTick(cb, er); - valid = false; - } - return valid; -} +var pna = require('process-nextick-args'); +/**/ -Writable.prototype.write = function (chunk, encoding, cb) { - var state = this._writableState; - var ret = false; - var isBuf = !state.objectMode && _isUint8Array(chunk); +module.exports = Writable; - if (isBuf && !Buffer.isBuffer(chunk)) { - chunk = _uint8ArrayToBuffer(chunk); - } +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} - if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; - if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ - if (typeof cb !== 'function') cb = nop; +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/**/ - if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { - state.pendingcb++; - ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); - } +/**/ +var Duplex; +/**/ - return ret; -}; +Writable.WritableState = WritableState; -Writable.prototype.cork = function () { - var state = this._writableState; +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ - state.corked++; +/**/ +var internalUtil = { + deprecate: require('util-deprecate') }; +/**/ -Writable.prototype.uncork = function () { - var state = this._writableState; +/**/ +var Stream = require('./internal/streams/stream'); +/**/ - if (state.corked) { - state.corked--; +/**/ - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); - } -}; +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} -Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { - // node::ParseEncoding() requires lower case. - if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); - this._writableState.defaultEncoding = encoding; - return this; -}; +/**/ -function decodeChunk(state, chunk, encoding) { - if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { - chunk = Buffer.from(chunk, encoding); - } - return chunk; -} +var destroyImpl = require('./internal/streams/destroy'); -Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function () { - return this._writableState.highWaterMark; - } -}); +util.inherits(Writable, Stream); -// 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, isBuf, chunk, encoding, cb) { - if (!isBuf) { - var newChunk = decodeChunk(state, chunk, encoding); - if (chunk !== newChunk) { - isBuf = true; - encoding = 'buffer'; - chunk = newChunk; - } - } - var len = state.objectMode ? 1 : chunk.length; +function nop() {} - state.length += len; +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. - if (!ret) state.needDrain = true; + options = options || {}; - if (state.writing || state.corked) { - var last = state.lastBufferedRequest; - state.lastBufferedRequest = { - chunk: chunk, - encoding: encoding, - isBuf: isBuf, - callback: cb, - next: null - }; - if (last) { - last.next = state.lastBufferedRequest; - } else { - state.bufferedRequest = state.lastBufferedRequest; - } - state.bufferedRequestCount += 1; - } else { - doWrite(stream, state, false, len, chunk, encoding, cb); - } - - return ret; -} + // 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. + var isDuplex = stream instanceof Duplex; -function doWrite(stream, state, writev, len, chunk, encoding, cb) { - state.writelen = len; - state.writecb = cb; - state.writing = true; - state.sync = true; - if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); - state.sync = false; -} + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; -function onwriteError(stream, state, sync, er, cb) { - --state.pendingcb; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - if (sync) { - // defer the callback if we are being called synchronously - // to avoid piling up things on the stack - pna.nextTick(cb, er); - // this can emit finish, and it will always happen - // after error - pna.nextTick(finishMaybe, stream, state); - stream._writableState.errorEmitted = true; - stream.emit('error', er); - } else { - // the caller expect this to happen before if - // it is async - cb(er); - stream._writableState.errorEmitted = true; - stream.emit('error', er); - // this can emit finish, but finish must - // always follow error - finishMaybe(stream, state); - } -} + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; -function onwriteStateUpdate(state) { - state.writing = false; - state.writecb = null; - state.length -= state.writelen; - state.writelen = 0; -} + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; -function onwrite(stream, er) { - var state = stream._writableState; - var sync = state.sync; - var cb = state.writecb; + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); - onwriteStateUpdate(state); + // if _final has been called + this.finalCalled = false; - if (er) onwriteError(stream, state, sync, er, cb);else { - // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state); + // 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; - if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { - clearBuffer(stream, state); - } + // has it been destroyed + this.destroyed = false; - if (sync) { - /**/ - asyncWrite(afterWrite, stream, state, finished, cb); - /**/ - } else { - afterWrite(stream, state, finished, cb); - } - } -} + // 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. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; -function afterWrite(stream, state, finished, cb) { - if (!finished) onwriteDrain(stream, state); - state.pendingcb--; - cb(); - finishMaybe(stream, state); -} + // 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.defaultEncoding || 'utf8'; -// Must force callback to be called on nextTick, so that we don't -// emit 'drain' before the write() consumer gets the 'false' return -// value, and has a chance to attach a 'drain' listener. -function onwriteDrain(stream, state) { - if (state.length === 0 && state.needDrain) { - state.needDrain = false; - stream.emit('drain'); - } -} + // 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; -// if there's something in the buffer waiting, then process it -function clearBuffer(stream, state) { - state.bufferProcessing = true; - var entry = state.bufferedRequest; + // a flag to see when we're in the middle of a write. + this.writing = false; - if (stream._writev && entry && entry.next) { - // Fast case, write everything using _writev() - var l = state.bufferedRequestCount; - var buffer = new Array(l); - var holder = state.corkedRequestsFree; - holder.entry = entry; + // when true all writes will be buffered until .uncork() call + this.corked = 0; - var count = 0; - var allBuffers = true; - while (entry) { - buffer[count] = entry; - if (!entry.isBuf) allBuffers = false; - entry = entry.next; - count += 1; - } - buffer.allBuffers = allBuffers; + // 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; - doWrite(stream, state, true, state.length, buffer, '', holder.finish); + // 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; - // doWrite is almost always async, defer these to save a bit of time - // as the hot path ends with doWrite - state.pendingcb++; - state.lastBufferedRequest = null; - if (holder.next) { - state.corkedRequestsFree = holder.next; - holder.next = null; - } else { - state.corkedRequestsFree = new CorkedRequest(state); - } - state.bufferedRequestCount = 0; - } else { - // Slow case, write chunks one-by-one - while (entry) { - var chunk = entry.chunk; - var encoding = entry.encoding; - var cb = entry.callback; - var len = state.objectMode ? 1 : chunk.length; + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; - doWrite(stream, state, false, len, chunk, encoding, cb); - entry = entry.next; - state.bufferedRequestCount--; - // if we didn't call the onwrite immediately, then - // it means that we need to wait until it does. - // also, that means that the chunk and cb are currently - // being processed, so move the buffer counter past them. - if (state.writing) { - break; - } - } + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; - if (entry === null) state.lastBufferedRequest = null; - } + // the amount that is being written when _write is called. + this.writelen = 0; - state.bufferedRequest = entry; - state.bufferProcessing = false; -} + this.bufferedRequest = null; + this.lastBufferedRequest = null; -Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); -}; + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; -Writable.prototype._writev = null; + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; -Writable.prototype.end = function (chunk, encoding, cb) { - var state = this._writableState; + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; - if (typeof chunk === 'function') { - cb = chunk; - chunk = null; - encoding = null; - } else if (typeof encoding === 'function') { - cb = encoding; - encoding = null; - } + // count buffered requests + this.bufferedRequestCount = 0; - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} - // .end() fully uncorks - if (state.corked) { - state.corked = 1; - this.uncork(); +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; } - - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) endWritable(this, state, cb); + return out; }; -function needFinish(state) { - return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; -} -function callFinal(stream, state) { - stream._final(function (err) { - state.pendingcb--; - if (err) { - stream.emit('error', err); +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + + return object && object._writableState instanceof WritableState; } - state.prefinished = true; - stream.emit('prefinish'); - finishMaybe(stream, state); }); -} -function prefinish(stream, state) { - if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function') { - state.pendingcb++; - state.finalCalled = true; - pna.nextTick(callFinal, stream, state); - } else { - state.prefinished = true; - stream.emit('prefinish'); - } - } +} else { + realHasInstance = function (object) { + return object instanceof this; + }; } -function finishMaybe(stream, state) { - var need = needFinish(state); - if (need) { - prefinish(stream, state); - if (state.pendingcb === 0) { - state.finished = true; - stream.emit('finish'); - } - } - return need; -} +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); -function endWritable(stream, state, cb) { - state.ending = true; - finishMaybe(stream, state); - if (cb) { - if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); - } - state.ended = true; - stream.writable = false; -} + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. -function onCorkedFinish(corkReq, state, err) { - var entry = corkReq.entry; - corkReq.entry = null; - while (entry) { - var cb = entry.callback; - state.pendingcb--; - cb(err); - entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); } -} -Object.defineProperty(Writable.prototype, 'destroyed', { - get: function () { - if (this._writableState === undefined) { - return false; - } - return this._writableState.destroyed; - }, - set: function (value) { - // we ignore the value if the stream - // has not been initialized yet - if (!this._writableState) { - return; - } + this._writableState = new WritableState(options, this); - // backward compatibility, the user is explicitly - // managing destroyed - this._writableState.destroyed = value; - } -}); + // legacy. + this.writable = true; -Writable.prototype.destroy = destroyImpl.destroy; -Writable.prototype._undestroy = destroyImpl.undestroy; -Writable.prototype._destroy = function (err, cb) { - this.end(); - cb(err); -}; -}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) -},{"./_stream_duplex":330,"./internal/streams/destroy":336,"./internal/streams/stream":337,"_process":399,"core-util-is":298,"inherits":311,"process-nextick-args":323,"safe-buffer":343,"timers":347,"util-deprecate":349}],335:[function(require,module,exports){ -'use strict'; + if (options) { + if (typeof options.write === 'function') this._write = options.write; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + if (typeof options.writev === 'function') this._writev = options.writev; -var Buffer = require('safe-buffer').Buffer; -var util = require('util'); + if (typeof options.destroy === 'function') this._destroy = options.destroy; -function copyBuffer(src, target, offset) { - src.copy(target, offset); + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); } -module.exports = function () { - function BufferList() { - _classCallCheck(this, BufferList); +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; - this.head = null; - this.tail = null; - this.length = 0; - } +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + pna.nextTick(cb, er); +} - BufferList.prototype.push = function push(v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; - }; +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; - BufferList.prototype.unshift = function unshift(v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; - }; + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + pna.nextTick(cb, er); + valid = false; + } + return valid; +} - BufferList.prototype.shift = function shift() { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; - }; +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); - BufferList.prototype.clear = function clear() { - this.head = this.tail = null; - this.length = 0; - }; + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } - BufferList.prototype.join = function join(s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; - }; + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } - BufferList.prototype.concat = function concat(n) { - if (this.length === 0) return Buffer.alloc(0); - if (this.length === 1) return this.head.data; - var ret = Buffer.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; - } - return ret; - }; + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - return BufferList; -}(); + if (typeof cb !== 'function') cb = nop; -if (util && util.inspect && util.inspect.custom) { - module.exports.prototype[util.inspect.custom] = function () { - var obj = util.inspect({ length: this.length }); - return this.constructor.name + ' ' + obj; - }; -} -},{"safe-buffer":343,"util":84}],336:[function(require,module,exports){ -'use strict'; + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } -/**/ + return ret; +}; -var pna = require('process-nextick-args'); -/**/ +Writable.prototype.cork = function () { + var state = this._writableState; -// undocumented cb() API, needed for core, not for public API -function destroy(err, cb) { - var _this = this; + state.corked++; +}; - var readableDestroyed = this._readableState && this._readableState.destroyed; - var writableDestroyed = this._writableState && this._writableState.destroyed; +Writable.prototype.uncork = function () { + var state = this._writableState; - if (readableDestroyed || writableDestroyed) { - if (cb) { - cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - pna.nextTick(emitErrorNT, this, err); - } - return this; - } + if (state.corked) { + state.corked--; - // we set destroyed to true before firing error callbacks in order - // to make it re-entrance safe in case destroy() is called within callbacks + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; - if (this._readableState) { - this._readableState.destroyed = true; - } +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; - // if this is a duplex stream mark the writable part as destroyed as well - if (this._writableState) { - this._writableState.destroyed = true; +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); } - - this._destroy(err || null, function (err) { - if (!cb && err) { - pna.nextTick(emitErrorNT, _this, err); - if (_this._writableState) { - _this._writableState.errorEmitted = true; - } - } else if (cb) { - cb(err); - } - }); - - return this; + return chunk; } -function undestroy() { - if (this._readableState) { - this._readableState.destroyed = false; - this._readableState.reading = false; - this._readableState.ended = false; - this._readableState.endEmitted = false; +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; } +}); - if (this._writableState) { - this._writableState.destroyed = false; - this._writableState.ended = false; - this._writableState.ending = false; - this._writableState.finished = false; - this._writableState.errorEmitted = false; +// 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, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } } -} - -function emitErrorNT(self, err) { - self.emit('error', err); -} + var len = state.objectMode ? 1 : chunk.length; -module.exports = { - destroy: destroy, - undestroy: undestroy -}; -},{"process-nextick-args":323}],337:[function(require,module,exports){ -module.exports = require('events').EventEmitter; + state.length += len; -},{"events":301}],338:[function(require,module,exports){ -module.exports = require('./readable').PassThrough + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; -},{"./readable":339}],339:[function(require,module,exports){ -exports = module.exports = require('./lib/_stream_readable.js'); -exports.Stream = exports; -exports.Readable = exports; -exports.Writable = require('./lib/_stream_writable.js'); -exports.Duplex = require('./lib/_stream_duplex.js'); -exports.Transform = require('./lib/_stream_transform.js'); -exports.PassThrough = require('./lib/_stream_passthrough.js'); + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } -},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334}],340:[function(require,module,exports){ -module.exports = require('./readable').Transform + return ret; +} -},{"./readable":339}],341:[function(require,module,exports){ -module.exports = require('./lib/_stream_writable.js'); +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} -},{"./lib/_stream_writable.js":334}],342:[function(require,module,exports){ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; -var runtime = (function (exports) { - "use strict"; + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + pna.nextTick(cb, er); + // this can emit finish, and it will always happen + // after error + pna.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } +} - var Op = Object.prototype; - var hasOwn = Op.hasOwnProperty; - var undefined; // More compressible than void 0. - var $Symbol = typeof Symbol === "function" ? Symbol : {}; - var iteratorSymbol = $Symbol.iterator || "@@iterator"; - var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; - var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} - function define(obj, key, value) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - return obj[key]; - } - try { - // IE 8 has a broken Object.defineProperty that only works on DOM objects. - define({}, ""); - } catch (err) { - define = function(obj, key, value) { - return obj[key] = value; - }; - } +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; - function wrap(innerFn, outerFn, self, tryLocsList) { - // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. - var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; - var generator = Object.create(protoGenerator.prototype); - var context = new Context(tryLocsList || []); + onwriteStateUpdate(state); - // The ._invoke method unifies the implementations of the .next, - // .throw, and .return methods. - generator._invoke = makeInvokeMethod(innerFn, self, context); + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); - return generator; - } - exports.wrap = wrap; + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } - // Try/catch helper to minimize deoptimizations. Returns a completion - // record like context.tryEntries[i].completion. This interface could - // have been (and was previously) designed to take a closure to be - // invoked without arguments, but in all the cases we care about we - // already have an existing method we want to call, so there's no need - // to create a new function object. We can even get away with assuming - // the method takes exactly one argument, since that happens to be true - // in every case, so we don't have to touch the arguments object. The - // only additional allocation required is the completion record, which - // has a stable shape and so hopefully should be cheap to allocate. - function tryCatch(fn, obj, arg) { - try { - return { type: "normal", arg: fn.call(obj, arg) }; - } catch (err) { - return { type: "throw", arg: err }; + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); } } +} - var GenStateSuspendedStart = "suspendedStart"; - var GenStateSuspendedYield = "suspendedYield"; - var GenStateExecuting = "executing"; - var GenStateCompleted = "completed"; - - // Returning this object from the innerFn has the same effect as - // breaking out of the dispatch switch statement. - var ContinueSentinel = {}; +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} - // Dummy constructor functions that we use as the .constructor and - // .constructor.prototype properties for functions that return Generator - // objects. For full spec compliance, you may wish to configure your - // minifier not to mangle the names of these two functions. - function Generator() {} - function GeneratorFunction() {} - function GeneratorFunctionPrototype() {} +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} - // This is a polyfill for %IteratorPrototype% for environments that - // don't natively support it. - var IteratorPrototype = {}; - define(IteratorPrototype, iteratorSymbol, function () { - return this; - }); +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; - var getProto = Object.getPrototypeOf; - var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); - if (NativeIteratorPrototype && - NativeIteratorPrototype !== Op && - hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { - // This environment has a native %IteratorPrototype%; use it instead - // of the polyfill. - IteratorPrototype = NativeIteratorPrototype; - } - - var Gp = GeneratorFunctionPrototype.prototype = - Generator.prototype = Object.create(IteratorPrototype); - GeneratorFunction.prototype = GeneratorFunctionPrototype; - define(Gp, "constructor", GeneratorFunctionPrototype); - define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); - GeneratorFunction.displayName = define( - GeneratorFunctionPrototype, - toStringTagSymbol, - "GeneratorFunction" - ); + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; - // Helper for defining the .next, .throw, and .return methods of the - // Iterator interface in terms of a single ._invoke method. - function defineIteratorMethods(prototype) { - ["next", "throw", "return"].forEach(function(method) { - define(prototype, method, function(arg) { - return this._invoke(method, arg); - }); - }); - } + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; - exports.isGeneratorFunction = function(genFun) { - var ctor = typeof genFun === "function" && genFun.constructor; - return ctor - ? ctor === GeneratorFunction || - // For the native GeneratorFunction constructor, the best we can - // do is to check its .name property. - (ctor.displayName || ctor.name) === "GeneratorFunction" - : false; - }; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); - exports.mark = function(genFun) { - if (Object.setPrototypeOf) { - Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; } else { - genFun.__proto__ = GeneratorFunctionPrototype; - define(genFun, toStringTagSymbol, "GeneratorFunction"); + state.corkedRequestsFree = new CorkedRequest(state); } - genFun.prototype = Object.create(Gp); - return genFun; - }; - - // Within the body of any async function, `await x` is transformed to - // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test - // `hasOwn.call(value, "__await")` to determine if the yielded value is - // meant to be awaited. - exports.awrap = function(arg) { - return { __await: arg }; - }; - - function AsyncIterator(generator, PromiseImpl) { - function invoke(method, arg, resolve, reject) { - var record = tryCatch(generator[method], generator, arg); - if (record.type === "throw") { - reject(record.arg); - } else { - var result = record.arg; - var value = result.value; - if (value && - typeof value === "object" && - hasOwn.call(value, "__await")) { - return PromiseImpl.resolve(value.__await).then(function(value) { - invoke("next", value, resolve, reject); - }, function(err) { - invoke("throw", err, resolve, reject); - }); - } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; - return PromiseImpl.resolve(value).then(function(unwrapped) { - // When a yielded Promise is resolved, its final value becomes - // the .value of the Promise<{value,done}> result for the - // current iteration. - result.value = unwrapped; - resolve(result); - }, function(error) { - // If a rejected Promise was yielded, throw the rejection back - // into the async generator function so it can be handled there. - return invoke("throw", error, resolve, reject); - }); + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; } } - var previousPromise; + if (entry === null) state.lastBufferedRequest = null; + } - function enqueue(method, arg) { - function callInvokeWithMethodAndArg() { - return new PromiseImpl(function(resolve, reject) { - invoke(method, arg, resolve, reject); - }); - } - - return previousPromise = - // If enqueue has been called before, then we want to wait until - // all previous Promises have been resolved before calling invoke, - // so that results are always delivered in the correct order. If - // enqueue has not been called before, then it is important to - // call invoke immediately, without waiting on a callback to fire, - // so that the async generator function has the opportunity to do - // any necessary setup in a predictable way. This predictability - // is why the Promise constructor synchronously invokes its - // executor callback, and why async functions synchronously - // execute code before the first await. Since we implement simple - // async functions in terms of async generators, it is especially - // important to get this right, even though it requires care. - previousPromise ? previousPromise.then( - callInvokeWithMethodAndArg, - // Avoid propagating failures to Promises returned by later - // invocations of the iterator. - callInvokeWithMethodAndArg - ) : callInvokeWithMethodAndArg(); - } - - // Define the unified helper method that is used to implement .next, - // .throw, and .return (see defineIteratorMethods). - this._invoke = enqueue; - } - - defineIteratorMethods(AsyncIterator.prototype); - define(AsyncIterator.prototype, asyncIteratorSymbol, function () { - return this; - }); - exports.AsyncIterator = AsyncIterator; - - // Note that simple async functions are implemented on top of - // AsyncIterator objects; they just return a Promise for the value of - // the final result produced by the iterator. - exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) { - if (PromiseImpl === void 0) PromiseImpl = Promise; - - var iter = new AsyncIterator( - wrap(innerFn, outerFn, self, tryLocsList), - PromiseImpl - ); - - return exports.isGeneratorFunction(outerFn) - ? iter // If outerFn is a generator, return the full iterator. - : iter.next().then(function(result) { - return result.done ? result.value : iter.next(); - }); - }; - - function makeInvokeMethod(innerFn, self, context) { - var state = GenStateSuspendedStart; - - return function invoke(method, arg) { - if (state === GenStateExecuting) { - throw new Error("Generator is already running"); - } - - if (state === GenStateCompleted) { - if (method === "throw") { - throw arg; - } - - // Be forgiving, per 25.3.3.3.3 of the spec: - // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume - return doneResult(); - } - - context.method = method; - context.arg = arg; - - while (true) { - var delegate = context.delegate; - if (delegate) { - var delegateResult = maybeInvokeDelegate(delegate, context); - if (delegateResult) { - if (delegateResult === ContinueSentinel) continue; - return delegateResult; - } - } - - if (context.method === "next") { - // Setting context._sent for legacy support of Babel's - // function.sent implementation. - context.sent = context._sent = context.arg; - - } else if (context.method === "throw") { - if (state === GenStateSuspendedStart) { - state = GenStateCompleted; - throw context.arg; - } - - context.dispatchException(context.arg); + state.bufferedRequest = entry; + state.bufferProcessing = false; +} - } else if (context.method === "return") { - context.abrupt("return", context.arg); - } +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); +}; - state = GenStateExecuting; +Writable.prototype._writev = null; - var record = tryCatch(innerFn, self, context); - if (record.type === "normal") { - // If an exception is thrown from innerFn, we leave state === - // GenStateExecuting and loop back for another invocation. - state = context.done - ? GenStateCompleted - : GenStateSuspendedYield; +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; - if (record.arg === ContinueSentinel) { - continue; - } + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } - return { - value: record.arg, - done: context.done - }; + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); - } else if (record.type === "throw") { - state = GenStateCompleted; - // Dispatch the exception by looping back around to the - // context.dispatchException(context.arg) call above. - context.method = "throw"; - context.arg = record.arg; - } - } - }; + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); } - // Call delegate.iterator[context.method](context.arg) and handle the - // result, either by returning a { value, done } result from the - // delegate iterator, or by modifying context.method and context.arg, - // setting context.delegate to null, and returning the ContinueSentinel. - function maybeInvokeDelegate(delegate, context) { - var method = delegate.iterator[context.method]; - if (method === undefined) { - // A .throw or .return when the delegate iterator has no .throw - // method always terminates the yield* loop. - context.delegate = null; - - if (context.method === "throw") { - // Note: ["return"] must be used for ES3 parsing compatibility. - if (delegate.iterator["return"]) { - // If the delegate iterator has a return method, give it a - // chance to clean up. - context.method = "return"; - context.arg = undefined; - maybeInvokeDelegate(delegate, context); - - if (context.method === "throw") { - // If maybeInvokeDelegate(context) changed context.method from - // "return" to "throw", let that override the TypeError below. - return ContinueSentinel; - } - } - - context.method = "throw"; - context.arg = new TypeError( - "The iterator does not provide a 'throw' method"); - } + // ignore unnecessary end() calls. + if (!state.ending) endWritable(this, state, cb); +}; - return ContinueSentinel; +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); } - - var record = tryCatch(method, delegate.iterator, context.arg); - - if (record.type === "throw") { - context.method = "throw"; - context.arg = record.arg; - context.delegate = null; - return ContinueSentinel; + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + pna.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); } + } +} - var info = record.arg; - - if (! info) { - context.method = "throw"; - context.arg = new TypeError("iterator result is not an object"); - context.delegate = null; - return ContinueSentinel; +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); } + } + return need; +} - if (info.done) { - // Assign the result of the finished delegate to the temporary - // variable specified by delegate.resultName (see delegateYield). - context[delegate.resultName] = info.value; +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} - // Resume execution at the desired location (see delegateYield). - context.next = delegate.nextLoc; +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } - // If context.method was "throw" but the delegate handled the - // exception, let the outer generator proceed normally. If - // context.method was "next", forget context.arg since it has been - // "consumed" by the delegate iterator. If context.method was - // "return", allow the original .return call to continue in the - // outer generator. - if (context.method !== "return") { - context.method = "next"; - context.arg = undefined; - } + // reuse the free corkReq. + state.corkedRequestsFree.next = corkReq; +} - } else { - // Re-yield the result returned by the delegate method. - return info; +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; } - // The delegate iterator is finished, so forget it and continue with - // the outer generator. - context.delegate = null; - return ContinueSentinel; + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; } +}); - // Define Generator.prototype.{next,throw,return} in terms of the - // unified ._invoke helper method. - defineIteratorMethods(Gp); +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) +},{"./_stream_duplex":454,"./internal/streams/destroy":460,"./internal/streams/stream":461,"_process":540,"core-util-is":384,"inherits":409,"process-nextick-args":443,"safe-buffer":463,"timers":486,"util-deprecate":488}],459:[function(require,module,exports){ +'use strict'; - define(Gp, toStringTagSymbol, "Generator"); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - // A Generator should always return itself as the iterator object when the - // @@iterator function is called on it. Some browsers' implementations of the - // iterator prototype chain incorrectly implement this, causing the Generator - // object to not be returned from this call. This ensures that doesn't happen. - // See https://github.com/facebook/regenerator/issues/274 for more details. - define(Gp, iteratorSymbol, function() { - return this; - }); +var Buffer = require('safe-buffer').Buffer; +var util = require('util'); - define(Gp, "toString", function() { - return "[object Generator]"; - }); +function copyBuffer(src, target, offset) { + src.copy(target, offset); +} - function pushTryEntry(locs) { - var entry = { tryLoc: locs[0] }; +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); - if (1 in locs) { - entry.catchLoc = locs[1]; - } + this.head = null; + this.tail = null; + this.length = 0; + } - if (2 in locs) { - entry.finallyLoc = locs[2]; - entry.afterLoc = locs[3]; - } + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; - this.tryEntries.push(entry); - } + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; - function resetTryEntry(entry) { - var record = entry.completion || {}; - record.type = "normal"; - delete record.arg; - entry.completion = record; - } + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; - function Context(tryLocsList) { - // The root entry object (effectively a try statement without a catch - // or a finally block) gives us a place to store values thrown from - // locations where there is no enclosing try statement. - this.tryEntries = [{ tryLoc: "root" }]; - tryLocsList.forEach(pushTryEntry, this); - this.reset(true); - } + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; - exports.keys = function(object) { - var keys = []; - for (var key in object) { - keys.push(key); - } - keys.reverse(); - - // Rather than returning an object with a next method, we keep - // things simple and return the next function itself. - return function next() { - while (keys.length) { - var key = keys.pop(); - if (key in object) { - next.value = key; - next.done = false; - return next; - } - } + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; - // To avoid creating an additional object, we just hang the .value - // and .done properties off the next function object itself. This - // also ensures that the minifier will not anonymize the function. - next.done = true; - return next; - }; + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; }; - function values(iterable) { - if (iterable) { - var iteratorMethod = iterable[iteratorSymbol]; - if (iteratorMethod) { - return iteratorMethod.call(iterable); - } + return BufferList; +}(); - if (typeof iterable.next === "function") { - return iterable; - } +if (util && util.inspect && util.inspect.custom) { + module.exports.prototype[util.inspect.custom] = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; + }; +} +},{"safe-buffer":463,"util":102}],460:[function(require,module,exports){ +'use strict'; - if (!isNaN(iterable.length)) { - var i = -1, next = function next() { - while (++i < iterable.length) { - if (hasOwn.call(iterable, i)) { - next.value = iterable[i]; - next.done = false; - return next; - } - } +/**/ - next.value = undefined; - next.done = true; +var pna = require('process-nextick-args'); +/**/ - return next; - }; +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; - return next.next = next; + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err) { + if (!this._writableState) { + pna.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + pna.nextTick(emitErrorNT, this, err); } } - // Return an iterator with no values. - return { next: doneResult }; + return this; } - exports.values = values; - function doneResult() { - return { value: undefined, done: true }; + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + if (this._readableState) { + this._readableState.destroyed = true; } - Context.prototype = { - constructor: Context, + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } - reset: function(skipTempReset) { - this.prev = 0; - this.next = 0; - // Resetting context._sent for legacy support of Babel's - // function.sent implementation. - this.sent = this._sent = undefined; - this.done = false; - this.delegate = null; - - this.method = "next"; - this.arg = undefined; - - this.tryEntries.forEach(resetTryEntry); - - if (!skipTempReset) { - for (var name in this) { - // Not sure about the optimal order of these conditions: - if (name.charAt(0) === "t" && - hasOwn.call(this, name) && - !isNaN(+name.slice(1))) { - this[name] = undefined; - } - } - } - }, - - stop: function() { - this.done = true; - - var rootEntry = this.tryEntries[0]; - var rootRecord = rootEntry.completion; - if (rootRecord.type === "throw") { - throw rootRecord.arg; - } - - return this.rval; - }, - - dispatchException: function(exception) { - if (this.done) { - throw exception; - } - - var context = this; - function handle(loc, caught) { - record.type = "throw"; - record.arg = exception; - context.next = loc; - - if (caught) { - // If the dispatched exception was caught by a catch block, - // then let that catch block handle the exception normally. - context.method = "next"; - context.arg = undefined; - } - - return !! caught; - } - - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - var record = entry.completion; - - if (entry.tryLoc === "root") { - // Exception thrown outside of any try block that could handle - // it, so set the completion value of the entire function to - // throw the exception. - return handle("end"); - } - - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"); - var hasFinally = hasOwn.call(entry, "finallyLoc"); - - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } else if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - - } else if (hasCatch) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } - - } else if (hasFinally) { - if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - - } else { - throw new Error("try statement without catch or finally"); - } - } - } - }, - - abrupt: function(type, arg) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc <= this.prev && - hasOwn.call(entry, "finallyLoc") && - this.prev < entry.finallyLoc) { - var finallyEntry = entry; - break; - } - } - - if (finallyEntry && - (type === "break" || - type === "continue") && - finallyEntry.tryLoc <= arg && - arg <= finallyEntry.finallyLoc) { - // Ignore the finally entry if control is not jumping to a - // location outside the try/catch block. - finallyEntry = null; - } - - var record = finallyEntry ? finallyEntry.completion : {}; - record.type = type; - record.arg = arg; - - if (finallyEntry) { - this.method = "next"; - this.next = finallyEntry.finallyLoc; - return ContinueSentinel; - } - - return this.complete(record); - }, - - complete: function(record, afterLoc) { - if (record.type === "throw") { - throw record.arg; - } - - if (record.type === "break" || - record.type === "continue") { - this.next = record.arg; - } else if (record.type === "return") { - this.rval = this.arg = record.arg; - this.method = "return"; - this.next = "end"; - } else if (record.type === "normal" && afterLoc) { - this.next = afterLoc; - } - - return ContinueSentinel; - }, - - finish: function(finallyLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.finallyLoc === finallyLoc) { - this.complete(entry.completion, entry.afterLoc); - resetTryEntry(entry); - return ContinueSentinel; - } - } - }, - - "catch": function(tryLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc === tryLoc) { - var record = entry.completion; - if (record.type === "throw") { - var thrown = record.arg; - resetTryEntry(entry); - } - return thrown; - } + this._destroy(err || null, function (err) { + if (!cb && err) { + if (!_this._writableState) { + pna.nextTick(emitErrorNT, _this, err); + } else if (!_this._writableState.errorEmitted) { + _this._writableState.errorEmitted = true; + pna.nextTick(emitErrorNT, _this, err); } + } else if (cb) { + cb(err); + } + }); - // The context.catch method must only be called with a location - // argument that corresponds to a known catch block. - throw new Error("illegal catch attempt"); - }, + return this; +} - delegateYield: function(iterable, resultName, nextLoc) { - this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }; +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } - if (this.method === "next") { - // Deliberately forget the last sent value so that we don't - // accidentally pass it on to the delegate. - this.arg = undefined; - } + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} - return ContinueSentinel; - } - }; +function emitErrorNT(self, err) { + self.emit('error', err); +} - // Regardless of whether this script is executing as a CommonJS module - // or not, return the runtime object so that we can declare the variable - // regeneratorRuntime in the outer scope, which allows this module to be - // injected easily by `bin/regenerator --include-runtime script.js`. - return exports; +module.exports = { + destroy: destroy, + undestroy: undestroy +}; +},{"process-nextick-args":443}],461:[function(require,module,exports){ +module.exports = require('events').EventEmitter; -}( - // If this script is executing as a CommonJS module, use module.exports - // as the regeneratorRuntime namespace. Otherwise create a new empty - // object. Either way, the resulting object will be used to initialize - // the regeneratorRuntime variable at the top of this file. - typeof module === "object" ? module.exports : {} -)); +},{"events":388}],462:[function(require,module,exports){ +var toString = {}.toString; -try { - regeneratorRuntime = runtime; -} catch (accidentalStrictMode) { - // This module should not be running in strict mode, so the above - // assignment should always work unless something is misconfigured. Just - // in case runtime.js accidentally runs in strict mode, in modern engines - // we can explicitly access globalThis. In older engines we can escape - // strict mode using a global Function call. This could conceivably fail - // if a Content Security Policy forbids using Function, but in that case - // the proper solution is to fix the accidental strict mode problem. If - // you've misconfigured your bundler to force strict mode and applied a - // CSP to forbid Function, and you're not willing to fix either of those - // problems, please detail your unique predicament in a GitHub issue. - if (typeof globalThis === "object") { - globalThis.regeneratorRuntime = runtime; - } else { - Function("r", "regeneratorRuntime = r")(runtime); - } -} +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; -},{}],343:[function(require,module,exports){ +},{}],463:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -26478,407 +30166,781 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":85}],344:[function(require,module,exports){ -(function (Buffer){(function (){ -;(function (sax) { // wrapper for non-node envs - sax.parser = function (strict, opt) { return new SAXParser(strict, opt) } - sax.SAXParser = SAXParser - sax.SAXStream = SAXStream - sax.createStream = createStream - - // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. - // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), - // since that's the earliest that a buffer overrun could occur. This way, checks are - // as rare as required, but as often as necessary to ensure never crossing this bound. - // Furthermore, buffers are only tested at most once per write(), so passing a very - // large string into write() might have undesirable effects, but this is manageable by - // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme - // edge case, result in creating at most one complete copy of the string passed in. - // Set to Infinity to have unlimited buffers. - sax.MAX_BUFFER_LENGTH = 64 * 1024 - - var buffers = [ - 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', - 'procInstName', 'procInstBody', 'entity', 'attribName', - 'attribValue', 'cdata', 'script' - ] - - sax.EVENTS = [ - 'text', - 'processinginstruction', - 'sgmldeclaration', - 'doctype', - 'comment', - 'opentagstart', - 'attribute', - 'opentag', - 'closetag', - 'opencdata', - 'cdata', - 'closecdata', - 'error', - 'end', - 'ready', - 'script', - 'opennamespace', - 'closenamespace' - ] +},{"buffer":103}],464:[function(require,module,exports){ +// 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. - function SAXParser (strict, opt) { - if (!(this instanceof SAXParser)) { - return new SAXParser(strict, opt) - } +'use strict'; - var parser = this - clearBuffers(parser) - parser.q = parser.c = '' - parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH - parser.opt = opt || {} - parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags - parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase' - parser.tags = [] - parser.closed = parser.closedRoot = parser.sawRoot = false - parser.tag = parser.error = null - parser.strict = !!strict - parser.noscript = !!(strict || parser.opt.noscript) - parser.state = S.BEGIN - parser.strictEntities = parser.opt.strictEntities - parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES) - parser.attribList = [] +/**/ - // namespaces form a prototype chain. - // it always points at the current tag, - // which protos to its parent tag. - if (parser.opt.xmlns) { - parser.ns = Object.create(rootNS) - } +var Buffer = require('safe-buffer').Buffer; +/**/ - // mostly just for error reporting - parser.trackPosition = parser.opt.position !== false - if (parser.trackPosition) { - parser.position = parser.line = parser.column = 0 - } - emit(parser, 'onready') +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; } +}; - if (!Object.create) { - Object.create = function (o) { - function F () {} - F.prototype = o - var newf = new F() - return newf +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; } } +}; - if (!Object.keys) { - Object.keys = function (o) { - var a = [] - for (var i in o) if (o.hasOwnProperty(i)) a.push(i) - return a - } - } +// 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; +} - function checkBufferLength (parser) { - var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10) - var maxActual = 0 - for (var i = 0, l = buffers.length; i < l; i++) { - var len = parser[buffers[i]].length - if (len > maxAllowed) { - // Text/cdata nodes can get big, and since they're buffered, - // we can get here under normal conditions. - // Avoid issues by emitting the text node now, - // so at least it won't get any bigger. - switch (buffers[i]) { - case 'textNode': - closeText(parser) - break - - case 'cdata': - emitNode(parser, 'oncdata', parser.cdata) - parser.cdata = '' - break - - case 'script': - emitNode(parser, 'onscript', parser.script) - parser.script = '' - break - - default: - error(parser, 'Max buffer length exceeded: ' + buffers[i]) - } - } - maxActual = Math.max(maxActual, len) - } - // schedule the next check for the earliest possible buffer overrun. - var m = sax.MAX_BUFFER_LENGTH - maxActual - parser.bufferCheckPosition = m + parser.position +// 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); +} - function clearBuffers (parser) { - for (var i = 0, l = buffers.length; i < l; i++) { - parser[buffers[i]] = '' - } +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 || ''; +}; - function flushBuffers (parser) { - closeText(parser) - if (parser.cdata !== '') { - emitNode(parser, 'oncdata', parser.cdata) - parser.cdata = '' - } - if (parser.script !== '') { - emitNode(parser, 'onscript', parser.script) - parser.script = '' - } - } +StringDecoder.prototype.end = utf8End; - SAXParser.prototype = { - end: function () { end(this) }, - write: write, - resume: function () { this.error = null; return this }, - close: function () { return this.write(null) }, - flush: function () { flushBuffers(this) } - } +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; - var Stream - try { - Stream = require('stream').Stream - } catch (ex) { - Stream = function () {} +// 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; +}; - var streamWraps = sax.EVENTS.filter(function (ev) { - return ev !== 'error' && ev !== 'end' - }) +// 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; +} - function createStream (strict, opt) { - return new SAXStream(strict, opt) +// 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; } - - function SAXStream (strict, opt) { - if (!(this instanceof SAXStream)) { - return new SAXStream(strict, opt) - } - - Stream.apply(this) - - this._parser = new SAXParser(strict, opt) - this.writable = true - this.readable = true - - var me = this - - this._parser.onend = function () { - me.emit('end') - } - - this._parser.onerror = function (er) { - me.emit('error', er) - - // if didn't throw, then means error was handled. - // go ahead and clear error, so we can write again. - me._parser.error = null + 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; } - - this._decoder = null - - streamWraps.forEach(function (ev) { - Object.defineProperty(me, 'on' + ev, { - get: function () { - return me._parser['on' + ev] - }, - set: function (h) { - if (!h) { - me.removeAllListeners(ev) - me._parser['on' + ev] = h - return h - } - me.on(ev, h) - }, - enumerable: true, - configurable: false - }) - }) + return nb; } + return 0; +} - SAXStream.prototype = Object.create(Stream.prototype, { - constructor: { - value: SAXStream +// 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'; } - }) - - SAXStream.prototype.write = function (data) { - if (typeof Buffer === 'function' && - typeof Buffer.isBuffer === 'function' && - Buffer.isBuffer(data)) { - if (!this._decoder) { - var SD = require('string_decoder').StringDecoder - this._decoder = new SD('utf8') + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; } - data = this._decoder.write(data) } - - this._parser.write(data.toString()) - this.emit('data', data) - return true } +} - SAXStream.prototype.end = function (chunk) { - if (chunk && chunk.length) { - this.write(chunk) - } - this._parser.end() - return true +// 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; +} - SAXStream.prototype.on = function (ev, handler) { - var me = this - if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) { - me._parser['on' + ev] = function () { - var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments) - args.splice(0, 0, ev) - me.emit.apply(me, args) +// 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); +} - return Stream.prototype.on.call(me, ev, handler) +// 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; +} - // this really needs to be replaced with character classes. - // XML allows all manner of ridiculous numbers and digits. - var CDATA = '[CDATA[' - var DOCTYPE = 'DOCTYPE' - var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace' - var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/' - var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE } +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); +} - // http://www.w3.org/TR/REC-xml/#NT-NameStartChar - // This implementation works on strings, a single character at a time - // as such, it cannot ever support astral-plane characters (10000-EFFFF) - // without a significant breaking change to either this parser, or the - // JavaScript language. Implementation of an emoji-capable xml parser - // is left as an exercise for the reader. - var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ +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; +} - var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/ +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} - var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ - var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/ +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} +},{"safe-buffer":463}],465:[function(require,module,exports){ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); - function isWhitespace (c) { - return c === ' ' || c === '\n' || c === '\r' || c === '\t' - } +},{"./lib/_stream_duplex.js":454,"./lib/_stream_passthrough.js":455,"./lib/_stream_readable.js":456,"./lib/_stream_transform.js":457,"./lib/_stream_writable.js":458}],466:[function(require,module,exports){ +/*! safe-buffer. MIT License. Feross Aboukhadijeh */ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer - function isQuote (c) { - return c === '"' || c === '\'' +// 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 isAttribEnd (c) { - return c === '>' || isWhitespace(c) - } +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} - function isMatch (regex, c) { - return regex.test(c) +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) +} - function notMatch (regex, c) { - return !isMatch(regex, c) +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 +} - var S = 0 - sax.STATE = { - BEGIN: S++, // leading byte order mark or whitespace - BEGIN_WHITESPACE: S++, // leading whitespace - TEXT: S++, // general stuff - TEXT_ENTITY: S++, // & and such. - OPEN_WAKA: S++, // < - SGML_DECL: S++, // - SCRIPT: S++, //