Commit 2101a218 authored by Alfakhori's avatar Alfakhori
Browse files

Merge branch 'Rosenstein' into 'master'

update some ui

See merge request !1
parents bf137ad8 91e89eab
# @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
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var t = _interopRequireWildcard(require("@babel/types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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 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
};
}
\ No newline at end of file
{
"_from": "@babel/helper-explode-assignable-expression@^7.7.0",
"_id": "@babel/helper-explode-assignable-expression@7.7.0",
"_inBundle": false,
"_integrity": "sha512-CDs26w2shdD1urNUAji2RJXyBFCaR+iBEGnFz3l7maizMkQe3saVw9WtjG1tz8CwbjvlFnaSLVhgnu1SWaherg==",
"_location": "/@babel/helper-explode-assignable-expression",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-explode-assignable-expression@^7.7.0",
"name": "@babel/helper-explode-assignable-expression",
"escapedName": "@babel%2fhelper-explode-assignable-expression",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/helper-builder-binary-assignment-operator-visitor"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.7.0.tgz",
"_shasum": "db2a6705555ae1f9f33b4b8212a546bc7f9dc3ef",
"_spec": "@babel/helper-explode-assignable-expression@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\helper-builder-binary-assignment-operator-visitor",
"bundleDependencies": false,
"dependencies": {
"@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to explode an assignable expression",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"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.7.0"
}
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.
# @babel/helper-function-name
> Helper function to change the property 'name' of every function
See our website [@babel/helper-function-name](https://babeljs.io/docs/en/next/babel-helper-function-name.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/helper-function-name
```
or using yarn:
```sh
yarn add @babel/helper-function-name --dev
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _helperGetFunctionArity = _interopRequireDefault(require("@babel/helper-get-function-arity"));
var _template = _interopRequireDefault(require("@babel/template"));
var t = _interopRequireWildcard(require("@babel/types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const buildPropertyMethodAssignmentWrapper = (0, _template.default)(`
(function (FUNCTION_KEY) {
function FUNCTION_ID() {
return FUNCTION_KEY.apply(this, arguments);
}
FUNCTION_ID.toString = function () {
return FUNCTION_KEY.toString();
}
return FUNCTION_ID;
})(FUNCTION)
`);
const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template.default)(`
(function (FUNCTION_KEY) {
function* FUNCTION_ID() {
return yield* FUNCTION_KEY.apply(this, arguments);
}
FUNCTION_ID.toString = function () {
return FUNCTION_KEY.toString();
};
return FUNCTION_ID;
})(FUNCTION)
`);
const visitor = {
"ReferencedIdentifier|BindingIdentifier"(path, state) {
if (path.node.name !== state.name) return;
const localDeclar = path.scope.getBindingIdentifier(state.name);
if (localDeclar !== state.outerDeclar) return;
state.selfReference = true;
path.stop();
}
};
function getNameFromLiteralId(id) {
if (t.isNullLiteral(id)) {
return "null";
}
if (t.isRegExpLiteral(id)) {
return `_${id.pattern}_${id.flags}`;
}
if (t.isTemplateLiteral(id)) {
return id.quasis.map(quasi => quasi.value.raw).join("");
}
if (id.value !== undefined) {
return id.value + "";
}
return "";
}
function wrap(state, method, id, scope) {
if (state.selfReference) {
if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) {
scope.rename(id.name);
} else {
if (!t.isFunction(method)) return;
let build = buildPropertyMethodAssignmentWrapper;
if (method.generator) {
build = buildGeneratorPropertyMethodAssignmentWrapper;
}
const template = build({
FUNCTION: method,
FUNCTION_ID: id,
FUNCTION_KEY: scope.generateUidIdentifier(id.name)
}).expression;
const params = template.callee.body.body[0].params;
for (let i = 0, len = (0, _helperGetFunctionArity.default)(method); i < len; i++) {
params.push(scope.generateUidIdentifier("x"));
}
return template;
}
}
method.id = id;
scope.getProgramParent().references[id.name] = true;
}
function visit(node, name, scope) {
const state = {
selfAssignment: false,
selfReference: false,
outerDeclar: scope.getBindingIdentifier(name),
references: [],
name: name
};
const binding = scope.getOwnBinding(name);
if (binding) {
if (binding.kind === "param") {
state.selfReference = true;
} else {}
} else if (state.outerDeclar || scope.hasGlobal(name)) {
scope.traverse(node, visitor, state);
}
return state;
}
function _default({
node,
parent,
scope,
id
}, localBinding = false) {
if (node.id) return;
if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, {
kind: "method"
})) && (!parent.computed || t.isLiteral(parent.key))) {
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
id = parent.id;
if (t.isIdentifier(id) && !localBinding) {
const binding = scope.parent.getBinding(id.name);
if (binding && binding.constant && scope.getBinding(id.name) === binding) {
node.id = t.cloneNode(id);
node.id[t.NOT_LOCAL_BINDING] = true;
return;
}
}
} else if (t.isAssignmentExpression(parent)) {
id = parent.left;
} else if (!id) {
return;
}
let name;
if (id && t.isLiteral(id)) {
name = getNameFromLiteralId(id);
} else if (id && t.isIdentifier(id)) {
name = id.name;
}
if (name === undefined) {
return;
}
name = t.toBindingIdentifierName(name);
id = t.identifier(name);
id[t.NOT_LOCAL_BINDING] = true;
const state = visit(node, name, scope);
return wrap(state, node, id, scope) || node;
}
\ No newline at end of file
{
"_from": "@babel/helper-function-name@^7.7.0",
"_id": "@babel/helper-function-name@7.7.0",
"_inBundle": false,
"_integrity": "sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q==",
"_location": "/@babel/helper-function-name",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-function-name@^7.7.0",
"name": "@babel/helper-function-name",
"escapedName": "@babel%2fhelper-function-name",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/helper-create-class-features-plugin",
"/@babel/helper-define-map",
"/@babel/helper-wrap-function",
"/@babel/plugin-transform-classes",
"/@babel/plugin-transform-function-name",
"/@babel/traverse"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz",
"_shasum": "44a5ad151cfff8ed2599c91682dda2ec2c8430a3",
"_spec": "@babel/helper-function-name@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\traverse",
"bundleDependencies": false,
"dependencies": {
"@babel/helper-get-function-arity": "^7.7.0",
"@babel/template": "^7.7.0",
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to change the property 'name' of every function",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-function-name",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name"
},
"version": "7.7.0"
}
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.
# @babel/helper-get-function-arity
> Helper function to get function arity
See our website [@babel/helper-get-function-arity](https://babeljs.io/docs/en/next/babel-helper-get-function-arity.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/helper-get-function-arity
```
or using yarn:
```sh
yarn add @babel/helper-get-function-arity --dev
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var t = _interopRequireWildcard(require("@babel/types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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(node) {
const params = node.params;
for (let i = 0; i < params.length; i++) {
const param = params[i];
if (t.isAssignmentPattern(param) || t.isRestElement(param)) {
return i;
}
}
return params.length;
}
\ No newline at end of file
{
"_from": "@babel/helper-get-function-arity@^7.7.0",
"_id": "@babel/helper-get-function-arity@7.7.0",
"_inBundle": false,
"_integrity": "sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw==",
"_location": "/@babel/helper-get-function-arity",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-get-function-arity@^7.7.0",
"name": "@babel/helper-get-function-arity",
"escapedName": "@babel%2fhelper-get-function-arity",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/helper-function-name",
"/@babel/plugin-transform-parameters"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz",
"_shasum": "c604886bc97287a1d1398092bc666bc3d7d7aa2d",
"_spec": "@babel/helper-get-function-arity@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\helper-function-name",
"bundleDependencies": false,
"dependencies": {
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to get function arity",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-get-function-arity",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-get-function-arity"
},
"version": "7.7.0"
}
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.
# @babel/helper-hoist-variables
> Helper function to hoist variables
See our website [@babel/helper-hoist-variables](https://babeljs.io/docs/en/next/babel-helper-hoist-variables.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/helper-hoist-variables
```
or using yarn:
```sh
yarn add @babel/helper-hoist-variables --dev
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var t = _interopRequireWildcard(require("@babel/types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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; }
const visitor = {
Scope(path, state) {
if (state.kind === "let") path.skip();
},
Function(path) {
path.skip();
},
VariableDeclaration(path, state) {
if (state.kind && path.node.kind !== state.kind) return;
const nodes = [];
const declarations = path.get("declarations");
let firstId;
for (const declar of declarations) {
firstId = declar.node.id;
if (declar.node.init) {
nodes.push(t.expressionStatement(t.assignmentExpression("=", declar.node.id, declar.node.init)));
}
for (const name of Object.keys(declar.getBindingIdentifiers())) {
state.emit(t.identifier(name), name, declar.node.init !== null);
}
}
if (path.parentPath.isFor({
left: path.node
})) {
path.replaceWith(firstId);
} else {
path.replaceWithMultiple(nodes);
}
}
};
function _default(path, emit, kind = "var") {
path.traverse(visitor, {
kind,
emit
});
}
\ No newline at end of file
{
"_from": "@babel/helper-hoist-variables@^7.7.0",
"_id": "@babel/helper-hoist-variables@7.7.0",
"_inBundle": false,
"_integrity": "sha512-LUe/92NqsDAkJjjCEWkNe+/PcpnisvnqdlRe19FahVapa4jndeuJ+FBiTX1rcAKWKcJGE+C3Q3tuEuxkSmCEiQ==",
"_location": "/@babel/helper-hoist-variables",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-hoist-variables@^7.7.0",
"name": "@babel/helper-hoist-variables",
"escapedName": "@babel%2fhelper-hoist-variables",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/helper-call-delegate",
"/@babel/plugin-transform-modules-systemjs"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.7.0.tgz",
"_shasum": "b4552e4cfe5577d7de7b183e193e84e4ec538c81",
"_spec": "@babel/helper-hoist-variables@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\plugin-transform-modules-systemjs",
"bundleDependencies": false,
"dependencies": {
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to hoist variables",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/helper-hoist-variables",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-hoist-variables"
},
"version": "7.7.0"
}
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.
# @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
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = memberExpressionToFunctions;
var t = _interopRequireWildcard(require("@babel/types"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { 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; }
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()
}));
}
\ No newline at end of file
{
"_from": "@babel/helper-member-expression-to-functions@^7.7.0",
"_id": "@babel/helper-member-expression-to-functions@7.7.0",
"_inBundle": false,
"_integrity": "sha512-QaCZLO2RtBcmvO/ekOLp8p7R5X2JriKRizeDpm5ChATAFWrrYDcDxPuCIBXKyBjY+i1vYSdcUTMIb8psfxHDPA==",
"_location": "/@babel/helper-member-expression-to-functions",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/helper-member-expression-to-functions@^7.7.0",
"name": "@babel/helper-member-expression-to-functions",
"escapedName": "@babel%2fhelper-member-expression-to-functions",
"scope": "@babel",
"rawSpec": "^7.7.0",
"saveSpec": null,
"fetchSpec": "^7.7.0"
},
"_requiredBy": [
"/@babel/helper-create-class-features-plugin",
"/@babel/helper-replace-supers"
],
"_resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.7.0.tgz",
"_shasum": "472b93003a57071f95a541ea6c2b098398bcad8a",
"_spec": "@babel/helper-member-expression-to-functions@^7.7.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\LAFJLBmf939XYm5gj\\dev\\node_modules\\@babel\\helper-create-class-features-plugin",
"author": {
"name": "Justin Ridgewell",
"email": "justin@ridgewell.name"
},
"bundleDependencies": false,
"dependencies": {
"@babel/types": "^7.7.0"
},
"deprecated": false,
"description": "Helper function to replace certain member expressions with function calls",
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea",
"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.7.0"
}
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.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment