Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "xform/mapcat"

Index

Functions

Functions

mapcat

  • mapcat<A, B>(fn: Fn<A, Iterable<B> | null | undefined>): Transducer<A, B>
  • mapcat<A, B>(fn: Fn<A, Iterable<B> | null | undefined>, src: Iterable<A>): IterableIterator<B>
  • 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.

    example
    [...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 ]

    Type parameters

    • A

    • B

    Parameters

    • fn: Fn<A, Iterable<B> | null | undefined>

      mapping function

    Returns Transducer<A, B>

  • Type parameters

    • A

    • B

    Parameters

    • fn: Fn<A, Iterable<B> | null | undefined>
    • src: Iterable<A>

    Returns IterableIterator<B>

Generated using TypeDoc