source: imaps-frontend/node_modules/lodash-es/unionBy.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[d565449]1import baseFlatten from './_baseFlatten.js';
2import baseIteratee from './_baseIteratee.js';
3import baseRest from './_baseRest.js';
4import baseUniq from './_baseUniq.js';
5import isArrayLikeObject from './isArrayLikeObject.js';
6import last from './last.js';
7
8/**
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
11 * which uniqueness is computed. Result values are chosen from the first
12 * array in which the value occurs. The iteratee is invoked with one argument:
13 * (value).
14 *
15 * @static
16 * @memberOf _
17 * @since 4.0.0
18 * @category Array
19 * @param {...Array} [arrays] The arrays to inspect.
20 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
21 * @returns {Array} Returns the new array of combined values.
22 * @example
23 *
24 * _.unionBy([2.1], [1.2, 2.3], Math.floor);
25 * // => [2.1, 1.2]
26 *
27 * // The `_.property` iteratee shorthand.
28 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
29 * // => [{ 'x': 1 }, { 'x': 2 }]
30 */
31var unionBy = baseRest(function(arrays) {
32 var iteratee = last(arrays);
33 if (isArrayLikeObject(iteratee)) {
34 iteratee = undefined;
35 }
36 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2));
37});
38
39export default unionBy;
Note: See TracBrowser for help on using the repository browser.