Home > vue-metamorph > astHelpers > findFirst
astHelpers.findFirst() function
Finds the first node in an AST that matches a partial node
Signature:
typescript
export declare function findFirst<M extends Matcher<namedTypes.ASTNode | AST.Node>>(ast: AST.Node | namedTypes.ASTNode, matcher: M): (AST.Node & {
type: M['type'];
}) | null;
Parameters
Parameter | Type | Description |
---|---|---|
ast | AST.Node | namedTypes.ASTNode | The node to traverse |
matcher | M | Partial object to match against |
(AST.Node & { type: M['type']; }) | null
The first matching node, or null if no matching node was found