root / HServer / 00.Server / 00.Program / node_modules / lodash / flatMapDeep.js
이력 | 보기 | 이력해설 | 다운로드 (796 Bytes)
1 |
var baseFlatten = require('./_baseFlatten'), |
---|---|
2 |
map = require('./map');
|
3 |
|
4 |
/** Used as references for various `Number` constants. */
|
5 |
var INFINITY = 1 / 0; |
6 |
|
7 |
/**
|
8 |
* This method is like `_.flatMap` except that it recursively flattens the
|
9 |
* mapped results.
|
10 |
*
|
11 |
* @static
|
12 |
* @memberOf _
|
13 |
* @since 4.7.0
|
14 |
* @category Collection
|
15 |
* @param {Array|Object} collection The collection to iterate over.
|
16 |
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
17 |
* @returns {Array} Returns the new flattened array.
|
18 |
* @example
|
19 |
*
|
20 |
* function duplicate(n) {
|
21 |
* return [[[n, n]]];
|
22 |
* }
|
23 |
*
|
24 |
* _.flatMapDeep([1, 2], duplicate);
|
25 |
* // => [1, 1, 2, 2]
|
26 |
*/
|
27 |
function flatMapDeep(collection, iteratee) { |
28 |
return baseFlatten(map(collection, iteratee), INFINITY);
|
29 |
} |
30 |
|
31 |
module.exports = flatMapDeep; |