|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
672 bytes
|
| Line | |
|---|
| 1 | import { last } from '../../array/last.mjs';
|
|---|
| 2 | import { uniq } from '../../array/uniq.mjs';
|
|---|
| 3 | import { uniqBy } from '../../array/uniqBy.mjs';
|
|---|
| 4 | import { ary } from '../../function/ary.mjs';
|
|---|
| 5 | import { flattenArrayLike } from '../_internal/flattenArrayLike.mjs';
|
|---|
| 6 | import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
|
|---|
| 7 | import { iteratee } from '../util/iteratee.mjs';
|
|---|
| 8 |
|
|---|
| 9 | function unionBy(...values) {
|
|---|
| 10 | const lastValue = last(values);
|
|---|
| 11 | const flattened = flattenArrayLike(values);
|
|---|
| 12 | if (isArrayLikeObject(lastValue) || lastValue == null) {
|
|---|
| 13 | return uniq(flattened);
|
|---|
| 14 | }
|
|---|
| 15 | return uniqBy(flattened, ary(iteratee(lastValue), 1));
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | export { unionBy };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.