forked from daren.hsu/line_push
update
This commit is contained in:
+3
-3
@@ -2,18 +2,18 @@
|
||||
|
||||
> Helper function to optimise call expression
|
||||
|
||||
See our website [@babel/helper-optimise-call-expression](https://babeljs.io/docs/en/next/babel-helper-optimise-call-expression.html) for more information.
|
||||
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-dev @babel/helper-optimise-call-expression
|
||||
npm install --save @babel/helper-optimise-call-expression
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-optimise-call-expression --dev
|
||||
yarn add @babel/helper-optimise-call-expression
|
||||
```
|
||||
|
||||
+21
-11
@@ -3,24 +3,34 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
exports.default = optimiseCallExpression;
|
||||
|
||||
var t = _interopRequireWildcard(require("@babel/types"));
|
||||
var _t = require("@babel/types");
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
const {
|
||||
callExpression,
|
||||
identifier,
|
||||
isIdentifier,
|
||||
isSpreadElement,
|
||||
memberExpression,
|
||||
optionalCallExpression,
|
||||
optionalMemberExpression
|
||||
} = _t;
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _default(callee, thisNode, args, optional) {
|
||||
if (args.length === 1 && t.isSpreadElement(args[0]) && t.isIdentifier(args[0].argument, {
|
||||
function optimiseCallExpression(callee, thisNode, args, optional) {
|
||||
if (args.length === 1 && isSpreadElement(args[0]) && isIdentifier(args[0].argument, {
|
||||
name: "arguments"
|
||||
})) {
|
||||
return t.callExpression(t.memberExpression(callee, t.identifier("apply")), [thisNode, args[0].argument]);
|
||||
} else {
|
||||
if (optional) {
|
||||
return t.optionalCallExpression(t.optionalMemberExpression(callee, t.identifier("call"), false, true), [thisNode, ...args], false);
|
||||
return optionalCallExpression(optionalMemberExpression(callee, identifier("apply"), false, true), [thisNode, args[0].argument], false);
|
||||
}
|
||||
|
||||
return t.callExpression(t.memberExpression(callee, t.identifier("call")), [thisNode, ...args]);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
+27
-16
@@ -1,46 +1,56 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@babel/helper-optimise-call-expression@7.10.4",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"@babel/helper-optimise-call-expression@7.18.6",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "@babel/helper-optimise-call-expression@7.10.4",
|
||||
"_id": "@babel/helper-optimise-call-expression@7.10.4",
|
||||
"_from": "@babel/helper-optimise-call-expression@7.18.6",
|
||||
"_id": "@babel/helper-optimise-call-expression@7.18.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-n3UGKY4VXwXThEiKrgRAoVPBMqeoPgHVqiHZOanAJCG9nQUL2pLRQirUzl0ioKclHGpGqRgIOkgcIJaIWLpygg==",
|
||||
"_integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==",
|
||||
"_location": "/@babel/helper-optimise-call-expression",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@babel/helper-optimise-call-expression@7.10.4",
|
||||
"raw": "@babel/helper-optimise-call-expression@7.18.6",
|
||||
"name": "@babel/helper-optimise-call-expression",
|
||||
"escapedName": "@babel%2fhelper-optimise-call-expression",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "7.10.4",
|
||||
"rawSpec": "7.18.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "7.10.4"
|
||||
"fetchSpec": "7.18.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/helper-create-class-features-plugin",
|
||||
"/@babel/helper-replace-supers",
|
||||
"/@babel/plugin-transform-classes"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.4.tgz",
|
||||
"_spec": "7.10.4",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz",
|
||||
"_spec": "7.18.6",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "The Babel Team",
|
||||
"url": "https://babel.dev/team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/babel/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.10.4"
|
||||
"@babel/types": "^7.18.6"
|
||||
},
|
||||
"description": "Helper function to optimise call expression",
|
||||
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
|
||||
"homepage": "https://github.com/babel/babel#readme",
|
||||
"devDependencies": {
|
||||
"@babel/generator": "^7.18.6",
|
||||
"@babel/parser": "^7.18.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-helper-optimise-call-expression",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"main": "./lib/index.js",
|
||||
"name": "@babel/helper-optimise-call-expression",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -50,5 +60,6 @@
|
||||
"url": "git+https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-helper-optimise-call-expression"
|
||||
},
|
||||
"version": "7.10.4"
|
||||
"type": "commonjs",
|
||||
"version": "7.18.6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user