UNPKG

tdesign-vue-next

Version:
94 lines (85 loc) 2.78 kB
/** * tdesign v1.15.2 * (c) 2025 tdesign * @license MIT */ 'use strict'; var _arrayFilter = require('./dep-d0f125b5.js'); var _baseGetTag = require('./dep-79f734cc.js'); var _baseUnary = require('./dep-79cd6be1.js'); var isArray = require('./dep-ce0157af.js'); var isArrayLikeObject = require('./dep-3df90229.js'); /** Built-in value references. */ var spreadableSymbol = _baseGetTag._Symbol ? _baseGetTag._Symbol.isConcatSpreadable : undefined; /** * Checks if `value` is a flattenable `arguments` object or array. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. */ function isFlattenable(value) { return isArray.isArray(value) || _baseUnary.isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]); } /** * The base implementation of `_.flatten` with support for restricting flattening. * * @private * @param {Array} array The array to flatten. * @param {number} depth The maximum recursion depth. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. * @param {Array} [result=[]] The initial result value. * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, depth, predicate, isStrict, result) { var index = -1, length = array.length; predicate || (predicate = isFlattenable); result || (result = []); while (++index < length) { var value = array[index]; if (depth > 0 && predicate(value)) { if (depth > 1) { // Recursively flatten arrays (susceptible to call stack limits). baseFlatten(value, depth - 1, predicate, isStrict, result); } else { _arrayFilter.arrayPush(result, value); } } else if (!isStrict) { result[result.length] = value; } } return result; } /** * Flattens `array` a single level deep. * * @static * @memberOf _ * @since 0.1.0 * @category Array * @param {Array} array The array to flatten. * @returns {Array} Returns the new flattened array. * @example * * _.flatten([1, [2, [3, [4]], 5]]); * // => [1, 2, [3, [4]], 5] */ function flatten(array) { var length = array == null ? 0 : array.length; return length ? baseFlatten(array, 1) : []; } /** * A specialized version of `baseRest` which flattens the rest array. * * @private * @param {Function} func The function to apply a rest parameter to. * @returns {Function} Returns the new function. */ function flatRest(func) { return isArrayLikeObject.setToString(isArrayLikeObject.overRest(func, undefined, flatten), func + ''); } exports.baseFlatten = baseFlatten; exports.flatRest = flatRest; //# sourceMappingURL=dep-c78b3175.js.map