wdpr
    Preparing search index...
    • Create a new element with all child arrays transformed by a stateful function.

      Like mapElementChildren, but the transform function also receives and returns a state value. State is threaded sequentially through each child group: the output state from one group becomes the input state for the next. This is useful when the transformation needs to track information across sibling groups, such as maintaining a monotonically increasing ID counter.

      Type Parameters

      • S

        The type of the threaded state

      Parameters

      • element: Element

        The element whose children should be transformed

      • state: S

        Initial state value

      • transform: (elements: Element[], state: S) => { elements: Element[]; state: S }

        Function that receives a child array and current state, returning transformed elements and updated state

      Returns { element: Element; state: S }

      Object with the new element and final state value