/** * @typedef {import('unist').Node} Node * @typedef {import('unist').Parent} Parent * @typedef {import('hast').Element} Element * * @typedef {string} TagName * @typedef {null|undefined|TagName|TestFunctionAnything|Array.} Test */ /** * Check if an element passes a test * * @callback TestFunctionAnything * @param {Element} element * @param {number|null|undefined} [index] * @param {Parent|null|undefined} [parent] * @returns {boolean|void} */ /** * Check if an element passes a certain node test * * @template {Element} X * @callback TestFunctionPredicate * @param {X} element * @param {number|null|undefined} [index] * @param {Parent|null|undefined} [parent] * @returns {element is X} */ /** * Check if a node is an element and passes a certain node test * * @callback AssertAnything * @param {unknown} [node] * @param {number|null|undefined} [index] * @param {Parent|null|undefined} [parent] * @returns {boolean} */ /** * Check if a node is an element and passes a certain node test * * @template {Element} Y * @callback AssertPredicate * @param {unknown} [node] * @param {number|null|undefined} [index] * @param {Parent|null|undefined} [parent] * @returns {node is Y} */ export const isElement: (( node: unknown, test: | T['tagName'] | TestFunctionPredicate | (T['tagName'] | TestFunctionPredicate)[], index?: number | undefined, parent?: | import('unist').Parent< import('unist').Node, import('unist').Data > | undefined, context?: unknown ) => node is T) & (( node?: unknown, test?: Test, index?: number | undefined, parent?: | import('unist').Parent< import('unist').Node, import('unist').Data > | undefined, context?: unknown ) => boolean) export const convertElement: (( test: T['tagName'] | TestFunctionPredicate ) => AssertPredicate) & ((test?: Test) => AssertAnything) export type Node = import('unist').Node export type Parent = import('unist').Parent export type Element = import('hast').Element export type TagName = string export type Test = | null | undefined | TagName | TestFunctionAnything | Array /** * Check if an element passes a test */ export type TestFunctionAnything = ( element: Element, index?: number | null | undefined, parent?: Parent | null | undefined ) => boolean | void /** * Check if an element passes a certain node test */ export type TestFunctionPredicate = ( element: X, index?: number | null | undefined, parent?: Parent | null | undefined ) => element is X /** * Check if a node is an element and passes a certain node test */ export type AssertAnything = ( node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined ) => boolean /** * Check if a node is an element and passes a certain node test */ export type AssertPredicate = ( node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined ) => node is Y