• 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.

    • Optionaliteratee: Iteratee<number, T, T[]>

      The function invoked per iteration.

    • Optionaldepth: number

      The maximum recursion depth.

    Returns R[]

    Returns the new flattened array.

    5.4.0

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

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

    flatMapDepth([1, 2], duplicate, 2)
    // => [[1, 1], [2, 2]]
  • This method is like flatMap except that it recursively flattens the mapped results up to depth times.

    Type Parameters

    • T
    • R = any

    Parameters

    • collection: Record<string, T>

      The collection to iterate over.

    • Optionaliteratee: Iteratee<string, T, Record<string, T>>

      The function invoked per iteration.

    • Optionaldepth: number

      The maximum recursion depth.

    Returns R[]

    Returns the new flattened array.

    5.4.0

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

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

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