ast-kit
Advanced tools
Comparing version 0.9.1 to 0.9.2
@@ -587,14 +587,14 @@ // src/check.ts | ||
return walkASTAsync(node, { | ||
async enter(node2, parent, key, index) { | ||
async enter(...args) { | ||
for (const { filter, cb: cb2 } of callbacks.enter) { | ||
if (!filter(node2)) | ||
if (!filter.apply(this, args)) | ||
continue; | ||
await cb2.call(this, node2, parent, key, index); | ||
await cb2.apply(this, args); | ||
} | ||
}, | ||
async leave(node2, parent, key, index) { | ||
async leave(...args) { | ||
for (const { filter, cb: cb2 } of callbacks.leave) { | ||
if (!filter(node2)) | ||
if (!filter.apply(this, args)) | ||
continue; | ||
await cb2.call(this, node2, parent, key, index); | ||
await cb2.apply(this, args); | ||
} | ||
@@ -601,0 +601,0 @@ } |
@@ -74,3 +74,3 @@ import * as t from '@babel/types'; | ||
} | ||
type WalkFilter<N extends t.Node = t.Node> = (node: t.Node) => node is N; | ||
type WalkFilter<N extends t.Node = t.Node> = (this: WalkThis<t.Node>, node: t.Node, parent: t.Node | null | undefined, key: string | null | undefined, index: number | null | undefined) => node is N; | ||
declare function walkASTSetup(node: t.Node, cb: (setup: WalkSetup) => void | Promise<void>): Promise<t.Node | null>; | ||
@@ -77,0 +77,0 @@ interface ImportBinding { |
@@ -587,14 +587,14 @@ // src/check.ts | ||
return walkASTAsync(node, { | ||
async enter(node2, parent, key, index) { | ||
async enter(...args) { | ||
for (const { filter, cb: cb2 } of callbacks.enter) { | ||
if (!filter(node2)) | ||
if (!filter.apply(this, args)) | ||
continue; | ||
await cb2.call(this, node2, parent, key, index); | ||
await cb2.apply(this, args); | ||
} | ||
}, | ||
async leave(node2, parent, key, index) { | ||
async leave(...args) { | ||
for (const { filter, cb: cb2 } of callbacks.leave) { | ||
if (!filter(node2)) | ||
if (!filter.apply(this, args)) | ||
continue; | ||
await cb2.call(this, node2, parent, key, index); | ||
await cb2.apply(this, args); | ||
} | ||
@@ -601,0 +601,0 @@ } |
{ | ||
"name": "ast-kit", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"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
71153