ut2
Version:
一个现代 JavaScript 实用工具库。[点击查看在线文档]。
27 lines (24 loc) • 993 B
JavaScript
import difference from './difference.js';
import identity from './identity.js';
import createIteratee from './internals/createIteratee.js';
import intersection from './intersection.js';
import isArray from './isArray.js';
import union from './union.js';
import uniq from './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);
}
export { xor as default };