main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
794 bytes
|
Line | |
---|
1 | import baseFlatten from './_baseFlatten.js';
|
---|
2 | import map from './map.js';
|
---|
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 | export default flatMapDeep;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.