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

estree-walker

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

estree-walker - npm Package Compare versions

Comparing version 0.5.2 to 0.6.0

5

CHANGELOG.md
# changelog
## 0.6.0
* Fix walker context type
* Update deps, remove unncessary Bublé transformation
## 0.5.2

@@ -4,0 +9,0 @@

79

dist/estree-walker.umd.js

@@ -7,63 +7,60 @@ (function (global, factory) {

function walk ( ast, ref) {
var enter = ref.enter;
var leave = ref.leave;
function walk(ast, { enter, leave }) {
visit(ast, null, enter, leave);
}
visit( ast, null, enter, leave );
}
let shouldSkip = false;
const context = { skip: () => shouldSkip = true };
var shouldSkip = false;
var context = { skip: function () { return shouldSkip = true; } };
const childKeys = {};
var childKeys = {};
const toString = Object.prototype.toString;
var toString = Object.prototype.toString;
function isArray(thing) {
return toString.call(thing) === '[object Array]';
}
function isArray ( thing ) {
return toString.call( thing ) === '[object Array]';
}
function visit(node, parent, enter, leave, prop, index) {
if (!node) return;
function visit ( node, parent, enter, leave, prop, index ) {
if ( !node ) { return; }
if (enter) {
const _shouldSkip = shouldSkip;
shouldSkip = false;
enter.call(context, node, parent, prop, index);
const skipped = shouldSkip;
shouldSkip = _shouldSkip;
if ( enter ) {
var _shouldSkip = shouldSkip;
shouldSkip = false;
enter.call( context, node, parent, prop, index );
var skipped = shouldSkip;
shouldSkip = _shouldSkip;
if (skipped) return;
}
if ( skipped ) { return; }
}
const keys = childKeys[node.type] || (
childKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object')
);
var keys = childKeys[ node.type ] || (
childKeys[ node.type ] = Object.keys( node ).filter( function (key) { return typeof node[ key ] === 'object'; } )
);
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
const value = node[key];
for ( var i = 0; i < keys.length; i += 1 ) {
var key = keys[i];
var value = node[ key ];
if (isArray(value)) {
for (let j = 0; j < value.length; j += 1) {
visit(value[j], node, enter, leave, key, j);
}
}
if ( isArray( value ) ) {
for ( var j = 0; j < value.length; j += 1 ) {
visit( value[j], node, enter, leave, key, j );
else if (value && value.type) {
visit(value, node, enter, leave, key, null);
}
}
else if ( value && value.type ) {
visit( value, node, enter, leave, key, null );
if (leave) {
leave(node, parent, prop, index);
}
}
if ( leave ) {
leave( node, parent, prop, index );
}
}
exports.walk = walk;
exports.childKeys = childKeys;
exports.walk = walk;
exports.childKeys = childKeys;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=estree-walker.umd.js.map

@@ -9,4 +9,14 @@ declare module "estree-walker" {

export type WalkerListener = (node: Node, parent?: Node, prop?: string, index?: number) => void;
export type WalkerContext = {
skip: () => void;
};
export type WalkerListener = (
this: WalkerContext,
node: Node,
parent?: Node,
prop?: string,
index?: number
) => void;
export interface WalkerOptions {

@@ -13,0 +23,0 @@ enter?: WalkerListener;

{
"name": "estree-walker",
"description": "Traverse an ESTree-compliant AST",
"version": "0.5.2",
"version": "0.6.0",
"author": "Rich Harris",

@@ -13,17 +13,12 @@ "license": "MIT",

"main": "dist/estree-walker.umd.js",
"module": "dist/estree-walker.es.js",
"jsnext:main": "dist/estree-walker.es.js",
"module": "src/estree-walker.js",
"scripts": {
"prepublish": "npm run lint && npm test",
"prepublishOnly": "npm test",
"build": "rollup -c",
"test": "mocha test/test.js --compilers js:buble/register",
"pretest": "npm run build",
"lint": "eslint src"
"test": "mocha test/test.js",
"pretest": "npm run build"
},
"devDependencies": {
"buble": "^0.15.2",
"eslint": "^4.5.0",
"mocha": "^3.5.0",
"rollup": "^0.48.0",
"rollup-plugin-buble": "^0.15.0"
"mocha": "^5.2.0",
"rollup": "^0.67.3"
},

@@ -30,0 +25,0 @@ "files": [

@@ -1,3 +0,3 @@

export function walk ( ast, { enter, leave }) {
visit( ast, null, enter, leave );
export function walk(ast, { enter, leave }) {
visit(ast, null, enter, leave);
}

@@ -12,41 +12,41 @@

function isArray ( thing ) {
return toString.call( thing ) === '[object Array]';
function isArray(thing) {
return toString.call(thing) === '[object Array]';
}
function visit ( node, parent, enter, leave, prop, index ) {
if ( !node ) return;
function visit(node, parent, enter, leave, prop, index) {
if (!node) return;
if ( enter ) {
let _shouldSkip = shouldSkip;
if (enter) {
const _shouldSkip = shouldSkip;
shouldSkip = false;
enter.call( context, node, parent, prop, index );
enter.call(context, node, parent, prop, index);
const skipped = shouldSkip;
shouldSkip = _shouldSkip;
if ( skipped ) return;
if (skipped) return;
}
const keys = childKeys[ node.type ] || (
childKeys[ node.type ] = Object.keys( node ).filter( key => typeof node[ key ] === 'object' )
const keys = childKeys[node.type] || (
childKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object')
);
for ( let i = 0; i < keys.length; i += 1 ) {
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
const value = node[ key ];
const value = node[key];
if ( isArray( value ) ) {
for ( let j = 0; j < value.length; j += 1 ) {
visit( value[j], node, enter, leave, key, j );
if (isArray(value)) {
for (let j = 0; j < value.length; j += 1) {
visit(value[j], node, enter, leave, key, j);
}
}
else if ( value && value.type ) {
visit( value, node, enter, leave, key, null );
else if (value && value.type) {
visit(value, node, enter, leave, key, null);
}
}
if ( leave ) {
leave( node, parent, prop, index );
if (leave) {
leave(node, parent, prop, index);
}
}

Sorry, the diff of this file is not supported yet

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