Socket
Socket
Sign inDemoInstall

estree-walker

Package Overview
Dependencies
0
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.0 to 1.0.0

4

CHANGELOG.md
# changelog
## 1.0.0
* Don't cache child keys
## 0.9.0

@@ -4,0 +8,0 @@

22

dist/estree-walker.umd.js

@@ -20,4 +20,2 @@ (function (global, factory) {

const childKeys = {};
function replace(parent, prop, index, node) {

@@ -82,13 +80,12 @@ if (parent) {

const keys = node.type && childKeys[node.type] || (
childKeys[node.type] = Object.keys(node).filter(key => typeof (node )[key] === 'object')
);
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
for (const key in node) {
const value = (node )[key];
if (Array.isArray(value)) {
if (typeof value !== 'object') {
continue;
}
else if (Array.isArray(value)) {
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
if (value[j] && value[j].type) {
if (value[j] !== null && typeof value[j].type === 'string') {
if (!visit(value[j], node, enter, leave, key, k)) {

@@ -102,3 +99,3 @@ // removed

else if (value && value.type) {
else if (value !== null && typeof value.type === 'string') {
visit(value, node, enter, leave, key, null);

@@ -126,3 +123,3 @@ }

const removed = should_remove;
replacement = _replacement;

@@ -139,3 +136,2 @@ should_remove = _should_remove;

exports.walk = walk;
exports.childKeys = childKeys;

@@ -142,0 +138,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

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

@@ -16,4 +16,3 @@ "license": "MIT",

"prepublishOnly": "npm run build && npm test",
"build-declarations": "tsc -d && node scripts/move-type-declarations.js",
"build": "npm run build-declarations && rollup -c",
"build": "tsc && rollup -c",
"test": "mocha --opts mocha.opts"

@@ -26,4 +25,2 @@ },

"rollup-plugin-sucrase": "^2.1.0",
"sander": "^0.6.0",
"tiny-glob": "^0.2.6",
"typescript": "^3.6.3"

@@ -30,0 +27,0 @@ },

@@ -14,4 +14,2 @@ function walk(ast, { enter, leave }) {

const childKeys = {};
function replace(parent, prop, index, node) {

@@ -76,13 +74,12 @@ if (parent) {

const keys = node.type && childKeys[node.type] || (
childKeys[node.type] = Object.keys(node).filter(key => typeof (node )[key] === 'object')
);
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
for (const key in node) {
const value = (node )[key];
if (Array.isArray(value)) {
if (typeof value !== 'object') {
continue;
}
else if (Array.isArray(value)) {
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
if (value[j] && value[j].type) {
if (value[j] !== null && typeof value[j].type === 'string') {
if (!visit(value[j], node, enter, leave, key, k)) {

@@ -96,3 +93,3 @@ // removed

else if (value && value.type) {
else if (value !== null && typeof value.type === 'string') {
visit(value, node, enter, leave, key, null);

@@ -120,3 +117,3 @@ }

const removed = should_remove;
replacement = _replacement;

@@ -132,2 +129,2 @@ should_remove = _should_remove;

export { walk, childKeys };
export { walk };

@@ -35,4 +35,2 @@ import { Node } from "estree";

export const childKeys: Record<string, string[]> = {};
function replace(parent: any, prop: string, index: number, node: Node) {

@@ -97,13 +95,12 @@ if (parent) {

const keys = node.type && childKeys[node.type] || (
childKeys[node.type] = Object.keys(node).filter(key => typeof (node as any)[key] === 'object')
);
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
for (const key in node) {
const value = (node as any)[key];
if (Array.isArray(value)) {
if (typeof value !== 'object') {
continue;
}
else if (Array.isArray(value)) {
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
if (value[j] && value[j].type) {
if (value[j] !== null && typeof value[j].type === 'string') {
if (!visit(value[j], node, enter, leave, key, k)) {

@@ -117,3 +114,3 @@ // removed

else if (value && value.type) {
else if (value !== null && typeof value.type === 'string') {
visit(value, node, enter, leave, key, null);

@@ -141,3 +138,3 @@ }

const removed = should_remove;
replacement = _replacement;

@@ -144,0 +141,0 @@ should_remove = _should_remove;

@@ -13,3 +13,2 @@ import { Node } from "estree";

export declare function walk(ast: Node, { enter, leave }: Walker): import("estree").Identifier | import("estree").SimpleLiteral | import("estree").RegExpLiteral | import("estree").Program | import("estree").FunctionDeclaration | import("estree").FunctionExpression | import("estree").ArrowFunctionExpression | import("estree").SwitchCase | import("estree").CatchClause | import("estree").VariableDeclarator | import("estree").ExpressionStatement | import("estree").BlockStatement | import("estree").EmptyStatement | import("estree").DebuggerStatement | import("estree").WithStatement | import("estree").ReturnStatement | import("estree").LabeledStatement | import("estree").BreakStatement | import("estree").ContinueStatement | import("estree").IfStatement | import("estree").SwitchStatement | import("estree").ThrowStatement | import("estree").TryStatement | import("estree").WhileStatement | import("estree").DoWhileStatement | import("estree").ForStatement | import("estree").ForInStatement | import("estree").ForOfStatement | import("estree").VariableDeclaration | import("estree").ClassDeclaration | import("estree").ThisExpression | import("estree").ArrayExpression | import("estree").ObjectExpression | import("estree").YieldExpression | import("estree").UnaryExpression | import("estree").UpdateExpression | import("estree").BinaryExpression | import("estree").AssignmentExpression | import("estree").LogicalExpression | import("estree").MemberExpression | import("estree").ConditionalExpression | import("estree").SimpleCallExpression | import("estree").NewExpression | import("estree").SequenceExpression | import("estree").TemplateLiteral | import("estree").TaggedTemplateExpression | import("estree").ClassExpression | import("estree").MetaProperty | import("estree").AwaitExpression | import("estree").Property | import("estree").Super | import("estree").TemplateElement | import("estree").SpreadElement | import("estree").ObjectPattern | import("estree").ArrayPattern | import("estree").RestElement | import("estree").AssignmentPattern | import("estree").ClassBody | import("estree").MethodDefinition | import("estree").ImportDeclaration | import("estree").ExportNamedDeclaration | import("estree").ExportDefaultDeclaration | import("estree").ExportAllDeclaration | import("estree").ImportSpecifier | import("estree").ImportDefaultSpecifier | import("estree").ImportNamespaceSpecifier | import("estree").ExportSpecifier;
export declare const childKeys: Record<string, string[]>;
export {};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc