source: trip-planner-front/node_modules/lodash/xorBy.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1var arrayFilter = require('./_arrayFilter'),
2 baseIteratee = require('./_baseIteratee'),
3 baseRest = require('./_baseRest'),
4 baseXor = require('./_baseXor'),
5 isArrayLikeObject = require('./isArrayLikeObject'),
6 last = require('./last');
7
8/**
9 * This method is like `_.xor` except that it accepts `iteratee` which is
10 * invoked for each element of each `arrays` to generate the criterion by
11 * which by which they're compared. The order of result values is determined
12 * by the order they occur in the arrays. The iteratee is invoked with one
13 * argument: (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 filtered values.
22 * @example
23 *
24 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
25 * // => [1.2, 3.4]
26 *
27 * // The `_.property` iteratee shorthand.
28 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
29 * // => [{ 'x': 2 }]
30 */
31var xorBy = baseRest(function(arrays) {
32 var iteratee = last(arrays);
33 if (isArrayLikeObject(iteratee)) {
34 iteratee = undefined;
35 }
36 return baseXor(arrayFilter(arrays, isArrayLikeObject), baseIteratee(iteratee, 2));
37});
38
39module.exports = xorBy;
Note: See TracBrowser for help on using the repository browser.