Improve code quality and write tests

This commit is contained in:
Shivam Mathur
2019-09-20 08:11:20 +05:30
parent db44db4b97
commit 43178a7254
3597 changed files with 255478 additions and 785554 deletions

View File

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-2018 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.

View File

@ -0,0 +1,19 @@
# @babel/helper-explode-assignable-expression
> Helper function to explode an assignable expression
See our website [@babel/helper-explode-assignable-expression](https://babeljs.io/docs/en/next/babel-helper-explode-assignable-expression.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/helper-explode-assignable-expression
```
or using yarn:
```sh
yarn add @babel/helper-explode-assignable-expression --dev
```

View File

@ -0,0 +1,86 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
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; } }
function getObjRef(node, nodes, file, scope) {
let ref;
if (t().isSuper(node)) {
return node;
} else if (t().isIdentifier(node)) {
if (scope.hasBinding(node.name)) {
return node;
} else {
ref = node;
}
} else if (t().isMemberExpression(node)) {
ref = node.object;
if (t().isSuper(ref) || t().isIdentifier(ref) && scope.hasBinding(ref.name)) {
return ref;
}
} else {
throw new Error(`We can't explode this node type ${node.type}`);
}
const temp = scope.generateUidIdentifierBasedOnNode(ref);
scope.push({
id: temp
});
nodes.push(t().assignmentExpression("=", t().cloneNode(temp), t().cloneNode(ref)));
return temp;
}
function getPropRef(node, nodes, file, scope) {
const prop = node.property;
const key = t().toComputedKey(node, prop);
if (t().isLiteral(key) && t().isPureish(key)) return key;
const temp = scope.generateUidIdentifierBasedOnNode(prop);
scope.push({
id: temp
});
nodes.push(t().assignmentExpression("=", t().cloneNode(temp), t().cloneNode(prop)));
return temp;
}
function _default(node, nodes, file, scope, allowedSingleIdent) {
let obj;
if (t().isIdentifier(node) && allowedSingleIdent) {
obj = node;
} else {
obj = getObjRef(node, nodes, file, scope);
}
let ref, uid;
if (t().isIdentifier(node)) {
ref = t().cloneNode(node);
uid = obj;
} else {
const prop = getPropRef(node, nodes, file, scope);
const computed = node.computed || t().isLiteral(prop);
uid = t().memberExpression(t().cloneNode(obj), t().cloneNode(prop), computed);
ref = t().memberExpression(t().cloneNode(obj), t().cloneNode(prop), computed);
}
return {
uid: uid,
ref: ref
};
}

View File

@ -0,0 +1,47 @@
{
"_args": [
[
"@babel/helper-explode-assignable-expression@7.1.0",
"E:\\python\\setup-php"
]
],
"_from": "@babel/helper-explode-assignable-expression@7.1.0",
"_id": "@babel/helper-explode-assignable-expression@7.1.0",
"_inBundle": false,
"_integrity": "sha512-NRQpfHrJ1msCHtKjbzs9YcMmJZOg6mQMmGRB+hbamEdG5PNpaSm95275VD92DvJKuyl0s2sFiDmMZ+EnnvufqA==",
"_location": "/@babel/helper-explode-assignable-expression",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/helper-explode-assignable-expression@7.1.0",
"name": "@babel/helper-explode-assignable-expression",
"escapedName": "@babel%2fhelper-explode-assignable-expression",
"scope": "@babel",
"rawSpec": "7.1.0",
"saveSpec": null,
"fetchSpec": "7.1.0"
},
"_requiredBy": [
"/@babel/helper-builder-binary-assignment-operator-visitor"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.1.0.tgz",
"_spec": "7.1.0",
"_where": "E:\\python\\setup-php",
"dependencies": {
"@babel/traverse": "^7.1.0",
"@babel/types": "^7.0.0"
},
"description": "Helper function to explode an assignable expression",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-explode-assignable-expression",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-assignable-expression"
},
"version": "7.1.0"
}