UNPKG

astx

Version:

super powerful structural search and replace for JavaScript and TypeScript to automate your refactoring

26 lines (25 loc) 989 B
import { NodePath, Node } from './types'; import { MatchResult } from './compileMatcher'; import { Backend } from './backend/Backend'; export declare type Match = { type: 'node' | 'nodes'; path: NodePath; node: Node; paths: NodePath[]; nodes: Node[]; pathCaptures?: Record<string, NodePath>; captures?: Record<string, Node>; arrayPathCaptures?: Record<string, NodePath[]>; arrayCaptures?: Record<string, Node[]>; stringCaptures?: Record<string, string>; }; export declare type FindOptions = { backend: Backend; where?: { [captureName: string]: (path: NodePath) => boolean; }; matchSoFar?: MatchResult; }; export declare function convertWithCaptures(matches: Match | Match[]): MatchResult; export declare function createMatch(paths: NodePath | NodePath[], result: MatchResult): Match; export default function find(paths: NodePath | readonly NodePath[], pattern: NodePath | readonly NodePath[], options: FindOptions): Match[];