@babel/helper-simple-access
Advanced tools
Comparing version 7.22.5 to 8.0.0-alpha.0
@@ -1,8 +0,3 @@ | ||
"use strict"; | ||
import * as _t from '@babel/types'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = simplifyAccess; | ||
var _t = require("@babel/types"); | ||
const { | ||
@@ -47,42 +42,8 @@ LOGICAL_OPERATORS, | ||
}; | ||
{ | ||
simpleAssignmentVisitor.UpdateExpression = { | ||
exit(path) { | ||
if (!this.includeUpdateExpression) return; | ||
const { | ||
scope, | ||
bindingNames | ||
} = this; | ||
const arg = path.get("argument"); | ||
if (!arg.isIdentifier()) return; | ||
const localName = arg.node.name; | ||
if (!bindingNames.has(localName)) return; | ||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) { | ||
return; | ||
} | ||
if (path.parentPath.isExpressionStatement() && !path.isCompletionRecord()) { | ||
const operator = path.node.operator == "++" ? "+=" : "-="; | ||
path.replaceWith(assignmentExpression(operator, arg.node, numericLiteral(1))); | ||
} else if (path.node.prefix) { | ||
path.replaceWith(assignmentExpression("=", identifier(localName), binaryExpression(path.node.operator[0], unaryExpression("+", arg.node), numericLiteral(1)))); | ||
} else { | ||
const old = path.scope.generateUidIdentifierBasedOnNode(arg.node, "old"); | ||
const varName = old.name; | ||
path.scope.push({ | ||
id: old | ||
}); | ||
const binary = binaryExpression(path.node.operator[0], identifier(varName), numericLiteral(1)); | ||
path.replaceWith(sequenceExpression([assignmentExpression("=", identifier(varName), unaryExpression("+", arg.node)), assignmentExpression("=", cloneNode(arg.node), binary), identifier(varName)])); | ||
} | ||
} | ||
}; | ||
} | ||
function simplifyAccess(path, bindingNames) { | ||
{ | ||
var _arguments$; | ||
path.traverse(simpleAssignmentVisitor, { | ||
scope: path.scope, | ||
bindingNames, | ||
seen: new WeakSet(), | ||
includeUpdateExpression: (_arguments$ = arguments[2]) != null ? _arguments$ : true | ||
seen: new WeakSet() | ||
}); | ||
@@ -92,2 +53,3 @@ } | ||
export { simplifyAccess as default }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@babel/helper-simple-access", | ||
"version": "7.22.5", | ||
"version": "8.0.0-alpha.0", | ||
"description": "Babel helper for ensuring that access to a given value is performed through simple accesses", | ||
@@ -18,12 +18,16 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"dependencies": { | ||
"@babel/types": "^7.22.5" | ||
"@babel/types": "^8.0.0-alpha.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.22.5", | ||
"@babel/traverse": "^7.22.5" | ||
"@babel/core": "^8.0.0-alpha.0", | ||
"@babel/traverse": "^8.0.0-alpha.0" | ||
}, | ||
"engines": { | ||
"node": ">=6.9.0" | ||
"node": "^16.20.0 || ^18.16.0 || >=20.0.0" | ||
}, | ||
"type": "commonjs" | ||
"exports": { | ||
".": "./lib/index.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"type": "module" | ||
} |
@@ -5,3 +5,3 @@ # @babel/helper-simple-access | ||
See our website [@babel/helper-simple-access](https://babeljs.io/docs/en/babel-helper-simple-access) for more information. | ||
See our website [@babel/helper-simple-access](https://babeljs.io/docs/babel-helper-simple-access) for more information. | ||
@@ -8,0 +8,0 @@ ## Install |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
10787
51
1
+ Added@babel/helper-string-parser@8.0.0-alpha.12(transitive)
+ Added@babel/helper-validator-identifier@8.0.0-alpha.12(transitive)
+ Added@babel/types@8.0.0-alpha.12(transitive)
+ Addedto-fast-properties@3.0.1(transitive)
- Removed@babel/helper-string-parser@7.24.8(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/types@7.25.6(transitive)
- Removedto-fast-properties@2.0.0(transitive)
Updated@babel/types@^8.0.0-alpha.0