source: node_modules/es-toolkit/dist/compat/array/unionWith.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: 569 bytes
RevLine 
[a762898]1import { last } from '../../array/last.mjs';
2import { uniq } from '../../array/uniq.mjs';
3import { uniqWith } from '../../array/uniqWith.mjs';
4import { flattenArrayLike } from '../_internal/flattenArrayLike.mjs';
5import { isArrayLikeObject } from '../predicate/isArrayLikeObject.mjs';
6
7function unionWith(...values) {
8 const lastValue = last(values);
9 const flattened = flattenArrayLike(values);
10 if (isArrayLikeObject(lastValue) || lastValue == null) {
11 return uniq(flattened);
12 }
13 return uniqWith(flattened, lastValue);
14}
15
16export { unionWith };
Note: See TracBrowser for help on using the repository browser.