mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-09-13 00:04:09 +07:00
Improve code quality and write tests
This commit is contained in:
22
node_modules/@babel/helper-member-expression-to-functions/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/helper-member-expression-to-functions/LICENSE
generated
vendored
Normal file
@ -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.
|
19
node_modules/@babel/helper-member-expression-to-functions/README.md
generated
vendored
Normal file
19
node_modules/@babel/helper-member-expression-to-functions/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# @babel/helper-member-expression-to-functions
|
||||
|
||||
> Helper function to replace certain member expressions with function calls
|
||||
|
||||
See our website [@babel/helper-member-expression-to-functions](https://babeljs.io/docs/en/next/babel-helper-member-expression-to-functions.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/helper-member-expression-to-functions
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-member-expression-to-functions --dev
|
||||
```
|
142
node_modules/@babel/helper-member-expression-to-functions/lib/index.js
generated
vendored
Normal file
142
node_modules/@babel/helper-member-expression-to-functions/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = memberExpressionToFunctions;
|
||||
|
||||
function t() {
|
||||
const data = _interopRequireWildcard(require("@babel/types"));
|
||||
|
||||
t = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
class AssignmentMemoiser {
|
||||
constructor() {
|
||||
this._map = new WeakMap();
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return this._map.has(key);
|
||||
}
|
||||
|
||||
get(key) {
|
||||
if (!this.has(key)) return;
|
||||
|
||||
const record = this._map.get(key);
|
||||
|
||||
const {
|
||||
value
|
||||
} = record;
|
||||
record.count--;
|
||||
|
||||
if (record.count === 0) {
|
||||
return t().assignmentExpression("=", value, key);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
set(key, value, count) {
|
||||
return this._map.set(key, {
|
||||
count,
|
||||
value
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const handle = {
|
||||
memoise() {},
|
||||
|
||||
handle(member) {
|
||||
const {
|
||||
node,
|
||||
parent,
|
||||
parentPath
|
||||
} = member;
|
||||
|
||||
if (parentPath.isUpdateExpression({
|
||||
argument: node
|
||||
})) {
|
||||
const {
|
||||
operator,
|
||||
prefix
|
||||
} = parent;
|
||||
this.memoise(member, 2);
|
||||
const value = t().binaryExpression(operator[0], t().unaryExpression("+", this.get(member)), t().numericLiteral(1));
|
||||
|
||||
if (prefix) {
|
||||
parentPath.replaceWith(this.set(member, value));
|
||||
} else {
|
||||
const {
|
||||
scope
|
||||
} = member;
|
||||
const ref = scope.generateUidIdentifierBasedOnNode(node);
|
||||
scope.push({
|
||||
id: ref
|
||||
});
|
||||
value.left = t().assignmentExpression("=", t().cloneNode(ref), value.left);
|
||||
parentPath.replaceWith(t().sequenceExpression([this.set(member, value), t().cloneNode(ref)]));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPath.isAssignmentExpression({
|
||||
left: node
|
||||
})) {
|
||||
const {
|
||||
operator,
|
||||
right
|
||||
} = parent;
|
||||
let value = right;
|
||||
|
||||
if (operator !== "=") {
|
||||
this.memoise(member, 2);
|
||||
value = t().binaryExpression(operator.slice(0, -1), this.get(member), value);
|
||||
}
|
||||
|
||||
parentPath.replaceWith(this.set(member, value));
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPath.isCallExpression({
|
||||
callee: node
|
||||
})) {
|
||||
const {
|
||||
arguments: args
|
||||
} = parent;
|
||||
parentPath.replaceWith(this.call(member, args));
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentPath.isObjectProperty({
|
||||
value: node
|
||||
}) && parentPath.parentPath.isObjectPattern() || parentPath.isAssignmentPattern({
|
||||
left: node
|
||||
}) && parentPath.parentPath.isObjectProperty({
|
||||
value: parent
|
||||
}) && parentPath.parentPath.parentPath.isObjectPattern() || parentPath.isArrayPattern() || parentPath.isAssignmentPattern({
|
||||
left: node
|
||||
}) && parentPath.parentPath.isArrayPattern() || parentPath.isRestElement()) {
|
||||
member.replaceWith(this.destructureSet(member));
|
||||
return;
|
||||
}
|
||||
|
||||
member.replaceWith(this.get(member));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function memberExpressionToFunctions(path, visitor, state) {
|
||||
path.traverse(visitor, Object.assign({}, handle, state, {
|
||||
memoiser: new AssignmentMemoiser()
|
||||
}));
|
||||
}
|
51
node_modules/@babel/helper-member-expression-to-functions/package.json
generated
vendored
Normal file
51
node_modules/@babel/helper-member-expression-to-functions/package.json
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@babel/helper-member-expression-to-functions@7.5.5",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "@babel/helper-member-expression-to-functions@7.5.5",
|
||||
"_id": "@babel/helper-member-expression-to-functions@7.5.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-5qZ3D1uMclSNqYcXqiHoA0meVdv+xUEex9em2fqMnrk/scphGlGgg66zjMrPJESPwrFJ6sbfFQYUSa0Mz7FabA==",
|
||||
"_location": "/@babel/helper-member-expression-to-functions",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@babel/helper-member-expression-to-functions@7.5.5",
|
||||
"name": "@babel/helper-member-expression-to-functions",
|
||||
"escapedName": "@babel%2fhelper-member-expression-to-functions",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "7.5.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "7.5.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/helper-replace-supers"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.5.5.tgz",
|
||||
"_spec": "7.5.5",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"author": {
|
||||
"name": "Justin Ridgewell",
|
||||
"email": "justin@ridgewell.name"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.5.5"
|
||||
},
|
||||
"description": "Helper function to replace certain member expressions with function calls",
|
||||
"gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "@babel/helper-member-expression-to-functions",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-member-expression-to-functions"
|
||||
},
|
||||
"version": "7.5.5"
|
||||
}
|
Reference in New Issue
Block a user