an Array or Iterable providing the elements to be joined
Optional
options: 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).
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 }) }
`
an Array or Iterable providing the elements to be joined
Optional
toGenerated: ((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.
Optional
options: 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).
the resulting CompositeGeneratorNode representing iterable
's content
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, orundefined
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 ofundefined
makes this function to ignore the corresponding item and no separator is appended, if configured.Examples: