Socket
Socket
Sign inDemoInstall

ast-types

Package Overview
Dependencies
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-types - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

15

lib/traverse.js

@@ -29,7 +29,12 @@ var assert = require("assert");

// 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;
if (node instanceof NodePath) {
traverse(node);
return node.value;
} else {
// 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;
}
};

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

],
"version": "0.3.3",
"version": "0.3.4",
"homepage": "http://github.com/benjamn/ast-types",

@@ -24,0 +24,0 @@ "repository": {

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

exports.testTraverse = function(t, assert) {
exports.testTraverseNode = function(t, assert) {
var traverse = types.traverse;

@@ -328,2 +328,36 @@

exports.testTraversePath = function(t, assert) {
var call = b.expressionStatement(
b.callExpression(
b.memberExpression(
b.identifier("foo"),
b.identifier("bar"),
false
),
[b.literal("baz")]
)
);
var path = new NodePath(call).get("expression", "callee");
var idCount = 0;
// Note that we're passing a path instead of a node as the first
// argument to types.traverse.
types.traverse(path, function(node) {
if (n.Identifier.check(node)) {
++idCount;
if (node.name === "bar") {
n.MemberExpression.assert(this.parent.node);
n.CallExpression.assert(this.parent.parent.node);
n.ExpressionStatement.assert(this.parent.parent.parent.node);
}
}
});
assert.strictEqual(idCount, 2);
t.finish();
};
exports.testReplaceRoot = function(t, assert) {

@@ -330,0 +364,0 @@ var ast = b.expressionStatement(

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