Options
All
  • Public
  • Public/Protected
  • All
Menu

Module flatMapDepth

Index

Functions Collection

Collection Functions

  • default<T, R>(collection: T[], iteratee?: Iteratee<number, T, T[]>, depth?: number): R[]
  • default<T, R>(collection: Record<string, T>, iteratee?: Iteratee<string, T, Record<string, T>>, depth?: number): R[]
  • This method is like flatMap except that it recursively flattens the mapped results up to depth times.

    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: T[]

      The collection to iterate over.

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

      The function invoked per iteration.

    • Optional depth: number

      The maximum recursion depth.

    Returns R[]

    Returns the new flattened array.

  • Type parameters

    • T

    • R = any

    Parameters

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

    Returns R[]