Function default

  • This method is like flatMap except that it recursively flattens the mapped results up to depth times.

    Type Parameters

    • T

    • R = any

    Parameters

    • collection: T[]

      The collection to iterate over.

    • Optional iteratee: Iteratee<number, T, T[]>

      The function invoked per iteration.

      Optional
    • Optional depth: number

      The maximum recursion depth.

      Optional

    Returns R[]

    Returns the new flattened array.

    Since

    5.4.0

    See

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

    Example

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

    flatMapDepth([1, 2], duplicate, 2)
    // => [[1, 1], [2, 2]]
  • Type Parameters

    • T

    • R = any

    Parameters

    • collection: Record<string, T>
    • Optional iteratee: Iteratee<string, T, Record<string, T>>
      Optional
    • Optional depth: number
      Optional

    Returns R[]