Socket
Socket
Sign inDemoInstall

ast-kit

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-kit - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

19

./dist/index.js

@@ -572,10 +572,13 @@ // src/check.ts

};
function getFilter(types) {
if (typeof types === "function")
return types;
return (node2) => isTypeOf(node2, Array.isArray(types) ? types : [types]);
}
const setup = {
onEnter(type, cb2) {
const types = Array.isArray(type) ? type : [type];
callbacks.enter.push({ types, cb: cb2 });
callbacks.enter.push({ filter: getFilter(type), cb: cb2 });
},
onLeave(type, cb2) {
const types = Array.isArray(type) ? type : [type];
callbacks.leave.push({ types, cb: cb2 });
callbacks.leave.push({ filter: getFilter(type), cb: cb2 });
}

@@ -586,4 +589,4 @@ };

async enter(node2, parent, key, index) {
for (const { types, cb: cb2 } of callbacks.enter) {
if (!isTypeOf(node2, types))
for (const { filter, cb: cb2 } of callbacks.enter) {
if (!filter(node2))
continue;

@@ -594,4 +597,4 @@ await cb2.call(this, node2, parent, key, index);

async leave(node2, parent, key, index) {
for (const { types, cb: cb2 } of callbacks.leave) {
if (!isTypeOf(node2, types))
for (const { filter, cb: cb2 } of callbacks.leave) {
if (!filter(node2))
continue;

@@ -598,0 +601,0 @@ await cb2.call(this, node2, parent, key, index);

@@ -71,5 +71,6 @@ import * as t from '@babel/types';

interface WalkSetup {
onEnter<T extends NodeType = NodeType>(type: T | T[], cb: SetupCallback<T>): void;
onLeave<T extends NodeType = NodeType>(type: T | T[], cb: SetupCallback<T>): void;
onEnter<T extends NodeType = NodeType>(type: T | T[] | WalkFilter<GetNode<T>>, cb: SetupCallback<T, GetNode<T>>): void;
onLeave<T extends NodeType = NodeType>(type: T | T[] | WalkFilter<GetNode<T>>, cb: SetupCallback<T, GetNode<T>>): void;
}
type WalkFilter<N extends t.Node = t.Node> = (node: t.Node) => node is N;
declare function walkASTSetup(node: t.Node, cb: (setup: WalkSetup) => void | Promise<void>): Promise<t.Node | null>;

@@ -76,0 +77,0 @@ interface ImportBinding {

@@ -572,10 +572,13 @@ // src/check.ts

};
function getFilter(types) {
if (typeof types === "function")
return types;
return (node2) => isTypeOf(node2, Array.isArray(types) ? types : [types]);
}
const setup = {
onEnter(type, cb2) {
const types = Array.isArray(type) ? type : [type];
callbacks.enter.push({ types, cb: cb2 });
callbacks.enter.push({ filter: getFilter(type), cb: cb2 });
},
onLeave(type, cb2) {
const types = Array.isArray(type) ? type : [type];
callbacks.leave.push({ types, cb: cb2 });
callbacks.leave.push({ filter: getFilter(type), cb: cb2 });
}

@@ -586,4 +589,4 @@ };

async enter(node2, parent, key, index) {
for (const { types, cb: cb2 } of callbacks.enter) {
if (!isTypeOf(node2, types))
for (const { filter, cb: cb2 } of callbacks.enter) {
if (!filter(node2))
continue;

@@ -594,4 +597,4 @@ await cb2.call(this, node2, parent, key, index);

async leave(node2, parent, key, index) {
for (const { types, cb: cb2 } of callbacks.leave) {
if (!isTypeOf(node2, types))
for (const { filter, cb: cb2 } of callbacks.leave) {
if (!filter(node2))
continue;

@@ -598,0 +601,0 @@ await cb2.call(this, node2, parent, key, index);

{
"name": "ast-kit",
"version": "0.9.0",
"version": "0.9.1",
"packageManager": "pnpm@8.6.0",

@@ -5,0 +5,0 @@ "description": "AST Toolkit.",

Sorry, the diff of this file is not supported yet

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