ut2
Version:
一个现代 JavaScript 实用工具库。[点击查看在线文档]。
29 lines (25 loc) • 1.02 kB
JavaScript
;
var difference = require('./difference.js');
var identity = require('./identity.js');
var createIteratee = require('./internals/createIteratee.js');
var intersection = require('./intersection.js');
var isArray = require('./isArray.js');
var union = require('./union.js');
var uniq = require('./uniq.js');
function xor(array, other, iteratee, strickCheck) {
if (other === void 0) { other = []; }
if (iteratee === void 0) { iteratee = identity; }
if (strickCheck === void 0) { strickCheck = false; }
if (!isArray(array) && !isArray(other)) {
return [];
}
var internalIteratee = createIteratee(iteratee);
if (!isArray(other)) {
return uniq(array, internalIteratee, strickCheck);
}
if (!isArray(array)) {
return uniq(other, internalIteratee, strickCheck);
}
return difference(union(array, other, internalIteratee, strickCheck), intersection(array, other, internalIteratee, strickCheck), internalIteratee, strickCheck);
}
module.exports = xor;