xor.js 811 B

1234567891011121314151617181920212223242526272829
  1. var arrayFilter = require('./_arrayFilter'),
  2. baseRest = require('./_baseRest'),
  3. baseXor = require('./_baseXor'),
  4. isArrayLikeObject = require('./isArrayLikeObject');
  5. /**
  6. * Creates an array of unique values that is the
  7. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  8. * of the given arrays. The order of result values is determined by the order
  9. * they occur in the arrays.
  10. *
  11. * @static
  12. * @memberOf _
  13. * @since 2.4.0
  14. * @category Array
  15. * @param {...Array} [arrays] The arrays to inspect.
  16. * @returns {Array} Returns the new array of filtered values.
  17. * @see _.difference, _.without
  18. * @example
  19. *
  20. * _.xor([2, 1], [2, 3]);
  21. * // => [1, 3]
  22. */
  23. var xor = baseRest(function(arrays) {
  24. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  25. });
  26. module.exports = xor;