• Joins the elements of the given iterable of pre-computed instances of Generated by appending the results to a CompositeGeneratorNode being returned finally. Each individual element is tested to be a string, a CompositeGeneratorNode, or undefined and included as is if that test is satisfied. Otherwise the result of applying String (string constructor) to the element is included.

    Note: empty strings being included in iterable are treated as ordinary string representations, while the value of undefined makes this function to ignore the corresponding item and no separator is appended, if configured.

    Examples:

      exandToNode`
    ${ joinToNode(['a', 'b'], { appendNewLineIfNotEmpty: true }) }

    ${ joinToNode(new Set(['a', undefined, getElementNode()]), { separator: ',', appendNewLineIfNotEmpty: true }) }
    `

    Type Parameters

    • Generated

    Parameters

    • iterable: Iterable<Generated> | Generated[]

      an Array or Iterable providing the elements to be joined

    • Optionaloptions: JoinOptions<Generated>

      optional config object for defining a separator, contributing specialized prefix and/or suffix providers, and activating conditional line-break insertion. In addition, a dedicated filter function can be provided that is required get provided with the original element indices in the aformentioned functions, if the list is to be filtered. If Array.filter would be applied to the original list, the indices will be those of the filtered list during subsequent processing that in particular will cause confusion when using the tracing variant of this function named (joinTracedToNode).

    Returns CompositeGeneratorNode | undefined

    the resulting CompositeGeneratorNode representing iterable's content

  • Joins the elements of the given iterable by applying toGenerated to each element and appending the results to a CompositeGeneratorNode being returned finally.

    Note: empty strings being returned by toGenerated are treated as ordinary string representations, while the result of undefined makes this function to ignore the corresponding item and no separator is appended, if configured.

    Examples:

      exandToNode`
    ${ joinToNode(['a', 'b'], String, { appendNewLineIfNotEmpty: true }) }

    ${ joinToNode(new Set(['a', undefined, 'b']), e => e && String(e), { separator: ',', appendNewLineIfNotEmpty: true }) }
    `

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T> | T[]

      an Array or Iterable providing the elements to be joined

    • OptionaltoGenerated: ((element: T, index: number, isLast: boolean) => Generated)

      a callback converting each individual element to a string, a CompositeGeneratorNode, or to undefined if to be omitted, defaults to the identity for strings, generator nodes, and undefined, and to String otherwise.

        • (element, index, isLast): Generated
        • Parameters

          • element: T
          • index: number
          • isLast: boolean

          Returns Generated

    • Optionaloptions: JoinOptions<T>

      optional config object for defining a separator, contributing specialized prefix and/or suffix providers, and activating conditional line-break insertion. In addition, a dedicated filter function can be provided that is required get provided with the original element indices in the aformentioned functions, if the list is to be filtered. If Array.filter would be applied to the original list, the indices will be those of the filtered list during subsequent processing that in particular will cause confusion when using the tracing variant of this function named (joinTracedToNode).

    Returns CompositeGeneratorNode | undefined

    the resulting CompositeGeneratorNode representing iterable's content