Socket
Socket
Sign inDemoInstall

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 2.1.0 to 3.0.0

23

index.js

@@ -1,2 +0,2 @@

var acorn = require('acorn-jsx/inject')(require('acorn'));
var babylon = require('babylon');
var assign = require('object-assign');

@@ -6,8 +6,21 @@

* @param {Object} options - Options to configure parser
* @param {Boolean} [options.ecmaVersion=5]
*/
module.exports = function(options) {
this.options = assign({
ecmaVersion: 6,
plugins: {jsx: true},
plugins: [
'jsx',
'flow',
'asyncFunctions',
'classConstructorCall',
'doExpressions',
'trailingFunctionCommas',
'objectRestSpread',
'decorators',
'classProperties',
'exportExtensions',
'exponentiationOperator',
'asyncGenerators',
'functionBind',
'functionSent'
],
sourceType: 'module'

@@ -32,3 +45,3 @@ }, options);

return acorn.parse(src, options);
return babylon.parse(src, options);
};

@@ -35,0 +48,0 @@

{
"name": "node-source-walk",
"version": "2.1.0",
"version": "3.0.0",
"description": "Execute a callback on every node of a source code's AST and stop walking when you see fit",

@@ -29,4 +29,3 @@ "main": "index.js",

"dependencies": {
"acorn": "^2.0.4",
"acorn-jsx": "^2.0.1",
"babylon": "~6.8.1",
"object-assign": "^4.0.1"

@@ -33,0 +32,0 @@ },

@@ -29,13 +29,16 @@ ### node-source-walk [![npm](http://img.shields.io/npm/v/node-source-walk.svg)](https://npmjs.org/package/node-source-walk) [![npm](http://img.shields.io/npm/dm/node-source-walk.svg)](https://npmjs.org/package/node-source-walk)

By default, Walker will use `acorn` supporting ES6 (and JSX) and the `sourceType: module`, but you can change any of the defaults as follows:
By default, Walker will use `babylon` (supporting ES6, JSX, Flow, and all other available babylon plugins) and the `sourceType: module`, but you can change any of the defaults as follows:
```js
var walker = new Walker({
ecmaVersion: 5,
sourceType: 'script'
sourceType: 'script',
// If you don't like experimental plugins
plugins: [
'jsx',
'flow'
]
});
```
* The supplied options are passed through to the parser, so you can configure it according
to acorn's documentation: https://github.com/marijnh/acorn
* The supplied options are passed through to the parser, so you can configure it according to babylon's documentation: https://github.com/babel/babylon

@@ -46,3 +49,3 @@ ### Public Members

* src: the contents of a file OR its AST (via Esprima or Acorn)
* src: the contents of a file **OR** its (already parsed) AST
* cb: a function that is called for every visited node

@@ -49,0 +52,0 @@

@@ -31,2 +31,9 @@ var assert = require('assert');

it('does not throw on ES7 async functions', function() {
var walker = new Walker();
assert.doesNotThrow(function() {
walker.walk('async function foo() {}', function() {});
});
});
describe('walk', function() {

@@ -72,3 +79,3 @@ var parseSpy, cb;

var secondNode = cb.getCall(1).args[0];
assert(secondNode.parent === firstNode.body);
assert(secondNode.parent === firstNode);
});

@@ -75,0 +82,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