This method is like `flatMap` except that it recursively flattens the mapped results up to `depth` times.
function duplicate(n) {
return [[[n, n]]]
}
flatMapDepth([1, 2], duplicate, 2)
// => [[1, 1], [2, 2]]
| Name | Type | Attribute | Description |
|---|---|---|---|
| collection | The collection to iterate over. | ||
| iteratee | The function invoked per iteration. | ||
| depth | The maximum recursion depth. |
{
"comment": "/**\r\n * This method is like `flatMap` except that it recursively flattens the\r\n * mapped results up to `depth` times.\r\n *\r\n * @since 4.7.0\r\n * @category Collection\r\n * @param {Array|Object} collection The collection to iterate over.\r\n * @param {Function} iteratee The function invoked per iteration.\r\n * @param {number} [depth=1] The maximum recursion depth.\r\n * @returns {Array} Returns the new flattened array.\r\n * @see flatMap, flatMapDeep, flatten, flattenDeep, flattenDepth, map, mapKeys, mapValues\r\n * @example\r\n *\r\n * function duplicate(n) {\r\n * return [[[n, n]]]\r\n * }\r\n *\r\n * flatMapDepth([1, 2], duplicate, 2)\r\n * // => [[1, 1], [2, 2]]\r\n */",
"meta": {
"range": [
739,
894
],
"filename": "flatMapDepth.js",
"lineno": 24,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100002606",
"name": "flatMapDepth",
"type": "FunctionDeclaration",
"paramnames": [
"collection",
"iteratee",
"depth"
]
},
"vars": {
"depth": "flatMapDepth~depth"
}
},
"description": "This method is like `flatMap` except that it recursively flattens the\rmapped results up to `depth` times.",
"since": "4.7.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Collection",
"value": "Collection"
}
],
"params": [
{
"type": {
"names": [
"Array",
"Object"
]
},
"description": "The collection to iterate over.",
"name": "collection"
},
{
"type": {
"names": [
"function"
]
},
"description": "The function invoked per iteration.",
"name": "iteratee"
},
{
"type": {
"names": [
"number"
]
},
"optional": true,
"defaultvalue": 1,
"description": "The maximum recursion depth.",
"name": "depth"
}
],
"returns": [
{
"type": {
"names": [
"Array"
]
},
"description": "Returns the new flattened array."
}
],
"see": [
"flatMap, flatMapDeep, flatten, flattenDeep, flattenDepth, map, mapKeys, mapValues"
],
"examples": [
"function duplicate(n) {\r return [[[n, n]]]\r}\r\rflatMapDepth([1, 2], duplicate, 2)\r// => [[1, 1], [2, 2]]"
],
"name": "flatMapDepth",
"longname": "flatMapDepth",
"kind": "function",
"scope": "global",
"___id": "T000002R000282",
"___s": true,
"filepath": "flatMapDepth.js"
}