node-source-walk
Advanced tools
Comparing version 1.1.2 to 1.2.0
19
index.js
var esprima = require('esprima'); | ||
var esprimaHarmony = require('esprima-fb'); | ||
module.exports = function () { | ||
// We use global state to stop the recursive | ||
// traversal of the AST | ||
/** | ||
* @param {Object} options | ||
* @param {Boolean} [options.esprimaHarmony=false] | ||
*/ | ||
module.exports = function (options) { | ||
options = options || {}; | ||
// We use global state to stop the recursive traversal of the AST | ||
this.shouldStop = false; | ||
if (options.esprimaHarmony) { | ||
esprima = esprimaHarmony; | ||
} | ||
}; | ||
@@ -18,3 +27,3 @@ | ||
node.forEach(function (x) { | ||
if(x != null) { | ||
if(x !== null) { | ||
// Mark that the node has been visited | ||
@@ -52,2 +61,2 @@ x.parent = node; | ||
this.shouldStop = true; | ||
}; | ||
}; |
{ | ||
"name": "node-source-walk", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Execute a callback on every node of a source code's AST and stop walking when you see fit", | ||
@@ -24,4 +24,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"esprima": "~1.0.4" | ||
"esprima": "~1.0.4", | ||
"esprima-fb": "~7001.1.0-dev-harmony-fb" | ||
} | ||
} |
@@ -1,3 +0,2 @@ | ||
Execute a callback on every node of a source code's AST and | ||
stop walking whenever you see fit. | ||
Execute a callback on every node of a source code's AST and stop walking whenever you see fit. | ||
@@ -36,2 +35,10 @@ *A variation of [substack/node-detective](https://github.com/substack/node-detective) | ||
By default, Walker will use `esprima`, but you can switch to `esprima-fb` (harmony branch) as follows: | ||
```js | ||
var walker = new Walker({ | ||
esprimaHarmony: true | ||
}); | ||
``` | ||
### Public Members | ||
@@ -52,2 +59,2 @@ | ||
* Allows you to traverse an AST node and execute a callback on it | ||
* Callback should expect the first argument to be an AST node, similar to `walk`'s callback. | ||
* Callback should expect the first argument to be an AST node, similar to `walk`'s callback. |
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
4060
61
59
2
+ Addedesprima-fb@7001.1.0-dev-harmony-fb(transitive)