Function filter

  • filter(test: ((elem: AnyNode) => boolean), node: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[]
  • Search a node and its children for nodes passing a test function. If node is not an array, it will be wrapped in one.

    Returns

    All nodes passing test.

    Parameters

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

      Function to test nodes on.

        • (elem: AnyNode): 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[]