|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
372 bytes
|
| Line | |
|---|
| 1 | import { flattenDepth } from './flattenDepth.mjs';
|
|---|
| 2 | import { map } from './map.mjs';
|
|---|
| 3 | import { isNil } from '../../predicate/isNil.mjs';
|
|---|
| 4 |
|
|---|
| 5 | function flatMap(collection, iteratee) {
|
|---|
| 6 | if (isNil(collection)) {
|
|---|
| 7 | return [];
|
|---|
| 8 | }
|
|---|
| 9 | const mapped = isNil(iteratee) ? map(collection) : map(collection, iteratee);
|
|---|
| 10 | return flattenDepth(mapped, 1);
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | export { flatMap };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.