Function flatMapDepth

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

    Type Parameters

    • T
    • TResult

    Parameters

    • array: T[]
    • iteratee: ListIterator<T, TResult | NestedArray<TResult>>

      The function invoked per iteration.

    • Optionaldepth: number

      The maximum recursion depth.

    Returns TResult[]

    Returns the new flattened array.

    4.7.0

    flatMap, flatMapDeep, flatten, flattenDeep, flattenDepth, map, mapKeys, mapValues

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

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