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

node-source-walk

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-source-walk - npm Package Compare versions

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 @@

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