summaryrefslogtreecommitdiff
path: root/node_modules/@babel/helper-optimise-call-expression
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/helper-optimise-call-expression
parentc5a5384e846f242e901e859fe600d695d8990a9a (diff)
added babel
Diffstat (limited to 'node_modules/@babel/helper-optimise-call-expression')
-rw-r--r--node_modules/@babel/helper-optimise-call-expression/LICENSE22
-rw-r--r--node_modules/@babel/helper-optimise-call-expression/README.md19
-rw-r--r--node_modules/@babel/helper-optimise-call-expression/lib/index.js33
-rw-r--r--node_modules/@babel/helper-optimise-call-expression/lib/index.js.map1
-rw-r--r--node_modules/@babel/helper-optimise-call-expression/package.json28
5 files changed, 103 insertions, 0 deletions
diff --git a/node_modules/@babel/helper-optimise-call-expression/LICENSE b/node_modules/@babel/helper-optimise-call-expression/LICENSE
new file mode 100644
index 00000000..f31575ec
--- /dev/null
+++ b/node_modules/@babel/helper-optimise-call-expression/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/helper-optimise-call-expression/README.md b/node_modules/@babel/helper-optimise-call-expression/README.md
new file mode 100644
index 00000000..a071d434
--- /dev/null
+++ b/node_modules/@babel/helper-optimise-call-expression/README.md
@@ -0,0 +1,19 @@
+# @babel/helper-optimise-call-expression
+
+> Helper function to optimise call expression
+
+See our website [@babel/helper-optimise-call-expression](https://babeljs.io/docs/en/babel-helper-optimise-call-expression) for more information.
+
+## Install
+
+Using npm:
+
+```sh
+npm install --save @babel/helper-optimise-call-expression
+```
+
+or using yarn:
+
+```sh
+yarn add @babel/helper-optimise-call-expression
+```
diff --git a/node_modules/@babel/helper-optimise-call-expression/lib/index.js b/node_modules/@babel/helper-optimise-call-expression/lib/index.js
new file mode 100644
index 00000000..f7bc0b2a
--- /dev/null
+++ b/node_modules/@babel/helper-optimise-call-expression/lib/index.js
@@ -0,0 +1,33 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = optimiseCallExpression;
+var _t = require("@babel/types");
+const {
+ callExpression,
+ identifier,
+ isIdentifier,
+ isSpreadElement,
+ memberExpression,
+ optionalCallExpression,
+ optionalMemberExpression
+} = _t;
+function optimiseCallExpression(callee, thisNode, args, optional) {
+ if (args.length === 1 && isSpreadElement(args[0]) && isIdentifier(args[0].argument, {
+ name: "arguments"
+ })) {
+ if (optional) {
+ return optionalCallExpression(optionalMemberExpression(callee, identifier("apply"), false, true), [thisNode, args[0].argument], false);
+ }
+ return callExpression(memberExpression(callee, identifier("apply")), [thisNode, args[0].argument]);
+ } else {
+ if (optional) {
+ return optionalCallExpression(optionalMemberExpression(callee, identifier("call"), false, true), [thisNode, ...args], false);
+ }
+ return callExpression(memberExpression(callee, identifier("call")), [thisNode, ...args]);
+ }
+}
+
+//# sourceMappingURL=index.js.map
diff --git a/node_modules/@babel/helper-optimise-call-expression/lib/index.js.map b/node_modules/@babel/helper-optimise-call-expression/lib/index.js.map
new file mode 100644
index 00000000..43d7dd93
--- /dev/null
+++ b/node_modules/@babel/helper-optimise-call-expression/lib/index.js.map
@@ -0,0 +1 @@
+{"version":3,"names":["_t","require","callExpression","identifier","isIdentifier","isSpreadElement","memberExpression","optionalCallExpression","optionalMemberExpression","optimiseCallExpression","callee","thisNode","args","optional","length","argument","name"],"sources":["../src/index.ts"],"sourcesContent":["import {\n callExpression,\n identifier,\n isIdentifier,\n isSpreadElement,\n memberExpression,\n optionalCallExpression,\n optionalMemberExpression,\n} from \"@babel/types\";\nimport type {\n CallExpression,\n Expression,\n OptionalCallExpression,\n} from \"@babel/types\";\n\n/**\n * A helper function that generates a new call expression with given thisNode.\n It will also optimize `(...arguments)` to `.apply(arguments)`\n *\n * @export\n * @param {Expression} callee The callee of call expression\n * @param {Expression} thisNode The desired this of call expression\n * @param {Readonly<CallExpression[\"arguments\"]>} args The arguments of call expression\n * @param {boolean} optional Whether the call expression is optional\n * @returns {CallExpression | OptionalCallExpression} The generated new call expression\n */\nexport default function optimiseCallExpression(\n callee: Expression,\n thisNode: Expression,\n args: Readonly<CallExpression[\"arguments\"]>,\n optional: boolean,\n): CallExpression | OptionalCallExpression {\n if (\n args.length === 1 &&\n isSpreadElement(args[0]) &&\n isIdentifier(args[0].argument, { name: \"arguments\" })\n ) {\n // a.b?.(...arguments);\n if (optional) {\n return optionalCallExpression(\n optionalMemberExpression(callee, identifier(\"apply\"), false, true),\n [thisNode, args[0].argument],\n false,\n );\n }\n // a.b(...arguments);\n return callExpression(memberExpression(callee, identifier(\"apply\")), [\n thisNode,\n args[0].argument,\n ]);\n } else {\n // a.b?.(arg1, arg2)\n if (optional) {\n return optionalCallExpression(\n optionalMemberExpression(callee, identifier(\"call\"), false, true),\n [thisNode, ...args],\n false,\n );\n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AAE,CAClEQ,QAAQ,EACR,GAAGC,IAAI,CACR,CAAC;EACJ;AACF"} \ No newline at end of file
diff --git a/node_modules/@babel/helper-optimise-call-expression/package.json b/node_modules/@babel/helper-optimise-call-expression/package.json
new file mode 100644
index 00000000..6dee76d5
--- /dev/null
+++ b/node_modules/@babel/helper-optimise-call-expression/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "@babel/helper-optimise-call-expression",
+ "version": "7.22.5",
+ "description": "Helper function to optimise call expression",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/babel/babel.git",
+ "directory": "packages/babel-helper-optimise-call-expression"
+ },
+ "homepage": "https://babel.dev/docs/en/next/babel-helper-optimise-call-expression",
+ "license": "MIT",
+ "publishConfig": {
+ "access": "public"
+ },
+ "main": "./lib/index.js",
+ "dependencies": {
+ "@babel/types": "^7.22.5"
+ },
+ "devDependencies": {
+ "@babel/generator": "^7.22.5",
+ "@babel/parser": "^7.22.5"
+ },
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "author": "The Babel Team (https://babel.dev/team)",
+ "type": "commonjs"
+} \ No newline at end of file