Function filter

  • Search a node and its children for nodes passing a test function. If node is not an array, it will be wrapped in one.

    Parameters

    • test: ((elem: AnyNode) => boolean)

      Function to test nodes on.

        • (elem): boolean
        • Parameters

          • elem: AnyNode

          Returns boolean

    • node: AnyNode | AnyNode[]

      Node to search. Will be included in the result set if it matches.

    • recurse: boolean = true

      Also consider child nodes.

    • limit: number = Infinity

      Maximum number of nodes to return.

    Returns AnyNode[]

    All nodes passing test.