Options
All
  • Public
  • Public/Protected
  • All
Menu

Module flatMap

Index

References

Functions Collection

References

Renames and re-exports flatMap

Collection Functions

  • flatMap<T, R>(collection: T[], iteratee?: ArrayIteratee<T, T[]>): R[]
  • flatMap<T, R>(collection: Record<string, T>, iteratee?: RecordIteratee<T, Record<string, T>>): R[]
  • Creates a flattened array of values by running each element in collection thru iteratee and flattening the mapped results. The iteratee is invoked with three arguments: (value, index|key, collection).

    since

    5.4.0

    see

    flatMapDeep,flatMapDepth,flatten,flattenDeep,flattenDepth,[[map]],mapKeys,mapValues

    example
    function duplicate(n) {
    return [n, n]
    }

    flatMap([1, 2], duplicate)
    // => [1, 1, 2, 2]

    Type parameters

    • T

    • R = any

    Parameters

    • collection: T[]

      The collection to iterate over.

    • Optional iteratee: ArrayIteratee<T, T[]>

      The function invoked per iteration.

    Returns R[]

    Returns the new flattened array.

  • Type parameters

    • T

    • R = any

    Parameters

    • collection: Record<string, T>
    • Optional iteratee: RecordIteratee<T, Record<string, T>>

    Returns R[]