@babel/traverse
Advanced tools
Comparing version 7.0.0-beta.4 to 7.0.0-beta.5
@@ -21,2 +21,3 @@ "use strict"; | ||
exports._resolve = _resolve; | ||
exports.isConstantExpression = isConstantExpression; | ||
exports.is = void 0; | ||
@@ -321,2 +322,42 @@ | ||
} | ||
} | ||
function isConstantExpression() { | ||
if (this.isIdentifier()) { | ||
var binding = this.scope.getBinding(this.node.name); | ||
if (!binding) { | ||
return false; | ||
} | ||
return binding.constant && binding.path.get("init").isConstantExpression(); | ||
} | ||
if (this.isLiteral()) { | ||
if (this.isRegExpLiteral()) { | ||
return false; | ||
} | ||
if (this.isTemplateLiteral()) { | ||
return this.get("expressions").every(function (expression) { | ||
return expression.isConstantExpression(); | ||
}); | ||
} | ||
return true; | ||
} | ||
if (this.isUnaryExpression()) { | ||
if (this.get("operator").node !== "void") { | ||
return false; | ||
} | ||
return this.get("argument").isConstantExpression(); | ||
} | ||
if (this.isBinaryExpression()) { | ||
return this.get("left").isConstantExpression() && this.get("right").isConstantExpression(); | ||
} | ||
return false; | ||
} |
{ | ||
"name": "@babel/traverse", | ||
"version": "7.0.0-beta.4", | ||
"version": "7.0.0-beta.5", | ||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", | ||
@@ -11,5 +11,5 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"dependencies": { | ||
"@babel/code-frame": "7.0.0-beta.4", | ||
"@babel/helper-function-name": "7.0.0-beta.4", | ||
"@babel/types": "7.0.0-beta.4", | ||
"@babel/code-frame": "7.0.0-beta.5", | ||
"@babel/helper-function-name": "7.0.0-beta.5", | ||
"@babel/types": "7.0.0-beta.5", | ||
"babylon": "7.0.0-beta.30", | ||
@@ -22,5 +22,5 @@ "debug": "^3.0.1", | ||
"devDependencies": { | ||
"@babel/generator": "7.0.0-beta.4", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.4" | ||
"@babel/generator": "7.0.0-beta.5", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.5" | ||
} | ||
} |
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
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
152609
4346
+ Added@babel/code-frame@7.0.0-beta.5(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.5(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.5(transitive)
+ Added@babel/template@7.0.0-beta.5(transitive)
+ Added@babel/types@7.0.0-beta.5(transitive)
- Removed@babel/code-frame@7.0.0-beta.4(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.4(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.4(transitive)
- Removed@babel/template@7.0.0-beta.4(transitive)
- Removed@babel/types@7.0.0-beta.4(transitive)
Updated@babel/types@7.0.0-beta.5