summaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-duplicate-keys
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
commitaa773172311dcada759dfbaac485f4bc6e00bc21 (patch)
treeca6d9a5eff3ab8f689f9acb4f0df791d9486813d /node_modules/@babel/plugin-transform-duplicate-keys
parentc5a5384e846f242e901e859fe600d695d8990a9a (diff)
added babel
Diffstat (limited to 'node_modules/@babel/plugin-transform-duplicate-keys')
-rw-r--r--node_modules/@babel/plugin-transform-duplicate-keys/LICENSE22
-rw-r--r--node_modules/@babel/plugin-transform-duplicate-keys/README.md19
-rw-r--r--node_modules/@babel/plugin-transform-duplicate-keys/lib/index.js61
-rw-r--r--node_modules/@babel/plugin-transform-duplicate-keys/lib/index.js.map1
-rw-r--r--node_modules/@babel/plugin-transform-duplicate-keys/package.json34
5 files changed, 137 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-transform-duplicate-keys/LICENSE b/node_modules/@babel/plugin-transform-duplicate-keys/LICENSE
new file mode 100644
index 00000000..f31575ec
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-duplicate-keys/LICENSE
@@ -0,0 +1,22 @@
+MIT License
+
+Copyright (c) 2014-present Sebastian McKenzie and other contributors
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/@babel/plugin-transform-duplicate-keys/README.md b/node_modules/@babel/plugin-transform-duplicate-keys/README.md
new file mode 100644
index 00000000..a2d6673f
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-duplicate-keys/README.md
@@ -0,0 +1,19 @@
+# @babel/plugin-transform-duplicate-keys
+
+> Compile objects with duplicate keys to valid strict ES5
+
+See our website [@babel/plugin-transform-duplicate-keys](https://babeljs.io/docs/en/babel-plugin-transform-duplicate-keys) for more information.
+
+## Install
+
+Using npm:
+
+```sh
+npm install --save-dev @babel/plugin-transform-duplicate-keys
+```
+
+or using yarn:
+
+```sh
+yarn add @babel/plugin-transform-duplicate-keys --dev
+```
diff --git a/node_modules/@babel/plugin-transform-duplicate-keys/lib/index.js b/node_modules/@babel/plugin-transform-duplicate-keys/lib/index.js
new file mode 100644
index 00000000..5a9b47d2
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-duplicate-keys/lib/index.js
@@ -0,0 +1,61 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+var _helperPluginUtils = require("@babel/helper-plugin-utils");
+var _core = require("@babel/core");
+function getName(key) {
+ if (_core.types.isIdentifier(key)) {
+ return key.name;
+ }
+ return key.value.toString();
+}
+var _default = (0, _helperPluginUtils.declare)(api => {
+ api.assertVersion(7);
+ return {
+ name: "transform-duplicate-keys",
+ visitor: {
+ ObjectExpression(path) {
+ const {
+ node
+ } = path;
+ const plainProps = node.properties.filter(prop => !_core.types.isSpreadElement(prop) && !prop.computed);
+ const alreadySeenData = Object.create(null);
+ const alreadySeenGetters = Object.create(null);
+ const alreadySeenSetters = Object.create(null);
+ for (const prop of plainProps) {
+ const name = getName(prop.key);
+ let isDuplicate = false;
+ switch (prop.kind) {
+ case "get":
+ if (alreadySeenData[name] || alreadySeenGetters[name]) {
+ isDuplicate = true;
+ }
+ alreadySeenGetters[name] = true;
+ break;
+ case "set":
+ if (alreadySeenData[name] || alreadySeenSetters[name]) {
+ isDuplicate = true;
+ }
+ alreadySeenSetters[name] = true;
+ break;
+ default:
+ if (alreadySeenData[name] || alreadySeenGetters[name] || alreadySeenSetters[name]) {
+ isDuplicate = true;
+ }
+ alreadySeenData[name] = true;
+ }
+ if (isDuplicate) {
+ prop.computed = true;
+ prop.key = _core.types.stringLiteral(name);
+ }
+ }
+ }
+ }
+ };
+});
+exports.default = _default;
+
+//# sourceMappingURL=index.js.map
diff --git a/node_modules/@babel/plugin-transform-duplicate-keys/lib/index.js.map b/node_modules/@babel/plugin-transform-duplicate-keys/lib/index.js.map
new file mode 100644
index 00000000..86ce6dbb
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-duplicate-keys/lib/index.js.map
@@ -0,0 +1 @@
+{"version":3,"names":["_helperPluginUtils","require","_core","getName","key","t","isIdentifier","name","value","toString","_default","declare","api","assertVersion","visitor","ObjectExpression","path","node","plainProps","properties","filter","prop","isSpreadElement","computed","alreadySeenData","Object","create","alreadySeenGetters","alreadySeenSetters","isDuplicate","kind","stringLiteral","exports","default"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { types as t } from \"@babel/core\";\n\nfunction getName(\n key: t.Identifier | t.StringLiteral | t.NumericLiteral | t.BigIntLiteral,\n) {\n if (t.isIdentifier(key)) {\n return key.name;\n }\n return key.value.toString();\n}\n\nexport default declare(api => {\n api.assertVersion(7);\n\n return {\n name: \"transform-duplicate-keys\",\n\n visitor: {\n ObjectExpression(path) {\n const { node } = path;\n const plainProps = node.properties.filter(\n prop => !t.isSpreadElement(prop) && !prop.computed,\n ) as (t.ObjectMethod | t.ObjectProperty)[];\n\n // A property is a duplicate key if:\n // * the property is a data property, and is preceded by a data,\n // getter, or setter property of the same name.\n // * the property is a getter property, and is preceded by a data or\n // getter property of the same name.\n // * the property is a setter property, and is preceded by a data or\n // setter property of the same name.\n\n const alreadySeenData = Object.create(null);\n const alreadySeenGetters = Object.create(null);\n const alreadySeenSetters = Object.create(null);\n\n for (const prop of plainProps) {\n const name = getName(\n // prop must be non-computed\n prop.key as\n | t.Identifier\n | t.StringLiteral\n | t.NumericLiteral\n | t.BigIntLiteral,\n );\n let isDuplicate = false;\n // @ts-expect-error prop.kind is not defined in ObjectProperty\n switch (prop.kind) {\n case \"get\":\n if (alreadySeenData[name] || alreadySeenGetters[name]) {\n isDuplicate = true;\n }\n alreadySeenGetters[name] = true;\n break;\n case \"set\":\n if (alreadySeenData[name] || alreadySeenSetters[name]) {\n isDuplicate = true;\n }\n alreadySeenSetters[name] = true;\n break;\n default:\n if (\n alreadySeenData[name] ||\n alreadySeenGetters[name] ||\n alreadySeenSetters[name]\n ) {\n isDuplicate = true;\n }\n alreadySeenData[name] = true;\n }\n\n if (isDuplicate) {\n // Rely on the computed properties transform to split the property\n // assignment out of the object literal.\n prop.computed = true;\n prop.key = t.stringLiteral(name);\n }\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,SAASE,OAAOA,CACdC,GAAwE,EACxE;EACA,IAAIC,WAAC,CAACC,YAAY,CAACF,GAAG,CAAC,EAAE;IACvB,OAAOA,GAAG,CAACG,IAAI;EACjB;EACA,OAAOH,GAAG,CAACI,KAAK,CAACC,QAAQ,CAAC,CAAC;AAC7B;AAAC,IAAAC,QAAA,GAEc,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,CAAC,CAAC,CAAC;EAEpB,OAAO;IACLN,IAAI,EAAE,0BAA0B;IAEhCO,OAAO,EAAE;MACPC,gBAAgBA,CAACC,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,CAACjB,GAAG,GAAGC,WAAC,CAAC0B,aAAa,CAACxB,IAAI,CAAC;UAClC;QACF;MACF;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAAAyB,OAAA,CAAAC,OAAA,GAAAvB,QAAA"} \ No newline at end of file
diff --git a/node_modules/@babel/plugin-transform-duplicate-keys/package.json b/node_modules/@babel/plugin-transform-duplicate-keys/package.json
new file mode 100644
index 00000000..2fbc731d
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-duplicate-keys/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "@babel/plugin-transform-duplicate-keys",
+ "version": "7.22.5",
+ "description": "Compile objects with duplicate keys to valid strict ES5",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/babel/babel.git",
+ "directory": "packages/babel-plugin-transform-duplicate-keys"
+ },
+ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-duplicate-keys",
+ "license": "MIT",
+ "publishConfig": {
+ "access": "public"
+ },
+ "main": "./lib/index.js",
+ "keywords": [
+ "babel-plugin"
+ ],
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.22.5"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.22.5",
+ "@babel/helper-plugin-test-runner": "^7.22.5"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "author": "The Babel Team (https://babel.dev/team)",
+ "type": "commonjs"
+} \ No newline at end of file