node-source-walk
Advanced tools
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" | ||
} | ||
} |
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
6851
3
106
+ Added@babel/parser@^7.0.0
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.2(transitive)
+ Added@babel/types@7.26.0(transitive)
- Removedbabylon@^6.17.0
- Removedbabylon@6.18.0(transitive)