UNPKG

generaltranslation

Version:

A language toolkit for AI developers

21 lines (20 loc) 970 B
import { MessageFormatElement, ParserOptions } from '@formatjs/icu-messageformat-parser'; type TraverseIcuOptions = ParserOptions & { recurseIntoVisited?: boolean; }; /** * Given an ICU string, traverse the AST and call the visitor function for each element that matches the type T * @param icu - The ICU string to traverse * @param shouldVisit - A function that returns true if the element should be visited * @param visitor - A function that is called for each element that matches the type T * @returns The modified AST of the ICU string * * @note This function is a heavy operation, use sparingly */ export declare function traverseIcu<T extends MessageFormatElement>({ icuString, shouldVisit, visitor, options: { recurseIntoVisited, ...otherOptions }, }: { icuString: string; shouldVisit: (element: MessageFormatElement) => element is T; visitor: (element: T) => void; options: TraverseIcuOptions; }): MessageFormatElement[]; export {};