Socket
Socket
Sign inDemoInstall

ast-types

Package Overview
Dependencies
27
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.3.1

6

lib/traverse.js

@@ -26,3 +26,7 @@ var types = require("./types");

traverse(new NodePath(node));
// Just in case we call this.replace at the root, there needs to be an
// additional parent Path to update.
var rootPath = new NodePath({ root: node });
traverse(rootPath.get("root"));
return rootPath.value.root;
};

4

package.json

@@ -21,3 +21,3 @@ {

],
"version": "0.3.0",
"version": "0.3.1",
"homepage": "http://github.com/benjamn/ast-types",

@@ -33,3 +33,3 @@ "repository": {

"dependencies": {
"ast-path": "~0.1.0"
"ast-path": "~0.1.1"
},

@@ -36,0 +36,0 @@ "devDependencies": {},

@@ -282,3 +282,3 @@ var types = require("../main");

traverse(ts, function(node) {
n.TryStatement.assert(traverse(ts, function(node) {
if (n.Literal.check(node)) {

@@ -293,3 +293,3 @@ literalCount += 1;

}
});
}), true);

@@ -329,2 +329,24 @@ assert.strictEqual(literalCount, 2);

exports.testReplaceRoot = function(t, assert) {
var ast = b.expressionStatement(
b.unaryExpression("!", b.sequenceExpression([
b.identifier("a"),
b.identifier("b"),
b.identifier("c")
]))
);
var callExp = types.traverse(ast, function(node) {
if (n.ExpressionStatement.check(node)) {
this.replace(b.callExpression(b.identifier("f"), [
node.expression
]));
}
});
n.CallExpression.assert(callExp, true);
t.finish();
};
exports.testNodePath = function(t, assert) {

@@ -331,0 +353,0 @@ assert.strictEqual(new Path({}).constructor, Path);

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc