Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xorWith.js 1.2KB

12345678910111213141516171819202122232425262728293031323334
  1. var arrayFilter = require('./_arrayFilter'),
  2. baseRest = require('./_baseRest'),
  3. baseXor = require('./_baseXor'),
  4. isArrayLikeObject = require('./isArrayLikeObject'),
  5. last = require('./last');
  6. /**
  7. * This method is like `_.xor` except that it accepts `comparator` which is
  8. * invoked to compare elements of `arrays`. The order of result values is
  9. * determined by the order they occur in the arrays. The comparator is invoked
  10. * with two arguments: (arrVal, othVal).
  11. *
  12. * @static
  13. * @memberOf _
  14. * @since 4.0.0
  15. * @category Array
  16. * @param {...Array} [arrays] The arrays to inspect.
  17. * @param {Function} [comparator] The comparator invoked per element.
  18. * @returns {Array} Returns the new array of filtered values.
  19. * @example
  20. *
  21. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  22. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  23. *
  24. * _.xorWith(objects, others, _.isEqual);
  25. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  26. */
  27. var xorWith = baseRest(function(arrays) {
  28. var comparator = last(arrays);
  29. comparator = typeof comparator == 'function' ? comparator : undefined;
  30. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  31. });
  32. module.exports = xorWith;