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

estraverse

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

estraverse - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

.editorconfig

186

estraverse.js

@@ -48,56 +48,5 @@ /*

BREAK,
SKIP;
SKIP,
REMOVE;
Syntax = {
AssignmentExpression: 'AssignmentExpression',
ArrayExpression: 'ArrayExpression',
ArrayPattern: 'ArrayPattern',
ArrowFunctionExpression: 'ArrowFunctionExpression',
BlockStatement: 'BlockStatement',
BinaryExpression: 'BinaryExpression',
BreakStatement: 'BreakStatement',
CallExpression: 'CallExpression',
CatchClause: 'CatchClause',
ClassBody: 'ClassBody',
ClassDeclaration: 'ClassDeclaration',
ClassExpression: 'ClassExpression',
ConditionalExpression: 'ConditionalExpression',
ContinueStatement: 'ContinueStatement',
DebuggerStatement: 'DebuggerStatement',
DirectiveStatement: 'DirectiveStatement',
DoWhileStatement: 'DoWhileStatement',
EmptyStatement: 'EmptyStatement',
ExpressionStatement: 'ExpressionStatement',
ForStatement: 'ForStatement',
ForInStatement: 'ForInStatement',
FunctionDeclaration: 'FunctionDeclaration',
FunctionExpression: 'FunctionExpression',
Identifier: 'Identifier',
IfStatement: 'IfStatement',
Literal: 'Literal',
LabeledStatement: 'LabeledStatement',
LogicalExpression: 'LogicalExpression',
MemberExpression: 'MemberExpression',
MethodDefinition: 'MethodDefinition',
NewExpression: 'NewExpression',
ObjectExpression: 'ObjectExpression',
ObjectPattern: 'ObjectPattern',
Program: 'Program',
Property: 'Property',
ReturnStatement: 'ReturnStatement',
SequenceExpression: 'SequenceExpression',
SwitchStatement: 'SwitchStatement',
SwitchCase: 'SwitchCase',
ThisExpression: 'ThisExpression',
ThrowStatement: 'ThrowStatement',
TryStatement: 'TryStatement',
UnaryExpression: 'UnaryExpression',
UpdateExpression: 'UpdateExpression',
VariableDeclaration: 'VariableDeclaration',
VariableDeclarator: 'VariableDeclarator',
WhileStatement: 'WhileStatement',
WithStatement: 'WithStatement',
YieldExpression: 'YieldExpression'
};
function ignoreJSHintError() { }

@@ -180,2 +129,70 @@

Syntax = {
AssignmentExpression: 'AssignmentExpression',
ArrayExpression: 'ArrayExpression',
ArrayPattern: 'ArrayPattern',
ArrowFunctionExpression: 'ArrowFunctionExpression',
BlockStatement: 'BlockStatement',
BinaryExpression: 'BinaryExpression',
BreakStatement: 'BreakStatement',
CallExpression: 'CallExpression',
CatchClause: 'CatchClause',
ClassBody: 'ClassBody',
ClassDeclaration: 'ClassDeclaration',
ClassExpression: 'ClassExpression',
/* CAUTION: It's deferred to ES7. */ ComprehensionBlock: 'ComprehensionBlock',
/* CAUTION: It's deferred to ES7. */ ComprehensionExpression: 'ComprehensionExpression',
ConditionalExpression: 'ConditionalExpression',
ContinueStatement: 'ContinueStatement',
DebuggerStatement: 'DebuggerStatement',
DirectiveStatement: 'DirectiveStatement',
DoWhileStatement: 'DoWhileStatement',
EmptyStatement: 'EmptyStatement',
ExportBatchSpecifier: 'ExportBatchSpecifier',
ExportDeclaration: 'ExportDeclaration',
ExportSpecifier: 'ExportSpecifier',
ExpressionStatement: 'ExpressionStatement',
ForStatement: 'ForStatement',
ForInStatement: 'ForInStatement',
ForOfStatement: 'ForOfStatement',
FunctionDeclaration: 'FunctionDeclaration',
FunctionExpression: 'FunctionExpression',
/* CAUTION: It's deferred to ES7. */ GeneratorExpression: 'GeneratorExpression',
Identifier: 'Identifier',
IfStatement: 'IfStatement',
ImportDeclaration: 'ImportDeclaration',
ImportDefaultSpecifier: 'ImportDefaultSpecifier',
ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
ImportSpecifier: 'ImportSpecifier',
Literal: 'Literal',
LabeledStatement: 'LabeledStatement',
LogicalExpression: 'LogicalExpression',
MemberExpression: 'MemberExpression',
MethodDefinition: 'MethodDefinition',
ModuleSpecifier: 'ModuleSpecifier',
NewExpression: 'NewExpression',
ObjectExpression: 'ObjectExpression',
ObjectPattern: 'ObjectPattern',
Program: 'Program',
Property: 'Property',
ReturnStatement: 'ReturnStatement',
SequenceExpression: 'SequenceExpression',
SpreadElement: 'SpreadElement',
SwitchStatement: 'SwitchStatement',
SwitchCase: 'SwitchCase',
TaggedTemplateExpression: 'TaggedTemplateExpression',
TemplateElement: 'TemplateElement',
TemplateLiteral: 'TemplateLiteral',
ThisExpression: 'ThisExpression',
ThrowStatement: 'ThrowStatement',
TryStatement: 'TryStatement',
UnaryExpression: 'UnaryExpression',
UpdateExpression: 'UpdateExpression',
VariableDeclaration: 'VariableDeclaration',
VariableDeclarator: 'VariableDeclarator',
WhileStatement: 'WhileStatement',
WithStatement: 'WithStatement',
YieldExpression: 'YieldExpression'
};
VisitorKeys = {

@@ -194,2 +211,4 @@ AssignmentExpression: ['left', 'right'],

ClassExpression: ['id', 'body', 'superClass'],
/* CAUTION: It's deferred to ES7. */ ComprehensionBlock: ['left', 'right'],
/* CAUTION: It's deferred to ES7. */ ComprehensionExpression: ['blocks', 'filter', 'body'],
ConditionalExpression: ['test', 'consequent', 'alternate'],

@@ -201,2 +220,5 @@ ContinueStatement: ['label'],

EmptyStatement: [],
ExportBatchSpecifier: [],
ExportDeclaration: ['declaration', 'specifiers', 'source'],
ExportSpecifier: ['id', 'name'],
ExpressionStatement: ['expression'],

@@ -208,4 +230,9 @@ ForStatement: ['init', 'test', 'update', 'body'],

FunctionExpression: ['id', 'params', 'defaults', 'rest', 'body'],
/* CAUTION: It's deferred to ES7. */ GeneratorExpression: ['blocks', 'filter', 'body'],
Identifier: [],
IfStatement: ['test', 'consequent', 'alternate'],
ImportDeclaration: ['specifiers', 'source'],
ImportDefaultSpecifier: ['id'],
ImportNamespaceSpecifier: ['id'],
ImportSpecifier: ['id', 'name'],
Literal: [],

@@ -216,2 +243,3 @@ LabeledStatement: ['label', 'body'],

MethodDefinition: ['key', 'value'],
ModuleSpecifier: [],
NewExpression: ['callee', 'arguments'],

@@ -224,4 +252,8 @@ ObjectExpression: ['properties'],

SequenceExpression: ['expressions'],
SpreadElement: ['argument'],
SwitchStatement: ['discriminant', 'cases'],
SwitchCase: ['test', 'consequent'],
TaggedTemplateExpression: ['tag', 'quasi'],
TemplateElement: [],
TemplateLiteral: ['quasis', 'expressions'],
ThisExpression: [],

@@ -242,6 +274,8 @@ ThrowStatement: ['argument'],

SKIP = {};
REMOVE = {};
VisitorOption = {
Break: BREAK,
Skip: SKIP
Skip: SKIP,
Remove: REMOVE
};

@@ -258,2 +292,12 @@

Reference.prototype.remove = function remove() {
if (isArray(this.parent)) {
this.parent.splice(this.key, 1);
return true;
} else {
this.parent.replace(null);
return false;
}
};
function Element(node, path, wrap, ref) {

@@ -352,2 +396,8 @@ this.node = node;

// API:
// remove node
Controller.prototype.remove = function () {
this.notify(REMOVE);
};
Controller.prototype.__initialize = function(root, visitor) {

@@ -452,2 +502,17 @@ this.visitor = visitor;

Controller.prototype.replace = function replace(root, visitor) {
function removeElem() {
var i, nextElem;
if (element.ref.remove()) {
// if removed from array, then shift following items' keys
for (i = 1; i < worklist.length; i++) {
nextElem = worklist[i];
if (nextElem.ref.parent !== element.ref.parent) {
break;
}
nextElem.path[nextElem.path.length - 1] = --nextElem.ref.key;
}
}
}
var worklist,

@@ -493,3 +558,3 @@ leavelist,

// so distinguish between undefined and null in this place
if (target !== undefined && target !== BREAK && target !== SKIP) {
if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
// replace

@@ -499,2 +564,6 @@ element.ref.replace(target);

if (this.__state === REMOVE || target === REMOVE) {
removeElem();
}
if (this.__state === BREAK || target === BREAK) {

@@ -510,3 +579,3 @@ return outer.root;

// so distinguish between undefined and null in this place
if (target !== undefined && target !== BREAK && target !== SKIP) {
if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
// replace

@@ -517,2 +586,7 @@ element.ref.replace(target);

if (this.__state === REMOVE || target === REMOVE) {
removeElem();
element.node = null;
}
if (this.__state === BREAK || target === BREAK) {

@@ -519,0 +593,0 @@ return outer.root;

@@ -6,5 +6,5 @@ {

"main": "estraverse.js",
"version": "1.5.1",
"version": "1.6.0",
"engines": {
"node": ">=0.4.0"
"node": ">=0.10.0"
},

@@ -39,6 +39,6 @@ "maintainers": [

"unit-test": "mocha --compilers coffee:coffee-script",
"release-major": "xyz --increment major",
"release-minor": "xyz --increment minor",
"release-patch": "xyz --increment patch"
"release-major": "xyz --increment major --tag X.Y.Z",
"release-minor": "xyz --increment minor --tag X.Y.Z",
"release-patch": "xyz --increment patch --tag X.Y.Z"
}
}

@@ -7,2 +7,6 @@ ### Estraverse [![Build Status](https://secure.travis-ci.org/Constellation/estraverse.png)](http://travis-ci.org/Constellation/estraverse)

### Documentation
You can find usage docs at [wiki page](https://github.com/Constellation/estraverse/wiki/Usage).
### Example Usage

@@ -25,3 +29,3 @@

We can use `this.skip` and `this.break` functions instead of using Skip and Break.
We can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break.

@@ -28,0 +32,0 @@ ```javascript

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