estree-walker
Advanced tools
Comparing version 0.6.0 to 0.6.1
# changelog | ||
## 0.6.1 | ||
* Only traverse nodes that exist and have a type ([#9](https://github.com/Rich-Harris/estree-walker/pull/9)) | ||
* Only cache keys for nodes with a type ([#8](https://github.com/Rich-Harris/estree-walker/pull/8)) | ||
## 0.6.0 | ||
@@ -4,0 +9,0 @@ |
@@ -35,3 +35,3 @@ (function (global, factory) { | ||
const keys = childKeys[node.type] || ( | ||
const keys = node.type && childKeys[node.type] || ( | ||
childKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object') | ||
@@ -46,3 +46,3 @@ ); | ||
for (let j = 0; j < value.length; j += 1) { | ||
visit(value[j], node, enter, leave, key, j); | ||
value[j] && value[j].type && visit(value[j], node, enter, leave, key, j); | ||
} | ||
@@ -49,0 +49,0 @@ } |
{ | ||
"name": "estree-walker", | ||
"description": "Traverse an ESTree-compliant AST", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"author": "Rich Harris", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -19,9 +19,9 @@ # estree-walker | ||
ast = acorn.parse( sourceCode, options ); // https://github.com/marijnh/acorn | ||
ast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn | ||
walk( ast, { | ||
enter: function ( node, parent ) { | ||
enter: function ( node, parent, prop, index ) { | ||
// some code happens | ||
}, | ||
leave: function ( node, parent ) { | ||
leave: function ( node, parent, prop, index ) { | ||
// some code happens | ||
@@ -46,2 +46,2 @@ } | ||
MIT | ||
MIT |
@@ -29,3 +29,3 @@ export function walk(ast, { enter, leave }) { | ||
const keys = childKeys[node.type] || ( | ||
const keys = node.type && childKeys[node.type] || ( | ||
childKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object') | ||
@@ -40,3 +40,3 @@ ); | ||
for (let j = 0; j < value.length; j += 1) { | ||
visit(value[j], node, enter, leave, key, j); | ||
value[j] && value[j].type && visit(value[j], node, enter, leave, key, j); | ||
} | ||
@@ -43,0 +43,0 @@ } |
Sorry, the diff of this file is not supported yet
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
9526
46