tdesign-react
Version:
TDesign Component for React
152 lines (142 loc) • 4.76 kB
JavaScript
/**
* tdesign v1.16.2
* (c) 2025 tdesign
* @license MIT
*/
;
var _getAllKeys = require('./dep-e018b522.js');
var isArrayLikeObject = require('./dep-0b70c7ec.js');
var _baseDifference = require('./dep-8053f7e1.js');
var _baseFlatten = require('./dep-54a7e129.js');
var _cacheHas = require('./dep-4f4b2eb1.js');
var _arrayIncludesWith = require('./dep-0fc2b225.js');
var _getTag = require('./dep-b23d5e45.js');
var noop = require('./dep-c811cbb2.js');
var _baseIsEqual = require('./dep-625279d1.js');
var last = require('./dep-002bcd4b.js');
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/**
* Creates a set object of `values`.
*
* @private
* @param {Array} values The values to add to the set.
* @returns {Object} Returns the new set.
*/
var createSet = !(_getTag.Set && 1 / _baseIsEqual.setToArray(new _getTag.Set([, -0]))[1] == INFINITY) ? noop.noop : function (values) {
return new _getTag.Set(values);
};
var createSet$1 = createSet;
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/**
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseUniq(array, iteratee, comparator) {
var index = -1,
includes = _arrayIncludesWith.arrayIncludes,
length = array.length,
isCommon = true,
result = [],
seen = result;
if (comparator) {
isCommon = false;
includes = _arrayIncludesWith.arrayIncludesWith;
} else if (length >= LARGE_ARRAY_SIZE) {
var set = iteratee ? null : createSet$1(array);
if (set) {
return _baseIsEqual.setToArray(set);
}
isCommon = false;
includes = _cacheHas.cacheHas;
seen = new _cacheHas.SetCache();
} else {
seen = iteratee ? [] : result;
}
outer: while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = comparator || value !== 0 ? value : 0;
if (isCommon && computed === computed) {
var seenIndex = seen.length;
while (seenIndex--) {
if (seen[seenIndex] === computed) {
continue outer;
}
}
if (iteratee) {
seen.push(computed);
}
result.push(value);
} else if (!includes(seen, computed, comparator)) {
if (seen !== result) {
seen.push(computed);
}
result.push(value);
}
}
return result;
}
/**
* The base implementation of methods like `_.xor`, without support for
* iteratee shorthands, that accepts an array of arrays to inspect.
*
* @private
* @param {Array} arrays The arrays to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of values.
*/
function baseXor(arrays, iteratee, comparator) {
var length = arrays.length;
if (length < 2) {
return length ? baseUniq(arrays[0]) : [];
}
var index = -1,
result = Array(length);
while (++index < length) {
var array = arrays[index],
othIndex = -1;
while (++othIndex < length) {
if (othIndex != index) {
result[index] = _baseDifference.baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
}
}
}
return baseUniq(_baseFlatten.baseFlatten(result, 1), iteratee, comparator);
}
/**
* This method is like `_.xor` except that it accepts `comparator` which is
* invoked to compare elements of `arrays`. The order of result values is
* determined by the order they occur in the arrays. The comparator is invoked
* with two arguments: (arrVal, othVal).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.xorWith(objects, others, _.isEqual);
* // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
*/
var xorWith = isArrayLikeObject.baseRest(function (arrays) {
var comparator = last.last(arrays);
comparator = typeof comparator == 'function' ? comparator : undefined;
return baseXor(_getAllKeys.arrayFilter(arrays, isArrayLikeObject.isArrayLikeObject), undefined, comparator);
});
var xorWith$1 = xorWith;
exports.xorWith = xorWith$1;
//# sourceMappingURL=dep-bfc7198e.js.map