4.17.11
3.10.1
2.4.2
1.3.1

_.flatMapDepth(collection, [iteratee=_.identity], [depth=1])

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

Since

4.7.0

Arguments

argument
collection
[iteratee=_.identity]
[depth=1]
type
(Array|Object)
Function
number
description
The collection to iterate over.
The function invoked per iteration.
The maximum recursion depth.

Returns

(array)

Example

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

_.flatMapDepth([1, 2], duplicate, 2);
// => [[1, 1], [2, 2]]
function duplicate(n) {
  return [[[n, n]]];
}

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