1 var baseFlatten = require('./internal/baseFlatten'),
2 baseIteratee = require('./internal/baseIteratee'),
3 baseUniq = require('./internal/baseUniq'),
4 isArrayLikeObject = require('./isArrayLikeObject'),
5 last = require('./last'),
6 rest = require('./rest');
9 * This method is like `_.union` except that it accepts `iteratee` which is
10 * invoked for each element of each `arrays` to generate the criterion by which
11 * uniqueness is computed. The iteratee is invoked with one argument: (value).
16 * @param {...Array} [arrays] The arrays to inspect.
17 * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
18 * @returns {Array} Returns the new array of combined values.
21 * _.unionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
22 * // => [2.1, 1.2, 4.3]
24 * // using the `_.property` iteratee shorthand
25 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
26 * // => [{ 'x': 1 }, { 'x': 2 }]
28 var unionBy = rest(function(arrays) {
29 var iteratee = last(arrays);
30 if (isArrayLikeObject(iteratee)) {
33 return baseUniq(baseFlatten(arrays, false, true), baseIteratee(iteratee));
36 module.exports = unionBy;