Socket
Socket
Sign inDemoInstall

node-source-walk

Package Overview
Dependencies
Maintainers
2
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 4.2.2 to 4.3.0

LICENSE

43

index.js

@@ -19,14 +19,18 @@ const parser = require('@babel/parser');

'flow',
'asyncGenerators',
'classProperties',
'doExpressions',
'objectRestSpread',
['decorators', {decoratorsBeforeExport: true}],
'classProperties',
'dynamicImport',
'exportDefaultFrom',
'exportNamespaceFrom',
'asyncGenerators',
'functionBind',
'functionSent',
'dynamicImport',
'optionalChaining',
'nullishCoalescingOperator'
'nullishCoalescingOperator',
'objectRestSpread',
[
'decorators', {
decoratorsBeforeExport: true
}
],
'optionalChaining'
],

@@ -62,20 +66,19 @@ allowHashBang: true,

module.exports.prototype.traverse = function(node, cb) {
if (this.shouldStop) { return; }
if (this.shouldStop) return;
if (Array.isArray(node)) {
for (let i = 0, l = node.length; i < l; i++) {
const x = node[i];
if (x !== null) {
for (const key of node) {
if (key !== null) {
// Mark that the node has been visited
x.parent = node;
this.traverse(x, cb);
key.parent = node;
this.traverse(key, cb);
}
}
} else if (node && typeof node === 'object') {
cb(node);
for (let key in node) {
// TODO switch to Object.entries
for (const key of Object.keys(node)) {
// Avoid visited nodes
if (key === 'parent' || !node[key]) { continue; }
if (key === 'parent' || !node[key]) continue;

@@ -114,7 +117,7 @@ node[key].parent = node;

function reverseTraverse(node, cb) {
if (this.shouldStop || !node.parent) { return; }
if (this.shouldStop || !node.parent) return;
if (node.parent instanceof Array) {
for (let i = 0, l = node.parent.length; i < l; i++) {
cb(node.parent[i]);
if (Array.isArray(node.parent)) {
for (const parent of node.parent) {
cb(parent);
}

@@ -121,0 +124,0 @@ } else {

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

@@ -5,0 +5,0 @@ "main": "index.js",

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