source: node_modules/es-toolkit/dist/compat/array/unionBy.mjs

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 
1import { last } from '../../array/last.mjs';
2import { uniq } from '../../array/uniq.mjs';
3import { uniqBy } from '../../array/uniqBy.mjs';
4import { ary } from '../../function/ary.mjs';
5import { flattenArrayLike } from '../_internal/flattenArrayLike.mjs';
6import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
7import { iteratee } from '../util/iteratee.mjs';
8
9function 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
18export { unionBy };
Note: See TracBrowser for help on using the repository browser.