export type MatcherFn = (node: Element) => T | undefined; export type MatcherObj = { [key: string]: MatcherObj | MatcherFn; }; export type MatcherObjResult = { [K in keyof O]: O[K] extends F ? ReturnType : O[K] extends MatcherObj ? MatcherObjResult : never; }; /** * Given a markup string or DOM element, creates an object aligning with the * shape of the matchers object, or the value returned by the matcher. * * @param source Source content * @param matchers Matcher function or object of matchers */ export declare function parse(source: string | Element, matchers?: undefined): undefined; /** * Given a markup string or DOM element, creates an object aligning with the * shape of the matchers object, or the value returned by the matcher. * * @param source Source content * @param matchers Object of matchers * @return Matched values, shaped by object */ export declare function parse(source: string | Element, matchers: O): MatcherObjResult; /** * Given a markup string or DOM element, creates an object aligning with the * shape of the matchers object, or the value returned by the matcher. * * @param source Source content * @param matcher Matcher function * @return Matched value */ export declare function parse(source: string | Element, matchers: F): ReturnType; /** * Given a markup string or DOM element, creates an object aligning with the * shape of the matchers object, or the value returned by the matcher. * * @param source Source content * @param matchers Matcher function or object of matchers */ export declare function parse(source: string | Element, matchers: O | F): MatcherObjResult | ReturnType; /** * Generates a function which matches node of type selector, returning an * attribute by property if the attribute exists. If no selector is passed, * returns property of the query element. * * @param name Property name * @return Property value */ export declare function prop(name: string): MatcherFn; /** * Generates a function which matches node of type selector, returning an * attribute by property if the attribute exists. If no selector is passed, * returns property of the query element. * * @param selector Optional selector * @param name Property name * @return Property value */ export declare function prop(selector: string | undefined, name: N): MatcherFn; /** * Generates a function which matches node of type selector, returning an * attribute by name if the attribute exists. If no selector is passed, * returns attribute of the query element. * * @param name Attribute name * @return Attribute value */ export declare function attr(name: string): MatcherFn; /** * Generates a function which matches node of type selector, returning an * attribute by name if the attribute exists. If no selector is passed, * returns attribute of the query element. * * @param selector Optional selector * @param name Attribute name * @return Attribute value */ export declare function attr(selector: string | undefined, name: string): MatcherFn; /** * Convenience for `prop( selector, 'innerHTML' )`. * * @see prop() * * @param selector Optional selector * @return Inner HTML */ export declare function html(selector?: string): MatcherFn; /** * Convenience for `prop( selector, 'textContent' )`. * * @see prop() * * @param selector Optional selector * @return Text content */ export declare function text(selector?: string): MatcherFn; /** * Creates a new matching context by first finding elements matching selector * using querySelectorAll before then running another `parse` on `matchers` * scoped to the matched elements. * * @see parse() * * @param selector Selector to match * @param matchers Matcher function or object of matchers * @return Matcher function which returns an array of matched value(s) */ export declare function query(selector: string, matchers?: F | O): MatcherFn[]>;