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 3.3.0 to 4.0.0

56

index.js

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

var babylon = require('babylon');
const parser = require('@babel/parser');

@@ -7,5 +7,4 @@ /**

*/
module.exports = function(options) {
options = options || {};
this.parser = options.parser || babylon;
module.exports = function(options = {}) {
this.parser = options.parser || parser;

@@ -17,24 +16,21 @@ if (options.parser) {

this.options = options;
this.options.plugins = options.plugins || [
'jsx',
'flow',
'asyncFunctions',
'classConstructorCall',
'doExpressions',
'trailingFunctionCommas',
'objectRestSpread',
'decorators',
'classProperties',
'exportExtensions',
'exponentiationOperator',
'asyncGenerators',
'functionBind',
'functionSent',
'dynamicImport'
];
this.options = Object.assign({
plugins: [
'jsx',
'flow',
'doExpressions',
'objectRestSpread',
['decorators', {decoratorsBeforeExport: false}],
'classProperties',
'exportDefaultFrom',
'exportNamespaceFrom',
'asyncGenerators',
'functionBind',
'functionSent',
'dynamicImport'
],
allowHashBang: true,
sourceType: 'module'
}, options);
this.options.allowHashBang = options.allowHashBang || true;
this.options.sourceType = options.sourceType || 'module';
// We use global state to stop the recursive traversal of the AST

@@ -68,4 +64,4 @@ this.shouldStop = false;

if (Array.isArray(node)) {
for (var i = 0, l = node.length; i < l; i++) {
var x = node[i];
for (let i = 0, l = node.length; i < l; i++) {
const x = node[i];
if (x !== null) {

@@ -81,3 +77,3 @@ // Mark that the node has been visited

for (var key in node) {
for (let key in node) {
// Avoid visited nodes

@@ -102,3 +98,3 @@ if (key === 'parent' || !node[key]) { continue; }

var ast = typeof src === 'object' ? src : this.parse(src);
const ast = typeof src === 'object' ? src : this.parse(src);

@@ -122,3 +118,3 @@ this.traverse(ast, cb);

if (node.parent instanceof Array) {
for (var i = 0, l = node.parent.length; i < l; i++) {
for (let i = 0, l = node.parent.length; i < l; i++) {
cb(node.parent[i]);

@@ -125,0 +121,0 @@ }

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

@@ -29,10 +29,13 @@ "main": "index.js",

"dependencies": {
"babylon": "^6.17.0"
"@babel/parser": "^7.0.0"
},
"engines": {
"node": ">=6.0"
},
"devDependencies": {
"jscs": "~2.4.0",
"jscs-preset-mrjoelkemp": "~1.0.0",
"mocha": "~2.2.5",
"sinon": "~1.17.4"
"mocha": "^5.2.0",
"sinon": "^6.1.5"
}
}
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