UNPKG

tdesign-react

Version:
152 lines (142 loc) 4.75 kB
/** * tdesign v1.15.1 * (c) 2025 tdesign * @license MIT */ 'use strict'; var _arrayFilter = require('./dep-efe6d243.js'); var isArrayLikeObject = require('./dep-6c297e20.js'); var _baseDifference = require('./dep-40e87384.js'); var _baseFlatten = require('./dep-fc29b8b5.js'); var _cacheHas = require('./dep-014b9b78.js'); var _arrayIncludesWith = require('./dep-297a4933.js'); var _Set = require('./dep-bff2c990.js'); var noop = require('./dep-139db759.js'); var _setToArray = require('./dep-abdd786a.js'); var last = require('./dep-d915c90f.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 = !(_Set.Set && 1 / _setToArray.setToArray(new _Set.Set([, -0]))[1] == INFINITY) ? noop.noop : function (values) { return new _Set.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 _setToArray.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(_arrayFilter.arrayFilter(arrays, isArrayLikeObject.isArrayLikeObject), undefined, comparator); }); var xorWith$1 = xorWith; exports.xorWith = xorWith$1; //# sourceMappingURL=dep-62f5b69f.js.map