node-source-walk
Advanced tools
Comparing version 1.2.0 to 1.3.0
18
index.js
@@ -1,16 +0,14 @@ | ||
var esprima = require('esprima'); | ||
var esprimaHarmony = require('esprima-fb'); | ||
var acorn = require('acorn'); | ||
/** | ||
* @param {Object} options | ||
* @param {Boolean} [options.esprimaHarmony=false] | ||
* @param {Object} options - Options to configure parser | ||
* @param {Boolean} [options.ecmaVersion=5] | ||
*/ | ||
module.exports = function (options) { | ||
options = options || {}; | ||
this.options = options || {}; | ||
this.options.ecmaVersion = this.options.ecmaVersion || 5; | ||
// We use global state to stop the recursive traversal of the AST | ||
this.shouldStop = false; | ||
if (options.esprimaHarmony) { | ||
esprima = esprimaHarmony; | ||
} | ||
}; | ||
@@ -52,3 +50,3 @@ | ||
var ast = esprima.parse(src); | ||
var ast = acorn.parse(src, this.options); | ||
@@ -55,0 +53,0 @@ this.traverse(ast, cb); |
{ | ||
"name": "node-source-walk", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Execute a callback on every node of a source code's AST and stop walking when you see fit", | ||
@@ -15,3 +15,5 @@ "main": "index.js", | ||
"ast", | ||
"traversal" | ||
"traversal", | ||
"esprima", | ||
"acorn" | ||
], | ||
@@ -25,5 +27,4 @@ "author": "Joel Kemp <joel@mrjoelkemp.com> (http://www.mrjoelkemp.com/)", | ||
"dependencies": { | ||
"esprima": "~1.0.4", | ||
"esprima-fb": "~7001.1.0-dev-harmony-fb" | ||
"acorn": "~0.10.0" | ||
} | ||
} |
@@ -35,10 +35,13 @@ Execute a callback on every node of a source code's AST and stop walking whenever you see fit. | ||
By default, Walker will use `esprima`, but you can switch to `esprima-fb` (harmony branch) as follows: | ||
By default, Walker will use `acorn` supporting ES5, but you can switch to es6 as follows: | ||
```js | ||
var walker = new Walker({ | ||
esprimaHarmony: true | ||
ecmaVersion: 6 | ||
}); | ||
``` | ||
* The supplied options are passed through to the parser, so you can configure it according | ||
to acorn's documentation: https://github.com/marijnh/acorn | ||
### Public Members | ||
@@ -45,0 +48,0 @@ |
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
4160
1
62
58
+ Addedacorn@~0.10.0
+ Addedacorn@0.10.0(transitive)
- Removedesprima@~1.0.4
- Removedesprima-fb@~7001.1.0-dev-harmony-fb
- Removedesprima@1.0.4(transitive)
- Removedesprima-fb@7001.1.0-dev-harmony-fb(transitive)