Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-helper-evaluate-path

Package Overview
Dependencies
Maintainers
7
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-helper-evaluate-path - npm Package Compare versions

Comparing version 0.5.0-alpha.34c3efe9 to 0.5.0-alpha.36b27d42

76

lib/index.js

@@ -14,3 +14,3 @@ "use strict";

} = {}) {
if (!tdz) {
if (!tdz && !path.isReferencedIdentifier()) {
return baseEvaluate(path);

@@ -77,3 +77,30 @@ }

if (!binding) {
return deopt(path);
const name = node.name;
if (!name) {
return deopt(path);
}
switch (name) {
case "undefined":
return {
confident: true,
value: undefined
};
case "NaN":
return {
confident: true,
value: NaN
};
case "Infinity":
return {
confident: true,
value: Infinity
};
default:
return deopt(path);
}
}

@@ -122,17 +149,33 @@

if (declaration.parentPath.isIfStatement() || declaration.parentPath.isLoop() || declaration.parentPath.isSwitchCase()) {
return {
shouldDeopt: true
};
if (declaration.parentPath) {
/**
* Handle when binding is created inside a parent block and
* the corresponding parent is removed by other plugins
* if (false) { var a } -> var a
*/
if (declaration.parentPath.removed) {
return {
confident: true,
value: void 0
};
}
if (declaration.parentPath.isIfStatement() || declaration.parentPath.isLoop() || declaration.parentPath.isSwitchCase()) {
return {
shouldDeopt: true
};
}
}
const fnParent = (binding.path.scope.getFunctionParent() || binding.path.scope.getProgramParent()).path;
let blockParent = binding.path.scope.getBlockParent().path;
const fnParent = binding.path.getFunctionParent();
if (blockParent === fnParent) {
if (!fnParent.isProgram()) blockParent = blockParent.get("body");
if (blockParent === fnParent && !fnParent.isProgram()) {
blockParent = blockParent.get("body");
} // detect Usage Outside Init Scope
if (!blockParent.get("body").some(stmt => stmt.isAncestor(refPath))) {
const blockBody = blockParent.get("body");
if (Array.isArray(blockBody) && !blockBody.some(stmt => stmt.isAncestor(refPath))) {
return {

@@ -158,6 +201,2 @@ shouldDeopt: true

}
return {
shouldDeopt: true
};
}

@@ -169,3 +208,3 @@ } else if (binding.kind === "let" || binding.kind === "const") {

if (declaration.parentPath.isIfStatement() || declaration.parentPath.isLoop() || declaration.parentPath.isSwitchCase()) {
if (declaration.parentPath && (declaration.parentPath.isIfStatement() || declaration.parentPath.isLoop() || declaration.parentPath.isSwitchCase())) {
return {

@@ -183,3 +222,8 @@ shouldDeopt: true

const stmts = scopePath.get("body");
let stmts = scopePath.get("body");
if (!Array.isArray(stmts)) {
stmts = [stmts];
}
const compareResult = compareBindingAndReference({

@@ -186,0 +230,0 @@ binding,

{
"name": "babel-helper-evaluate-path",
"version": "0.5.0-alpha.34c3efe9",
"version": "0.5.0-alpha.36b27d42",
"description": "path.evaluate wrapped in a try catch",

@@ -5,0 +5,0 @@ "keywords": [

@@ -34,3 +34,3 @@ # babel-helper-evaluate-path

```sh
npm install babel-helper-evaluate-path
npm install babel-helper-evaluate-path --save-dev
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc