Transducer. Similar to {@link (map:1)}, but expects the given mapping function fn to return an iterable result (or null) and then emits each value of the result individually downstream. null or undefined result values will be skipped / omitted.
fn
null
undefined
[...mapcat((x) => [x, x], [1, 2, 3])] // [ 1, 1, 2, 2, 3, 3 ] [...mapcat((x) => x > 2 ? [x, x, x] : null, [1, 2, 3])] // [ 3, 3, 3 ]
mapping function
Generated using TypeDoc
Transducer. Similar to {@link (map:1)}, but expects the given mapping function
fn
to return an iterable result (ornull
) and then emits each value of the result individually downstream.null
orundefined
result values will be skipped / omitted.[...mapcat((x) => [x, x], [1, 2, 3])] // [ 1, 1, 2, 2, 3, 3 ] [...mapcat((x) => x > 2 ? [x, x, x] : null, [1, 2, 3])] // [ 3, 3, 3 ]