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

ast-util

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-util - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

20

lib/index.js

@@ -268,7 +268,12 @@ /* jshint node:true, undef:true, unused:true */

types.traverse(ast, function(node) {
if (isReference(this) && !this.scope.lookup(node.name)) {
if (!(node.name in seen)) {
seen[node.name] = true;
globals.push(node);
types.visit(ast, {
visitNode: function(path) {
this.traverse(path);
var node = path.value;
if (isReference(path) && !path.scope.lookup(node.name)) {
if (!(node.name in seen)) {
seen[node.name] = true;
globals.push(node);
}
}

@@ -356,8 +361,7 @@ }

bodyPath.get(0).replace(
bodyPath.unshift(
b.variableDeclaration(
'var',
[b.variableDeclarator(identifier, init || null)]
),
bodyPath.get(0).value
)
);

@@ -364,0 +368,0 @@

8

package.json
{
"name": "ast-util",
"version": "0.3.0",
"version": "0.3.1",
"description": "Utilities for AST transformers.",

@@ -31,9 +31,9 @@ "main": "lib/index.js",

"mocha": "^1.18.2",
"recast": "^0.5.16",
"recast": "^0.6.2",
"esprima": "git://github.com/ariya/esprima.git#harmony"
},
"dependencies": {
"ast-types": "^0.3.26",
"private": "^0.1.3"
"ast-types": "^0.4.1",
"private": "^0.1.5"
}
}

@@ -24,5 +24,9 @@ /* jshint node:true, mocha:true, undef:true, unused:true */

var ast = parse(source);
types.traverse(ast, function(node) {
if (n.Identifier.check(node) && node.name === 'IT') {
callback.call(this, node);
types.visit(ast, {
visitIdentifier: function(path) {
if (path.value.name === 'IT') {
callback.call(path, path.value);
return false;
}
this.traverse(path);
}

@@ -213,6 +217,7 @@ });

it('can check names', function() {
types.traverse(parse('a'), function(node) {
if (n.Identifier.check(node)) {
assert.ok(util.isReference(this, 'a'));
assert.ok(!util.isReference(this, 'b'));
types.visit(parse('a'), {
visitIdentifier: function(path) {
assert.ok(util.isReference(path, 'a'));
assert.ok(!util.isReference(path, 'b'));
return false;
}

@@ -303,8 +308,8 @@ });

types.traverse(ast, function(node) {
if (n.VariableDeclaration.check(node)) {
util.injectVariable(this.scope, b.identifier('b'));
this.replace(b.expressionStatement(
types.visit(ast, {
visitVariableDeclaration: function(path) {
util.injectVariable(path.scope, b.identifier('b'));
return b.expressionStatement(
b.callExpression(b.identifier('replacement'), [])
));
);
}

@@ -311,0 +316,0 @@ });

Sorry, the diff of this file is not supported yet

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