{"version":3,"file":"browser.global.js","sources":["../src/array/at.ts","../src/array/difference.ts","../src/array/differenceBy.ts","../src/array/differenceWith.ts","../src/array/dropRightWhile.ts","../src/array/dropWhile.ts","../src/array/flatten.ts","../src/array/intersection.ts","../src/array/intersectionBy.ts","../src/array/intersectionWith.ts","../src/array/last.ts","../src/array/sample.ts","../src/math/random.ts","../src/math/randomInt.ts","../src/array/uniq.ts","../src/array/uniqBy.ts","../src/array/unionBy.ts","../src/array/uniqWith.ts","../src/array/unionWith.ts","../src/array/unzip.ts","../src/array/zip.ts","../src/error/AbortError.ts","../src/error/TimeoutError.ts","../src/function/after.ts","../src/function/ary.ts","../src/function/debounce.ts","../src/function/flow.ts","../src/function/identity.ts","../src/function/noop.ts","../src/function/partial.ts","../src/function/partialRight.ts","../src/math/mean.ts","../src/math/sum.ts","../src/math/median.ts","../src/math/range.ts","../src/predicate/isPrimitive.ts","../src/predicate/isTypedArray.ts","../src/object/clone.ts","../src/compat/_internal/getSymbols.ts","../src/object/cloneDeep.ts","../src/predicate/isPlainObject.ts","../src/object/flattenObject.ts","../src/object/mapKeys.ts","../src/object/mapValues.ts","../src/object/merge.ts","../src/compat/predicate/isObjectLike.ts","../src/predicate/isBlob.ts","../src/compat/_internal/getTag.ts","../src/compat/_internal/tags.ts","../src/compat/util/eq.ts","../src/predicate/isEqualWith.ts","../src/predicate/isJSONValue.ts","../src/predicate/isLength.ts","../src/predicate/isNil.ts","../src/promise/delay.ts","../src/promise/timeout.ts","../src/string/capitalize.ts","../src/string/words.ts","../src/string/deburr.ts","../src/string/escape.ts","../src/string/trimEnd.ts","../src/string/trimStart.ts","../src/string/trim.ts","../src/string/unescape.ts","../src/compat/_internal/toArray.ts","../src/compat/predicate/isArrayLike.ts","../src/compat/predicate/isArrayLikeObject.ts","../src/compat/array/last.ts","../src/compat/_internal/isDeepKey.ts","../src/compat/_internal/toKey.ts","../src/compat/util/toPath.ts","../src/compat/object/get.ts","../src/compat/object/property.ts","../src/compat/predicate/isObject.ts","../src/compat/predicate/isMatch.ts","../src/compat/predicate/matches.ts","../src/compat/object/cloneDeep.ts","../src/compat/_internal/isIndex.ts","../src/compat/predicate/isArguments.ts","../src/compat/object/has.ts","../src/compat/predicate/matchesProperty.ts","../src/compat/util/iteratee.ts","../src/compat/predicate/isSymbol.ts","../src/compat/util/toNumber.ts","../src/compat/util/toFinite.ts","../src/compat/util/toInteger.ts","../src/compat/_internal/isIterateeCall.ts","../src/compat/predicate/isString.ts","../src/compat/predicate/isArray.ts","../src/compat/array/flatten.ts","../src/compat/array/forEach.ts","../src/compat/array/head.ts","../src/array/head.ts","../src/compat/_internal/compareValues.ts","../src/compat/_internal/isKey.ts","../src/compat/array/orderBy.ts","../src/compat/object/set.ts","../src/compat/function/attempt.ts","../src/compat/function/bind.ts","../src/compat/function/bindKey.ts","../src/compat/function/curry.ts","../src/compat/function/curryRight.ts","../src/compat/function/debounce.ts","../src/compat/_internal/decimalAdjust.ts","../src/compat/math/clamp.ts","../src/math/clamp.ts","../src/compat/math/sumBy.ts","../src/compat/object/defaults.ts","../src/compat/predicate/isPlainObject.ts","../src/compat/predicate/isTypedArray.ts","../src/compat/object/mergeWith.ts","../src/compat/object/unset.ts","../src/compat/predicate/isNil.ts","../src/compat/predicate/conformsTo.ts","../src/compat/util/toString.ts","../src/compat/_internal/normalizeForCase.ts","../src/compat/string/escape.ts","../src/compat/string/template.ts","../src/compat/_internal/MAX_SAFE_INTEGER.ts","../src/compat/util/uniqueId.ts","../src/compat/function/ary.ts","../src/compat/function/before.ts","../src/compat/string/camelCase.ts","../src/string/camelCase.ts","../src/compat/array/castArray.ts","../src/compat/math/ceil.ts","../src/compat/array/chunk.ts","../src/array/chunk.ts","../src/compat/array/compact.ts","../src/array/compact.ts","../src/compat/array/concat.ts","../src/compat/predicate/conforms.ts","../src/compat/util/constant.ts","../src/string/constantCase.ts","../src/array/countBy.ts","../src/compat/util/defaultTo.ts","../src/compat/function/defer.ts","../src/compat/array/difference.ts","../src/compat/array/differenceBy.ts","../src/compat/_internal/flattenArrayLike.ts","../src/compat/array/drop.ts","../src/array/drop.ts","../src/compat/array/dropRight.ts","../src/array/dropRight.ts","../src/compat/array/dropRightWhile.ts","../src/compat/array/dropWhile.ts","../src/compat/string/endsWith.ts","../src/string/escapeRegExp.ts","../src/compat/array/every.ts","../src/compat/array/fill.ts","../src/array/fill.ts","../src/compat/array/filter.ts","../src/compat/array/find.ts","../src/compat/array/findIndex.ts","../src/object/findKey.ts","../src/compat/array/findLastIndex.ts","../src/array/flatMap.ts","../src/array/flatMapDeep.ts","../src/array/flattenDeep.ts","../src/compat/array/flattenDeep.ts","../src/compat/array/flattenDepth.ts","../src/compat/function/flip.ts","../src/compat/math/floor.ts","../src/compat/function/flow.ts","../src/compat/function/flowRight.ts","../src/function/flowRight.ts","../src/array/forEachRight.ts","../src/compat/object/fromPairs.ts","../src/array/groupBy.ts","../src/compat/math/inRange.ts","../src/math/inRange.ts","../src/compat/array/includes.ts","../src/compat/array/indexOf.ts","../src/array/initial.ts","../src/compat/array/intersection.ts","../src/compat/array/intersectionBy.ts","../src/util/invariant.ts","../src/object/invert.ts","../src/compat/object/invertBy.ts","../src/compat/predicate/isArrayBuffer.ts","../src/predicate/isArrayBuffer.ts","../src/compat/predicate/isBoolean.ts","../src/compat/predicate/isDate.ts","../src/predicate/isDate.ts","../src/compat/predicate/isEmpty.ts","../src/compat/_internal/isPrototype.ts","../src/predicate/isEqual.ts","../src/compat/predicate/isEqualWith.ts","../src/compat/predicate/isError.ts","../src/predicate/isFile.ts","../src/compat/predicate/isFinite.ts","../src/predicate/isFunction.ts","../src/compat/predicate/isInteger.ts","../src/compat/predicate/isMap.ts","../src/predicate/isMap.ts","../src/compat/predicate/isNaN.ts","../src/predicate/isNotNil.ts","../src/predicate/isNull.ts","../src/compat/predicate/isNumber.ts","../src/compat/predicate/isRegExp.ts","../src/predicate/isRegExp.ts","../src/compat/predicate/isSafeInteger.ts","../src/compat/predicate/isSet.ts","../src/predicate/isSet.ts","../src/array/isSubset.ts","../src/array/isSubsetWith.ts","../src/predicate/isUndefined.ts","../src/compat/predicate/isWeakMap.ts","../src/predicate/isWeakMap.ts","../src/compat/predicate/isWeakSet.ts","../src/predicate/isWeakSet.ts","../src/compat/array/join.ts","../src/compat/string/kebabCase.ts","../src/string/kebabCase.ts","../src/array/keyBy.ts","../src/compat/string/lowerCase.ts","../src/string/lowerCase.ts","../src/string/lowerFirst.ts","../src/compat/object/mapKeys.ts","../src/compat/object/mapValues.ts","../src/compat/math/max.ts","../src/array/maxBy.ts","../src/math/meanBy.ts","../src/math/medianBy.ts","../src/function/memoize.ts","../src/compat/object/merge.ts","../src/compat/math/min.ts","../src/array/minBy.ts","../src/function/negate.ts","../src/compat/object/omit.ts","../src/object/omitBy.ts","../src/function/once.ts","../src/compat/string/pad.ts","../src/string/pad.ts","../src/compat/string/padEnd.ts","../src/compat/string/padStart.ts","../src/compat/math/parseInt.ts","../src/array/partition.ts","../src/string/pascalCase.ts","../src/compat/object/pick.ts","../src/object/pickBy.ts","../src/array/pullAt.ts","../src/compat/math/random.ts","../src/math/rangeRight.ts","../src/compat/function/rearg.ts","../src/compat/string/repeat.ts","../src/compat/string/replace.ts","../src/compat/function/rest.ts","../src/function/rest.ts","../src/compat/math/round.ts","../src/compat/array/sample.ts","../src/array/sampleSize.ts","../src/array/shuffle.ts","../src/compat/array/size.ts","../src/compat/array/slice.ts","../src/compat/string/snakeCase.ts","../src/string/snakeCase.ts","../src/compat/array/some.ts","../src/compat/array/sortBy.ts","../src/compat/function/spread.ts","../src/compat/string/startCase.ts","../src/compat/string/startsWith.ts","../src/compat/math/sum.ts","../src/compat/array/tail.ts","../src/array/tail.ts","../src/compat/array/take.ts","../src/array/take.ts","../src/compat/array/takeRight.ts","../src/array/takeRight.ts","../src/array/takeRightWhile.ts","../src/array/takeWhile.ts","../src/compat/function/throttle.ts","../src/compat/util/times.ts","../src/compat/object/toDefaulted.ts","../src/array/toFilled.ts","../src/compat/util/toLength.ts","../src/compat/_internal/MAX_ARRAY_LENGTH.ts","../src/object/toMerged.ts","../src/compat/util/toSafeInteger.ts","../src/compat/string/trim.ts","../src/compat/string/trimEnd.ts","../src/compat/string/trimStart.ts","../src/function/unary.ts","../src/compat/array/union.ts","../src/compat/array/uniq.ts","../src/compat/array/uniqBy.ts","../src/compat/array/unzip.ts","../src/array/unzipWith.ts","../src/compat/string/upperCase.ts","../src/string/upperCase.ts","../src/string/upperFirst.ts","../src/promise/withTimeout.ts","../src/compat/array/without.ts","../src/array/without.ts","../src/array/xor.ts","../src/array/union.ts","../src/array/xorBy.ts","../src/array/xorWith.ts","../src/compat/array/zip.ts","../src/array/zipObject.ts","../src/compat/array/zipObjectDeep.ts","../src/array/zipWith.ts"],"sourcesContent":["/**\n * Retrieves elements from an array at the specified indices.\n *\n * This function supports negative indices, which count from the end of the array.\n *\n * @template T\n * @param {readonly T[]} arr - The array to retrieve elements from.\n * @param {number[]} indices - An array of indices specifying the positions of elements to retrieve.\n * @returns {Array} A new array containing the elements at the specified indices.\n *\n * @example\n * const numbers = [10, 20, 30, 40, 50];\n * const result = at(numbers, [1, 3, 4]);\n * console.log(result); // [20, 40, 50]\n */\nexport function at(arr: readonly T[], indices: number[]): Array {\n const result = new Array(indices.length);\n const length = arr.length;\n\n for (let i = 0; i < indices.length; i++) {\n let index = indices[i];\n\n index = Number.isInteger(index) ? index : Math.trunc(index) || 0;\n\n if (index < 0) {\n index += length;\n }\n\n result[i] = arr[index];\n }\n\n return result;\n}\n","/**\n * Computes the difference between two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements\n * that are present in the first array but not in the second array. It effectively\n * filters out any elements from the first array that also appear in the second array.\n *\n * @template T\n * @param {T[]} firstArr - The array from which to derive the difference. This is the primary array\n * from which elements will be compared and filtered.\n * @param {T[]} secondArr - The array containing elements to be excluded from the first array.\n * Each element in this array will be checked against the first array, and if a match is found,\n * that element will be excluded from the result.\n * @returns {T[]} A new array containing the elements that are present in the first array but not\n * in the second array.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [2, 4];\n * const result = difference(array1, array2);\n * // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.\n */\nexport function difference(firstArr: readonly T[], secondArr: readonly T[]): T[] {\n const secondSet = new Set(secondArr);\n\n return firstArr.filter(item => !secondSet.has(item));\n}\n","/**\n * Computes the difference between two arrays after mapping their elements through a provided function.\n *\n * This function takes two arrays and a mapper function. It returns a new array containing the elements\n * that are present in the first array but not in the second array, based on the identity calculated\n * by the mapper function.\n *\n * Essentially, it filters out any elements from the first array that, when\n * mapped, match an element in the mapped version of the second array.\n *\n * @template T, U\n * @param {T[]} firstArr - The primary array from which to derive the difference.\n * @param {T[]} secondArr - The array containing elements to be excluded from the first array.\n * @param {(value: T) => U} mapper - The function to map the elements of both arrays. This function\n * is applied to each element in both arrays, and the comparison is made based on the mapped values.\n * @returns {T[]} A new array containing the elements from the first array that do not have a corresponding\n * mapped identity in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = differenceBy(array1, array2, mapper);\n * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.\n */\nexport function differenceBy(firstArr: readonly T[], secondArr: readonly T[], mapper: (value: T) => U): T[] {\n const mappedSecondSet = new Set(secondArr.map(item => mapper(item)));\n\n return firstArr.filter(item => {\n return !mappedSecondSet.has(mapper(item));\n });\n}\n","/**\n * Computes the difference between two arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom comparison function. It returns a new array containing\n * the elements that are present in the first array but not in the second array. The comparison to determine\n * if elements are equal is made using the provided custom function.\n *\n * @template T\n * @param {T[]} firstArr - The array from which to get the difference.\n * @param {T[]} secondArr - The array containing elements to exclude from the first array.\n * @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.\n * @returns {T[]} A new array containing the elements from the first array that do not match any elements in the second array\n * according to the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = differenceWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.\n */\nexport function differenceWith(\n firstArr: readonly T[],\n secondArr: readonly T[],\n areItemsEqual: (x: T, y: T) => boolean\n): T[] {\n return firstArr.filter(firstItem => {\n return secondArr.every(secondItem => {\n return !areItemsEqual(firstItem, secondItem);\n });\n });\n}\n","/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array from the end and drops elements until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T, index: number, arr: T[]) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element from the end,\n * and dropping continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRightWhile(array, x => x > 3);\n * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.\n */\nexport function dropRightWhile(\n arr: readonly T[],\n canContinueDropping: (item: T, index: number, arr: readonly T[]) => boolean\n): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!canContinueDropping(arr[i], i, arr)) {\n return arr.slice(0, i + 1);\n }\n }\n\n return [];\n}\n","/**\n * Removes elements from the beginning of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the start until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T, index: number, arr: T[]) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropWhile(array, x => x < 3);\n * // result will be [3, 4, 5] since elements less than 3 are dropped.\n */\nexport function dropWhile(\n arr: readonly T[],\n canContinueDropping: (item: T, index: number, arr: readonly T[]) => boolean\n): T[] {\n const dropEndIndex = arr.findIndex((item, index, arr) => !canContinueDropping(item, index, arr));\n\n if (dropEndIndex === -1) {\n return [];\n }\n\n return arr.slice(dropEndIndex);\n}\n","/**\n * Flattens an array up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template D - The depth to which the array should be flattened.\n * @param {T[]} arr - The array to flatten.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array>} A new array that has been flattened.\n *\n * @example\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);\n * // Returns: [1, 2, 3, 4, [5, 6]]\n *\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flatten(arr: readonly T[], depth = 1 as D): Array> {\n const result: Array> = [];\n const flooredDepth = Math.floor(depth);\n\n const recursive = (arr: readonly T[], currentDepth: number) => {\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n if (Array.isArray(item) && currentDepth < flooredDepth) {\n recursive(item, currentDepth + 1);\n } else {\n result.push(item as FlatArray);\n }\n }\n };\n\n recursive(arr, 0);\n return result;\n}\n","/**\n * Returns the intersection of two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements that are\n * present in both arrays. It effectively filters out any elements from the first array that\n * are not found in the second array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @returns {T[]} A new array containing the elements that are present in both arrays.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [3, 4, 5, 6, 7];\n * const result = intersection(array1, array2);\n * // result will be [3, 4, 5] since these elements are in both arrays.\n */\nexport function intersection(firstArr: readonly T[], secondArr: readonly T[]): T[] {\n const secondSet = new Set(secondArr);\n\n return firstArr.filter(item => {\n return secondSet.has(item);\n });\n}\n","/**\n * Returns the intersection of two arrays based on a mapping function.\n *\n * This function takes two arrays and a mapping function. It returns a new array containing\n * the elements from the first array that, when mapped using the provided function, have matching\n * mapped elements in the second array. It effectively filters out any elements from the first array\n * that do not have corresponding mapped values in the second array.\n *\n * @template T - The type of elements in the array.\n * @template U - The type of mapped elements.\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.\n * @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = intersectionBy(array1, array2, mapper);\n * // result will be [{ id: 2 }] since only this element has a matching id in both arrays.\n */\nexport function intersectionBy(firstArr: readonly T[], secondArr: readonly T[], mapper: (item: T) => U): T[] {\n const mappedSecondSet = new Set(secondArr.map(mapper));\n return firstArr.filter(item => mappedSecondSet.has(mapper(item)));\n}\n","/**\n * Returns the intersection of two arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom equality function. It returns a new array containing\n * the elements from the first array that have matching elements in the second array, as determined\n * by the custom equality function. It effectively filters out any elements from the first array that\n * do not have corresponding matches in the second array according to the equality function.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.\n * This function takes two arguments, one from each array, and returns `true` if the elements are considered equal, and `false` otherwise.\n * @returns {T[]} A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = intersectionWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 2 }] since this element has a matching id in both arrays.\n */\nexport function intersectionWith(\n firstArr: readonly T[],\n secondArr: readonly T[],\n areItemsEqual: (x: T, y: T) => boolean\n): T[] {\n return firstArr.filter(firstItem => {\n return secondArr.some(secondItem => {\n return areItemsEqual(firstItem, secondItem);\n });\n });\n}\n","/**\n * Returns the last element of an array.\n *\n * This function takes an array and returns the last element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * Unlike some implementations, this function is optimized for performance\n * by directly accessing the last index of the array.\n *\n * @template T - The type of elements in the array.\n * @param {[...T[], T]} arr - The array from which to get the last element.\n * @returns {T} The last element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const lastElement = last(arr);\n * // lastElement will be 3\n *\n * const emptyArr: number[] = [];\n * const noElement = last(emptyArr);\n * // noElement will be undefined\n */\nexport function last(arr: readonly [...T[], T]): T;\n\n/**\n * Returns the last element of an array.\n *\n * This function takes an array and returns the last element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * Unlike some implementations, this function is optimized for performance\n * by directly accessing the last index of the array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to get the last element.\n * @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const lastElement = last(arr);\n * // lastElement will be 3\n *\n * const emptyArr: number[] = [];\n * const noElement = last(emptyArr);\n * // noElement will be undefined\n */\nexport function last(arr: readonly T[]): T | undefined;\n\n/**\n * Returns the last element of an array.\n *\n * This function takes an array and returns the last element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * Unlike some implementations, this function is optimized for performance\n * by directly accessing the last index of the array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to get the last element.\n * @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const lastElement = last(arr);\n * // lastElement will be 3\n *\n * const emptyArr: number[] = [];\n * const noElement = last(emptyArr);\n * // noElement will be undefined\n */\nexport function last(arr: readonly T[]): T | undefined {\n return arr[arr.length - 1];\n}\n","/**\n * Returns a random element from an array.\n *\n * This function takes an array and returns a single element selected randomly from the array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to sample from.\n * @returns {T} A random element from the array.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const randomElement = sample(array);\n * // randomElement will be one of the elements from the array, selected randomly.\n */\nexport function sample(arr: readonly T[]): T {\n const randomIndex = Math.floor(Math.random() * arr.length);\n return arr[randomIndex];\n}\n","/**\n * Generate a random number within the given range.\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between 0 (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `0`.\n *\n * @example\n * const result1 = random(5); // Returns a random number between 0 and 5.\n * const result2 = random(0); // If the `maximum` is less than or equal to 0, an error is thrown.\n */\nexport function random(maximum: number): number;\n\n/**\n * Generate a random number within the given range.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result1 = random(0, 5); // Returns a random number between 0 and 5.\n * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown.\n * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.\n */\nexport function random(minimum: number, maximum: number): number;\n\n/**\n * Generate a random number within the given range.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result1 = random(0, 5); // Returns a random number between 0 and 5.\n * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown.\n * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.\n */\nexport function random(minimum: number, maximum?: number): number {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n\n return Math.random() * (maximum - minimum) + minimum;\n}\n","import { random } from './random.ts';\n\n/**\n * Generates a random integer between 0 (inclusive) and the given maximum (exclusive).\n *\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random integer between 0 (inclusive) and maximum (exclusive).\n * @throws {Error} Throws an error if `maximum` is not greater than `0`.\n *\n * @example\n * const result = randomInt(5); // result will be a random integer between 0 (inclusive) and 5 (exclusive)\n */\nexport function randomInt(maximum: number): number;\n\n/**\n * Generates a random integer between minimum (inclusive) and maximum (exclusive).\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random integer between minimum (inclusive) and maximum (exclusive).\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive)\n * const result2 = randomInt(5, 0); // This will throw an error\n */\nexport function randomInt(minimum: number, maximum: number): number;\n\n/**\n * Generates a random integer between minimum (inclusive) and maximum (exclusive).\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random integer between minimum (inclusive) and maximum (exclusive).\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive)\n * const result2 = randomInt(5, 0); // This will throw an error\n */\nexport function randomInt(minimum: number, maximum?: number): number {\n return Math.floor(random(minimum, maximum!));\n}\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @template T - The type of elements in the array.\n * @template U - The type of mapped elements.\n * @param {T[]} arr - The array to process.\n * @param {(item: T) => U} mapper - The function used to convert the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @example\n * const array = [\n * { category: 'fruit', name: 'apple' },\n * { category: 'fruit', name: 'banana' },\n * { category: 'vegetable', name: 'carrot' },\n * ];\n * uniqBy(array, item => item.category).length\n * // 2\n * ```\n */\nexport function uniqBy(arr: readonly T[], mapper: (item: T) => U): T[] {\n const map = new Map();\n\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return Array.from(map.values());\n}\n","import { uniqBy } from './uniqBy.ts';\n\n/**\n * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.\n *\n * @template T - The type of elements in the array.\n * @template U - The type of mapped elements.\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for numbers (modulo comparison)\n * const moduloMapper = (x) => x % 3;\n * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);\n * // Returns [1, 2, 3]\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = (obj) => obj.id;\n * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]\n */\nexport function unionBy(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[] {\n return uniqBy(arr1.concat(arr2), mapper);\n}\n","/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the comparator function.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith(arr: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n","import { uniqWith } from './uniqWith.ts';\n\n/**\n * Creates an array of unique values from two given arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom equality function, merges the arrays, and returns\n * a new array containing only the unique values as determined by the custom equality function.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.\n * It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.\n * @returns {T[]} A new array of unique values based on the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }];\n * const array2 = [{ id: 2 }, { id: 3 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = unionWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays\n */\nexport function unionWith(\n arr1: readonly T[],\n arr2: readonly T[],\n areItemsEqual: (item1: T, item2: T) => boolean\n): T[] {\n return uniqWith(arr1.concat(arr2), areItemsEqual);\n}\n","/**\n * Gathers elements in the same position in an internal array\n * from a grouped array of elements and returns them as a new array.\n *\n * @template T - The type of elements in the nested array.\n * @param {Array<[...T]>} zipped - The nested array to unzip.\n * @returns {Unzip} A new array of unzipped elements.\n *\n * @example\n * const zipped = [['a', true, 1],['b', false, 2]];\n * const result = unzip(zipped);\n * // result will be [['a', 'b'], [true, false], [1, 2]]\n */\nexport function unzip(zipped: ReadonlyArray<[...T]>): Unzip {\n // For performance reasons, use this implementation instead of\n // const maxLen = Math.max(...zipped.map(arr => arr.length));\n let maxLen = 0;\n\n for (let i = 0; i < zipped.length; i++) {\n if (zipped[i].length > maxLen) {\n maxLen = zipped[i].length;\n }\n }\n\n const result = new Array(maxLen) as Unzip;\n\n for (let i = 0; i < maxLen; i++) {\n result[i] = new Array(zipped.length);\n for (let j = 0; j < zipped.length; j++) {\n result[i][j] = zipped[j][i];\n }\n }\n\n return result;\n}\n\ntype Unzip = { [I in keyof K]: Array };\n","/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T\n * @param {T[]} arr1 - The first array to zip.\n * @returns {Array<[T]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const result = zip(arr1);\n * // result will be [[1], [2], [3]]\n */\nexport function zip(arr1: readonly T[]): Array<[T]>;\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T, U\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} arr2 - The second array to zip.\n * @returns {Array<[T, U]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const result = zip(arr1, arr2);\n * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]\n */\nexport function zip(arr1: readonly T[], arr2: readonly U[]): Array<[T, U]>;\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T, U, V\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} arr2 - The second array to zip.\n * @param {V[]} arr3 - The third array to zip.\n * @returns {Array<[T, U, V]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const arr3 = [true, false];\n * const result = zip(arr1, arr2, arr3);\n * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]\n */\nexport function zip(arr1: readonly T[], arr2: readonly U[], arr3: readonly V[]): Array<[T, U, V]>;\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T, U, V, W\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} arr2 - The second array to zip.\n * @param {V[]} arr3 - The third array to zip.\n * @param {W[]} arr4 - The fourth array to zip.\n * @returns {Array<[T, U, V, W]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const arr3 = [true, false];\n * const arr4 = [null, null, null];\n * const result = zip(arr1, arr2, arr3, arr4);\n * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]\n */\nexport function zip(\n arr1: readonly T[],\n arr2: readonly U[],\n arr3: readonly V[],\n arr4: readonly W[]\n): Array<[T, U, V, W]>;\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T\n * @param {...Array} arrs - The arrays to zip together.\n * @returns {T[][]} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const arr3 = [true, false];\n * const result = zip(arr1, arr2, arr3);\n * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]\n */\nexport function zip(...arrs: Array): T[][] {\n // For performance reasons, use this implementation instead of\n // const rowCount = Math.max(...arrs.map(x => x.length));\n let rowCount = 0;\n\n for (let i = 0; i < arrs.length; i++) {\n if (arrs[i].length > rowCount) {\n rowCount = arrs[i].length;\n }\n }\n const columnCount = arrs.length;\n const result = Array(rowCount);\n\n for (let i = 0; i < rowCount; ++i) {\n const row = Array(columnCount);\n for (let j = 0; j < columnCount; ++j) {\n row[j] = arrs[j][i];\n }\n result[i] = row;\n }\n return result;\n}\n","/**\n * An error class representing an aborted operation.\n * @augments Error\n */\nexport class AbortError extends Error {\n constructor(message = 'The operation was aborted') {\n super(message);\n this.name = 'AbortError';\n }\n}\n","/**\n * An error class representing an timeout operation.\n * @augments Error\n */\nexport class TimeoutError extends Error {\n constructor(message = 'The operation was timed out') {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n","/**\n * Creates a function that only executes starting from the `n`-th call.\n * The provided function will be invoked starting from the `n`-th call.\n *\n * This is particularly useful for scenarios involving events or asynchronous operations\n * where an action should occur only after a certain number of invocations.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of calls required for `func` to execute.\n * @param {F} func - The function to be invoked.\n * @returns {(...args: Parameters) => ReturnType | undefined} - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` starting from the `n`-th call.\n * - Returns `undefined` if fewer than `n` calls have been made.\n * @throws {Error} - Throws an error if `n` is negative.\n * @example\n *\n * const afterFn = after(3, () => {\n * console.log(\"called\")\n * });\n *\n * // Will not log anything.\n * afterFn()\n * // Will not log anything.\n * afterFn()\n * // Will log 'called'.\n * afterFn()\n */\n\nexport function after any>(\n n: number,\n func: F\n): (...args: Parameters) => ReturnType | undefined {\n if (!Number.isInteger(n) || n < 0) {\n throw new Error(`n must be a non-negative integer.`);\n }\n\n let counter = 0;\n return (...args: Parameters) => {\n if (++counter >= n) {\n return func(...args);\n }\n return undefined;\n };\n}\n","/**\n * Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.\n *\n * @template F - The type of the function.\n * @param {F} func - The function to cap arguments for.\n * @param {number} n - The arity cap.\n * @returns {(...args: any[]) => ReturnType} Returns the new capped function.\n *\n * @example\n * function fn(a: number, b: number, c: number) {\n * return Array.from(arguments);\n * }\n *\n * ary(fn, 0)(1, 2, 3) // []\n * ary(fn, 1)(1, 2, 3) // [1]\n * ary(fn, 2)(1, 2, 3) // [1, 2]\n * ary(fn, 3)(1, 2, 3) // [1, 2, 3]\n */\nexport function ary any>(func: F, n: number): (...args: any[]) => ReturnType {\n return function (this: any, ...args: Parameters) {\n return func.apply(this, args.slice(0, n));\n };\n}\n","interface DebounceOptions {\n /**\n * An optional AbortSignal to cancel the debounced function.\n */\n signal?: AbortSignal;\n\n /**\n * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.\n * If `edges` includes \"leading\", the function will be invoked at the start of the delay period.\n * If `edges` includes \"trailing\", the function will be invoked at the end of the delay period.\n * If both \"leading\" and \"trailing\" are included, the function will be invoked at both the start and end of the delay period.\n * @default [\"trailing\"]\n */\n edges?: Array<'leading' | 'trailing'>;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @returns A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce void>(\n func: F,\n debounceMs: number,\n { signal, edges }: DebounceOptions = {}\n): ((...args: Parameters) => void) & {\n /**\n * Schedules the execution of the debounced function after the specified debounce delay.\n * This method resets any existing timer, ensuring that the function is only invoked\n * after the delay has elapsed since the last call to the debounced function.\n * It is typically called internally whenever the debounced function is invoked.\n *\n * @returns {void}\n */\n schedule: () => void;\n\n /**\n * Cancels any pending execution of the debounced function.\n * This method clears the active timer and resets any stored context or arguments.\n */\n cancel: () => void;\n\n /**\n * Immediately invokes the debounced function if there is a pending execution.\n * This method also cancels the current timer, ensuring that the function executes right away.\n */\n flush: () => void;\n} {\n let pendingThis: any = undefined;\n let pendingArgs: Parameters | null = null;\n\n const leading = edges != null && edges.includes('leading');\n const trailing = edges == null || edges.includes('trailing');\n\n const invoke = () => {\n if (pendingArgs !== null) {\n func.apply(pendingThis, pendingArgs);\n pendingThis = undefined;\n pendingArgs = null;\n }\n };\n\n const onTimerEnd = () => {\n if (trailing) {\n invoke();\n }\n\n cancel();\n };\n\n let timeoutId: ReturnType | null = null;\n\n const schedule = () => {\n if (timeoutId != null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n timeoutId = null;\n\n onTimerEnd();\n }, debounceMs);\n };\n\n const cancelTimer = () => {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n };\n\n const cancel = () => {\n cancelTimer();\n pendingThis = undefined;\n pendingArgs = null;\n };\n\n const flush = () => {\n cancelTimer();\n invoke();\n };\n\n const debounced = function (this: any, ...args: Parameters) {\n if (signal?.aborted) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n pendingThis = this;\n pendingArgs = args;\n\n const isFirstCall = timeoutId == null;\n\n schedule();\n\n if (leading && isFirstCall) {\n invoke();\n }\n };\n\n debounced.schedule = schedule;\n debounced.cancel = cancel;\n debounced.flush = flush;\n\n signal?.addEventListener('abort', cancel, { once: true });\n\n return debounced;\n}\n","/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {() => R} f The function to invoke.\n * @returns {() => R} Returns the new composite function.\n *\n * @example\n * function noArgFunc() {\n * return 42;\n * }\n *\n * const combined = flow(noArgFunc);\n * console.log(combined()); // 42\n */\nexport function flow(f: () => R): () => R;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R} f1 The function to invoke.\n * @returns {(...args: A) => R} Returns the new composite function.\n *\n * @example\n * function oneArgFunc(a: number) {\n * return a * 2;\n * }\n *\n * const combined = flow(oneArgFunc);\n * console.log(combined(5)); // 10\n */\nexport function flow(f1: (...args: A) => R): (...args: A) => R;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @returns {(...args: A) => R2} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n *\n * const combined = flow(add, square);\n * console.log(combined(1, 2)); // 9\n */\nexport function flow(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @returns {(...args: A) => R3} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n *\n * const combined = flow(add, square, double);\n * console.log(combined(1, 2)); // 18\n */\nexport function flow(\n f1: (...args: A) => R1,\n f2: (a: R1) => R2,\n f3: (a: R2) => R3\n): (...args: A) => R3;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R3) => R4} f4 The function to invoke.\n * @returns {(...args: A) => R4} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n * const toStr = (n: number) => n.toString();\n *\n * const combined = flow(add, square, double, toStr);\n * console.log(combined(1, 2)); // '18'\n */\nexport function flow(\n f1: (...args: A) => R1,\n f2: (a: R1) => R2,\n f3: (a: R2) => R3,\n f4: (a: R3) => R4\n): (...args: A) => R4;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R3) => R4} f4 The function to invoke.\n * @param {(a: R4) => R5} f5 The function to invoke.\n * @returns {(...args: A) => R5} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n * const toStr = (n: number) => n.toString();\n * const split = (s: string) => s.split('');\n *\n * const combined = flow(add, square, double, toStr, split);\n * console.log(combined(1, 2)); // ['1', '8']\n */\nexport function flow(\n f1: (...args: A) => R1,\n f2: (a: R1) => R2,\n f3: (a: R2) => R3,\n f4: (a: R3) => R4,\n f5: (a: R4) => R5\n): (...args: A) => R5;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {Array<(...args: any[]) => any>} funcs The functions to invoke.\n * @returns {(...args: any[]) => any} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n *\n * const combined = flow(add, square);\n * console.log(combined(1, 2)); // 9\n */\nexport function flow(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {Array<(...args: any[]) => any>} funcs The functions to invoke.\n * @returns {(...args: any[]) => any} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n *\n * const combined = flow(add, square);\n * console.log(combined(1, 2)); // 9\n */\nexport function flow(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any {\n return function (this: any, ...args: any[]) {\n let result = funcs.length ? funcs[0].apply(this, args) : args[0];\n\n for (let i = 1; i < funcs.length; i++) {\n result = funcs[i].call(this, result);\n }\n\n return result;\n };\n}\n","/**\n * Returns the input value unchanged.\n *\n * @template T - The type of the input value.\n * @param {T} x - The value to be returned.\n * @returns {T} The input value.\n *\n * @example\n * // Returns 5\n * identity(5);\n *\n * @example\n * // Returns 'hello'\n * identity('hello');\n *\n * @example\n * // Returns { key: 'value' }\n * identity({ key: 'value' });\n */\nexport function identity(x: T): T {\n return x;\n}\n","/**\n * A no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * noop(); // Does nothing\n *\n * @returns {void} This function does not return anything.\n */\nexport function noop(): void {}\n","/**\n * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.\n *\n * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.\n *\n * Note: This method doesn't set the `length` property of partially applied functions.\n *\n * @template F The type of the function to partially apply.\n * @param {F} func The function to partially apply arguments to.\n * @param {any[]} partialArgs The arguments to be partially applied.\n * @returns {F} Returns the new partially applied function.\n *\n * @example\n * function greet(greeting, name) {\n * return greeting + ' ' + name;\n * }\n *\n * const sayHelloTo = partial(greet, 'hello');\n * sayHelloTo('fred');\n * // => 'hello fred'\n *\n * // Partially applied with placeholders.\n * const greetFred = partial(greet, partial.placeholder, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n */\nexport function partial any>(func: F, ...partialArgs: any[]): F {\n return function (this: any, ...providedArgs: any[]) {\n const args: any[] = [];\n\n let startIndex = 0;\n for (let i = 0; i < partialArgs.length; i++) {\n const arg = partialArgs[i];\n\n if (arg === partial.placeholder) {\n args.push(providedArgs[startIndex++]);\n } else {\n args.push(arg);\n }\n }\n for (let i = startIndex; i < providedArgs.length; i++) {\n args.push(providedArgs[i]);\n }\n\n return func.apply(this, args);\n } as any as F;\n}\n\nconst partialPlaceholder: unique symbol = Symbol('partial.placeholder');\npartial.placeholder = partialPlaceholder;\n","/**\n * This method is like `partial` except that partially applied arguments are appended to the arguments it receives.\n *\n * The partialRight.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.\n *\n * Note: This method doesn't set the `length` property of partially applied functions.\n *\n * @template F The type of the function to partially apply.\n * @param {F} func The function to partially apply arguments to.\n * @param {any[]} partialArgs The arguments to be partially applied.\n * @returns {F} Returns the new partially applied function.\n *\n * @example\n * function greet(greeting, name) {\n * return greeting + ' ' + name;\n * }\n *\n * const greetFred = partialRight(greet, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n *\n * // Partially applied with placeholders.\n * const sayHelloTo = partialRight(greet, 'hello', partialRight.placeholder);\n * sayHelloTo('fred');\n * // => 'hello fred'\n */\nexport function partialRight any>(func: F, ...partialArgs: any[]): F {\n return function (this: any, ...providedArgs: any[]) {\n const placeholderLength = partialArgs.filter(arg => arg === partialRightPlaceholder).length;\n const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);\n const args: any[] = [];\n\n let providedIndex = 0;\n for (let i = 0; i < rangeLength; i++) {\n args.push(providedArgs[providedIndex++]);\n }\n for (let i = 0; i < partialArgs.length; i++) {\n const arg = partialArgs[i];\n\n if (arg === partialRight.placeholder) {\n args.push(providedArgs[providedIndex++]);\n } else {\n args.push(arg);\n }\n }\n return func.apply(this, args);\n } as any as F;\n}\n\nconst partialRightPlaceholder: unique symbol = Symbol('partialRight.placeholder');\npartialRight.placeholder = partialRightPlaceholder;\n","import { sum } from './sum.ts';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the average.\n * @returns {number} The average of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = mean(numbers);\n * // result will be 3\n */\nexport function mean(nums: readonly number[]): number {\n return sum(nums) / nums.length;\n}\n","/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (let i = 0; i < nums.length; i++) {\n result += nums[i];\n }\n\n return result;\n}\n","/**\n * Calculates the median of an array of numbers.\n *\n * The median is the middle value of a sorted array.\n * If the array has an odd number of elements, the median is the middle value.\n * If the array has an even number of elements, it returns the average of the two middle values.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the median.\n * @returns {number} The median of all the numbers in the array.\n *\n * @example\n * const arrayWithOddNumberOfElements = [1, 2, 3, 4, 5];\n * const result = median(arrayWithOddNumberOfElements);\n * // result will be 3\n *\n * @example\n * const arrayWithEvenNumberOfElements = [1, 2, 3, 4];\n * const result = median(arrayWithEvenNumberOfElements);\n * // result will be 2.5\n */\nexport function median(nums: readonly number[]): number {\n if (nums.length === 0) {\n return NaN;\n }\n\n const sorted = nums.slice().sort((a, b) => a - b);\n const middleIndex = Math.floor(sorted.length / 2);\n\n if (sorted.length % 2 === 0) {\n return (sorted[middleIndex - 1] + sorted[middleIndex]) / 2;\n } else {\n return sorted[middleIndex];\n }\n}\n","/**\n * Returns an array of numbers from `0` (inclusive) to `end` (exclusive), incrementing by `1`.\n *\n * @param {number} end - The end number of the range (exclusive).\n * @returns {number[]} An array of numbers from `0` (inclusive) to `end` (exclusive) with a step of `1`.\n *\n * @example\n * // Returns [0, 1, 2, 3]\n * range(4);\n */\nexport function range(end: number): number[];\n\n/**\n * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `1`.\n *\n * @param {number} start - The starting number of the range (inclusive).\n * @param {number} end - The end number of the range (exclusive).\n * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with a step of `1`.\n *\n * @example\n * // Returns [1, 2, 3]\n * range(1, 4);\n */\nexport function range(start: number, end: number): number[];\n\n/**\n * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `step`.\n *\n * @param {number} start - The starting number of the range (inclusive).\n * @param {number} end - The end number of the range (exclusive).\n * @param {number} step - The step value for the range.\n * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`.\n *\n * @example\n * // Returns [0, 5, 10, 15]\n * range(0, 20, 5);\n */\nexport function range(start: number, end: number, step: number): number[];\n\n/**\n * Returns an array of numbers from `start` (inclusive) to `end` (exclusive), incrementing by `step`.\n *\n * @param {number} start - The starting number of the range (inclusive).\n * @param {number} end - The end number of the range (exclusive).\n * @param {number} step - The step value for the range.\n * @returns {number[]} An array of numbers from `start` (inclusive) to `end` (exclusive) with the specified `step`.\n * @throws {Error} Throws an error if the step value is not a non-zero integer.\n *\n * @example\n * // Returns [0, 1, 2, 3]\n * range(4);\n *\n * @example\n * // Returns [0, -1, -2, -3]\n * range(0, -4, -1);\n */\nexport function range(start: number, end?: number, step: number = 1): number[] {\n if (end == null) {\n end = start;\n start = 0;\n }\n\n if (!Number.isInteger(step) || step === 0) {\n throw new Error(`The step value must be a non-zero integer.`);\n }\n\n const length = Math.max(Math.ceil((end - start) / step), 0);\n const result = new Array(length);\n\n for (let i = 0; i < length; i++) {\n result[i] = start + i * step;\n }\n\n return result;\n}\n","/**\n * Checks whether a value is a JavaScript primitive.\n * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.\n *\n * @param {unknown} value The value to check.\n * @returns {value is\n * null\n * | undefined\n * | string\n * | number\n * | boolean\n * | symbol\n * | bigint} Returns true if `value` is a primitive, false otherwise.\n *\n * @example\n * isPrimitive(null); // true\n * isPrimitive(undefined); // true\n * isPrimitive('123'); // true\n * isPrimitive(false); // true\n * isPrimitive(true); // true\n * isPrimitive(Symbol('a')); // true\n * isPrimitive(123n); // true\n * isPrimitive({}); // false\n * isPrimitive(new Date()); // false\n * isPrimitive(new Map()); // false\n * isPrimitive(new Set()); // false\n * isPrimitive([1, 2, 3]); // false\n */\nexport function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint {\n return value == null || (typeof value !== 'object' && typeof value !== 'function');\n}\n","/**\n * Checks if a value is a TypedArray.\n * @param {unknown} x The value to check.\n * @returns {x is\n * Uint8Array\n * | Uint8ClampedArray\n * | Uint16Array\n * | Uint32Array\n * | BigUint64Array\n * | Int8Array\n * | Int16Array\n * | Int32Array\n * | BigInt64Array\n * | Float32Array\n * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.\n *\n * @example\n * const arr = new Uint8Array([1, 2, 3]);\n * isTypedArray(arr); // true\n *\n * const regularArray = [1, 2, 3];\n * isTypedArray(regularArray); // false\n *\n * const buffer = new ArrayBuffer(16);\n * isTypedArray(buffer); // false\n */\nexport function isTypedArray(\n x: unknown\n): x is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return ArrayBuffer.isView(x) && !(x instanceof DataView);\n}\n","import { isPrimitive } from '../predicate/isPrimitive.ts';\nimport { isTypedArray } from '../predicate/isTypedArray.ts';\n\n/**\n * Creates a shallow clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A shallow clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n */\nexport function clone(obj: T): T {\n if (isPrimitive(obj)) {\n return obj;\n }\n\n if (\n Array.isArray(obj) ||\n isTypedArray(obj) ||\n obj instanceof ArrayBuffer ||\n (typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)\n ) {\n return obj.slice(0) as T;\n }\n\n const prototype = Object.getPrototypeOf(obj);\n const Constructor = prototype.constructor;\n\n if (obj instanceof Date || obj instanceof Map || obj instanceof Set) {\n return new Constructor(obj);\n }\n\n if (obj instanceof RegExp) {\n const newRegExp = new Constructor(obj);\n newRegExp.lastIndex = obj.lastIndex;\n\n return newRegExp;\n }\n\n if (obj instanceof DataView) {\n return new Constructor(obj.buffer.slice(0));\n }\n\n if (obj instanceof Error) {\n const newError = new Constructor(obj.message);\n\n newError.stack = obj.stack;\n newError.name = obj.name;\n newError.cause = obj.cause;\n\n return newError;\n }\n\n if (typeof File !== 'undefined' && obj instanceof File) {\n const newFile = new Constructor([obj], obj.name, { type: obj.type, lastModified: obj.lastModified });\n return newFile;\n }\n\n if (typeof obj === 'object') {\n const newObject = Object.create(prototype);\n return Object.assign(newObject, obj);\n }\n\n return obj;\n}\n","export function getSymbols(object: any) {\n return Object.getOwnPropertySymbols(object).filter(symbol =>\n Object.prototype.propertyIsEnumerable.call(object, symbol)\n );\n}\n","import { getSymbols } from '../compat/_internal/getSymbols.ts';\nimport { isPrimitive } from '../predicate/isPrimitive.ts';\nimport { isTypedArray } from '../predicate/isTypedArray.ts';\n\n/**\n * Creates a deep clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A deep clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n * @example\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n */\nexport function cloneDeep(obj: T): T {\n return cloneDeepImpl(obj);\n}\n\nfunction cloneDeepImpl(obj: T, stack = new Map()): T {\n if (isPrimitive(obj)) {\n return obj as T;\n }\n\n if (stack.has(obj)) {\n return stack.get(obj) as T;\n }\n\n if (Array.isArray(obj)) {\n const result: any = new Array(obj.length);\n stack.set(obj, result);\n\n for (let i = 0; i < obj.length; i++) {\n result[i] = cloneDeepImpl(obj[i], stack);\n }\n\n // For RegExpArrays\n if (Object.hasOwn(obj, 'index')) {\n // eslint-disable-next-line\n // @ts-ignore\n result.index = obj.index;\n }\n if (Object.hasOwn(obj, 'input')) {\n // eslint-disable-next-line\n // @ts-ignore\n result.input = obj.input;\n }\n\n return result as T;\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as T;\n }\n\n if (obj instanceof RegExp) {\n const result = new RegExp(obj.source, obj.flags);\n\n result.lastIndex = obj.lastIndex;\n\n return result as T;\n }\n\n if (obj instanceof Map) {\n const result = new Map();\n stack.set(obj, result);\n\n for (const [key, value] of obj) {\n result.set(key, cloneDeepImpl(value, stack));\n }\n\n return result as T;\n }\n\n if (obj instanceof Set) {\n const result = new Set();\n stack.set(obj, result);\n\n for (const value of obj) {\n result.add(cloneDeepImpl(value, stack));\n }\n\n return result as T;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (typeof Buffer !== 'undefined' && Buffer.isBuffer(obj)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return obj.subarray() as T;\n }\n\n if (isTypedArray(obj)) {\n const result = new (Object.getPrototypeOf(obj).constructor)(obj.length);\n stack.set(obj, result);\n\n for (let i = 0; i < obj.length; i++) {\n result[i] = cloneDeepImpl(obj[i], stack);\n }\n\n return result as T;\n }\n\n if (obj instanceof ArrayBuffer || (typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)) {\n return obj.slice(0) as T;\n }\n\n if (obj instanceof DataView) {\n const result = new DataView(obj.buffer.slice(0), obj.byteOffset, obj.byteLength);\n stack.set(obj, result);\n\n copyProperties(result, obj, stack);\n\n return result as T;\n }\n\n // For legacy NodeJS support\n if (typeof File !== 'undefined' && obj instanceof File) {\n const result = new File([obj], obj.name, { type: obj.type });\n stack.set(obj, result);\n\n copyProperties(result, obj, stack);\n\n return result as T;\n }\n\n if (obj instanceof Blob) {\n const result = new Blob([obj], { type: obj.type });\n stack.set(obj, result);\n\n copyProperties(result, obj, stack);\n\n return result as T;\n }\n\n if (obj instanceof Error) {\n const result = new (obj.constructor as { new (): Error })();\n stack.set(obj, result);\n\n result.message = obj.message;\n result.name = obj.name;\n result.stack = obj.stack;\n result.cause = obj.cause;\n\n copyProperties(result, obj, stack);\n\n return result as T;\n }\n\n if (typeof obj === 'object' && obj !== null) {\n const result = Object.create(Object.getPrototypeOf(obj));\n\n stack.set(obj, result);\n\n copyProperties(result, obj, stack);\n\n return result as T;\n }\n\n return obj;\n}\n\n// eslint-disable-next-line\nexport function copyProperties(target: any, source: any, stack?: Map): void {\n const keys = [...Object.keys(source), ...getSymbols(source)];\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const descriptor = Object.getOwnPropertyDescriptor(target, key);\n\n if (descriptor == null || descriptor.writable) {\n target[key] = cloneDeepImpl(source[key], stack);\n }\n }\n}\n","/**\n * Checks if a given value is a plain object.\n *\n * @param {object} value - The value to check.\n * @returns {value is Record} - True if the value is a plain object, otherwise false.\n *\n * @example\n * ```typescript\n * // ✅👇 True\n *\n * isPlainObject({ }); // ✅\n * isPlainObject({ key: 'value' }); // ✅\n * isPlainObject({ key: new Date() }); // ✅\n * isPlainObject(new Object()); // ✅\n * isPlainObject(Object.create(null)); // ✅\n * isPlainObject({ nested: { key: true} }); // ✅\n * isPlainObject(new Proxy({}, {})); // ✅\n * isPlainObject({ [Symbol('tag')]: 'A' }); // ✅\n *\n * // ✅👇 (cross-realms, node context, workers, ...)\n * const runInNewContext = await import('node:vm').then(\n * (mod) => mod.runInNewContext\n * );\n * isPlainObject(runInNewContext('({})')); // ✅\n *\n * // ❌👇 False\n *\n * class Test { };\n * isPlainObject(new Test()) // ❌\n * isPlainObject(10); // ❌\n * isPlainObject(null); // ❌\n * isPlainObject('hello'); // ❌\n * isPlainObject([]); // ❌\n * isPlainObject(new Date()); // ❌\n * isPlainObject(new Uint8Array([1])); // ❌\n * isPlainObject(Buffer.from('ABC')); // ❌\n * isPlainObject(Promise.resolve({})); // ❌\n * isPlainObject(Object.create({})); // ❌\n * isPlainObject(new (class Cls {})); // ❌\n * isPlainObject(globalThis); // ❌,\n * ```\n */\nexport function isPlainObject(value: unknown): value is Record {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n const proto = Object.getPrototypeOf(value) as typeof Object.prototype | null;\n\n const hasObjectPrototype =\n proto === null ||\n proto === Object.prototype ||\n // Required to support node:vm.runInNewContext({})\n Object.getPrototypeOf(proto) === null;\n\n if (!hasObjectPrototype) {\n return false;\n }\n\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n","import { isPlainObject } from '../predicate/isPlainObject.ts';\n\n/**\n * Flattens a nested object into a single level object with dot-separated keys.\n *\n * @param {object} object - The object to flatten.\n * @returns {Record} - The flattened object.\n *\n * @example\n * const nestedObject = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: [2, 3]\n * };\n *\n * const flattened = flattenObject(nestedObject);\n * console.log(flattened);\n * // Output:\n * // {\n * // 'a.b.c': 1,\n * // 'd.0': 2,\n * // 'd.1': 3\n * // }\n */\nexport function flattenObject(object: object): Record {\n return flattenObjectImpl(object);\n}\n\nfunction flattenObjectImpl(object: object, prefix = ''): Record {\n const result: Record = {};\n const keys = Object.keys(object);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = (object as any)[key];\n\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n\n if (isPlainObject(value) && Object.keys(value).length > 0) {\n Object.assign(result, flattenObjectImpl(value, prefixedKey));\n continue;\n }\n\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n result[`${prefixedKey}.${index}`] = value[index];\n }\n continue;\n }\n\n result[prefixedKey] = value;\n }\n\n return result;\n}\n","/**\n * Creates a new object with the same values as the given object, but with keys generated\n * by running each own enumerable property of the object through the iteratee function.\n *\n * @template T - The type of the object.\n * @template K - The type of the new keys generated by the iteratee function.\n *\n * @param {T} object - The object to iterate over.\n * @param {(value: T[keyof T], key: keyof T, object: T) => K} getNewKey - The function invoked per own enumerable property.\n * @returns {Record} - Returns the new mapped object.\n *\n * @example\n * // Example usage:\n * const obj = { a: 1, b: 2 };\n * const result = mapKeys(obj, (value, key) => key + value);\n * console.log(result); // { a1: 1, b2: 2 }\n */\nexport function mapKeys, K extends PropertyKey>(\n object: T,\n getNewKey: (value: T[keyof T], key: keyof T, object: T) => K\n): Record {\n const result = {} as Record;\n const keys = Object.keys(object) as Array;\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = object[key];\n\n result[getNewKey(value, key, object)] = value as any;\n }\n\n return result;\n}\n","/**\n * Creates a new object with the same keys as the given object, but with values generated\n * by running each own enumerable property of the object through the iteratee function.\n *\n * @template T - The type of the object.\n * @template K - The type of the keys in the object.\n * @template V - The type of the new values generated by the iteratee function.\n *\n * @param {T} object - The object to iterate over.\n * @param {(value: T[K], key: K, object: T) => V} getNewValue - The function invoked per own enumerable property.\n * @returns {Record} - Returns the new mapped object.\n *\n * @example\n * // Example usage:\n * const obj = { a: 1, b: 2 };\n * const result = mapValues(obj, (value) => value * 2);\n * console.log(result); // { a: 2, b: 4 }\n */\nexport function mapValues(\n object: T,\n getNewValue: (value: T[K], key: K, object: T) => V\n): Record {\n const result = {} as Record;\n const keys = Object.keys(object);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i] as K;\n const value = object[key];\n\n result[key] = getNewValue(value, key, object);\n }\n\n return result;\n}\n","import { isPlainObject } from '../predicate/isPlainObject.ts';\n\n/**\n * Merges the properties of the source object into the target object.\n *\n * This function performs a deep merge, meaning nested objects and arrays are merged recursively.\n * If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is undefined, it will not overwrite a defined property in the target object.\n *\n * Note that this function mutates the target object.\n *\n * @param {T} target - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S} source - The source object whose properties will be merged into the target object.\n * @returns {T & S} The updated target object with properties from the source object merged in.\n *\n * @template T - Type of the target object.\n * @template S - Type of the source object.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [3, 2], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [1, 2, 3] }\n */\nexport function merge, S extends Record>(\n target: T,\n source: S\n): T & S {\n const sourceKeys = Object.keys(source) as Array;\n\n for (let i = 0; i < sourceKeys.length; i++) {\n const key = sourceKeys[i];\n\n const sourceValue = source[key];\n const targetValue = target[key];\n\n if (Array.isArray(sourceValue)) {\n if (Array.isArray(targetValue)) {\n target[key] = merge(targetValue, sourceValue);\n } else {\n target[key] = merge([], sourceValue);\n }\n } else if (isPlainObject(sourceValue)) {\n if (isPlainObject(targetValue)) {\n target[key] = merge(targetValue, sourceValue);\n } else {\n target[key] = merge({}, sourceValue);\n }\n } else if (targetValue === undefined || sourceValue !== undefined) {\n target[key] = sourceValue;\n }\n }\n\n return target;\n}\n","/**\n * Checks if the given value is object-like.\n *\n * A value is object-like if its type is object and it is not null.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object-like value.\n *\n * @template T - The type of value.\n * @param {T} value - The value to test if it is an object-like.\n * @returns {value is object} `true` if the value is an object-like, `false` otherwise.\n *\n * @example\n * const value1 = { a: 1 };\n * const value2 = [1, 2, 3];\n * const value3 = 'abc';\n * const value4 = () => {};\n * const value5 = null;\n *\n * console.log(isObjectLike(value1)); // true\n * console.log(isObjectLike(value2)); // true\n * console.log(isObjectLike(value3)); // false\n * console.log(isObjectLike(value4)); // false\n * console.log(isObjectLike(value5)); // false\n */\n\nexport function isObjectLike(value: unknown): value is object {\n return typeof value === 'object' && value !== null;\n}\n","/**\n * Checks if the given value is a Blob.\n *\n * This function tests whether the provided value is an instance of `Blob`.\n * It returns `true` if the value is an instance of `Blob`, and `false` otherwise.\n *\n * @param {unknown} x - The value to test if it is a Blob.\n * @returns {x is Blob} True if the value is a Blob, false otherwise.\n *\n * @example\n * const value1 = new Blob();\n * const value2 = {};\n *\n * console.log(isBlob(value1)); // true\n * console.log(isBlob(value2)); // false\n */\nexport function isBlob(x: unknown): x is Blob {\n // Return false if Blob is not supported in the environment\n if (typeof Blob === 'undefined') {\n return false;\n }\n\n return x instanceof Blob;\n}\n","/**\n * Gets the `toStringTag` of `value`.\n *\n * @private\n * @param {T} value The value to query.\n * @returns {string} Returns the `Object.prototype.toString.call` result.\n */\nexport function getTag(value: T) {\n if (value == null) {\n return value === undefined ? '[object Undefined]' : '[object Null]';\n }\n return Object.prototype.toString.call(value);\n}\n","export const regexpTag = '[object RegExp]';\nexport const stringTag = '[object String]';\nexport const numberTag = '[object Number]';\nexport const booleanTag = '[object Boolean]';\nexport const argumentsTag = '[object Arguments]';\nexport const symbolTag = '[object Symbol]';\nexport const dateTag = '[object Date]';\nexport const mapTag = '[object Map]';\nexport const setTag = '[object Set]';\nexport const arrayTag = '[object Array]';\nexport const functionTag = '[object Function]';\nexport const arrayBufferTag = '[object ArrayBuffer]';\nexport const objectTag = '[object Object]';\nexport const errorTag = '[object Error]';\nexport const dataViewTag = '[object DataView]';\nexport const uint8ArrayTag = '[object Uint8Array]';\nexport const uint8ClampedArrayTag = '[object Uint8ClampedArray]';\nexport const uint16ArrayTag = '[object Uint16Array]';\nexport const uint32ArrayTag = '[object Uint32Array]';\nexport const bigUint64ArrayTag = '[object BigUint64Array]';\nexport const int8ArrayTag = '[object Int8Array]';\nexport const int16ArrayTag = '[object Int16Array]';\nexport const int32ArrayTag = '[object Int32Array]';\nexport const bigInt64ArrayTag = '[object BigInt64Array]';\nexport const float32ArrayTag = '[object Float32Array]';\nexport const float64ArrayTag = '[object Float64Array]';\n","/**\n * Performs a `SameValueZero` comparison between two values to determine if they are equivalent.\n *\n * @param {unknown} value - The value to compare.\n * @param {unknown} other - The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n *\n * @example\n * eq(1, 1); // true\n * eq(0, -0); // true\n * eq(NaN, NaN); // true\n * eq('a', Object('a')); // false\n */\nexport function eq(value?: unknown, other?: unknown): boolean {\n return value === other || (Number.isNaN(value) && Number.isNaN(other));\n}\n","import { isPlainObject } from './isPlainObject.ts';\nimport { getSymbols } from '../compat/_internal/getSymbols.ts';\nimport { getTag } from '../compat/_internal/getTag.ts';\nimport {\n argumentsTag,\n arrayBufferTag,\n arrayTag,\n bigInt64ArrayTag,\n bigUint64ArrayTag,\n booleanTag,\n dataViewTag,\n dateTag,\n errorTag,\n float32ArrayTag,\n float64ArrayTag,\n functionTag,\n int8ArrayTag,\n int16ArrayTag,\n int32ArrayTag,\n mapTag,\n numberTag,\n objectTag,\n regexpTag,\n setTag,\n stringTag,\n symbolTag,\n uint8ArrayTag,\n uint8ClampedArrayTag,\n uint16ArrayTag,\n uint32ArrayTag,\n} from '../compat/_internal/tags.ts';\nimport { eq } from '../compat/util/eq.ts';\n\ndeclare let Buffer:\n | {\n isBuffer: (a: any) => boolean;\n }\n | undefined;\n\n/**\n * Compares two values for equality using a custom comparison function.\n *\n * The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.\n *\n * This function also uses the custom equality function to compare values inside objects,\n * arrays, maps, sets, and other complex structures, ensuring a deep comparison.\n *\n * This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.\n *\n * The custom comparison function can take up to six parameters:\n * - `x`: The value from the first object `a`.\n * - `y`: The value from the second object `b`.\n * - `property`: The property key used to get `x` and `y`.\n * - `xParent`: The parent of the first value `x`.\n * - `yParent`: The parent of the second value `y`.\n * - `stack`: An internal stack (Map) to handle circular references.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @param {(x: any, y: any, property?: PropertyKey, xParent?: any, yParent?: any, stack?: Map) => boolean | void} areValuesEqual - A function to customize the comparison.\n * If it returns a boolean, that result will be used. If it returns undefined,\n * the default equality comparison will be used.\n * @returns {boolean} `true` if the values are equal according to the customizer, otherwise `false`.\n *\n * @example\n * const customizer = (a, b) => {\n * if (typeof a === 'string' && typeof b === 'string') {\n * return a.toLowerCase() === b.toLowerCase();\n * }\n * };\n * isEqualWith('Hello', 'hello', customizer); // true\n * isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true\n * isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true\n */\nexport function isEqualWith(\n a: any,\n b: any,\n areValuesEqual: (\n x: any,\n y: any,\n property?: PropertyKey,\n xParent?: any,\n yParent?: any,\n stack?: Map\n ) => boolean | void\n): boolean {\n return isEqualWithImpl(a, b, undefined, undefined, undefined, undefined, areValuesEqual);\n}\n\nfunction isEqualWithImpl(\n a: any,\n b: any,\n property: PropertyKey | undefined,\n aParent: any,\n bParent: any,\n stack: Map | undefined,\n areValuesEqual: (\n x: any,\n y: any,\n property?: PropertyKey,\n xParent?: any,\n yParent?: any,\n stack?: Map\n ) => boolean | void\n): boolean {\n const result = areValuesEqual(a, b, property, aParent, bParent, stack);\n\n if (result !== undefined) {\n return result;\n }\n\n if (typeof a === typeof b) {\n switch (typeof a) {\n case 'bigint':\n case 'string':\n case 'boolean':\n case 'symbol':\n case 'undefined': {\n return a === b;\n }\n case 'number': {\n return a === b || Object.is(a, b);\n }\n case 'function': {\n return a === b;\n }\n case 'object': {\n return areObjectsEqual(a, b, stack, areValuesEqual);\n }\n }\n }\n\n return areObjectsEqual(a, b, stack, areValuesEqual);\n}\n\nfunction areObjectsEqual(\n a: any,\n b: any,\n stack: Map | undefined,\n areValuesEqual: (\n x: any,\n y: any,\n property?: PropertyKey,\n xParent?: any,\n yParent?: any,\n stack?: Map\n ) => boolean | void\n) {\n if (Object.is(a, b)) {\n return true;\n }\n\n let aTag = getTag(a);\n let bTag = getTag(b);\n\n if (aTag === argumentsTag) {\n aTag = objectTag;\n }\n\n if (bTag === argumentsTag) {\n bTag = objectTag;\n }\n\n if (aTag !== bTag) {\n return false;\n }\n\n switch (aTag) {\n case stringTag:\n return a.toString() === b.toString();\n\n case numberTag: {\n const x = a.valueOf();\n const y = b.valueOf();\n\n return eq(x, y);\n }\n\n case booleanTag:\n case dateTag:\n case symbolTag:\n return Object.is(a.valueOf(), b.valueOf());\n\n case regexpTag: {\n return a.source === b.source && a.flags === b.flags;\n }\n\n case functionTag: {\n return a === b;\n }\n }\n\n stack = stack ?? new Map();\n\n const aStack = stack.get(a);\n const bStack = stack.get(b);\n\n if (aStack != null && bStack != null) {\n return aStack === b;\n }\n\n stack.set(a, b);\n stack.set(b, a);\n\n try {\n switch (aTag) {\n case mapTag: {\n if (a.size !== b.size) {\n return false;\n }\n\n for (const [key, value] of a.entries()) {\n if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) {\n return false;\n }\n }\n\n return true;\n }\n\n case setTag: {\n if (a.size !== b.size) {\n return false;\n }\n\n const aValues = Array.from(a.values());\n const bValues = Array.from(b.values());\n\n for (let i = 0; i < aValues.length; i++) {\n const aValue = aValues[i];\n const index = bValues.findIndex(bValue => {\n return isEqualWithImpl(aValue, bValue, undefined, a, b, stack, areValuesEqual);\n });\n\n if (index === -1) {\n return false;\n }\n\n bValues.splice(index, 1);\n }\n\n return true;\n }\n\n case arrayTag:\n case uint8ArrayTag:\n case uint8ClampedArrayTag:\n case uint16ArrayTag:\n case uint32ArrayTag:\n case bigUint64ArrayTag:\n case int8ArrayTag:\n case int16ArrayTag:\n case int32ArrayTag:\n case bigInt64ArrayTag:\n case float32ArrayTag:\n case float64ArrayTag: {\n // Buffers are also treated as [object Uint8Array]s.\n if (typeof Buffer !== 'undefined' && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {\n return false;\n }\n\n if (a.length !== b.length) {\n return false;\n }\n\n for (let i = 0; i < a.length; i++) {\n if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) {\n return false;\n }\n }\n\n return true;\n }\n\n case arrayBufferTag: {\n if (a.byteLength !== b.byteLength) {\n return false;\n }\n\n return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);\n }\n\n case dataViewTag: {\n if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {\n return false;\n }\n\n return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);\n }\n\n case errorTag: {\n return a.name === b.name && a.message === b.message;\n }\n\n case objectTag: {\n const areEqualInstances =\n areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) ||\n (isPlainObject(a) && isPlainObject(b));\n\n if (!areEqualInstances) {\n return false;\n }\n\n const aKeys = [...Object.keys(a), ...getSymbols(a)];\n const bKeys = [...Object.keys(b), ...getSymbols(b)];\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const propKey = aKeys[i];\n const aProp = (a as any)[propKey];\n\n if (!Object.hasOwn(b, propKey)) {\n return false;\n }\n\n const bProp = (b as any)[propKey];\n\n if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) {\n return false;\n }\n }\n\n return true;\n }\n default: {\n return false;\n }\n }\n } finally {\n stack.delete(a);\n stack.delete(b);\n }\n}\n","/**\n * The functions isJSONValue, isJSONArray, and isJSONObject are grouped in this file\n * to prevent any circular dependency issues.\n */\nimport { isPlainObject } from './isPlainObject.ts';\n\n/**\n * Checks if a given value is a valid JSON value.\n *\n * A valid JSON value can be:\n * - null\n * - a JSON object (an object with string keys and valid JSON values)\n * - a JSON array (an array of valid JSON values)\n * - a string\n * - a number\n * - a boolean\n *\n * @param {unknown} value - The value to check.\n * @returns {boolean} - True if the value is a valid JSON value, otherwise false.\n *\n * @example\n * console.log(isJSONValue(null)); // true\n * console.log(isJSONValue({ key: \"value\" })); // true\n * console.log(isJSONValue([1, 2, 3])); // true\n * console.log(isJSONValue(\"Hello\")); // true\n * console.log(isJSONValue(42)); // true\n * console.log(isJSONValue(true)); // true\n * console.log(isJSONValue(undefined)); // false\n * console.log(isJSONValue(() => {})); // false\n */\nexport function isJSONValue(value: unknown): value is Record | any[] | string | number | boolean | null {\n switch (typeof value) {\n case 'object': {\n return value === null || isJSONArray(value) || isJSONObject(value);\n }\n case 'string':\n case 'number':\n case 'boolean': {\n return true;\n }\n default: {\n return false;\n }\n }\n}\n\n/**\n * Checks if a given value is a valid JSON array.\n *\n * A valid JSON array is defined as an array where all items are valid JSON values.\n *\n * @param {unknown} value - The value to check.\n * @returns {value is any[]} - True if the value is a valid JSON array, otherwise false.\n *\n * @example\n * console.log(isJSONArray([1, 2, 3])); // true\n * console.log(isJSONArray([\"string\", null, true])); // true\n * console.log(isJSONArray([1, 2, () => {}])); // false\n * console.log(isJSONArray(\"not an array\")); // false\n */\nexport function isJSONArray(value: unknown): value is any[] {\n if (!Array.isArray(value)) {\n return false;\n }\n\n return value.every(item => isJSONValue(item));\n}\n\n/**\n * Checks if a value is a JSON object.\n *\n * A valid JSON object is defined as an object with string keys and valid JSON values.\n *\n * @param {unknown} obj The value to check.\n * @returns {obj is Record} True if `obj` is a JSON object, false otherwise.\n *\n * @example\n * isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true\n * isJSONObject({ regexp: /test/ }); // false\n * isJSONObject(123); // false\n */\nexport function isJSONObject(obj: unknown): obj is Record {\n if (!isPlainObject(obj)) {\n return false;\n }\n\n const keys = Reflect.ownKeys(obj);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = obj[key];\n\n if (typeof key !== 'string') {\n return false;\n }\n\n if (!isJSONValue(value)) {\n return false;\n }\n }\n\n return true;\n}\n","/**\n * Checks if a given value is a valid length.\n *\n * A valid length is of type `number`, is a non-negative integer, and is less than or equal to\n * JavaScript's maximum safe integer (`Number.MAX_SAFE_INTEGER`).\n * It returns `true` if the value is a valid length, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the\n * argument to a valid length (`number`).\n *\n * @param {unknown} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n *\n * @example\n * isLength(0); // true\n * isLength(42); // true\n * isLength(-1); // false\n * isLength(1.5); // false\n * isLength(Number.MAX_SAFE_INTEGER); // true\n * isLength(Number.MAX_SAFE_INTEGER + 1); // false\n */\nexport function isLength(value: unknown): value is number {\n return Number.isSafeInteger(value) && (value as number) >= 0;\n}\n","/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x: unknown): x is null | undefined {\n return x == null;\n}\n","import { AbortError } from '../error/AbortError.ts';\n\ninterface DelayOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @param {DelayOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.\n * @returns {Promise} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const { signal } = controller;\n *\n * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms\n * try {\n * await delay(100, { signal });\n * } catch (error) {\n * console.error(error); // Will log 'AbortError'\n * }\n * }\n */\nexport function delay(ms: number, { signal }: DelayOptions = {}): Promise {\n return new Promise((resolve, reject) => {\n const abortError = () => {\n reject(new AbortError());\n };\n\n const abortHandler = () => {\n clearTimeout(timeoutId);\n abortError();\n };\n\n if (signal?.aborted) {\n return abortError();\n }\n\n const timeoutId = setTimeout(() => {\n signal?.removeEventListener('abort', abortHandler);\n resolve();\n }, ms);\n\n signal?.addEventListener('abort', abortHandler, { once: true });\n });\n}\n","import { delay } from './delay.ts';\nimport { TimeoutError } from '../error/TimeoutError.ts';\n\n/**\n * Returns a promise that rejects with a `TimeoutError` after a specified delay.\n *\n * @param {number} ms - The delay duration in milliseconds.\n * @returns {Promise} A promise that rejects with a `TimeoutError` after the specified delay.\n * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay.\n *\n * @example\n * try {\n * await timeout(1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'The operation was timed out'\n * }\n */\nexport async function timeout(ms: number): Promise {\n await delay(ms);\n throw new TimeoutError();\n}\n","/**\n * Converts the first character of string to upper case and the remaining to lower case.\n *\n * @template T - Literal type of the string.\n * @param {T} str - The string to be converted to uppercase.\n * @returns {Capitalize} - The capitalized string.\n *\n * @example\n * const result = capitalize('fred') // returns 'Fred'\n * const result2 = capitalize('FRED') // returns 'Fred'\n */\n\nexport function capitalize(str: T): Capitalize {\n return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize;\n}\n\ntype Capitalize = T extends `${infer F}${infer R}` ? `${Uppercase}${Lowercase}` : T;\n","/**\n * Regular expression pattern to split strings into words for various case conversions\n *\n * This pattern matches sequences of characters in a string, considering the following cases:\n * - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n * - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n * - Single uppercase letters\n * - Sequences of digits\n * - Emojis and other Unicode characters\n *\n * The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n * a consistent format like snake case. It also supports emojis and other Unicode characters.\n *\n * @example\n * const matches = 'camelCaseHTTPRequest🚀'.match(CASE_SPLIT_PATTERN);\n * // matches: ['camel', 'Case', 'HTTP', 'Request', '🚀']\n */\nexport const CASE_SPLIT_PATTERN =\n /\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+/gu;\n\n/**\n * Splits `string` into an array of its words, treating spaces and punctuation marks as separators.\n *\n * @param {string} str The string to inspect.\n * @param {RegExp | string} [pattern] The pattern to match words.\n * @returns {string[]} Returns the words of `string`.\n *\n * @example\n * words('fred, barney, & pebbles');\n * // => ['fred', 'barney', 'pebbles']\n *\n * words('camelCaseHTTPRequest🚀');\n * // => ['camel', 'Case', 'HTTP', 'Request', '🚀']\n *\n * words('Lunedì 18 Set')\n * // => ['Lunedì', '18', 'Set']\n */\nexport function words(str: string): string[] {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n","const deburrMap = new Map(\n // eslint-disable-next-line no-restricted-syntax\n Object.entries({\n Æ: 'Ae',\n Ð: 'D',\n Ø: 'O',\n Þ: 'Th',\n ß: 'ss',\n æ: 'ae',\n ð: 'd',\n ø: 'o',\n þ: 'th',\n Đ: 'D',\n đ: 'd',\n Ħ: 'H',\n ħ: 'h',\n ı: 'i',\n IJ: 'IJ',\n ij: 'ij',\n ĸ: 'k',\n Ŀ: 'L',\n ŀ: 'l',\n Ł: 'L',\n ł: 'l',\n ʼn: \"'n\",\n Ŋ: 'N',\n ŋ: 'n',\n Œ: 'Oe',\n œ: 'oe',\n Ŧ: 'T',\n ŧ: 't',\n ſ: 's',\n })\n);\n\n/**\n * Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.\n * For example, \"Crème brûlée\" becomes \"Creme brulee\".\n *\n * @param {string} str - The input string to be deburred.\n * @returns {string} - The deburred string with special characters replaced by their ASCII equivalents.\n *\n * @example\n * // Basic usage:\n * deburr('Æthelred') // returns 'Aethelred'\n *\n * @example\n * // Handling diacritical marks:\n * deburr('München') // returns 'Munchen'\n *\n * @example\n * // Special characters:\n * deburr('Crème brûlée') // returns 'Creme brulee'\n */\nexport function deburr(str: string): string {\n str = str.normalize('NFD');\n\n let result = '';\n\n for (let i = 0; i < str.length; i++) {\n const char = str[i];\n\n if ((char >= '\\u0300' && char <= '\\u036f') || (char >= '\\ufe20' && char <= '\\ufe23')) {\n continue;\n }\n\n result += deburrMap.get(char) ?? char;\n }\n\n return result;\n}\n","const htmlEscapes: Record = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": ''',\n};\n\n/**\n * Converts the characters \"&\", \"<\", \">\", '\"', and \"'\" in `str` to their corresponding HTML entities.\n * For example, \"<\" becomes \"<\".\n *\n * @param {string} str The string to escape.\n * @returns {string} Returns the escaped string.\n *\n * @example\n * escape('This is a
element.'); // returns 'This is a <div> element.'\n * escape('This is a \"quote\"'); // returns 'This is a "quote"'\n * escape(\"This is a 'quote'\"); // returns 'This is a 'quote''\n * escape('This is a & symbol'); // returns 'This is a & symbol'\n */\nexport function escape(str: string): string {\n return str.replace(/[&<>\"']/g, match => htmlEscapes[match]);\n}\n","/**\n * Removes trailing whitespace or specified characters from a string.\n *\n * @param {string} str - The string from which trailing characters will be trimmed.\n * @param {string | string[]} chars - The character(s) to remove from the end of the string.\n * @returns {string} - The resulting string after the specified trailing character has been removed.\n *\n * @example\n * const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello'\n * const trimmedStr2 = trimEnd('123000', '0') // returns '123'\n * const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab'\n * const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'\n */\nexport function trimEnd(str: string, chars?: string | string[]): string {\n if (chars === undefined) {\n return str.trimEnd();\n }\n\n let endIndex = str.length;\n\n switch (typeof chars) {\n case 'string': {\n while (endIndex > 0 && str[endIndex - 1] === chars) {\n endIndex--;\n }\n break;\n }\n case 'object': {\n while (endIndex > 0 && chars.includes(str[endIndex - 1])) {\n endIndex--;\n }\n }\n }\n\n return str.substring(0, endIndex);\n}\n","/**\n * Removes leading whitespace or specified characters from a string.\n *\n * @param {string} str - The string from which leading characters will be trimmed.\n * @param {string | string[]} chars - The character(s) to remove from the start of the string.\n * @returns {string} - The resulting string after the specified leading character has been removed.\n *\n * @example\n * const trimmedStr1 = trimStart('---hello', '-') // returns 'hello'\n * const trimmedStr2 = trimStart('000123', '0') // returns '123'\n * const trimmedStr3 = trimStart('abcabcabc', 'a') // returns 'bcabcabc'\n * const trimmedStr4 = trimStart('xxxtrimmed', 'x') // returns 'trimmed'\n */\nexport function trimStart(str: string, chars?: string | string[]): string {\n if (chars === undefined) {\n return str.trimStart();\n }\n let startIndex = 0;\n\n switch (typeof chars) {\n case 'string': {\n while (startIndex < str.length && str[startIndex] === chars) {\n startIndex++;\n }\n break;\n }\n case 'object': {\n while (startIndex < str.length && chars.includes(str[startIndex])) {\n startIndex++;\n }\n }\n }\n\n return str.substring(startIndex);\n}\n","import { trimEnd } from './trimEnd.ts';\nimport { trimStart } from './trimStart.ts';\n\n/**\n * Removes leading and trailing whitespace or specified characters from a string.\n *\n * @param {string} str - The string from which characters will be trimmed.\n * @param {string | string[]} chars - The character(s) to remove from the string. Can be a single character or an array of characters.\n * @returns {string} - The resulting string after the specified characters have been removed.\n *\n * @example\n * trim(\" hello \"); // \"hello\"\n * trim(\"--hello--\", \"-\"); // \"hello\"\n * trim(\"##hello##\", [\"#\", \"o\"]); // \"hell\"\n */\nexport function trim(str: string, chars?: string | string[]): string {\n if (chars === undefined) {\n return str.trim();\n }\n\n return trimStart(trimEnd(str, chars), chars);\n}\n","const htmlUnescapes: Record = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\",\n};\n\n/**\n * Converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `str` to their corresponding characters.\n * It is the inverse of `escape`.\n *\n * @param {string} str The string to unescape.\n * @returns {string} Returns the unescaped string.\n *\n * @example\n * unescape('This is a <div> element.'); // returns 'This is a
element.'\n * unescape('This is a "quote"'); // returns 'This is a \"quote\"'\n * unescape('This is a 'quote''); // returns 'This is a 'quote''\n * unescape('This is a & symbol'); // returns 'This is a & symbol'\n */\nexport function unescape(str: string): string {\n return str.replace(/&(?:amp|lt|gt|quot|#(0+)?39);/g, match => htmlUnescapes[match] || \"'\");\n}\n","export function toArray(value: ArrayLike): T[] {\n return Array.isArray(value) ? value : Array.from(value);\n}\n","import { isLength } from '../../predicate/isLength.ts';\n\n/**\n * Checks if `value` is array-like.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike} Returns `true` if `value` is array-like, else `false`.\n *\n * @example\n * isArrayLike([1, 2, 3]); // true\n * isArrayLike('abc'); // true\n * isArrayLike({ 0: 'a', length: 1 }); // true\n * isArrayLike({}); // false\n * isArrayLike(null); // false\n * isArrayLike(undefined); // false\n */\nexport function isArrayLike(value: unknown): value is ArrayLike {\n return value != null && typeof value !== 'function' && isLength((value as ArrayLike).length);\n}\n","import { isArrayLike } from './isArrayLike.ts';\nimport { isObjectLike } from './isObjectLike.ts';\n\n/**\n * Checks if the given value is a non-primitive, array-like object.\n *\n * @param {unknown} value The value to check.\n * @returns {value is ArrayLike & object} `true` if the value is a non-primitive, array-like object, `false` otherwise.\n *\n * @example\n * isArrayLikeObject([1, 2, 3]); // true\n * isArrayLikeObject({ 0: 'a', length: 1 }); // true\n * isArrayLikeObject('abc'); // false\n * isArrayLikeObject(()=>{}); // false\n */\nexport function isArrayLikeObject(value: unknown): value is ArrayLike & object {\n return isObjectLike(value) && isArrayLike(value);\n}\n","import { last as lastToolkit } from '../../array/last.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Returns the last element of an array.\n *\n * This function takes an array and returns the last element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * Unlike some implementations, this function is optimized for performance\n * by directly accessing the last index of the array.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to get the last element.\n * @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const lastElement = last(arr);\n * // lastElement will be 3\n *\n * const emptyArr: number[] = [];\n * const noElement = last(emptyArr);\n * // noElement will be undefined\n */\nexport function last(array: ArrayLike | null | undefined): T | undefined {\n if (!isArrayLike(array)) {\n return undefined;\n }\n return lastToolkit(toArray(array));\n}\n","/**\n * Checks if a given key is a deep key.\n *\n * A deep key is a string that contains a dot (.) or square brackets with a property accessor.\n *\n * @param {PropertyKey} key - The key to check.\n * @returns {boolean} - Returns true if the key is a deep key, otherwise false.\n *\n * Examples:\n *\n * isDeepKey('a.b') // true\n * isDeepKey('a[b]') // true\n * isDeepKey('a') // false\n * isDeepKey(123) // false\n * isDeepKey('a.b.c') // true\n * isDeepKey('a[b][c]') // true\n */\nexport function isDeepKey(key: PropertyKey): boolean {\n switch (typeof key) {\n case 'number':\n case 'symbol': {\n return false;\n }\n case 'string': {\n return key.includes('.') || key.includes('[') || key.includes(']');\n }\n }\n}\n","/**\n * Converts `value` to a string key if it's not a string or symbol.\n *\n * @private\n * @param {*} value The value to inspect.\n * @returns {string|symbol} Returns the key.\n */\nexport function toKey(value: number) {\n if (Object.is(value, -0)) {\n return '-0';\n }\n return value.toString();\n}\n","/**\n * Converts a deep key string into an array of path segments.\n *\n * This function takes a string representing a deep key (e.g., 'a.b.c' or 'a[b][c]') and breaks it down into an array of strings, each representing a segment of the path.\n *\n * @param {string} deepKey - The deep key string to convert.\n * @returns {string[]} An array of strings, each representing a segment of the path.\n *\n * Examples:\n *\n * toPath('a.b.c') // Returns ['a', 'b', 'c']\n * toPath('a[b][c]') // Returns ['a', 'b', 'c']\n * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c']\n * toPath('a[\"b.c\"].d') // Returns ['a', 'b.c', 'd']\n * toPath('') // Returns []\n * toPath('.a[b].c.d[e][\"f.g\"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h']\n */\nexport function toPath(deepKey: string): string[] {\n const result: string[] = [];\n const length = deepKey.length;\n\n if (length === 0) {\n return result;\n }\n\n let index = 0;\n let key = '';\n let quoteChar = '';\n let bracket = false;\n\n // Leading dot\n if (deepKey.charCodeAt(0) === 46) {\n result.push('');\n index++;\n }\n\n while (index < length) {\n const char = deepKey[index];\n\n if (quoteChar) {\n if (char === '\\\\' && index + 1 < length) {\n // Escape character\n index++;\n key += deepKey[index];\n } else if (char === quoteChar) {\n // End of quote\n quoteChar = '';\n } else {\n key += char;\n }\n } else if (bracket) {\n if (char === '\"' || char === \"'\") {\n // Start of quoted string inside brackets\n quoteChar = char;\n } else if (char === ']') {\n // End of bracketed segment\n bracket = false;\n result.push(key);\n key = '';\n } else {\n key += char;\n }\n } else {\n if (char === '[') {\n // Start of bracketed segment\n bracket = true;\n if (key) {\n result.push(key);\n key = '';\n }\n } else if (char === '.') {\n if (key) {\n result.push(key);\n key = '';\n }\n } else {\n key += char;\n }\n }\n\n index++;\n }\n\n if (key) {\n result.push(key);\n }\n\n return result;\n}\n","import type { Get } from './get.types.ts';\nimport { isDeepKey } from '../_internal/isDeepKey.ts';\nimport { toKey } from '../_internal/toKey.ts';\nimport { toPath } from '../util/toPath.ts';\n\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n *\n * @param {T} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K]} - Returns the resolved value.\n */\nexport function get(object: T, path: K | readonly [K]): T[K];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @returns {T[K] | undefined} - Returns the resolved value.\n */\nexport function get(\n object: T | null | undefined,\n path: K | readonly [K]\n): T[K] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K - The type of the key in the object.\n * @template D - The type of the default value.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {K | [K]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude | D} - Returns the resolved value.\n */\nexport function get(\n object: T | null | undefined,\n path: K | readonly [K],\n defaultValue: D\n): Exclude | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n *\n * @param {T} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2]} - Returns the resolved value.\n */\nexport function get(\n object: T,\n path: readonly [K1, K2]\n): T[K1][K2];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @returns {T[K1][K2] | undefined} - Returns the resolved value.\n */\nexport function get(\n object: T | null | undefined,\n path: readonly [K1, K2]\n): T[K1][K2] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template D - The type of the default value.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude | D} - Returns the resolved value.\n */\nexport function get(\n object: T | null | undefined,\n path: readonly [K1, K2],\n defaultValue: D\n): Exclude | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n *\n * @param {T} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3]} - Returns the resolved value.\n */\nexport function get(\n object: T,\n path: readonly [K1, K2, K3]\n): T[K1][K2][K3];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.\n */\nexport function get(\n object: T | null | undefined,\n path: readonly [K1, K2, K3]\n): T[K1][K2][K3] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template D - The type of the default value.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude | D} - Returns the resolved value.\n */\nexport function get(\n object: T | null | undefined,\n path: readonly [K1, K2, K3],\n defaultValue: D\n): Exclude | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n *\n * @param {T} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4]} - Returns the resolved value.\n */\nexport function get<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3],\n>(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4];\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.\n */\nexport function get<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3],\n>(object: T | null | undefined, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the first key in the object.\n * @template K2 - The type of the second key in the object.\n * @template K3 - The type of the third key in the object.\n * @template K4 - The type of the fourth key in the object.\n * @template D - The type of the default value.\n *\n * @param {T | null | undefined} object - The object to query.\n * @param {[K1, K2, K3, K4]} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude | D} - Returns the resolved value.\n */\nexport function get<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T[K1],\n K3 extends keyof T[K1][K2],\n K4 extends keyof T[K1][K2][K3],\n D,\n>(\n object: T | null | undefined,\n path: readonly [K1, K2, K3, K4],\n defaultValue: D\n): Exclude | D;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the value.\n *\n * @param {Record} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T} - Returns the resolved value.\n */\nexport function get(object: Record, path: number): T;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the value.\n *\n * @param {Record | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @returns {T | undefined} - Returns the resolved value.\n */\nexport function get(object: Record | null | undefined, path: number): T | undefined;\n/**\n * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the value.\n * @template D - The type of the default value.\n *\n * @param {Record | null | undefined} object - The object to query.\n * @param {number} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {T | D} - Returns the resolved value.\n */\nexport function get(object: Record | null | undefined, path: number, defaultValue: D): T | D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning the default value.\n *\n * @template D - The type of the default value.\n *\n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {D} - Returns the default value.\n */\nexport function get(object: null | undefined, path: PropertyKey, defaultValue: D): D;\n/**\n * Retrieves the value at a given path from a null or undefined object, returning undefined.\n *\n * @param {null | undefined} object - The object to query.\n * @param {PropertyKey} path - The path of the property to get.\n * @returns {undefined} - Returns undefined.\n */\nexport function get(object: null | undefined, path: PropertyKey): undefined;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template P - The type of the path.\n *\n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @returns {string extends P ? any : Get} - Returns the resolved value.\n */\nexport function get(data: T, path: P): string extends P ? any : Get;\n/**\n * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @template T - The type of the object.\n * @template P - The type of the path.\n * @template D - The type of the default value.\n *\n * @param {T} data - The object to query.\n * @param {P} path - The path of the property to get.\n * @param {D} defaultValue - The value returned if the resolved value is undefined.\n * @returns {Exclude, null | undefined> | D} - Returns the resolved value.\n */\nexport function get>(\n data: T,\n path: P,\n defaultValue: D\n): Exclude, null | undefined> | D;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param {unknown} object - The object to query.\n * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.\n * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.\n * @returns {any} - Returns the resolved value.\n */\nexport function get(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;\n/**\n * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.\n *\n * @param {unknown} object - The object to query.\n * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.\n * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.\n * @returns {any} - Returns the resolved value.\n */\nexport function get(object: any, path: PropertyKey | readonly PropertyKey[], defaultValue?: any): any {\n if (object == null) {\n return defaultValue;\n }\n\n switch (typeof path) {\n case 'string': {\n const result = object[path];\n\n if (result === undefined) {\n if (isDeepKey(path)) {\n return get(object, toPath(path), defaultValue);\n } else {\n return defaultValue;\n }\n }\n\n return result;\n }\n case 'number':\n case 'symbol': {\n if (typeof path === 'number') {\n path = toKey(path);\n }\n\n const result = object[path];\n\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n default: {\n if (Array.isArray(path)) {\n return getWithPath(object, path, defaultValue);\n }\n\n if (Object.is(path?.valueOf(), -0)) {\n path = '-0';\n } else {\n path = String(path);\n }\n\n const result = object[path];\n\n if (result === undefined) {\n return defaultValue;\n }\n\n return result;\n }\n }\n}\n\nfunction getWithPath(object: any, path: readonly PropertyKey[], defaultValue?: any): any {\n if (path.length === 0) {\n return defaultValue;\n }\n\n let current = object;\n\n for (let index = 0; index < path.length; index++) {\n if (current == null) {\n return defaultValue;\n }\n\n current = current[path[index]];\n }\n\n if (current === undefined) {\n return defaultValue;\n }\n\n return current;\n}\n","import { get } from './get.ts';\n\n/**\n * Creates a function that returns the value at a given path of an object.\n *\n * @param {PropertyKey | PropertyKey[]} path - The path of the property to get.\n * @returns {(object: unknown) => any} - Returns a new function that takes an object and returns the value at the specified path.\n *\n * @example\n * const getObjectValue = property('a.b.c');\n * const result = getObjectValue({ a: { b: { c: 3 } } });\n * console.log(result); // => 3\n *\n * @example\n * const getObjectValue = property(['a', 'b', 'c']);\n * const result = getObjectValue({ a: { b: { c: 3 } } });\n * console.log(result); // => 3\n */\nexport function property(path: PropertyKey | readonly PropertyKey[]): (object: unknown) => any {\n return function (object: unknown) {\n return get(object, path);\n };\n}\n","/**\n * Checks if the given value is an object. An object is a value that is\n * not a primitive type (string, number, boolean, symbol, null, or undefined).\n *\n * This function tests whether the provided value is an object or not.\n * It returns `true` if the value is an object, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an object value.\n *\n * @param {unknown} value - The value to check if it is an object.\n * @returns {value is object} `true` if the value is an object, `false` otherwise.\n *\n * @example\n * const value1 = {};\n * const value2 = [1, 2, 3];\n * const value3 = () => {};\n * const value4 = null;\n *\n * console.log(isObject(value1)); // true\n * console.log(isObject(value2)); // true\n * console.log(isObject(value3)); // true\n * console.log(isObject(value4)); // false\n */\n\nexport function isObject(value: unknown): value is object {\n return value !== null && (typeof value === 'object' || typeof value === 'function');\n}\n","import { isObject } from './isObject.ts';\nimport { isPrimitive } from '../../predicate/isPrimitive.ts';\nimport { eq } from '../util/eq.ts';\n\n/**\n * Checks if the target matches the source by comparing their structures and values.\n * This function supports deep comparison for objects, arrays, maps, and sets.\n *\n * @param {unknown} target - The target value to match against.\n * @param {unknown} source - The source value to match with.\n * @returns {boolean} - Returns `true` if the target matches the source, otherwise `false`.\n *\n * @example\n * // Basic usage\n * isMatch({ a: 1, b: 2 }, { a: 1 }); // true\n *\n * @example\n * // Matching arrays\n * isMatch([1, 2, 3], [1, 2, 3]); // true\n *\n * @example\n * // Matching maps\n * const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);\n * const sourceMap = new Map([['key1', 'value1']]);\n * isMatch(targetMap, sourceMap); // true\n *\n * @example\n * // Matching sets\n * const targetSet = new Set([1, 2, 3]);\n * const sourceSet = new Set([1, 2]);\n * isMatch(targetSet, sourceSet); // true\n */\nexport function isMatch(target: unknown, source: unknown): boolean;\n/**\n * Checks if the target matches the source by comparing their structures and values.\n * This function supports deep comparison for objects, arrays, maps, and sets.\n *\n * @param {unknown} target - The target value to match against.\n * @param {unknown} source - The source value to match with.\n * @returns {boolean} - Returns `true` if the target matches the source, otherwise `false`.\n *\n * @example\n * // Basic usage\n * isMatch({ a: 1, b: 2 }, { a: 1 }); // true\n *\n * @example\n * // Matching arrays\n * isMatch([1, 2, 3], [1, 2, 3]); // true\n *\n * @example\n * // Matching maps\n * const targetMap = new Map([['key1', 'value1'], ['key2', 'value2']]);\n * const sourceMap = new Map([['key1', 'value1']]);\n * isMatch(targetMap, sourceMap); // true\n *\n * @example\n * // Matching sets\n * const targetSet = new Set([1, 2, 3]);\n * const sourceSet = new Set([1, 2]);\n * isMatch(targetSet, sourceSet); // true\n */\nexport function isMatch(target: any, source: any): boolean {\n if (source === target) {\n return true;\n }\n\n switch (typeof source) {\n case 'object': {\n if (source == null) {\n return true;\n }\n\n const keys = Object.keys(source as any);\n\n if (target == null) {\n if (keys.length === 0) {\n return true;\n }\n\n return false;\n }\n\n if (Array.isArray(source)) {\n return isArrayMatch(target, source);\n }\n\n if (source instanceof Map) {\n return isMapMatch(target, source);\n }\n\n if (source instanceof Set) {\n return isSetMatch(target, source);\n }\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (!isPrimitive(target) && !(key in target)) {\n return false;\n }\n\n if (source[key] === undefined && target[key] !== undefined) {\n return false;\n }\n\n if (source[key] === null && target[key] !== null) {\n return false;\n }\n\n if (!isMatch(target[key], source[key])) {\n return false;\n }\n }\n\n return true;\n }\n case 'function': {\n if (Object.keys(source).length > 0) {\n return isMatch(target, { ...source });\n }\n\n return false;\n }\n default: {\n if (!isObject(target)) {\n return eq(target, source);\n }\n\n return !source;\n }\n }\n}\n\nexport function isMapMatch(target: unknown, source: Map) {\n if (source.size === 0) {\n return true;\n }\n\n if (!(target instanceof Map)) {\n return false;\n }\n\n for (const [key, value] of source.entries()) {\n if (!isMatch(target.get(key), value)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isArrayMatch(target: unknown, source: readonly unknown[]) {\n if (source.length === 0) {\n return true;\n }\n\n if (!Array.isArray(target)) {\n return false;\n }\n\n const countedIndex = new Set();\n\n for (let i = 0; i < source.length; i++) {\n const sourceItem = source[i];\n const index = target.findIndex((targetItem, index) => {\n return isMatch(targetItem, sourceItem) && !countedIndex.has(index);\n });\n\n if (index === -1) {\n return false;\n }\n\n countedIndex.add(index);\n }\n\n return true;\n}\n\nexport function isSetMatch(target: unknown, source: Set) {\n if (source.size === 0) {\n return true;\n }\n\n if (!(target instanceof Set)) {\n return false;\n }\n\n return isArrayMatch([...target], [...source]);\n}\n","import { isMatch } from './isMatch.ts';\nimport { cloneDeep } from '../../object/cloneDeep.ts';\n\n/**\n * Creates a function that performs a deep comparison between a given target and the source object.\n *\n * @param {unknown} source - The source object to create the matcher from.\n * @returns {(target: unknown) => boolean} - Returns a function that takes a target object and returns `true` if the target matches the source, otherwise `false`.\n *\n * @example\n * // Basic usage\n * const matcher = matches({ a: 1, b: 2 });\n * matcher({ a: 1, b: 2, c: 3 }); // true\n * matcher({ a: 1, c: 3 }); // false\n *\n * @example\n * // Matching arrays\n * const arrayMatcher = matches([1, 2, 3]);\n * arrayMatcher([1, 2, 3, 4]); // true\n * arrayMatcher([4, 5, 6]); // false\n *\n * @example\n * // Matching objects with nested structures\n * const nestedMatcher = matches({ a: { b: 2 } });\n * nestedMatcher({ a: { b: 2, c: 3 } }); // true\n * nestedMatcher({ a: { c: 3 } }); // false\n */\nexport function matches(source: unknown): (target: unknown) => boolean {\n source = cloneDeep(source);\n\n return (target?: unknown): boolean => {\n return isMatch(target, source);\n };\n}\n","import { cloneDeep as cloneDeepToolkit, copyProperties } from '../../object/cloneDeep.ts';\nimport { argumentsTag, booleanTag, numberTag, stringTag } from '../_internal/tags.ts';\n\n/**\n * Creates a deep clone of the given object.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to clone.\n * @returns {T} - A deep clone of the given object.\n *\n * @example\n * // Clone a primitive values\n * const num = 29;\n * const clonedNum = clone(num);\n * console.log(clonedNum); // 29\n * console.log(clonedNum === num) ; // true\n *\n * @example\n * // Clone an array\n * const arr = [1, 2, 3];\n * const clonedArr = clone(arr);\n * console.log(clonedArr); // [1, 2, 3]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an array with nested objects\n * const arr = [1, { a: 1 }, [1, 2, 3]];\n * const clonedArr = clone(arr);\n * arr[1].a = 2;\n * console.log(arr); // [2, { a: 2 }, [1, 2, 3]]\n * console.log(clonedArr); // [1, { a: 1 }, [1, 2, 3]]\n * console.log(clonedArr === arr); // false\n *\n * @example\n * // Clone an object\n * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };\n * const clonedObj = clone(obj);\n * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }\n * console.log(clonedObj === obj); // false\n *\n * @example\n * // Clone an object with nested objects\n * const obj = { a: 1, b: { c: 1 } };\n * const clonedObj = clone(obj);\n * obj.b.c = 2;\n * console.log(obj); // { a: 1, b: { c: 2 } }\n * console.log(clonedObj); // { a: 1, b: { c: 1 } }\n * console.log(clonedObj === obj); // false\n */\nexport function cloneDeep(obj: T): T {\n if (typeof obj !== 'object') {\n return cloneDeepToolkit(obj);\n }\n\n switch (Object.prototype.toString.call(obj)) {\n case numberTag:\n case stringTag:\n case booleanTag: {\n // eslint-disable-next-line\n // @ts-ignore\n const result = new obj.constructor(obj?.valueOf()) as T;\n copyProperties(result, obj);\n return result;\n }\n\n case argumentsTag: {\n const result = {} as any;\n\n copyProperties(result, obj);\n\n // eslint-disable-next-line\n // @ts-ignore\n result.length = obj.length;\n // eslint-disable-next-line\n // @ts-ignore\n result[Symbol.iterator] = obj[Symbol.iterator];\n\n return result as T;\n }\n\n default: {\n return cloneDeepToolkit(obj);\n }\n }\n}\n","const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\\d*)$/;\n\nexport function isIndex(value: PropertyKey): boolean {\n switch (typeof value) {\n case 'number': {\n return Number.isInteger(value) && value >= 0 && value < Number.MAX_SAFE_INTEGER;\n }\n case 'symbol': {\n return false;\n }\n case 'string': {\n return IS_UNSIGNED_INTEGER.test(value);\n }\n }\n}\n","import { getTag } from '../_internal/getTag.ts';\n\n/**\n * Checks if the given value is an arguments object.\n *\n * This function tests whether the provided value is an arguments object or not.\n * It returns `true` if the value is an arguments object, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an arguments object.\n *\n * @param {unknown} value - The value to test if it is an arguments object.\n * @returns {value is IArguments} `true` if the value is an arguments, `false` otherwise.\n *\n * @example\n * const args = (function() { return arguments; })();\n * const strictArgs = (function() { 'use strict'; return arguments; })();\n * const value = [1, 2, 3];\n *\n * console.log(isArguments(args)); // true\n * console.log(isArguments(strictArgs)); // true\n * console.log(isArguments(value)); // false\n */\nexport function isArguments(value?: unknown): value is IArguments {\n return value !== null && typeof value === 'object' && getTag(value) === '[object Arguments]';\n}\n","import { isDeepKey } from '../_internal/isDeepKey.ts';\nimport { isIndex } from '../_internal/isIndex.ts';\nimport { isArguments } from '../predicate/isArguments.ts';\nimport { toPath } from '../util/toPath.ts';\n\n/**\n * Checks if a given path exists within an object.\n *\n * You can provide the path as a single property key, an array of property keys,\n * or a string representing a deep path.\n *\n * If the path is an index and the object is an array or an arguments object, the function will verify\n * if the index is valid and within the bounds of the array or arguments object, even if the array or\n * arguments object is sparse (i.e., not all indexes are defined).\n *\n * @param {object} object - The object to query.\n * @param {PropertyKey | PropertyKey[]} path - The path to check. This can be a single property key,\n * an array of property keys, or a string representing a deep path.\n * @returns {boolean} Returns `true` if the path exists in the object, `false` otherwise.\n *\n * @example\n *\n * const obj = { a: { b: { c: 3 } } };\n *\n * has(obj, 'a'); // true\n * has(obj, ['a', 'b']); // true\n * has(obj, ['a', 'b', 'c']); // true\n * has(obj, 'a.b.c'); // true\n * has(obj, 'a.b.d'); // false\n * has(obj, ['a', 'b', 'c', 'd']); // false\n * has([], 0); // false\n * has([1, 2, 3], 2); // true\n * has([1, 2, 3], 5); // false\n */\nexport function has(object: unknown, path: PropertyKey | readonly PropertyKey[]): boolean;\n\n/**\n * Checks if a given path exists within an object.\n *\n * You can provide the path as a single property key, an array of property keys,\n * or a string representing a deep path.\n *\n * If the path is an index and the object is an array or an arguments object, the function will verify\n * if the index is valid and within the bounds of the array or arguments object, even if the array or\n * arguments object is sparse (i.e., not all indexes are defined).\n *\n * @param {object} object - The object to query.\n * @param {PropertyKey | PropertyKey[]} path - The path to check. This can be a single property key,\n * an array of property keys, or a string representing a deep path.\n * @returns {boolean} Returns `true` if the path exists in the object, `false` otherwise.\n *\n * @example\n *\n * const obj = { a: { b: { c: 3 } } };\n *\n * has(obj, 'a'); // true\n * has(obj, ['a', 'b']); // true\n * has(obj, ['a', 'b', 'c']); // true\n * has(obj, 'a.b.c'); // true\n * has(obj, 'a.b.d'); // false\n * has(obj, ['a', 'b', 'c', 'd']); // false\n * has([], 0); // false\n * has([1, 2, 3], 2); // true\n * has([1, 2, 3], 5); // false\n */\nexport function has(object: any, path: PropertyKey | readonly PropertyKey[]): boolean {\n let resolvedPath;\n\n if (Array.isArray(path)) {\n resolvedPath = path;\n } else if (typeof path === 'string' && isDeepKey(path) && object?.[path] == null) {\n resolvedPath = toPath(path);\n } else {\n resolvedPath = [path];\n }\n\n if (resolvedPath.length === 0) {\n return false;\n }\n\n let current = object;\n\n for (let i = 0; i < resolvedPath.length; i++) {\n const key = resolvedPath[i];\n\n // Check if the current key is a direct property of the current object\n if (current == null || !Object.hasOwn(current, key)) {\n const isSparseIndex = (Array.isArray(current) || isArguments(current)) && isIndex(key) && key < current.length;\n\n if (!isSparseIndex) {\n return false;\n }\n }\n\n current = current[key];\n }\n\n return true;\n}\n","import { isMatch } from './isMatch.ts';\nimport { toKey } from '../_internal/toKey.ts';\nimport { cloneDeep } from '../object/cloneDeep.ts';\nimport { get } from '../object/get.ts';\nimport { has } from '../object/has.ts';\n\n/**\n * Creates a function that checks if a given target object matches a specific property value.\n *\n * The returned function takes a target object and determines if the property at the\n * specified path within the target object is equal to the given value.\n *\n * @param {PropertyKey | PropertyKey[]} property - The property path to check within the target object.\n * This can be a single property key or an array of property keys.\n * @param {unknown} source - The value to compare against the property value in the target object.\n *\n * @returns {(target: unknown) => boolean} - A function that takes a target object and returns\n * `true` if the property value at the given path in the target object matches the provided value,\n * otherwise returns `false`.\n *\n * @example\n * // Using a single property key\n * const checkName = matchesProperty('name', 'Alice');\n * console.log(checkName({ name: 'Alice' })); // true\n * console.log(checkName({ name: 'Bob' })); // false\n *\n * // Using an array of property keys\n * const checkNested = matchesProperty(['address', 'city'], 'New York');\n * console.log(checkNested({ address: { city: 'New York' } })); // true\n * console.log(checkNested({ address: { city: 'Los Angeles' } })); // false\n */\nexport function matchesProperty(\n property: PropertyKey | readonly PropertyKey[],\n source: unknown\n): (target?: unknown) => boolean {\n switch (typeof property) {\n case 'object': {\n if (Object.is(property?.valueOf(), -0)) {\n property = '-0';\n }\n break;\n }\n case 'number': {\n property = toKey(property);\n break;\n }\n }\n\n source = cloneDeep(source);\n\n return function (target?: unknown) {\n const result = get(target, property as PropertyKey | PropertyKey[]);\n\n if (result === undefined) {\n return has(target, property as PropertyKey | PropertyKey[]);\n }\n\n if (source === undefined) {\n return result === undefined;\n }\n\n return isMatch(result, source);\n };\n}\n","import { identity } from '../../function/identity.ts';\nimport { property } from '../object/property.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Returns a `identity` function when `value` is `null` or `undefined`.\n *\n * @param {null} [value] - The value to convert to an iteratee.\n * @returns {(value: T) => T} - Returns a `identity` function.\n *\n * @example\n * const func = iteratee();\n * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [{ a: 1 }, { a: 2 }, { a: 3 }]\n */\nexport function iteratee(value?: null): (value: T) => T;\n\n/**\n * Returns a given `func` function when `value` is a `function`.\n *\n * @template {(...args: any[]) => unknown} F - The function type.\n * @param {F} func - The function to return.\n * @returns {F} - Returns the given function.\n *\n * @example\n * const func = iteratee((object) => object.a);\n * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3]\n */\nexport function iteratee unknown>(func: F): F;\n\n/**\n * Creates a function that invokes `value` with the arguments of the created function.\n *\n * The created function returns the property value for a given element.\n *\n * @param {symbol | number | string | object} value - The value to convert to an iteratee.\n * @returns {(...args: any[]) => any} - Returns the new iteratee function.\n *\n * @example\n * const func = iteratee('a');\n * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3]\n *\n * const func = iteratee({ a: 1 });\n * [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }\n *\n * const func = iteratee(['a', 1]);\n * [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }\n */\nexport function iteratee(value: symbol | number | string | object): (...args: any[]) => any;\n\n/**\n * Creates a function that returns a value from an element in a collection.\n *\n * You can call `iteratee` with the following types of arguments:\n *\n * - **Function**: Returns the function as-is, which will be called with the element from the collection.\n * - **Property name**: Returns the value of the specified property from the element.\n * - **Property-value pair**: Returns a boolean indicating whether the element's property matches the given value.\n * - **Partial object**: Returns a boolean indicating whether the element matches the properties of the partial object.\n *\n * If you don't provide any arguments or pass `null`, this function will return a function that simply returns its input unchanged.\n *\n * @param {symbol | number | string | object | null | ((...args: any[]) => any)} value - The value to convert to an iteratee.\n * @returns {(...args: any[]) => unknown} - Returns the new iteratee function.\n * @example\n * const func = iteratee();\n * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [{ a: 1 }, { a: 2 }, { a: 3 }]\n *\n * const func = iteratee((object) => object.a);\n * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3]\n *\n * const func = iteratee('a');\n * [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3]\n *\n * const func = iteratee({ a: 1 });\n * [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }\n *\n * const func = iteratee(['a', 1]);\n * [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }\n */\nexport function iteratee(\n value?: symbol | number | string | object | null | ((...args: any[]) => unknown)\n): (...args: any[]) => any {\n if (value == null) {\n return identity;\n }\n\n switch (typeof value) {\n case 'function': {\n return value as any;\n }\n case 'object': {\n if (Array.isArray(value) && value.length === 2) {\n return matchesProperty(value[0], value[1]);\n }\n\n return matches(value);\n }\n case 'string':\n case 'symbol':\n case 'number': {\n return property(value);\n }\n }\n}\n","/**\n * Check whether a value is a symbol.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `symbol`.\n *\n * @param {unknown} value The value to check.\n * @returns {value is symbol} Returns `true` if `value` is a symbol, else `false`.\n * @example\n * isSymbol(Symbol.iterator);\n * // => true\n *\n * isSymbol('abc');\n * // => false\n */\nexport function isSymbol(value?: unknown): value is symbol {\n return typeof value === 'symbol' || value instanceof Symbol;\n}\n","import { isSymbol } from '../predicate/isSymbol.ts';\n\n/**\n * Converts `value` to a number.\n *\n * Unlike `Number()`, this function returns `NaN` for symbols.\n *\n * @param {unknown} value - The value to convert.\n * @returns {number} Returns the number.\n *\n * @example\n * toNumber(3.2); // => 3.2\n * toNumber(Number.MIN_VALUE); // => 5e-324\n * toNumber(Infinity); // => Infinity\n * toNumber('3.2'); // => 3.2\n * toNumber(Symbol.iterator); // => NaN\n * toNumber(NaN); // => NaN\n */\nexport function toNumber(value?: unknown): number {\n if (isSymbol(value)) {\n return NaN;\n }\n\n return Number(value);\n}\n","import { toNumber } from './toNumber.ts';\n\n/**\n * Converts `value` to a finite number.\n *\n * @param {unknown} value - The value to convert.\n * @returns {number} Returns the number.\n *\n * @example\n * toNumber(3.2); // => 3.2\n * toNumber(Number.MIN_VALUE); // => 5e-324\n * toNumber(Infinity); // => 1.7976931348623157e+308\n * toNumber('3.2'); // => 3.2\n * toNumber(Symbol.iterator); // => 0\n * toNumber(NaN); // => 0\n */\nexport function toFinite(value?: unknown): number {\n if (!value) {\n return value === 0 ? value : 0;\n }\n\n value = toNumber(value);\n\n if (value === Infinity || value === -Infinity) {\n const sign = value < 0 ? -1 : 1;\n return sign * Number.MAX_VALUE;\n }\n\n return value === value ? (value as number) : 0;\n}\n","import { toFinite } from './toFinite.ts';\n\n/**\n * Converts `value` to an integer.\n *\n * This function first converts `value` to a finite number. If the result has any decimal places,\n * they are removed by rounding down to the nearest whole number.\n *\n * @param {unknown} value - The value to convert.\n * @returns {number} Returns the number.\n *\n * @example\n * toInteger(3.2); // => 3\n * toInteger(Number.MIN_VALUE); // => 0\n * toInteger(Infinity); // => 1.7976931348623157e+308\n * toInteger('3.2'); // => 3\n * toInteger(Symbol.iterator); // => 0\n * toInteger(NaN); // => 0\n */\nexport function toInteger(value?: unknown): number {\n const finite = toFinite(value);\n const remainder = finite % 1;\n\n return remainder ? finite - remainder : finite;\n}\n","import { isIndex } from './isIndex.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { isObject } from '../predicate/isObject.ts';\nimport { eq } from '../util/eq.ts';\n\nexport function isIterateeCall(value: unknown, index: unknown, object: unknown): boolean {\n if (!isObject(object)) {\n return false;\n }\n\n if (\n (typeof index === 'number' && isArrayLike(object) && isIndex(index) && index < object.length) ||\n (typeof index === 'string' && index in object)\n ) {\n return eq((object as any)[index], value);\n }\n\n return false;\n}\n","/**\n * Checks if a given value is string.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `string`.\n *\n * @param {unknown} value The value to check if it is string.\n * @returns {value is string} Returns `true` if `value` is a string, else `false`.\n *\n * @example\n * const value1 = 'abc';\n * const value2 = 123;\n * const value3 = true;\n *\n * console.log(isString(value1)); // true\n * console.log(isString(value2)); // false\n * console.log(isString(value3)); // false\n */\n\nexport function isString(value?: unknown): value is string {\n return typeof value === 'string' || value instanceof String;\n}\n","/**\n * Checks if the given value is an array.\n *\n * This function tests whether the provided value is an array or not.\n * It returns `true` if the value is an array, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to an array.\n *\n * @param {unknown} value - The value to test if it is an array.\n * @returns {value is any[]} `true` if the value is an array, `false` otherwise.\n *\n * @example\n * const value1 = [1, 2, 3];\n * const value2 = 'abc';\n * const value3 = () => {};\n *\n * console.log(isArray(value1)); // true\n * console.log(isArray(value2)); // false\n * console.log(isArray(value3)); // false\n */\nexport function isArray(value?: unknown): value is any[] {\n return Array.isArray(value);\n}\n","import { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Flattens an array up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template D - The depth to which the array should be flattened.\n * @param {ArrayLike | null | undefined} value - The object to flatten.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array> | []} A new array that has been flattened.\n *\n * @example\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);\n * // Returns: [1, 2, 3, 4, [5, 6]]\n *\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flatten(\n value: ArrayLike | null | undefined,\n depth = 1 as D\n): Array> | [] {\n const result: Array> = [];\n const flooredDepth = Math.floor(depth);\n\n if (!isArrayLike(value)) {\n return result;\n }\n\n const recursive = (arr: readonly T[], currentDepth: number) => {\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n if (\n currentDepth < flooredDepth &&\n (Array.isArray(item) ||\n Boolean(item?.[Symbol.isConcatSpreadable as keyof object]) ||\n (item !== null && typeof item === 'object' && Object.prototype.toString.call(item) === '[object Arguments]'))\n ) {\n if (Array.isArray(item)) {\n recursive(item, currentDepth + 1);\n } else {\n recursive(Array.from(item as T[]), currentDepth + 1);\n }\n } else {\n result.push(item as FlatArray);\n }\n }\n };\n\n recursive(Array.from(value), 0);\n\n return result;\n}\n","import { identity } from '../../function/identity';\nimport { range } from '../../math/range';\nimport { isArrayLike } from '../predicate/isArrayLike';\n\n/**\n * Iterates over each element of the array invoking the provided callback function for each element.\n *\n * @template K - The type of elements in the array.\n * @template T - The type of the array.\n * @param {T | null | undefined} array - The array to iterate over.\n * @param {(value: K, index: number, array: T) => unknown} [callback] - The function invoked for each element.\n * The callback function receives three arguments:\n * - 'value': The current element being processed in the array.\n * - 'index': The index of the current element being processed in the array.\n * - 'array': The array 'forEach' was called upon.\n * @returns {T} Returns the original array.\n *\n * @example\n * forEach([1, 2, 3], (value, index, array) => console.log(value, index));\n * // Output:\n * // 1 0\n * // 2 1\n * // 3 2\n *\n */\nexport function forEach(array: T[], callback?: (value: T, index: number, array: T[]) => unknown): T[];\n\n/**\n * Iterates over each element of the array invoking the provided callback function for each element.\n *\n * @template K - The type of elements in the array.\n * @template T - The type of the array.\n * @param {T | null | undefined} array - The array to iterate over.\n * @param {(value: K, index: number, array: T) => unknown} [callback] - The function invoked for each element.\n * The callback function receives three arguments:\n * - 'value': The current element being processed in the array.\n * - 'index': The index of the current element being processed in the array.\n * - 'array': The array 'forEach' was called upon.\n * @returns {T} Returns the original array.\n *\n * @example\n * forEach([1, 2, 3], (value, index, array) => console.log(value, index));\n * // Output:\n * // 1 0\n * // 2 1\n * // 3 2\n *\n */\nexport function forEach(\n array: readonly T[],\n callback?: (value: T, index: number, array: T[]) => unknown\n): readonly T[];\n\n/**\n * Iterates over each element of the array invoking the provided callback function for each element.\n *\n * @template T - The type of string.\n * @param {T | null | undefined} string - The string to iterate over\n * @param {(value: T, index: number, string: T) => unknown} [callback] - The function invoked for each char.\n * The callback function receives three arguments:\n * - 'char': The current char being processed in the string.\n * - 'index': The index of the current char being processed in the string.\n * - 'string': The string 'forEach' was called upon.\n * @returns {T} Returns the original string.\n *\n * @example\n * forEach('abc', (char, index, string) => console.log(char, index));\n * // Output:\n * // 'a' 0\n * // 'b' 1\n * // 'c' 2\n */\nexport function forEach(\n string: T,\n callback?: (char: string, index: number, string: string) => unknown\n): T;\n\n/**\n * Iterates over each element of the array invoking the provided callback function for each element.\n *\n * @template T - The type of elements in the array.\n * @param { ArrayLike } array - The array to iterate over.\n * @param {(value: T, index: number, array: ArrayLike) => unknown} [callback] - The function invoked for each element.\n * The callback function receives three arguments:\n * - 'value': The current element being processed in the array.\n * - 'index': The index of the current element being processed in the array.\n * - 'array': The array 'forEach' was called upon.\n * @returns {T} Returns the original array.\n *\n * @example\n * forEach([1, 2, 3], (value, index, array) => console.log(value, index));\n * // Output:\n * // 1 0\n * // 2 1\n * // 3 2\n *\n */\nexport function forEach(\n array: ArrayLike,\n callback?: (value: T, index: number, array: ArrayLike) => unknown\n): ArrayLike;\n\n/**\n * Iterates over each element of the object invoking the provided callback function for each property.\n *\n * @template T - The type of object.\n * @param {T} object - The object to iterate over.\n * @param {(value: T[keyof T], key: keyof T, object: T) => unknown} [callback] - The function invoked for each property.\n * The callback function receives three arguments:\n * - 'value': The current property being processed in the object.\n * - 'key': The key of the current property being processed in the object.\n * - 'object': The object 'forEach' was called upon.\n * @returns {T} Returns the original object.\n *\n * @example\n * forEach({'a': 1, 'b': 2 }, (value, key, object) => console.log(value, key));\n * // Output:\n * // 1 'a'\n * // 2 'b'\n */\nexport function forEach(\n object: T,\n callback?: (value: T[keyof T], key: keyof T, object: T) => unknown\n): T;\n\n/**\n * Iterates over each element of the object invoking the provided callback function for each property.\n *\n * @template T - The type of object.\n * @param {T} object - The object to iterate over.\n * @param {(value: T[keyof T], key: keyof T, object: T) => unknown} [callback] - The function invoked for each property.\n * The callback function receives three arguments:\n * - 'value': The current property being processed in the object.\n * - 'key': The key of the current property being processed in the object.\n * - 'object': The object 'forEach' was called upon.\n * @returns {T} Returns the original object.\n *\n * @example\n * forEach({'a': 1, 'b': 2 }, (value, key, object) => console.log(value, key));\n * // Output:\n * // 1 'a'\n * // 2 'b'\n */\nexport function forEach(\n collection: ArrayLike | Record | string | null | undefined,\n callback: (item: any, index: any, arr: any) => unknown = identity\n): ArrayLike | Record | string | null | undefined {\n if (!collection) {\n return collection;\n }\n\n const keys: PropertyKey[] =\n isArrayLike(collection) || Array.isArray(collection) ? range(0, collection.length) : Object.keys(collection);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = (collection as any)[key];\n\n const result = callback(value, key, collection);\n\n if (result === false) {\n break;\n }\n }\n\n return collection;\n}\n","import { head as headToolkit } from '../../array/head.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Returns the first element of an array or `undefined` if the array is empty.\n *\n * This function takes an array and returns the first element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | undefined | null} arr - The array from which to get the first element.\n * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const emptyArr: number[] = [];\n * const noElement = head(emptyArr);\n * // noElement will be undefined\n */\nexport function head(arr: ArrayLike | undefined | null): T | undefined {\n if (!isArrayLike(arr)) {\n return undefined;\n }\n return headToolkit(toArray(arr));\n}\n","/**\n * Returns the first element of an array.\n *\n * This function takes an array and returns the first element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * @template T - The type of elements in the array.\n * @param {[T, ...T[]]} arr - A non-empty array from which to get the first element.\n * @returns {T} The first element of the array.\n *\n * @example\n * const arr = [1, 2, 3];\n * const firstElement = head(arr);\n * // firstElement will be 1\n */\nexport function head(arr: readonly [T, ...T[]]): T;\n\n/**\n * Returns the first element of an array or `undefined` if the array is empty.\n *\n * This function takes an array and returns the first element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to get the first element.\n * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const emptyArr: number[] = [];\n * const noElement = head(emptyArr);\n * // noElement will be undefined\n */\nexport function head(arr: readonly T[]): T | undefined;\n\n/**\n * Returns the first element of an array or `undefined` if the array is empty.\n *\n * This function takes an array and returns the first element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to get the first element.\n * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const emptyArr: number[] = [];\n * const noElement = head(emptyArr);\n * // noElement will be undefined\n */\nexport function head(arr: readonly T[]): T | undefined {\n return arr[0];\n}\n","function getPriority(a: unknown): 0 | 1 | 2 | 3 | 4 {\n if (typeof a === 'symbol') {\n return 1;\n }\n\n if (a === null) {\n return 2;\n }\n\n if (a === undefined) {\n return 3;\n }\n\n if (a !== a) {\n return 4;\n }\n\n return 0;\n}\n\nexport const compareValues = (a: V, b: V, order: string) => {\n if (a !== b) {\n // If both values are strings, compare them using localeCompare.\n if (typeof a === 'string' && typeof b === 'string') {\n return order === 'desc' ? b.localeCompare(a) : a.localeCompare(b);\n }\n\n const aPriority = getPriority(a);\n const bPriority = getPriority(b);\n\n // If both values are of the same priority and are normal values, compare them.\n if (aPriority === bPriority && aPriority === 0) {\n if (a < b) {\n return order === 'desc' ? 1 : -1;\n }\n\n if (a > b) {\n return order === 'desc' ? -1 : 1;\n }\n }\n\n return order === 'desc' ? bPriority - aPriority : aPriority - bPriority;\n }\n\n return 0;\n};\n","import { isSymbol } from '../predicate/isSymbol.ts';\n\n/** Matches any deep property path. (e.g. `a.b[0].c`)*/\nconst regexIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/;\n/** Matches any word character (alphanumeric & underscore).*/\nconst regexIsPlainProp = /^\\w*$/;\n\n/**\n * Checks if `value` is a property name and not a property path. (It's ok that the `value` is not in the keys of the `object`)\n * @param {unknown} value The value to check.\n * @param {unknown} object The object to query.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n *\n * @example\n * isKey('a', { a: 1 });\n * // => true\n *\n * isKey('a.b', { a: { b: 2 } });\n * // => false\n */\nexport function isKey(value?: unknown, object?: unknown): value is PropertyKey {\n if (Array.isArray(value)) {\n return false;\n }\n\n if (typeof value === 'number' || typeof value === 'boolean' || value == null || isSymbol(value)) {\n return true;\n }\n\n return (\n (typeof value === 'string' && (regexIsPlainProp.test(value) || !regexIsDeepProp.test(value))) ||\n (object != null && Object.hasOwn(object, value as PropertyKey))\n );\n}\n","import { compareValues } from '../_internal/compareValues.ts';\nimport { isKey } from '../_internal/isKey.ts';\nimport { toPath } from '../util/toPath.ts';\n\nexport type Criterion = ((item: T) => unknown) | PropertyKey | PropertyKey[] | null | undefined;\n/**\n * Sorts an array of objects based on multiple properties and their corresponding order directions.\n *\n * This function takes an array of objects, an array of criteria to sort by, and an array of order directions.\n * It returns the sorted array, ordering by each key according to its corresponding direction ('asc' for ascending or 'desc' for descending).\n * If values for a key are equal, it moves to the next key to determine the order.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | object | null | undefined} collection - The array of objects to be sorted.\n * @param {Criterion | Array>} criteria - An array of criteria (property names or property paths or custom key functions) to sort by.\n * @param {unknown | unknown[]} orders - An array of order directions ('asc' for ascending or 'desc' for descending).\n * @param {unknown} [guard] Enables use as an iteratee for methods like `_.reduce`.\n * @returns {T[]} - The sorted array.\n *\n * @example\n * // Sort an array of objects by 'user' in ascending order and 'age' in descending order.\n * const users = [\n * { user: 'fred', age: 48 },\n * { user: 'barney', age: 34 },\n * { user: 'fred', age: 40 },\n * { user: 'barney', age: 36 },\n * ];\n * const result = orderBy(users, ['user', (item) => item.age], ['asc', 'desc']);\n * // result will be:\n * // [\n * // { user: 'barney', age: 36 },\n * // { user: 'barney', age: 34 },\n * // { user: 'fred', age: 48 },\n * // { user: 'fred', age: 40 },\n * // ]\n */\nexport function orderBy(\n collection: ArrayLike | object | null | undefined,\n criteria?: Criterion | Array>,\n orders?: unknown | unknown[],\n guard?: unknown\n): T[] {\n if (collection == null) {\n return [];\n }\n\n orders = guard ? undefined : orders;\n\n if (!Array.isArray(collection)) {\n collection = Object.values(collection);\n }\n\n if (!Array.isArray(criteria)) {\n criteria = criteria == null ? [null] : [criteria];\n }\n if (criteria.length === 0) {\n criteria = [null];\n }\n\n if (!Array.isArray(orders)) {\n orders = orders == null ? [] : [orders];\n }\n\n // For Object('desc') case\n orders = (orders as unknown[]).map(order => String(order));\n\n const getValueByNestedPath = (object: object, path: PropertyKey[]) => {\n let target: object = object;\n\n for (let i = 0; i < path.length && target != null; ++i) {\n target = target[path[i] as keyof typeof target];\n }\n\n return target;\n };\n\n const getValueByCriterion = (criterion: Criterion | { key: PropertyKey; path: string[] }, object: T) => {\n if (object == null || criterion == null) {\n return object;\n }\n\n if (typeof criterion === 'object' && 'key' in criterion) {\n if (Object.hasOwn(object, criterion.key)) {\n return object[criterion.key as keyof typeof object];\n }\n\n return getValueByNestedPath(object, criterion.path);\n }\n\n if (typeof criterion === 'function') {\n return criterion(object);\n }\n\n if (Array.isArray(criterion)) {\n return getValueByNestedPath(object, criterion);\n }\n\n if (typeof object === 'object') {\n return object[criterion as keyof typeof object];\n }\n\n return object;\n };\n\n // Prepare all cases for criteria\n const preparedCriteria = criteria.map(criterion => {\n // lodash handles a array with one element as a single criterion\n if (Array.isArray(criterion) && criterion.length === 1) {\n criterion = criterion[0];\n }\n\n if (criterion == null || typeof criterion === 'function' || Array.isArray(criterion) || isKey(criterion)) {\n return criterion;\n }\n\n // If criterion is not key, it has possibility to be a deep path. So we have to prepare both cases.\n return { key: criterion, path: toPath(criterion) };\n });\n\n // Array.prototype.sort() always shifts the `undefined` values to the end of the array. So we have to prevent it by using a wrapper object.\n const preparedCollection = (collection as T[]).map(item => ({\n original: item,\n criteria: preparedCriteria.map(criterion => getValueByCriterion(criterion, item)),\n }));\n\n return preparedCollection\n .slice()\n .sort((a, b) => {\n for (let i = 0; i < preparedCriteria.length; i++) {\n const comparedResult = compareValues(a.criteria[i], b.criteria[i], (orders as string[])[i]);\n\n if (comparedResult !== 0) {\n return comparedResult;\n }\n }\n\n return 0;\n })\n .map(item => item.original);\n}\n","import { isIndex } from '../_internal/isIndex.ts';\nimport { toPath } from '../util/toPath.ts';\n\n/**\n * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to modify.\n * @param {PropertyKey | PropertyKey[]} path - The path of the property to set.\n * @param {any} value - The value to set.\n * @returns {T} - The modified object.\n *\n * @example\n * // Set a value in a nested object\n * const obj = { a: { b: { c: 3 } } };\n * set(obj, 'a.b.c', 4);\n * console.log(obj.a.b.c); // 4\n *\n * @example\n * // Set a value in an array\n * const arr = [1, 2, 3];\n * set(arr, 1, 4);\n * console.log(arr[1]); // 4\n *\n * @example\n * // Create non-existent path and set value\n * const obj = {};\n * set(obj, 'a.b.c', 4);\n * console.log(obj); // { a: { b: { c: 4 } } }\n */\nexport function set(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;\n/**\n * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.\n *\n * @template T - The type of the object.\n * @param {T} obj - The object to modify.\n * @param {PropertyKey | PropertyKey[]} path - The path of the property to set.\n * @param {any} value - The value to set.\n * @returns {T} - The modified object.\n *\n * @example\n * // Set a value in a nested object\n * const obj = { a: { b: { c: 3 } } };\n * set(obj, 'a.b.c', 4);\n * console.log(obj.a.b.c); // 4\n *\n * @example\n * // Set a value in an array\n * const arr = [1, 2, 3];\n * set(arr, 1, 4);\n * console.log(arr[1]); // 4\n *\n * @example\n * // Create non-existent path and set value\n * const obj = {};\n * set(obj, 'a.b.c', 4);\n * console.log(obj); // { a: { b: { c: 4 } } }\n */\nexport function set(obj: T, path: PropertyKey | readonly PropertyKey[], value: unknown): T {\n const resolvedPath = Array.isArray(path) ? path : typeof path === 'string' ? toPath(path) : [path];\n\n let current: any = obj;\n\n for (let i = 0; i < resolvedPath.length - 1; i++) {\n const key = resolvedPath[i];\n const nextKey = resolvedPath[i + 1];\n\n if (current[key] == null) {\n current[key] = isIndex(nextKey) ? [] : {};\n }\n\n current = current[key];\n }\n\n const lastKey = resolvedPath[resolvedPath.length - 1];\n current[lastKey] = value;\n\n return obj;\n}\n","/**\n * Attempts to execute a function with the provided arguments.\n * If the function throws an error, it catches the error and returns it.\n * If the caught error is not an instance of Error, it wraps it in a new Error.\n *\n * @param {F} func - The function to be executed.\n * @param {...Parameters} args - The arguments to pass to the function.\n * @returns {ReturnType | Error} The return value of the function if successful, or an Error if an exception is thrown.\n *\n * @template F - The type of the function being attempted.\n *\n * @example\n * // Example 1: Successful execution\n * const result = attempt((x, y) => x + y, 2, 3);\n * console.log(result); // Output: 5\n *\n * @example\n * // Example 2: Function throws an error\n * const errorResult = attempt(() => {\n * throw new Error(\"Something went wrong\");\n * });\n * console.log(errorResult); // Output: Error: Something went wrong\n *\n * @example\n * // Example 3: Non-Error thrown\n * const nonErrorResult = attempt(() => {\n * throw \"This is a string error\";\n * });\n * console.log(nonErrorResult); // Output: Error: This is a string error\n */\nexport function attempt any>(func: F, ...args: Parameters): ReturnType | Error {\n try {\n return func(...args);\n } catch (e: any) {\n return e instanceof Error ? e : new Error(e);\n }\n}\n","/**\n * Creates a function that invokes `func` with the `this` binding of `thisArg` and `partials` prepended to the arguments it receives.\n *\n * The `bind.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.\n *\n * Note: Unlike native `Function#bind`, this method doesn't set the `length` property of bound functions.\n *\n * @template F - The type of the function to bind.\n * @param {F} func - The function to bind.\n * @param {unknown} thisObj - The `this` binding of `func`.\n * @param {...any} partialArgs - The arguments to be partially applied.\n * @returns {F} - Returns the new bound function.\n *\n * @example\n * function greet(greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * }\n * const object = { user: 'fred' };\n * let bound = bind(greet, object, 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * bound = bind(greet, object, bind.placeholder, '!');\n * bound('hi');\n * // => 'hi fred!'\n */\nexport function bind any>(func: F, thisObj?: unknown, ...partialArgs: any[]): F {\n const bound = function (this: any, ...providedArgs: any[]) {\n const args: any[] = [];\n\n // Populate args by merging partialArgs and providedArgs.\n // e.g.. when we call bind(func, {}, [1, bind.placeholder, 3])(2, 4);\n // we have args with [1, 2, 3, 4].\n let startIndex = 0;\n\n for (let i = 0; i < partialArgs.length; i++) {\n const arg = partialArgs[i];\n\n if (arg === bind.placeholder) {\n args.push(providedArgs[startIndex++]);\n } else {\n args.push(arg);\n }\n }\n\n for (let i = startIndex; i < providedArgs.length; i++) {\n args.push(providedArgs[i]);\n }\n\n if (this instanceof bound) {\n // @ts-expect-error - fn is a constructor\n return new func(...args);\n }\n\n return func.apply(thisObj, args);\n };\n\n return bound as any as F;\n}\n\nconst bindPlaceholder: unique symbol = Symbol('bind.placeholder');\nbind.placeholder = bindPlaceholder;\n","/**\n * Creates a function that invokes the method at `object[key]` with `partialArgs` prepended to the arguments it receives.\n *\n * This method differs from `bind` by allowing bound functions to reference methods that may be redefined or don't yet exist.\n *\n * The `bindKey.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.\n *\n * @template T - The type of the object to bind.\n * @template K - The type of the key to bind.\n * @param {T} object - The object to invoke the method on.\n * @param {K} key - The key of the method.\n * @param {...any} partialArgs - The arguments to be partially applied.\n * @returns {T[K] extends (...args: any[]) => any ? (...args: any[]) => ReturnType : never} - Returns the new bound function.\n *\n * @example\n * const object = {\n * user: 'fred',\n * greet: function (greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * },\n * };\n *\n * let bound = bindKey(object, 'greet', 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * object.greet = function (greeting, punctuation) {\n * return greeting + 'ya ' + this.user + punctuation;\n * };\n *\n * bound('!');\n * // => 'hiya fred!'\n *\n * // Bound with placeholders.\n * bound = bindKey(object, 'greet', bindKey.placeholder, '!');\n * bound('hi');\n * // => 'hiya fred!'\n */\nexport function bindKey, K extends keyof T>(\n object: T,\n key: K,\n ...partialArgs: any[]\n): T[K] extends (...args: any[]) => any ? (...args: any[]) => ReturnType : never {\n const bound = function (this: any, ...providedArgs: any[]) {\n const args: any[] = [];\n\n // Populate args by merging partialArgs and providedArgs.\n // e.g.. when we call bind(func, {}, [1, bind.placeholder, 3])(2, 4);\n // we have args with [1, 2, 3, 4].\n let startIndex = 0;\n\n for (let i = 0; i < partialArgs.length; i++) {\n const arg = partialArgs[i];\n\n if (arg === bindKey.placeholder) {\n args.push(providedArgs[startIndex++]);\n } else {\n args.push(arg);\n }\n }\n\n for (let i = startIndex; i < providedArgs.length; i++) {\n args.push(providedArgs[i]);\n }\n\n if (this instanceof bound) {\n return new object[key](...args);\n }\n\n // eslint-disable-next-line prefer-spread\n return object[key].apply(object, args);\n };\n\n return bound as any;\n}\n\nconst bindKeyPlaceholder: unique symbol = Symbol('bindKey.placeholder');\nbindKey.placeholder = bindKeyPlaceholder;\n","/**\n * Creates a function that accepts arguments of `func` and either invokes `func` returning its result, if at least `arity` number of arguments have been provided, or returns a function that accepts the remaining `func` arguments, and so on.\n * The arity of `func` may be specified if `func.length` is not sufficient.\n *\n * The `curry.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.\n *\n * Note: This method doesn't set the `length` property of curried functions.\n *\n * @param {(...args: any[]) => any} func - The function to curry.\n * @param {number=func.length} arity - The arity of func.\n * @param {unknown} guard - Enables use as an iteratee for methods like `Array#map`.\n * @returns {((...args: any[]) => any) & { placeholder: typeof curry.placeholder }} - Returns the new curried function.\n *\n * @example\n * const abc = function(a, b, c) {\n * return Array.from(arguments);\n * };\n *\n * let curried = curry(abc);\n *\n * curried(1)(2)(3);\n * // => [1, 2, 3]\n *\n * curried(1, 2)(3);\n * // => [1, 2, 3]\n *\n * curried(1, 2, 3);\n * // => [1, 2, 3]\n *\n * // Curried with placeholders.\n * curried(1)(curry.placeholder, 3)(2);\n * // => [1, 2, 3]\n *\n * // Curried with arity.\n * curried = curry(abc, 2);\n *\n * curried(1)(2);\n * // => [1, 2]\n */\nexport function curry(\n func: (...args: any[]) => any,\n arity: number = func.length,\n guard?: unknown\n): ((...args: any[]) => any) & { placeholder: typeof curry.placeholder } {\n arity = guard ? func.length : arity;\n arity = Number.parseInt(arity as any, 10);\n if (Number.isNaN(arity) || arity < 1) {\n arity = 0;\n }\n\n const wrapper = function (this: any, ...partialArgs: any[]) {\n const holders = partialArgs.filter(item => item === curry.placeholder);\n const length = partialArgs.length - holders.length;\n if (length < arity) {\n return makeCurry(func, arity - length, partialArgs);\n }\n if (this instanceof wrapper) {\n // @ts-expect-error - fn is a constructor\n return new func(...partialArgs);\n }\n return func.apply(this, partialArgs);\n };\n\n wrapper.placeholder = curryPlaceholder;\n\n return wrapper;\n}\n\nfunction makeCurry(\n func: (...args: any[]) => any,\n arity: number,\n partialArgs: any[]\n): ((...args: any[]) => any) & { placeholder: typeof curry.placeholder } {\n function wrapper(this: any, ...providedArgs: any[]) {\n const holders = providedArgs.filter(item => item === curry.placeholder);\n const length = providedArgs.length - holders.length;\n providedArgs = composeArgs(providedArgs, partialArgs);\n if (length < arity) {\n return makeCurry(func, arity - length, providedArgs);\n }\n if (this instanceof wrapper) {\n // @ts-expect-error - fn is a constructor\n return new func(...providedArgs);\n }\n return func.apply(this, providedArgs);\n }\n wrapper.placeholder = curryPlaceholder;\n return wrapper;\n}\n\nfunction composeArgs(providedArgs: any[], partialArgs: any[]): any[] {\n const args = [];\n let startIndex = 0;\n for (let i = 0; i < partialArgs.length; i++) {\n const arg = partialArgs[i];\n\n if (arg === curry.placeholder && startIndex < providedArgs.length) {\n args.push(providedArgs[startIndex++]);\n } else {\n args.push(arg);\n }\n }\n for (let i = startIndex; i < providedArgs.length; i++) {\n args.push(providedArgs[i]);\n }\n return args;\n}\n\nconst curryPlaceholder: unique symbol = Symbol('curry.placeholder');\ncurry.placeholder = curryPlaceholder;\n","/**\n * Creates a function that accepts arguments of `func` and either invokes `func` returning its result, if at least `arity` number of arguments have been provided, or returns a function that accepts the remaining `func` arguments, and so on.\n * The arity of `func` may be specified if `func.length` is not sufficient.\n *\n * Unlike `curry`, this function curries the function from right to left.\n *\n * The `curryRight.placeholder` value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.\n *\n * Note: This method doesn't set the `length` property of curried functions.\n *\n * @param {(...args: any[]) => any} func - The function to curry.\n * @param {number=func.length} arity - The arity of func.\n * @param {unknown} guard - Enables use as an iteratee for methods like `Array#map`.\n * @returns {((...args: any[]) => any) & { placeholder: typeof curryRight.placeholder }} - Returns the new curried function.\n *\n * @example\n * const abc = function(a, b, c) {\n * return Array.from(arguments);\n * };\n *\n * let curried = curryRight(abc);\n *\n * curried(3)(2)(1);\n * // => [1, 2, 3]\n *\n * curried(2, 3)(1);\n * // => [1, 2, 3]\n *\n * curried(1, 2, 3);\n * // => [1, 2, 3]\n *\n * // Curried with placeholders.\n * curried(3)(curryRight.placeholder, 2)(1);\n * // => [1, 2, 3]\n *\n * // Curried with arity.\n * curried = curryRight(abc, 2);\n *\n * curried(2)(1);\n * // => [1, 2]\n */\nexport function curryRight(\n func: (...args: any[]) => any,\n arity: number = func.length,\n guard?: unknown\n): ((...args: any[]) => any) & { placeholder: typeof curryRight.placeholder } {\n arity = guard ? func.length : arity;\n arity = Number.parseInt(arity as any, 10);\n if (Number.isNaN(arity) || arity < 1) {\n arity = 0;\n }\n\n const wrapper = function (this: any, ...partialArgs: any[]) {\n const holders = partialArgs.filter(item => item === curryRight.placeholder);\n const length = partialArgs.length - holders.length;\n if (length < arity) {\n return makeCurryRight(func, arity - length, partialArgs);\n }\n if (this instanceof wrapper) {\n // @ts-expect-error - fn is a constructor\n return new func(...partialArgs);\n }\n return func.apply(this, partialArgs);\n };\n\n wrapper.placeholder = curryRightPlaceholder;\n\n return wrapper;\n}\n\nfunction makeCurryRight(\n func: (...args: any[]) => any,\n arity: number,\n partialArgs: any[]\n): ((...args: any[]) => any) & { placeholder: typeof curryRight.placeholder } {\n function wrapper(this: any, ...providedArgs: any[]) {\n const holders = providedArgs.filter(item => item === curryRight.placeholder);\n const length = providedArgs.length - holders.length;\n providedArgs = composeArgs(providedArgs, partialArgs);\n if (length < arity) {\n return makeCurryRight(func, arity - length, providedArgs);\n }\n if (this instanceof wrapper) {\n // @ts-expect-error - fn is a constructor\n return new func(...providedArgs);\n }\n return func.apply(this, providedArgs);\n }\n wrapper.placeholder = curryRightPlaceholder;\n return wrapper;\n}\n\nfunction composeArgs(providedArgs: any[], partialArgs: any[]): any[] {\n const placeholderLength = partialArgs.filter(arg => arg === curryRight.placeholder).length;\n const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);\n const args: any[] = [];\n\n let providedIndex = 0;\n for (let i = 0; i < rangeLength; i++) {\n args.push(providedArgs[providedIndex++]);\n }\n for (let i = 0; i < partialArgs.length; i++) {\n const arg = partialArgs[i];\n\n if (arg === curryRight.placeholder) {\n if (providedIndex < providedArgs.length) {\n args.push(providedArgs[providedIndex++]);\n } else {\n args.push(arg);\n }\n } else {\n args.push(arg);\n }\n }\n return args;\n}\n\nconst curryRightPlaceholder: unique symbol = Symbol('curryRight.placeholder');\ncurryRight.placeholder = curryRightPlaceholder;\n","import { debounce as debounceToolkit } from '../../function/debounce.ts';\n\ninterface DebounceOptions {\n /**\n * An optional AbortSignal to cancel the debounced function.\n */\n signal?: AbortSignal;\n\n /**\n * If `true`, the function will be invoked on the leading edge of the timeout.\n * @default false\n */\n leading?: boolean;\n\n /**\n * If `true`, the function will be invoked on the trailing edge of the timeout.\n * @default true\n */\n trailing?: boolean;\n\n /**\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @default Infinity\n */\n maxWait?: number;\n}\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds\n * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`\n * method to cancel any pending execution.\n *\n * You can set the debounced function to run at the start (`leading`) or end (`trailing`) of the delay period.\n * If `leading` is true, the function runs immediately on the first call.\n * If `trailing` is true, the function runs after `debounceMs` milliseconds have passed since the last call.\n * If both `leading` and `trailing` are true, the function runs at both the start and end, but it must be called at least twice within `debounceMs` milliseconds for this to happen\n * (since one debounced function call cannot trigger the function twice).\n *\n * You can also set a `maxWait` time, which is the maximum time the function is allowed to be delayed before it is called.\n *\n * @template F - The type of function.\n * @param {F} func - The function to debounce.\n * @param {number} debounceMs - The number of milliseconds to delay.\n * @param {DebounceOptions} options - The options object\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.\n * @param {boolean} options.leading - If `true`, the function will be invoked on the leading edge of the timeout.\n * @param {boolean} options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout.\n * @param {number} options.maxWait - The maximum time `func` is allowed to be delayed before it's invoked.\n * @returns A new debounced function with a `cancel` method.\n *\n * @example\n * const debouncedFunction = debounce(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' after 1 second if not called again in that time\n * debouncedFunction();\n *\n * // Will not log anything as the previous call is canceled\n * debouncedFunction.cancel();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const signal = controller.signal;\n * const debouncedWithSignal = debounce(() => {\n * console.log('Function executed');\n * }, 1000, { signal });\n *\n * debouncedWithSignal();\n *\n * // Will cancel the debounced function call\n * controller.abort();\n */\nexport function debounce any>(\n func: F,\n debounceMs = 0,\n options: DebounceOptions = {}\n): ((...args: Parameters) => ReturnType | undefined) & {\n cancel: () => void;\n flush: () => void;\n} {\n if (typeof options !== 'object') {\n options = {};\n }\n\n const { signal, leading = false, trailing = true, maxWait } = options;\n\n const edges = Array(2);\n\n if (leading) {\n edges[0] = 'leading';\n }\n\n if (trailing) {\n edges[1] = 'trailing';\n }\n\n let result: ReturnType | undefined = undefined;\n let pendingAt: number | null = null;\n\n const _debounced = debounceToolkit(\n function (this: any, ...args: Parameters) {\n result = func.apply(this, args);\n pendingAt = null;\n },\n debounceMs,\n { signal, edges }\n );\n\n const debounced = function (this: any, ...args: Parameters) {\n if (maxWait != null) {\n if (pendingAt === null) {\n pendingAt = Date.now();\n } else {\n if (Date.now() - pendingAt >= maxWait) {\n result = func.apply(this, args);\n pendingAt = Date.now();\n\n _debounced.cancel();\n _debounced.schedule();\n\n return result;\n }\n }\n }\n\n _debounced.apply(this, args);\n return result;\n };\n\n const flush = () => {\n _debounced.flush();\n return result;\n };\n\n debounced.cancel = _debounced.cancel;\n debounced.flush = flush;\n\n return debounced;\n}\n","export function decimalAdjust(\n type: 'round' | 'floor' | 'ceil',\n number: number | string,\n precision: number | string = 0\n): number {\n number = Number(number);\n if (Object.is(number, -0)) {\n number = '-0';\n }\n precision = Math.min(Number.parseInt(precision as string, 10), 292);\n if (precision) {\n const [magnitude, exponent = 0] = number.toString().split('e');\n let adjustedValue: string | number = Math[type](Number(`${magnitude}e${Number(exponent) + precision}`));\n if (Object.is(adjustedValue, -0)) {\n adjustedValue = '-0';\n }\n const [newMagnitude, newExponent = 0] = adjustedValue.toString().split('e');\n return Number(`${newMagnitude}e${Number(newExponent) - precision}`);\n }\n return Math[type](Number(number));\n}\n","import { clamp as clampToolkit } from '../../math/clamp.ts';\n\n/**\n * Clamps a number within the inclusive upper bound.\n *\n * This function takes a number and a maximum bound, and returns the number clamped within the specified upper bound.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified upper bound.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n */\nexport function clamp(value: number, maximum: number): number;\n\n/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, minimum: number, maximum: number): number;\n\n/**\n * Clamps a number within the specified bounds.\n *\n * This function takes a number and one or two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} bound1 - The minimum bound to clamp the number, or the maximum bound if bound2 is not provided.\n * @param {number} [bound2] - The maximum bound to clamp the number. If not provided, the function will only consider bound1 as the upper limit.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (Number.isNaN(bound1)) {\n bound1 = 0;\n }\n\n if (Number.isNaN(bound2)) {\n bound2 = 0;\n }\n\n return clampToolkit(value, bound1, bound2!);\n}\n","/**\n * Clamps a number within the inclusive upper bound.\n *\n * This function takes a number and a maximum bound, and returns the number clamped within the specified upper bound.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified upper bound.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n */\nexport function clamp(value: number, maximum: number): number;\n\n/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, minimum: number, maximum: number): number;\n\n/**\n * Clamps a number within the specified bounds.\n *\n * This function takes a number and one or two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} bound1 - The minimum bound to clamp the number, or the maximum bound if bound2 is not provided.\n * @param {number} [bound2] - The maximum bound to clamp the number. If not provided, the function will only consider bound1 as the upper limit.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n\n return Math.min(Math.max(value, bound1), bound2);\n}\n","import { iteratee as iterateeToolkit } from '../util/iteratee';\n\n/**\n * Computes the sum of the `number` values in `array`.\n *\n * @param {ArrayLike | null | undefined} array - The array to iterate over.\n * @returns {number} Returns the sum.\n *\n * @example\n * sumBy([1, 2, 3]); // => 6\n * sumBy(null); // => 0\n * sumBy(undefined); // => 0\n */\nexport function sumBy(array: ArrayLike | null | undefined): number;\n\n/**\n * Computes the sum of the `bigint` values in `array`.\n *\n * @param {ArrayLike} array - The array to iterate over.\n * @returns {bigint} Returns the sum.\n *\n * @example\n * sumBy([1n, 2n, 3n]); // => 6n\n */\nexport function sumBy(array: ArrayLike): bigint;\n/**\n * Computes the sum of the values in `array`.\n *\n * It does not coerce values to `number`.\n *\n * @param {ArrayLike | null | undefined} array - The array to iterate over.\n * @returns {unknown} Returns the sum.\n *\n * @example\n * sumBy([\"1\", \"2\"]); // => \"12\"\n * sumBy([1, undefined, 2]); // => 3\n */\nexport function sumBy(array: ArrayLike | null | undefined): unknown;\n\n/**\n * Compmutes the sum of the `number` values that are returned by the `iteratee` function.\n *\n * @template T - The type of the array elements.\n * @param {ArrayLike} array - The array to iterate over.\n * @param {(value: T) => number} iteratee - The function invoked per iteration.\n * @returns {number} Returns the sum.\n *\n * @example\n * sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], object => object.a); // => 6\n */\nexport function sumBy(array: ArrayLike, iteratee: (value: T) => number): number;\n\n/**\n * Compmutes the sum of the `bigint` values that are returned by the `iteratee` function.\n *\n * NOTE: If the `array` is empty, the function returns `0`.\n *\n * @template T - The type of the array elements.\n * @param {ArrayLike} array - The array to iterate over.\n * @param {(value: T) => bigint} iteratee - The function invoked per iteration.\n * @returns {bigint | number} Returns the sum.\n *\n * @example\n * sumBy([{ a: 1n }, { a: 2n }, { a: 3n }], object => object.a); // => 6n\n * sumBy([], (item: { a: bigint }) => item.a); // => 0\n */\nexport function sumBy(array: ArrayLike, iteratee: (value: T) => bigint): bigint | number;\n\n/**\n * Compmutes the sum of the values that are returned by the `iteratee` function.\n *\n * It does not coerce values to `number`.\n *\n * @template T - The type of the array elements.\n * @param {ArrayLike | null | undefined} array - The array to iterate over.\n * @param {(value: T) => number | bigint} iteratee - The function invoked per iteration.\n * @returns {unknown} Returns the sum.\n *\n * @example\n * sumBy([1, undefined, 2], value => value); // => 3\n * sumBy(null); // => 0\n * sumBy(undefined); // => 0\n * sumBy([1, 2, 3]); // => 6\n * sumBy([1n, 2n, 3n]); // => 6n\n * sumBy([{ a: \"1\" }, { a: \"2\" }], object => object.a); // => \"12\"\n */\nexport function sumBy(array: ArrayLike | null | undefined, iteratee?: (value: T) => number | bigint): unknown {\n if (!array || !array.length) {\n return 0;\n }\n\n if (iteratee != null) {\n iteratee = iterateeToolkit(iteratee);\n }\n\n let result: any = iteratee ? iteratee(array[0]) : array[0];\n\n for (let i = 1; i < array.length; i++) {\n const current = iteratee ? iteratee(array[i]) : array[i];\n\n if (current !== undefined) {\n result += current;\n }\n }\n\n return result;\n}\n","import { eq } from '../util/eq.ts';\n\n/**\n * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.\n * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.\n *\n * You can pass in multiple objects to define these default values,\n * and they will be applied in order from left to right.\n * Once a property has been assigned a value, any subsequent values for that property will be ignored.\n *\n * Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead.\n *\n * @template T - The type of the object being processed.\n * @param {T} object - The target object.\n * @returns {T} The object itself.\n */\nexport function defaults(object: T): NonNullable;\n\n/**\n * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.\n * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.\n *\n * You can pass in multiple objects to define these default values,\n * and they will be applied in order from left to right.\n * Once a property has been assigned a value, any subsequent values for that property will be ignored.\n *\n * Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead.\n *\n * @template T - The type of the object being processed.\n * @template S - The type of the object that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S} source - The object that specifies the default values to apply.\n * @returns {NonNullable} The `object` that has been updated with default values from `source`, ensuring that all properties are defined and none are left as `undefined`.\n */\nexport function defaults(object: T, source: S): NonNullable;\n\n/**\n * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.\n * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.\n *\n * You can pass in multiple objects to define these default values,\n * and they will be applied in order from left to right.\n * Once a property has been assigned a value, any subsequent values for that property will be ignored.\n *\n * Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead.\n *\n * @template T - The type of the object being processed.\n * @template S1 - The type of the first object that provides default values.\n * @template S2 - The type of the second object that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S1} source1 - The first object that specifies the default values to apply.\n * @param {S2} source2 - The second object that specifies the default values to apply.\n * @returns {NonNullable} The `object` that has been updated with default values from `source1` and `source2`, ensuring that all properties are defined and none are left as `undefined`.\n */\nexport function defaults(\n object: T,\n source1: S1,\n source2: S2\n): NonNullable;\n\n/**\n * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.\n * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.\n *\n * You can pass in multiple objects to define these default values,\n * and they will be applied in order from left to right.\n * Once a property has been assigned a value, any subsequent values for that property will be ignored.\n *\n * Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead.\n *\n * @template T - The type of the object being processed.\n * @template S1 - The type of the first object that provides default values.\n * @template S2 - The type of the second object that provides default values.\n * @template S3 - The type of the third object that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S1} source1 - The first object that specifies the default values to apply.\n * @param {S2} source2 - The second object that specifies the default values to apply.\n * @param {S3} source3 - The third object that specifies the default values to apply.\n * @returns {NonNullable} The `object` that has been updated with default values from `source1`, `source2`, and `source3`, ensuring that all properties are defined and none are left as `undefined`.\n */\nexport function defaults(\n object: T,\n source1: S1,\n source2: S2,\n source3: S3\n): NonNullable;\n/**\n * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.\n * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.\n *\n * You can pass in multiple objects to define these default values,\n * and they will be applied in order from left to right.\n * Once a property has been assigned a value, any subsequent values for that property will be ignored.\n *\n * Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead.\n *\n * @template T - The type of the object being processed.\n * @template S1 - The type of the first object that provides default values.\n * @template S2 - The type of the second object that provides default values.\n * @template S3 - The type of the third object that provides default values.\n * @template S4 - The type of the fourth object that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S1} source1 - The first object that specifies the default values to apply.\n * @param {S2} source2 - The second object that specifies the default values to apply.\n * @param {S3} source3 - The third object that specifies the default values to apply.\n * @param {S4} source4 - The fourth object that specifies the default values to apply.\n * @returns {NonNullable} The `object` that has been updated with default values from `source1`, `source2`, `source3`, and `source4`, ensuring that all properties are defined and none are left as `undefined`.\n */\nexport function defaults(\n object: T,\n source1: S1,\n source2: S2,\n source3: S3,\n source4: S4\n): NonNullable;\n\n/**\n * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.\n * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.\n *\n * You can pass in multiple objects to define these default values,\n * and they will be applied in order from left to right.\n * Once a property has been assigned a value, any subsequent values for that property will be ignored.\n *\n * Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead.\n *\n * @template T - The type of the object being processed.\n * @template S - The type of the objects that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S[]} source - The objects that specifies the default values to apply.\n * @returns {object} The `object` that has been updated with default values from `sources`, ensuring that all properties are defined and none are left as `undefined`.\n *\n * @example\n * defaults({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 }\n * defaults({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 }\n * defaults({ a: null }, { a: 1 }); // { a: null }\n * defaults({ a: undefined }, { a: 1 }); // { a: 1 }\n */\nexport function defaults(object: T, ...sources: S[]): object;\n\n/**\n * Assigns default values to an `object`, ensuring that certain properties do not remain `undefined`.\n * It sets default values for properties that are either `undefined` or inherited from `Object.prototype`.\n *\n * You can pass in multiple objects to define these default values,\n * and they will be applied in order from left to right.\n * Once a property has been assigned a value, any subsequent values for that property will be ignored.\n *\n * Note: This function modifies the first argument, `object`. If you want to keep `object` unchanged, consider using `toDefaulted` instead.\n *\n * @template T - The type of the object being processed.\n * @template S - The type of the objects that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S[]} source - The objects that specifies the default values to apply.\n * @returns {object} The `object` that has been updated with default values from `sources`, ensuring that all properties are defined and none are left as `undefined`.\n *\n * @example\n * defaults({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 }\n * defaults({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 }\n * defaults({ a: null }, { a: 1 }); // { a: null }\n * defaults({ a: undefined }, { a: 1 }); // { a: 1 }\n */\nexport function defaults(object: T, ...sources: S[]): object {\n object = Object(object);\n const objectProto = Object.prototype;\n\n for (let i = 0; i < sources.length; i++) {\n const source = sources[i];\n const keys = Object.keys(source) as Array;\n\n for (let j = 0; j < keys.length; j++) {\n const key = keys[j];\n const value = (object as any)[key];\n\n if (\n value === undefined ||\n (!Object.hasOwn(object, key) && eq(value, objectProto[key as keyof typeof objectProto]))\n ) {\n (object as any)[key] = source[key];\n }\n }\n }\n\n return object;\n}\n","/**\n * Checks if a given value is a plain object.\n *\n * A plain object is an object created by the `{}` literal, `new Object()`, or\n * `Object.create(null)`.\n *\n * This function also handles objects with custom\n * `Symbol.toStringTag` properties.\n *\n * `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the\n * default string description of objects.\n *\n * @param {unknown} [object] - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n *\n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(isPlainObject(new Map())); // false\n */\nexport function isPlainObject(object?: unknown): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (Object.prototype.toString.call(object) !== '[object Object]') {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const tag = object[Symbol.toStringTag];\n\n if (tag == null) {\n return false;\n }\n\n const isTagReadonly = !Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable;\n\n if (isTagReadonly) {\n return false;\n }\n\n return object.toString() === `[object ${tag}]`;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}\n","import { isTypedArray as isTypedArrayToolkit } from '../../predicate/isTypedArray.ts';\n\n/**\n * Checks if a value is a TypedArray.\n * @param {unknown} x The value to check.\n * @returns {x is\n * Uint8Array\n * | Uint8ClampedArray\n * | Uint16Array\n * | Uint32Array\n * | BigUint64Array\n * | Int8Array\n * | Int16Array\n * | Int32Array\n * | BigInt64Array\n * | Float32Array\n * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.\n *\n * @example\n * const arr = new Uint8Array([1, 2, 3]);\n * isTypedArray(arr); // true\n *\n * const regularArray = [1, 2, 3];\n * isTypedArray(regularArray); // false\n *\n * const buffer = new ArrayBuffer(16);\n * isTypedArray(buffer); // false\n */\nexport function isTypedArray(\n x?: unknown\n): x is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return isTypedArrayToolkit(x);\n}\n","import { cloneDeep } from './cloneDeep.ts';\nimport { clone } from '../../object/clone.ts';\nimport { getSymbols } from '../_internal/getSymbols.ts';\nimport { isArguments } from '../predicate/isArguments.ts';\nimport { isObjectLike } from '../predicate/isObjectLike.ts';\nimport { isPlainObject } from '../predicate/isPlainObject.ts';\nimport { isTypedArray } from '../predicate/isTypedArray.ts';\n\ndeclare let Buffer:\n | {\n isBuffer: (a: any) => boolean;\n }\n | undefined;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * You can provide a custom `merge` function to control how properties are merged. The `merge` function is called for each property that is being merged and receives the following arguments:\n *\n * - `targetValue`: The current value of the property in the target object.\n * - `sourceValue`: The value of the property in the source object.\n * - `key`: The key of the property being merged.\n * - `target`: The target object.\n * - `source`: The source object.\n * - `stack`: A `Map` used to keep track of objects that have already been processed to handle circular references.\n *\n * The `merge` function should return the value to be set in the target object. If it returns `undefined`, a default deep merge will be applied for arrays and objects.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {T} target - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S} source - The first source object whose properties will be merged into the target object.\n * @param {(targetValue: any, sourceValue: any, key: string, target: T, source: S, stack: Map) => any} merge - The function to customize merging properties.\n * @returns {T & S} The updated target object with properties from the source object(s) merged in.\n *\n * @template T - Type of the target object.\n * @template S - Type of the first source object.\n *\n * @example\n * const target = { a: 1, b: 2 };\n * const source = { b: 3, c: 4 };\n *\n * mergeWith(target, source, (targetValue, sourceValue) => {\n * if (typeof targetValue === 'number' && typeof sourceValue === 'number') {\n * return targetValue + sourceValue;\n * }\n * });\n * // Returns { a: 1, b: 5, c: 4 }\n * @example\n * const target = { a: [1], b: [2] };\n * const source = { a: [3], b: [4] };\n *\n * const result = mergeWith(target, source, (objValue, srcValue) => {\n * if (Array.isArray(objValue)) {\n * return objValue.concat(srcValue);\n * }\n * });\n *\n * expect(result).toEqual({ a: [1, 3], b: [2, 4] });\n */\nexport function mergeWith(\n target: T,\n source: S,\n merge: (targetValue: any, sourceValue: any, key: string, target: T, source: S, stack: Map) => any\n): T & S;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * You can provide a custom `merge` function to control how properties are merged. The `merge` function is called for each property that is being merged and receives the following arguments:\n *\n * - `targetValue`: The current value of the property in the target object.\n * - `sourceValue`: The value of the property in the source object.\n * - `key`: The key of the property being merged.\n * - `target`: The target object.\n * - `source`: The source object.\n * - `stack`: A `Map` used to keep track of objects that have already been processed to handle circular references.\n *\n * The `merge` function should return the value to be set in the target object. If it returns `undefined`, a default deep merge will be applied for arrays and objects.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {O} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S1} source1 - The first source object to be merged into the target object.\n * @param {S2} source2 - The second source object to be merged into the target object.\n * @param {(targetValue: any, sourceValue: any, key: string, target: any, source: any, stack: Map) => any} merge - The function to customize merging properties.\n * @returns {O & S1 & S2} The updated target object with properties from the source objects merged in.\n *\n * @template O - Type of the target object.\n * @template S1 - Type of the first source object.\n * @template S2 - Type of the second source object.\n *\n * @example\n * const target = { a: 1, b: 2 };\n * const source = { b: 3, c: 4 };\n *\n * mergeWith(target, source, (targetValue, sourceValue) => {\n * if (typeof targetValue === 'number' && typeof sourceValue === 'number') {\n * return targetValue + sourceValue;\n * }\n * });\n * // Returns { a: 1, b: 5, c: 4 }\n * @example\n * const target = { a: [1], b: [2] };\n * const source = { a: [3], b: [4] };\n *\n * const result = mergeWith(target, source, (objValue, srcValue) => {\n * if (Array.isArray(objValue)) {\n * return objValue.concat(srcValue);\n * }\n * });\n *\n * expect(result).toEqual({ a: [1, 3], b: [2, 4] });\n */\nexport function mergeWith(\n object: O,\n source1: S1,\n source2: S2,\n merge: (targetValue: any, sourceValue: any, key: string, target: any, source: any, stack: Map) => any\n): O & S1 & S2;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * You can provide a custom `merge` function to control how properties are merged. The `merge` function is called for each property that is being merged and receives the following arguments:\n *\n * - `targetValue`: The current value of the property in the target object.\n * - `sourceValue`: The value of the property in the source object.\n * - `key`: The key of the property being merged.\n * - `target`: The target object.\n * - `source`: The source object.\n * - `stack`: A `Map` used to keep track of objects that have already been processed to handle circular references.\n *\n * The `merge` function should return the value to be set in the target object. If it returns `undefined`, a default deep merge will be applied for arrays and objects.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {O} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S1} source1 - The first source object whose properties will be merged into the target object.\n * @param {S2} source2 - The second source object whose properties will be merged into the target object.\n * @param {S3} source3 - The third source object whose properties will be merged into the target object.\n * @param {(targetValue: any, sourceValue: any, key: string, target: any, source: any, stack: Map) => any} merge - The function to customize merging properties.\n * @returns {O & S1 & S2 & S3} The updated target object with properties from the source object(s) merged in.\n *\n * @template O - Type of the target object.\n * @template S1 - Type of the first source object.\n * @template S2 - Type of the second source object.\n * @template S3 - Type of the third source object.\n *\n * @example\n * const target = { a: 1, b: 2 };\n * const source = { b: 3, c: 4 };\n *\n * mergeWith(target, source, (targetValue, sourceValue) => {\n * if (typeof targetValue === 'number' && typeof sourceValue === 'number') {\n * return targetValue + sourceValue;\n * }\n * });\n * // Returns { a: 1, b: 5, c: 4 }\n * @example\n * const target = { a: [1], b: [2] };\n * const source = { a: [3], b: [4] };\n *\n * const result = mergeWith(target, source, (objValue, srcValue) => {\n * if (Array.isArray(objValue)) {\n * return objValue.concat(srcValue);\n * }\n * });\n *\n * expect(result).toEqual({ a: [1, 3], b: [2, 4] });\n */\nexport function mergeWith(\n object: O,\n source1: S1,\n source2: S2,\n source3: S3,\n merge: (targetValue: any, sourceValue: any, key: string, target: any, source: any, stack: Map) => any\n): O & S1 & S2 & S3;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * You can provide a custom `merge` function to control how properties are merged. The `merge` function is called for each property that is being merged and receives the following arguments:\n *\n * - `targetValue`: The current value of the property in the target object.\n * - `sourceValue`: The value of the property in the source object.\n * - `key`: The key of the property being merged.\n * - `target`: The target object.\n * - `source`: The source object.\n * - `stack`: A `Map` used to keep track of objects that have already been processed to handle circular references.\n *\n * The `merge` function should return the value to be set in the target object. If it returns `undefined`, a default deep merge will be applied for arrays and objects.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {O} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S1} source1 - The first source object whose properties will be merged into the target object.\n * @param {S2} source2 - The second source object whose properties will be merged into the target object.\n * @param {S3} source3 - The third source object whose properties will be merged into the target object.\n * @param {S4} source4 - The fourth source object whose properties will be merged into the target object.\n * @param {(targetValue: any, sourceValue: any, key: string, target: any, source: any, stack: Map) => any} merge - The function to customize merging properties.\n * @returns {O & S1 & S2 & S3 & S4} The updated target object with properties from the source object(s) merged in.\n *\n * @template O - Type of the target object.\n * @template S1 - Type of the first source object.\n * @template S2 - Type of the second source object.\n * @template S3 - Type of the third source object.\n * @template S4 - Type of the fourth source object.\n *\n * @example\n * const target = { a: 1, b: 2 };\n * const source = { b: 3, c: 4 };\n *\n * mergeWith(target, source, (targetValue, sourceValue) => {\n * if (typeof targetValue === 'number' && typeof sourceValue === 'number') {\n * return targetValue + sourceValue;\n * }\n * });\n * // Returns { a: 1, b: 5, c: 4 }\n * @example\n * const target = { a: [1], b: [2] };\n * const source = { a: [3], b: [4] };\n *\n * const result = mergeWith(target, source, (objValue, srcValue) => {\n * if (Array.isArray(objValue)) {\n * return objValue.concat(srcValue);\n * }\n * });\n *\n * expect(result).toEqual({ a: [1, 3], b: [2, 4] });\n */\nexport function mergeWith(\n object: O,\n source1: S1,\n source2: S2,\n source3: S3,\n source4: S4,\n merge: (targetValue: any, sourceValue: any, key: string, target: any, source: any, stack: Map) => any\n): O & S1 & S2 & S3;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * You can provide a custom `merge` function to control how properties are merged. The `merge` function is called for each property that is being merged and receives the following arguments:\n *\n * - `targetValue`: The current value of the property in the target object.\n * - `sourceValue`: The value of the property in the source object.\n * - `key`: The key of the property being merged.\n * - `target`: The target object.\n * - `source`: The source object.\n * - `stack`: A `Map` used to keep track of objects that have already been processed to handle circular references.\n *\n * The `merge` function should return the value to be set in the target object. If it returns `undefined`, a default deep merge will be applied for arrays and objects.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {any} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {any[]} sources - The source objects whose properties will be merged into the target object.\n * @param {...any} otherArgs - Additional source objects to merge into the target object, including the custom `merge` function.\n * @returns {any} The updated target object with properties from the source object(s) merged in.\n *\n * @example\n * const target = { a: 1, b: 2 };\n * const source = { b: 3, c: 4 };\n *\n * mergeWith(target, source, (targetValue, sourceValue) => {\n * if (typeof targetValue === 'number' && typeof sourceValue === 'number') {\n * return targetValue + sourceValue;\n * }\n * });\n * // Returns { a: 1, b: 5, c: 4 }\n * @example\n * const target = { a: [1], b: [2] };\n * const source = { a: [3], b: [4] };\n *\n * const result = mergeWith(target, source, (objValue, srcValue) => {\n * if (Array.isArray(objValue)) {\n * return objValue.concat(srcValue);\n * }\n * });\n *\n * expect(result).toEqual({ a: [1, 3], b: [2, 4] });\n */\nexport function mergeWith(object: any, ...otherArgs: any[]): any;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * You can provide a custom `merge` function to control how properties are merged. The `merge` function is called for each property that is being merged and receives the following arguments:\n *\n * - `targetValue`: The current value of the property in the target object.\n * - `sourceValue`: The value of the property in the source object.\n * - `key`: The key of the property being merged.\n * - `target`: The target object.\n * - `source`: The source object.\n * - `stack`: A `Map` used to keep track of objects that have already been processed to handle circular references.\n *\n * The `merge` function should return the value to be set in the target object. If it returns `undefined`, a default deep merge will be applied for arrays and objects.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {any} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {any[]} sources - The source objects whose properties will be merged into the target object.\n * @param {...any} otherArgs - Additional source objects to merge into the target object, including the custom `merge` function.\n * @returns {any} The updated target object with properties from the source object(s) merged in.\n *\n * @example\n * const target = { a: 1, b: 2 };\n * const source = { b: 3, c: 4 };\n *\n * mergeWith(target, source, (targetValue, sourceValue) => {\n * if (typeof targetValue === 'number' && typeof sourceValue === 'number') {\n * return targetValue + sourceValue;\n * }\n * });\n * // Returns { a: 1, b: 5, c: 4 }\n * @example\n * const target = { a: [1], b: [2] };\n * const source = { a: [3], b: [4] };\n *\n * const result = mergeWith(target, source, (objValue, srcValue) => {\n * if (Array.isArray(objValue)) {\n * return objValue.concat(srcValue);\n * }\n * });\n *\n * expect(result).toEqual({ a: [1, 3], b: [2, 4] });\n */\nexport function mergeWith(object: any, ...otherArgs: any[]): any {\n const sources = otherArgs.slice(0, -1);\n const merge = otherArgs[otherArgs.length - 1] as (\n targetValue: any,\n sourceValue: any,\n key: string | symbol,\n target: any,\n source: any,\n stack: Map\n ) => any;\n\n let result = object;\n\n for (let i = 0; i < sources.length; i++) {\n const source = sources[i];\n\n result = mergeWithDeep(object, source, merge, new Map());\n }\n\n return result;\n}\n\nfunction mergeWithDeep(\n target: any,\n source: any,\n merge: (\n targetValue: any,\n sourceValue: any,\n key: string | symbol,\n target: any,\n source: any,\n stack: Map\n ) => any,\n stack: Map\n) {\n if (source == null || typeof source !== 'object') {\n return target;\n }\n\n if (stack.has(source)) {\n return clone(stack.get(source));\n }\n\n stack.set(source, target);\n\n if (Array.isArray(source)) {\n source = source.slice();\n for (let i = 0; i < source.length; i++) {\n source[i] = source[i] ?? undefined;\n }\n }\n\n const sourceKeys = [...Object.keys(source), ...getSymbols(source)];\n\n for (let i = 0; i < sourceKeys.length; i++) {\n const key = sourceKeys[i];\n\n let sourceValue = source[key];\n let targetValue = target[key];\n\n if (isArguments(sourceValue)) {\n sourceValue = { ...sourceValue };\n }\n\n if (isArguments(targetValue)) {\n targetValue = { ...targetValue };\n }\n\n if (typeof Buffer !== 'undefined' && Buffer.isBuffer(sourceValue)) {\n sourceValue = cloneDeep(sourceValue);\n }\n\n if (Array.isArray(sourceValue)) {\n if (typeof targetValue === 'object') {\n const cloned: any = [];\n const targetKeys = Reflect.ownKeys(targetValue);\n\n for (let i = 0; i < targetKeys.length; i++) {\n const targetKey = targetKeys[i];\n cloned[targetKey] = targetValue[targetKey];\n }\n\n targetValue = cloned;\n } else {\n targetValue = [];\n }\n }\n\n const merged = merge(targetValue, sourceValue, key, target, source, stack);\n\n if (merged != null) {\n target[key] = merged;\n } else if (Array.isArray(sourceValue)) {\n target[key] = mergeWithDeep(targetValue, sourceValue, merge, stack);\n } else if (isObjectLike(targetValue) && isObjectLike(sourceValue)) {\n target[key] = mergeWithDeep(targetValue, sourceValue, merge, stack);\n } else if (targetValue == null && isPlainObject(sourceValue)) {\n target[key] = mergeWithDeep({}, sourceValue, merge, stack);\n } else if (targetValue == null && isTypedArray(sourceValue)) {\n target[key] = cloneDeep(sourceValue);\n } else if (targetValue === undefined || sourceValue !== undefined) {\n target[key] = sourceValue;\n }\n }\n\n return target;\n}\n","import { get } from './get.ts';\nimport { isDeepKey } from '../_internal/isDeepKey.ts';\nimport { toKey } from '../_internal/toKey.ts';\nimport { toPath } from '../util/toPath.ts';\n\n/**\n * Removes the property at the given path of the object.\n *\n * @param {unknown} obj - The object to modify.\n * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to unset.\n * @returns {boolean} - Returns true if the property is deleted, else false.\n *\n * @example\n * const obj = { a: { b: { c: 42 } } };\n * unset(obj, 'a.b.c'); // true\n * console.log(obj); // { a: { b: {} } }\n *\n * @example\n * const obj = { a: { b: { c: 42 } } };\n * unset(obj, ['a', 'b', 'c']); // true\n * console.log(obj); // { a: { b: {} } }\n */\nexport function unset(obj: any, path: PropertyKey | readonly PropertyKey[]): boolean {\n if (obj == null) {\n return true;\n }\n\n switch (typeof path) {\n case 'symbol':\n case 'number':\n case 'object': {\n if (Array.isArray(path)) {\n return unsetWithPath(obj, path);\n }\n\n if (typeof path === 'number') {\n path = toKey(path);\n } else if (typeof path === 'object') {\n if (Object.is(path?.valueOf(), -0)) {\n path = '-0';\n } else {\n path = String(path);\n }\n }\n\n if (obj?.[path] === undefined) {\n return true;\n }\n\n try {\n delete obj[path];\n return true;\n } catch {\n return false;\n }\n }\n case 'string': {\n if (obj?.[path] === undefined && isDeepKey(path)) {\n return unsetWithPath(obj, toPath(path));\n }\n\n try {\n delete obj[path];\n return true;\n } catch {\n return false;\n }\n }\n }\n}\n\nfunction unsetWithPath(obj: unknown, path: readonly PropertyKey[]): boolean {\n const parent = get(obj, path.slice(0, -1), obj);\n const lastKey = path[path.length - 1];\n\n if (parent?.[lastKey] === undefined) {\n return true;\n }\n\n try {\n delete parent[lastKey];\n return true;\n } catch {\n return false;\n }\n}\n","/**\n * Checks if a given value is null or undefined.\n *\n * This function tests whether the provided value is either `null` or `undefined`.\n * It returns `true` if the value is `null` or `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null` or `undefined`.\n *\n * @param {unknown} x - The value to test for null or undefined.\n * @returns {boolean} `true` if the value is null or undefined, `false` otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n * const result1 = isNil(value1); // true\n * const result2 = isNil(value2); // true\n * const result3 = isNil(value3); // false\n */\nexport function isNil(x?: unknown): x is null | undefined {\n return x == null;\n}\n","/**\n * Checks if `object` conforms to `source` by invoking the predicate properties of `source` with the corresponding property values of `object`.\n *\n * Note: This method is equivalent to `conforms` when source is partially applied.\n *\n * @param {Record} target The object to inspect.\n * @param {Record boolean>} source The object of property predicates to conform to.\n * @returns {boolean} Returns `true` if `object` conforms, else `false`.\n *\n * @example\n *\n * const object = { 'a': 1, 'b': 2 };\n * const source = {\n * 'a': (n) => n > 0,\n * 'b': (n) => n > 1\n * };\n *\n * console.log(conformsTo(object, source)); // => true\n *\n * const source2 = {\n * 'a': (n) => n > 1,\n * 'b': (n) => n > 1\n * };\n *\n * console.log(conformsTo(object, source2)); // => false\n */\nexport function conformsTo(\n target: Record,\n source: Record boolean>\n): boolean {\n if (source == null) {\n return true;\n }\n\n if (target == null) {\n return Object.keys(source).length === 0;\n }\n\n const keys = Object.keys(source);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const predicate = source[key];\n const value = target[key];\n if ((value === undefined && !(key in target)) || !predicate(value)) {\n return false;\n }\n }\n return true;\n}\n","/**\n * Converts `value` to a string.\n *\n * An empty string is returned for `null` and `undefined` values.\n * The sign of `-0` is preserved.\n *\n * @param {unknown} value - The value to convert.\n * @returns {string} Returns the converted string.\n *\n * @example\n * toString(null) // returns ''\n * toString(undefined) // returns ''\n * toString(-0) // returns '-0'\n * toString([1, 2, -0]) // returns '1,2,-0'\n * toString([Symbol('a'), Symbol('b')]) // returns 'Symbol(a),Symbol(b)'\n */\nexport function toString(value?: unknown): string {\n if (value == null) {\n return '';\n }\n\n if (Array.isArray(value)) {\n return value.map(toString).join(',');\n }\n\n const result = String(value);\n\n if (result === '0' && Object.is(Number(value), -0)) {\n return '-0';\n }\n\n return result;\n}\n","import { toString } from '../util/toString.ts';\n\nexport function normalizeForCase(str: unknown): string {\n // Coerce to string\n if (typeof str !== 'string') {\n str = toString(str);\n }\n\n // Remove contraction apostrophes\n return (str as string).replace(/['\\u2019]/g, '');\n}\n","import { escape as escapeToolkit } from '../../string/escape.ts';\nimport { toString } from '../util/toString.ts';\n\n/**\n * Converts the characters \"&\", \"<\", \">\", '\"', and \"'\" in `str` to their corresponding HTML entities.\n * For example, \"<\" becomes \"<\".\n *\n * @param {string} str The string to escape.\n * @returns {string} Returns the escaped string.\n *\n * @example\n * escape('This is a
element.'); // returns 'This is a <div> element.'\n * escape('This is a \"quote\"'); // returns 'This is a "quote"'\n * escape(\"This is a 'quote'\"); // returns 'This is a 'quote''\n * escape('This is a & symbol'); // returns 'This is a & symbol'\n */\nexport function escape(string?: string): string {\n return escapeToolkit(toString(string));\n}\n","import { escape } from './escape.ts';\nimport { attempt } from '../function/attempt.ts';\nimport { defaults } from '../object/defaults.ts';\nimport { toString } from '../util/toString.ts';\n\n// A regular expression for matching literal string in ES template string.\nconst esTemplateRegExp = /\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g;\n\n// A regular expression for matching unescaped characters in string.\nconst unEscapedRegExp = /['\\n\\r\\u2028\\u2029\\\\]/g;\n\n// A regular expression for matching no match.\nconst noMatchExp = /($^)/;\n\nconst escapeMap = new Map([\n ['\\\\', '\\\\'],\n [\"'\", \"'\"],\n ['\\n', 'n'],\n ['\\r', 'r'],\n ['\\u2028', 'u2028'],\n ['\\u2029', 'u2029'],\n]);\n\nfunction escapeString(match: string): string {\n return `\\\\${escapeMap.get(match)}`;\n}\n\n// Only import the necessary functions for preventing circular dependencies.(lodash-es also does this)\nexport const templateSettings = {\n escape: /<%-([\\s\\S]+?)%>/g,\n evaluate: /<%([\\s\\S]+?)%>/g,\n interpolate: /<%=([\\s\\S]+?)%>/g,\n variable: '',\n imports: {\n _: {\n escape,\n template,\n },\n },\n};\n\ninterface TemplateOptions {\n escape?: RegExp;\n evaluate?: RegExp;\n interpolate?: RegExp;\n variable?: string;\n imports?: Record;\n sourceURL?: string;\n}\n\n/**\n * Compiles a template string into a function that can interpolate data properties.\n *\n * This function allows you to create a template with custom delimiters for escaping,\n * evaluating, and interpolating values. It can also handle custom variable names and\n * imported functions.\n *\n * @param {string} string - The template string.\n * @param {TemplateOptions} [options] - The options object.\n * @param {RegExp} [options.escape] - The regular expression for \"escape\" delimiter.\n * @param {RegExp} [options.evaluate] - The regular expression for \"evaluate\" delimiter.\n * @param {RegExp} [options.interpolate] - The regular expression for \"interpolate\" delimiter.\n * @param {string} [options.variable] - The data object variable name.\n * @param {Record} [options.imports] - The object of imported functions.\n * @param {string} [options.sourceURL] - The source URL of the template.\n * @param {unknown} [guard] - The guard to detect if the function is called with `options`.\n * @returns {(data?: object) => string} Returns the compiled template function.\n *\n * @example\n * // Use the \"escape\" delimiter to escape data properties.\n * const compiled = template('<%- value %>');\n * compiled({ value: '
' }); // returns '<div>'\n *\n * @example\n * // Use the \"interpolate\" delimiter to interpolate data properties.\n * const compiled = template('<%= value %>');\n * compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'\n *\n * @example\n * // Use the \"evaluate\" delimiter to evaluate JavaScript code.\n * const compiled = template('<% if (value) { %>Yes<% } else { %>No<% } %>');\n * compiled({ value: true }); // returns 'Yes'\n *\n * @example\n * // Use the \"variable\" option to specify the data object variable name.\n * const compiled = template('<%= data.value %>', { variable: 'data' });\n * compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'\n *\n * @example\n * // Use the \"imports\" option to import functions.\n * const compiled = template('<%= _.toUpper(value) %>', { imports: { _: { toUpper } } });\n * compiled({ value: 'hello, world!' }); // returns 'HELLO, WORLD!'\n *\n * @example\n * // Use the custom \"escape\" delimiter.\n * const compiled = template('<@ value @>', { escape: /<@([\\s\\S]+?)@>/g });\n * compiled({ value: '
' }); // returns '<div>'\n *\n * @example\n * // Use the custom \"evaluate\" delimiter.\n * const compiled = template('<# if (value) { #>Yes<# } else { #>No<# } #>', { evaluate: /<#([\\s\\S]+?)#>/g });\n * compiled({ value: true }); // returns 'Yes'\n *\n * @example\n * // Use the custom \"interpolate\" delimiter.\n * const compiled = template('<$ value $>', { interpolate: /<\\$([\\s\\S]+?)\\$>/g });\n * compiled({ value: 'Hello, World!' }); // returns 'Hello, World!'\n *\n * @example\n * // Use the \"sourceURL\" option to specify the source URL of the template.\n * const compiled = template('hello <%= user %>!', { sourceURL: 'template.js' });\n */\nexport function template(\n string: string,\n options?: TemplateOptions,\n guard?: unknown\n): ((data?: object) => string) & { source: string } {\n string = toString(string);\n\n if (guard) {\n options = templateSettings;\n }\n\n options = defaults({ ...options }, templateSettings);\n\n const delimitersRegExp = new RegExp(\n [\n options.escape?.source ?? noMatchExp.source,\n options.interpolate?.source ?? noMatchExp.source,\n options.interpolate ? esTemplateRegExp.source : noMatchExp.source,\n options.evaluate?.source ?? noMatchExp.source,\n '$',\n ].join('|'),\n 'g'\n );\n\n let lastIndex = 0;\n let isEvaluated = false;\n let source = `__p += ''`;\n\n for (const match of string.matchAll(delimitersRegExp)) {\n const [fullMatch, escapeValue, interpolateValue, esTemplateValue, evaluateValue] = match;\n const { index } = match;\n\n source += ` + '${string.slice(lastIndex, index).replace(unEscapedRegExp, escapeString)}'`;\n\n if (escapeValue) {\n source += ` + _.escape(${escapeValue})`;\n }\n\n if (interpolateValue) {\n source += ` + ((${interpolateValue}) == null ? '' : ${interpolateValue})`;\n } else if (esTemplateValue) {\n source += ` + ((${esTemplateValue}) == null ? '' : ${esTemplateValue})`;\n }\n\n if (evaluateValue) {\n source += `;\\n${evaluateValue};\\n __p += ''`;\n isEvaluated = true;\n }\n\n lastIndex = index + fullMatch.length;\n }\n\n const imports = defaults({ ...options.imports }, templateSettings.imports);\n const importsKeys = Object.keys(imports);\n const importValues = Object.values(imports);\n\n const sourceURL = `//# sourceURL=${\n options.sourceURL ? String(options.sourceURL).replace(/[\\r\\n]/g, ' ') : `es-toolkit.templateSource[${Date.now()}]`\n }\\n`;\n\n const compiledFunction = `function(${options.variable || 'obj'}) {\n let __p = '';\n ${options.variable ? '' : 'if (obj == null) { obj = {}; }'}\n ${isEvaluated ? `function print() { __p += Array.prototype.join.call(arguments, ''); }` : ''}\n ${options.variable ? source : `with(obj) {\\n${source}\\n}`}\n return __p;\n }`;\n\n const result = attempt(() => new Function(...importsKeys, `${sourceURL}return ${compiledFunction}`)(...importValues));\n\n result.source = compiledFunction;\n\n if (result instanceof Error) {\n throw result;\n }\n\n return result;\n}\n","export const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;\n","/** Counter used to generate unique numeric identifiers. */\nlet idCounter = 0;\n\n/**\n * Generates a unique identifier, optionally prefixed with a given string.\n *\n * @param {string} [prefix] - An optional string to prefix the unique identifier.\n * If not provided or not a string, only the unique\n * numeric identifier is returned.\n * @returns {string} A string containing the unique identifier, with the optional\n * prefix if provided.\n *\n * @example\n * // Generate a unique ID with a prefix\n * uniqueId('user_'); // => 'user_1'\n *\n * @example\n * // Generate a unique ID without a prefix\n * uniqueId(); // => '2'\n *\n * @example\n * // Subsequent calls increment the internal counter\n * uniqueId('item_'); // => 'item_3'\n * uniqueId(); // => '4'\n */\nexport function uniqueId(prefix = ''): string {\n const id = ++idCounter;\n\n return `${prefix}${id}`;\n}\n","import { ary as aryToolkit } from '../../function/ary.ts';\n\n/**\n * Creates a function that invokes func, with up to `n` arguments, ignoring any additional arguments.\n *\n * @template F - The type of the function.\n * @param {F} func - The function to cap arguments for.\n * @param {number} n - The arity cap.\n * @param {unknown} guard - The value to guard the arity cap.\n * @returns {(...args: any[]) => ReturnType} Returns the new capped function.\n *\n * @example\n * function fn(a: number, b: number, c: number) {\n * return Array.from(arguments);\n * }\n *\n * ary(fn, 0)(1, 2, 3); // []\n * ary(fn, 1)(1, 2, 3); // [1]\n * ary(fn, 2)(1, 2, 3); // [1, 2]\n * ary(fn, 3)(1, 2, 3); // [1, 2, 3]\n */\nexport function ary any>(\n func: F,\n n: number = func.length,\n guard?: unknown\n): (...args: any[]) => ReturnType {\n if (guard) {\n n = func.length;\n }\n\n if (Number.isNaN(n) || n < 0) {\n n = 0;\n }\n\n return aryToolkit(func, n);\n}\n","import { toInteger } from '../util/toInteger.ts';\n\n/**\n * Creates a function that invokes `func`, with the `this` binding and arguments\n * of the created function, while it's called less than `n` times. Subsequent\n * calls to the created function return the result of the last `func` invocation.\n *\n * @template F - The type of the function to be invoked.\n * @param {number} n - The number of times the returned function is allowed to call `func` before stopping.\n * - If `n` is 0, `func` will never be called.\n * - If `n` is a positive integer, `func` will be called up to `n-1` times.\n * @param {F} func - The function to be called with the limit applied.\n * @returns {(...args: Parameters) => ReturnType } - A new function that:\n * - Tracks the number of calls.\n * - Invokes `func` until the `n-1`-th call.\n * - Returns last result of `func`, if `n` is reached.\n * @throws {TypeError} - If `func` is not a function.\n * @example\n * let count = 0;\n * const before3 = before(3, () => ++count);\n *\n * before3(); // => 1\n * before3(); // => 2\n * before3(); // => 2\n */\nexport function before any>(\n n: number,\n func: F\n): (...args: Parameters) => ReturnType {\n if (typeof func !== 'function') {\n throw new TypeError('Expected a function');\n }\n\n let result: ReturnType;\n n = toInteger(n);\n\n return function (this: unknown, ...args: Parameters) {\n if (--n > 0) {\n result = func.apply(this, args);\n }\n\n if (n <= 1 && func) {\n // for garbage collection\n func = undefined as any;\n }\n\n return result;\n };\n}\n","import { camelCase as camelCaseToolkit } from '../../string/camelCase.ts';\nimport { normalizeForCase } from '../_internal/normalizeForCase.ts';\n\n/**\n * Converts a string to camel case.\n *\n * Camel case is the naming convention in which the first word is written in lowercase and\n * each subsequent word begins with a capital letter, concatenated without any separator characters.\n *\n * @param {string | object} str - The string that is to be changed to camel case.\n * @returns {string} - The converted string to camel case.\n *\n * @example\n * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'\n * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'\n * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'\n * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'\n */\n\nexport function camelCase(str?: string | object): string {\n return camelCaseToolkit(normalizeForCase(str));\n}\n","import { capitalize } from './capitalize.ts';\nimport { words as getWords } from './words.ts';\n\n/**\n * Converts a string to camel case.\n *\n * Camel case is the naming convention in which the first word is written in lowercase and\n * each subsequent word begins with a capital letter, concatenated without any separator characters.\n *\n * @param {string} str - The string that is to be changed to camel case.\n * @returns {string} - The converted string to camel case.\n *\n * @example\n * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'\n * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'\n * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'\n * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'\n * const convertedStr5 = camelCase('Keep unicode 😅') // returns 'keepUnicode😅'\n */\nexport function camelCase(str: string): string {\n const words = getWords(str);\n\n if (words.length === 0) {\n return '';\n }\n\n const [first, ...rest] = words;\n\n return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;\n}\n","/**\n * Casts value as an array if it's not one.\n *\n * @template T The type of elements in the array.\n * @param {T | T[]} value The value to be cast to an array.\n * @returns {T[]} An array containing the input value if it wasn't an array, or the original array if it was.\n *\n * @example\n * const arr1 = castArray(1);\n * // Returns: [1]\n *\n * const arr2 = castArray([1]);\n * // Returns: [1]\n *\n * const arr3 = castArray({'a': 1});\n * // Returns: [{'a': 1}]\n *\n * const arr4 = castArray(null);\n * // Returns: [null]\n *\n * const arr5 = castArray(undefined);\n * // Returns: [undefined]\n *\n * const arr6 = castArray();\n * // Returns: []\n */\n\nexport function castArray(value?: T | readonly T[]): T[] {\n if (arguments.length === 0) {\n return [];\n }\n\n return Array.isArray(value) ? value : ([value] as T[]);\n}\n","import { decimalAdjust } from '../_internal/decimalAdjust.ts';\n\n/**\n * Computes number rounded up to precision.\n *\n * @param {number | string} number The number to round up.\n * @param {number | string} precision The precision to round up to.\n * @returns {number} Returns the rounded up number.\n *\n * @example\n * ceil(4.006); // => 5\n * ceil(6.004, 2); // => 6.01\n * ceil(6040, -2); // => 6100\n */\nexport function ceil(number: number | string, precision: number | string = 0): number {\n return decimalAdjust('ceil', number, precision);\n}\n","import { chunk as chunkToolkit } from '../../array/chunk.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk(arr: ArrayLike | null | undefined, size = 1): T[][] {\n size = Math.max(Math.floor(size), 0);\n\n if (size === 0 || !isArrayLike(arr)) {\n return [];\n }\n\n return chunkToolkit(toArray(arr), size);\n}\n","/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk(arr: readonly T[], size: number): T[][] {\n if (!Number.isInteger(size) || size <= 0) {\n throw new Error('Size must be an integer greater than zero.');\n }\n\n const chunkLength = Math.ceil(arr.length / size);\n const result: T[][] = Array(chunkLength);\n\n for (let index = 0; index < chunkLength; index++) {\n const start = index * size;\n const end = start + size;\n\n result[index] = arr.slice(start, end);\n }\n\n return result;\n}\n","import { compact as compactToolkit } from '../../array/compact.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\n\ntype Falsey = false | null | 0 | 0n | '' | undefined;\ntype NotFalsey = Exclude;\n\n/**\n * Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The input array to remove falsey values.\n * @returns {Array>} - A new array with all falsey values removed.\n *\n * @example\n * compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);\n * Returns: [1, 2, 3, 4, 5]\n */\nexport function compact(arr: ArrayLike | null | undefined): Array> {\n if (!isArrayLike(arr)) {\n return [];\n }\n\n return compactToolkit(Array.from(arr));\n}\n","type NotFalsey = Exclude;\n\n/**\n * Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The input array to remove falsey values.\n * @returns {Array>} - A new array with all falsey values removed.\n *\n * @example\n * compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);\n * Returns: [1, 2, 3, 4, 5]\n */\nexport function compact(arr: readonly T[]): Array> {\n const result: Array> = [];\n\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n if (item) {\n result.push(item as NotFalsey);\n }\n }\n\n return result;\n}\n","import { flatten } from '../../array/flatten.ts';\n\n/**\n * Concatenates multiple arrays and values into a single array.\n *\n * @template T The type of elements in the array.\n * @param {...(T | T[])} values - The values and/or arrays to concatenate.\n * @returns {T[]} A new array containing all the input values.\n *\n * @example\n * // Concatenate individual values\n * concat(1, 2, 3);\n * // returns [1, 2, 3]\n *\n * @example\n * // Concatenate arrays of values\n * concat([1, 2], [3, 4]);\n * // returns [1, 2, 3, 4]\n *\n * @example\n * // Concatenate a mix of individual values and arrays\n * concat(1, [2, 3], 4);\n * // returns [1, 2, 3, 4]\n *\n * @example\n * // Concatenate nested arrays\n * concat([1, [2, 3]], 4);\n * // returns [1, [2, 3], 4]\n */\nexport function concat(...values: Array): T[] {\n return flatten(values) as T[];\n}\n","import { conformsTo } from './conformsTo.ts';\nimport { cloneDeep } from '../../object/cloneDeep.ts';\n\n/**\n * Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`.\n *\n * Note: The created function is equivalent to `conformsTo` with source partially applied.\n *\n * @param {Record boolean>} source The object of property predicates to conform to.\n * @returns {(object: Record) => boolean} Returns the new spec function.\n *\n * @example\n * const isPositive = (n) => n > 0;\n * const isEven = (n) => n % 2 === 0;\n * const predicates = { a: isPositive, b: isEven };\n * const conform = conforms(predicates);\n *\n * console.log(conform({ a: 2, b: 4 })); // true\n * console.log(conform({ a: -1, b: 4 })); // false\n * console.log(conform({ a: 2, b: 3 })); // false\n * console.log(conform({ a: 0, b: 2 })); // false\n */\nexport function conforms(\n source: Record boolean>\n): (object: Record) => boolean {\n source = cloneDeep(source);\n\n return function (object: Record) {\n return conformsTo(object, source);\n };\n}\n","/**\n * Creates a new function that always returns `undefined`.\n *\n * @returns {() => undefined} Returns the new constant function.\n */\nexport function constant(): () => undefined;\n\n/**\n * Creates a new function that always returns `value`.\n *\n * @template T - The type of the value to return.\n * @param {T} value - The value to return from the new function.\n * @returns {() => T} Returns the new constant function.\n */\nexport function constant(value: T): () => T;\n\n/**\n * Creates a new function that always returns `value`.\n *\n * @template T - The type of the value to return.\n * @param {T} value - The value to return from the new function.\n * @returns {() => T | undefined} Returns the new constant function.\n *\n * @example\n * const object = { a: 1 };\n * const returnsObject = constant(object);\n *\n * returnsObject(); // => { a: 1 }\n * returnsObject() === object; // => true\n */\nexport function constant(value?: T): () => T | undefined {\n return () => value;\n}\n","import { words as getWords } from './words.ts';\n\n/**\n * Converts a string to constant case.\n *\n * Constant case is a naming convention where each word is written in uppercase letters and separated by an underscore (`_`). For example, `CONSTANT_CASE`.\n *\n * @param {string} str - The string that is to be changed to constant case.\n * @returns {string} - The converted string to constant case.\n *\n * @example\n * const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE'\n * const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE'\n * const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT'\n * const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST'\n */\n\nexport function constantCase(str: string): string {\n const words = getWords(str);\n return words.map(word => word.toUpperCase()).join('_');\n}\n","/**\n * Count the occurrences of each item in an array\n * based on a transformation function.\n *\n * This function takes an array and a transformation function\n * that converts each item in the array to a key. It then\n * counts the occurrences of each transformed item and returns\n * an object with the transformed items as keys and the counts\n * as values.\n *\n * @template T - The type of the items in the input array.\n * @template K - The type of keys.\n * @param {T[]} arr - The input array to count occurrences.\n * @param {(item: T) => K} mapper - The transformation function that maps each item to a key.\n * @returns {Record} An object containing the transformed items as keys and the\n * counts as values.\n *\n * @example\n * const array = ['a', 'b', 'c', 'a', 'b', 'a'];\n * const result = countBy(array, x => x);\n * // result will be { a: 3, b: 2, c: 1 }\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = countBy(array, item => item % 2 === 0 ? 'even' : 'odd');\n * // result will be { odd: 3, even: 2 }\n */\nexport function countBy(arr: readonly T[], mapper: (item: T) => K): Record {\n const result = {} as Record;\n\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n const key = mapper(item);\n\n result[key] = (result[key] ?? 0) + 1;\n }\n\n return result;\n}\n","/**\n * Returns the default value for `null`, `undefined`, and `NaN`.\n *\n * @param {T | null | undefined} value - The value to check.\n * @param {T} [defaultValue] - The default value to return if the first value is null, undefined, or NaN.\n * @returns {T} Returns either the first value or the default value.\n *\n * @example\n * defaultTo(null, 'default') // returns 'default'\n * defaultTo(undefined, 42) // returns 42\n * defaultTo(NaN, 0) // returns 0\n * defaultTo('actual', 'default') // returns 'actual'\n * defaultTo(123, 0) // returns 123\n */\nexport function defaultTo(value: T | null | undefined, defaultValue?: T): T;\n\n/**\n * Returns the default value for `null`, `undefined`, and `NaN`.\n *\n * @param {unknown} value - The value to check.\n * @param {unknown} defaultValue - The default value to return if the first value is null, undefined, or NaN.\n * @returns {any} Returns either the first value or the default value.\n *\n * @example\n * defaultTo(null, 'default') // returns 'default'\n * defaultTo(undefined, 42) // returns 42\n * defaultTo(NaN, 0) // returns 0\n * defaultTo('actual', 'default') // returns 'actual'\n * defaultTo(123, 0) // returns 123\n */\nexport function defaultTo(value?: unknown, defaultValue?: unknown): any {\n if (value == null || Number.isNaN(value)) {\n return defaultValue;\n }\n\n return value;\n}\n","/**\n * Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.\n *\n * @param {F} func The function to defer.\n * @param {Parameters} args The arguments to invoke `func` with.\n * @returns {number} Returns the timer id.\n *\n * @example\n * defer((text) => {\n * console.log(text);\n * }, 'deferred');\n * // => Logs 'deferred' after the current call stack has cleared.\n */\nexport function defer any>(func: F, ...args: Parameters): number {\n if (typeof func !== 'function') {\n throw new TypeError('Expected a function');\n }\n return setTimeout(func, 1, ...args);\n}\n","import { difference as differenceToolkit } from '../../array/difference.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\n\n/**\n * Computes the difference between an array and multiple arrays.\n *\n * @template T\n * @param {ArrayLike | undefined | null} arr - The primary array from which to derive the difference. This is the main array\n * from which elements will be compared and filtered.\n * @param {Array>} values - Multiple arrays containing elements to be excluded from the primary array.\n * These arrays will be flattened into a single array, and each element in this array will be checked against the primary array.\n * If a match is found, that element will be excluded from the result.\n * @returns {T[]} A new array containing the elements that are present in the primary array but not\n * in the flattened array.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [2, 4];\n * const array3 = [5, 6];\n * const result = difference(array1, array2, array3);\n * // result will be [1, 3] since 2, 4, and 5 are in the other arrays and are excluded from the result.\n *\n * @example\n * const arrayLike1 = { 0: 1, 1: 2, 2: 3, length: 3 };\n * const arrayLike2 = { 0: 2, 1: 4, length: 2 };\n * const result = difference(arrayLike1, arrayLike2);\n * // result will be [1, 3] since 2 is in both array-like objects and is excluded from the result.\n */\nexport function difference(arr: ArrayLike | undefined | null, ...values: Array>): T[] {\n if (!isArrayLikeObject(arr)) {\n return [];\n }\n\n const arr1 = toArray(arr);\n const arr2 = [];\n\n for (let i = 0; i < values.length; i++) {\n const value = values[i];\n if (isArrayLikeObject(value)) {\n arr2.push(...Array.from(value));\n }\n }\n\n return differenceToolkit(arr1, arr2);\n}\n","import { last } from './last.ts';\nimport { difference as differenceToolkit } from '../../array/difference.ts';\nimport { differenceBy as differenceByToolkit } from '../../array/differenceBy.ts';\nimport { flattenArrayLike } from '../_internal/flattenArrayLike.ts';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\nimport { iteratee as createIteratee } from '../util/iteratee.ts';\n\ntype Iteratee = PropertyKey | Partial | ((value: T) => unknown);\n\n/**\n * Computes the difference between an array and another array using an iteratee function.\n *\n * @template T1, T2\n * @param {ArrayLike | null | undefined} array - The primary array from which to derive the difference.\n * @param {ArrayLike} values - The array containing elements to be excluded from the primary array.\n * @param {Iteratee} iteratee - The iteratee invoked per element.\n * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values array.\n *\n * @example\n * const result = differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);\n * // result will be [1.2]\n *\n * @example\n * const result = differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], 'x');\n * // result will be [{ x: 2 }]\n */\nexport function differenceBy(\n array: ArrayLike | null | undefined,\n values: ArrayLike,\n iteratee: Iteratee\n): T1[];\n\n/**\n * Computes the difference between an array and two other arrays using an iteratee function.\n *\n * @template T1, T2, T3\n * @param {ArrayLike | null | undefined} array - The primary array from which to derive the difference.\n * @param {ArrayLike} values1 - The first array containing elements to be excluded from the primary array.\n * @param {ArrayLike} values2 - The second array containing elements to be excluded from the primary array.\n * @param {Iteratee} iteratee - The iteratee invoked per element.\n * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.\n *\n * @example\n * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], Math.floor);\n * // result will be []\n */\nexport function differenceBy(\n array: ArrayLike | null | undefined,\n values1: ArrayLike,\n values2: ArrayLike,\n iteratee: Iteratee\n): T1[];\n\n/**\n * Computes the difference between an array and three other arrays using an iteratee function.\n *\n * @template T1, T2, T3, T4\n * @param {ArrayLike | null | undefined} array - The primary array from which to derive the difference.\n * @param {ArrayLike} values1 - The first array containing elements to be excluded from the primary array.\n * @param {ArrayLike} values2 - The second array containing elements to be excluded from the primary array.\n * @param {ArrayLike} values3 - The third array containing elements to be excluded from the primary array.\n * @param {Iteratee} iteratee - The iteratee invoked per element.\n * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.\n *\n * @example\n * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], Math.floor);\n * // result will be []\n */\nexport function differenceBy(\n array: ArrayLike | null | undefined,\n values1: ArrayLike,\n values2: ArrayLike,\n values3: ArrayLike,\n iteratee: Iteratee\n): T1[];\n\n/**\n * Computes the difference between an array and four other arrays using an iteratee function.\n *\n * @template T1, T2, T3, T4, T5\n * @param {ArrayLike | null | undefined} array - The primary array from which to derive the difference.\n * @param {ArrayLike} values1 - The first array containing elements to be excluded from the primary array.\n * @param {ArrayLike} values2 - The second array containing elements to be excluded from the primary array.\n * @param {ArrayLike} values3 - The third array containing elements to be excluded from the primary array.\n * @param {ArrayLike} values4 - The fourth array containing elements to be excluded from the primary array.\n * @param {Iteratee} iteratee - The iteratee invoked per element.\n * @returns {T1[]} A new array containing the elements that are present in the primary array but not in the values arrays.\n *\n * @example\n * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], [3.4], Math.floor);\n * // result will be []\n */\nexport function differenceBy(\n array: ArrayLike | null | undefined,\n values1: ArrayLike,\n values2: ArrayLike,\n values3: ArrayLike,\n values4: ArrayLike,\n iteratee: Iteratee\n): T1[];\n\n/**\n * Computes the difference between an array and multiple arrays using an iteratee function.\n *\n * @template T\n * @param {ArrayLike | null | undefined} array - The primary array from which to derive the difference.\n * @param {...Array>} values - Multiple arrays containing elements to be excluded from the primary array.\n * @returns {T[]} A new array containing the elements that are present in the primary array but not in the values arrays.\n *\n * @example\n * const result = differenceBy([2.1, 1.2], [2.3, 3.4], [1.2], [2.1], [3.4], Math.floor);\n * // result will be []\n */\nexport function differenceBy(array: ArrayLike | null | undefined, ...values: Array>): T[];\n\n/**\n * Computes the difference between an array and multiple arrays using an iteratee function.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The primary array from which to derive the difference.\n * @param {...any[]} values - Multiple arrays containing elements to be excluded from the primary array.\n * @returns {T[]} A new array containing the elements that are present in the primary array but not in the values arrays.\n */\nexport function differenceBy(arr: ArrayLike | null | undefined, ..._values: any[]): T[] {\n if (!isArrayLikeObject(arr)) {\n return [];\n }\n\n const iteratee = last(_values);\n const values = flattenArrayLike(_values);\n\n if (isArrayLikeObject(iteratee)) {\n return differenceToolkit(Array.from(arr), values);\n }\n\n return differenceByToolkit(Array.from(arr), values, createIteratee(iteratee));\n}\n","import { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\n\nexport function flattenArrayLike(values: Array>): T[] {\n const result: T[] = [];\n\n for (let i = 0; i < values.length; i++) {\n const arrayLike = values[i];\n\n if (!isArrayLikeObject(arrayLike)) {\n continue;\n }\n\n for (let j = 0; j < arrayLike.length; j++) {\n result.push(arrayLike[j]);\n }\n }\n\n return result;\n}\n","import { drop as dropToolkit } from '../../array/drop.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { toInteger } from '../util/toInteger.ts';\n\n/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} collection - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @param {unknown} [guard] - Enables use as an iteratee for methods like `_.map`.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop(collection: ArrayLike | null | undefined, itemsCount: number = 1, guard?: unknown): T[] {\n if (!isArrayLike(collection)) {\n return [];\n }\n itemsCount = guard ? 1 : toInteger(itemsCount);\n\n return dropToolkit(toArray(collection), itemsCount);\n}\n","/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.max(itemsCount, 0);\n\n return arr.slice(itemsCount);\n}\n","import { dropRight as dropRightToolkit } from '../../array/dropRight.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { toInteger } from '../util/toInteger.ts';\n\n/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} collection - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @param {unknown} [guard] - Enables use as an iteratee for methods like `_.map`.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight(\n collection: ArrayLike | null | undefined,\n itemsCount: number = 1,\n guard?: unknown\n): T[] {\n if (!isArrayLike(collection)) {\n return [];\n }\n itemsCount = guard ? 1 : toInteger(itemsCount);\n\n return dropRightToolkit(toArray(collection), itemsCount);\n}\n","/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.min(-itemsCount, 0);\n\n if (itemsCount === 0) {\n return arr.slice();\n }\n\n return arr.slice(0, itemsCount);\n}\n","import { dropRightWhile as dropRightWhileToolkit } from '../../array/dropRightWhile.ts';\nimport { property } from '../object/property.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Drops elements from the end of an array while the predicate function returns truthy.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {(item: T, index: number, arr: T[]) => unknown} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, index, and array, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [5, 4, 3, 2, 1];\n * const result = dropRightWhile(array, x => x < 3);\n * result will be [5, 4, 3] since elements less than 3 are dropped.\n */\nexport function dropRightWhile(\n arr: ArrayLike | null | undefined,\n canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown\n): T[];\n\n/**\n * Drops elements from the end of an array while the specified object properties match.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {Partial} objectToDrop - An object specifying the properties to match for dropping elements.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [{ a: 1 }, { a: 2 }, { a: 3 }];\n * const result = dropRightWhile(array, { a: 3 });\n * result will be [{ a: 1 }, { a: 2 }] since the last object matches the properties of the provided object.\n */\nexport function dropRightWhile(arr: ArrayLike | null | undefined, objectToDrop: Partial): T[];\n\n/**\n * Drops elements from the end of an array while the specified property matches a given value.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {[keyof T, unknown]} propertyToDrop - A tuple containing the property key and the value to match for dropping elements.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const result = dropRightWhile(array, ['id', 3]);\n * result will be [{ id: 1 }, { id: 2 }] since the last object has the id property matching the value 3.\n */\nexport function dropRightWhile(arr: ArrayLike | null | undefined, propertyToDrop: [keyof T, unknown]): T[];\n\n/**\n * Drops elements from the end of an array while the specified property name matches.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {string} propertyToDrop - The name of the property to match for dropping elements.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [{ isActive: false }, { isActive: true }, { isActive: true }];\n * const result = dropRightWhile(array, 'isActive');\n * result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.\n */\nexport function dropRightWhile(arr: ArrayLike | null | undefined, propertyToDrop: string): T[];\n\n/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the end until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {(item: T, index: number, arr: T[]) => unknown} predicate - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, index, and array, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [3, 2, 1];\n * const result = dropRightWhile(array, (item, index, arr) => index >= 1);\n * // Returns: [3]\n */\nexport function dropRightWhile(\n arr: ArrayLike | null | undefined,\n predicate: ((item: T, index: number, arr: readonly T[]) => unknown) | Partial | [keyof T, unknown] | string\n): T[] {\n if (!isArrayLike(arr)) {\n return [];\n }\n\n return dropRightWhileImpl(Array.from(arr), predicate);\n}\n\nfunction dropRightWhileImpl(\n arr: readonly T[],\n predicate: ((item: T, index: number, arr: readonly T[]) => unknown) | Partial | [keyof T, unknown] | string\n): T[] {\n switch (typeof predicate) {\n case 'function': {\n return dropRightWhileToolkit(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));\n }\n case 'object': {\n if (Array.isArray(predicate) && predicate.length === 2) {\n const key = predicate[0];\n const value = predicate[1];\n\n return dropRightWhileToolkit(arr, matchesProperty(key, value));\n } else {\n return dropRightWhileToolkit(arr, matches(predicate));\n }\n }\n case 'string': {\n return dropRightWhileToolkit(arr, property(predicate));\n }\n }\n}\n","import { dropWhile as dropWhileToolkit } from '../../array/dropWhile.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { property } from '../object/property.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Drops elements from the beginning of an array while the predicate function returns truthy.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {(item: T, index: number, arr: T[]) => unknown} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, index, and array, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropWhile(array, x => x < 3);\n * result will be [3, 4, 5] since elements less than 3 are dropped.\n */\nexport function dropWhile(\n arr: ArrayLike | null | undefined,\n canContinueDropping: (item: T, index: number, arr: readonly T[]) => unknown\n): T[];\n\n/**\n * Drops elements from the beginning of an array while the specified object properties match.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {Partial} objectToDrop - An object specifying the properties to match for dropping elements.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [{ a: 1 }, { a: 2 }, { a: 3 }];\n * const result = dropWhile(array, { a: 1 });\n * result will be [{ a: 2 }, { a: 3 }] since the first object matches the properties of the provided object.\n */\nexport function dropWhile(arr: ArrayLike | null | undefined, objectToDrop: Partial): T[];\n\n/**\n * Drops elements from the beginning of an array while the specified property matches a given value.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {[keyof T, unknown]} propertyToDrop - A tuple containing the property key and the value to match for dropping elements.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const result = dropWhile(array, ['id', 1]);\n * result will be [{ id: 2 }, { id: 3 }] since the first object has the id property matching the value 1.\n */\nexport function dropWhile(arr: ArrayLike | null | undefined, propertyToDrop: [keyof T, unknown]): T[];\n\n/**\n * Drops elements from the beginning of an array while the specified property name matches.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {string} propertyToDrop - The name of the property to match for dropping elements.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [{ isActive: true }, { isActive: true }, { isActive: false }];\n * const result = dropWhile(array, 'isActive');\n * result will be [{ isActive: false }] since it drops elements until it finds one with a falsy isActive property.\n */\nexport function dropWhile(arr: ArrayLike | null | undefined, propertyToDrop: string): T[];\n\n/**\n * Removes elements from the beginning of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the start until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array from which to drop elements.\n * @param {(item: T, index: number, arr: T[]) => unknown} predicate - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, index, and array, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = dropWhile(array, (item, index, arr) => index < 2);\n * // Returns: [3]\n */\nexport function dropWhile(\n arr: ArrayLike | null | undefined,\n predicate: ((item: T, index: number, arr: readonly T[]) => unknown) | Partial | [keyof T, unknown] | string\n): T[] {\n if (!isArrayLike(arr)) {\n return [];\n }\n\n return dropWhileImpl(toArray(arr), predicate);\n}\n\nfunction dropWhileImpl(\n arr: readonly T[],\n predicate: ((item: T, index: number, arr: readonly T[]) => unknown) | Partial | [keyof T, unknown] | string\n): T[] {\n switch (typeof predicate) {\n case 'function': {\n return dropWhileToolkit(arr, (item, index, arr) => Boolean(predicate(item, index, arr)));\n }\n case 'object': {\n if (Array.isArray(predicate) && predicate.length === 2) {\n const key = predicate[0];\n const value = predicate[1];\n\n return dropWhileToolkit(arr, matchesProperty(key, value));\n } else {\n return dropWhileToolkit(arr, matches(predicate));\n }\n }\n case 'string': {\n return dropWhileToolkit(arr, property(predicate));\n }\n }\n}\n","/**\n * Checks if a string contains another string at the end of the string.\n *\n * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional position from the start to search up to this index\n * @returns {boolean} - True if the str string ends with the target string.\n *\n * @example\n * const isPrefix = endsWith('fooBar', 'foo') // returns true\n * const isPrefix = endsWith('fooBar', 'bar') // returns false\n * const isPrefix = endsWith('fooBar', 'abc') // returns false\n * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true\n * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false\n */\nexport function endsWith(str: string, target: string, position: number = str.length): boolean {\n return str.endsWith(target, position);\n}\n","/**\n * Escapes the RegExp special characters \"^\", \"$\", \"\\\\\", \".\", \"*\", \"+\", \"?\", \"(\", \")\", \"[\", \"]\", \"{\", \"}\", and \"|\" in `str`.\n *\n * @param {string} str The string to escape.\n * @returns {string} Returns the escaped string.\n *\n * @example\n * import { escapeRegExp } from 'es-toolkit/string';\n *\n * escapeRegExp('[es-toolkit](https://es-toolkit.slash.page/)'); // returns '\\[es-toolkit\\]\\(https://es-toolkit\\.slash\\.page/\\)'\n */\nexport function escapeRegExp(str: string): string {\n return str.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n}\n","import { identity } from '../../function/identity.ts';\nimport { isIterateeCall } from '../_internal/isIterateeCall.ts';\nimport { property } from '../object/property.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Checks if all elements in an array are truthy.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to check through.\n * @returns {boolean} - `true` if all elements are truthy, or `false` if at least one element is falsy.\n *\n * @example\n * const items = [1, 2, 3, 4];\n * const result = every(items);\n * console.log(result); // true\n *\n * const itemsWithFalsy = [1, 0, 3, 4];\n * const resultWithFalsy = every(itemsWithFalsy);\n * console.log(resultWithFalsy); // false\n */\nexport function every(arr: ArrayLike | null | undefined): boolean;\n\n/**\n * Checks if every item in an array matches the given predicate function.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to check through.\n * @param {(item: T, index: number, arr: T[]) => unknown} doesMatch - A function that takes an item, its index, and the array, and returns a truthy value if the item matches the criteria.\n * @returns {boolean} - `true` if every item matches the predicate, or `false` if at least one item does not match.\n *\n * @example\n * // Using a predicate function\n * const items = [1, 2, 3, 4, 5];\n * const result = every(items, (item) => item > 0);\n * console.log(result); // true\n */\nexport function every(\n arr: ArrayLike | null | undefined,\n doesMatch: (item: T, index: number, arr: readonly T[]) => unknown\n): boolean;\n\n/**\n * Checks if every item in an array matches the given partial object.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to check through.\n * @param {Partial} doesMatch - A partial object that specifies the properties to match.\n * @returns {boolean} - `true` if every item matches the partial object, or `false` if at least one item does not match.\n *\n * @example\n * // Using a partial object\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = every(items, { name: 'Bob' });\n * console.log(result); // false\n */\nexport function every(arr: ArrayLike | null | undefined, doesMatch: Partial): boolean;\n\n/**\n * Checks if every item in an array matches a property with a specific value.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to check through.\n * @param {[keyof T, unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.\n * @returns {boolean} - `true` if every item has the specified property value, or `false` if at least one item does not match.\n *\n * @example\n * // Using a property-value pair\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = every(items, ['name', 'Alice']);\n * console.log(result); // false\n */\nexport function every(arr: ArrayLike | null | undefined, doesMatchProperty: [keyof T, unknown]): boolean;\n\n/**\n * Checks if every item in an array has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to check through.\n * @param {string} propertyToCheck - The property name to check.\n * @returns {boolean} - `true` if every item has the specified property, or `false` if at least one item does not match.\n *\n * @example\n * // Using a property name\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = every(items, 'name');\n * console.log(result); // true\n */\nexport function every(arr: ArrayLike | null | undefined, propertyToCheck: string): boolean;\n\n/**\n * Checks if every item in an object matches the given predicate function.\n *\n * @template T\n * @param {T | null | undefined} object - The object to check through.\n * @param {(value: T[keyof T], key: keyof T, object: T) => unknown} doesMatch - A function that takes an value, its key, and the object, and returns a truthy value if the item matches the criteria.\n * @returns {boolean} - `true` if every property value matches the predicate, or `false` if at least one does not match.\n *\n * @example\n * // Using a predicate function\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = every(obj, (value) => value > 0);\n * console.log(result); // true\n */\nexport function every>(\n object: T | null | undefined,\n doesMatch: (value: T[keyof T], key: keyof T, object: T) => unknown\n): boolean;\n\n/**\n * Checks if every item in an object matches the given partial value.\n *\n * @template T\n * @param {T | null | undefined} object - The object to check through.\n * @param {Partial} doesMatch - A partial value to match against the values of the object.\n * @returns {boolean} - `true` if every property value matches the partial value, or `false` if at least one does not match.\n *\n * @example\n * // Using a partial value\n * const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };\n * const result = every(obj, { name: 'Bob' });\n * console.log(result); // false\n */\nexport function every>(\n object: T | null | undefined,\n doesMatch: Partial\n): boolean;\n\n/**\n * Checks if every item in an object matches a property with a specific value.\n *\n * @template T\n * @param {T | null | undefined} object - The object to check through.\n * @param {[keyof T[keyof T], unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.\n * @returns {boolean} - `true` if every item has the specified property value, or `false` if at least one item does not match.\n *\n * @example\n * // Using a property-value pair\n * const obj = { alice: { id: 1, name: 'Alice' }, bob: { id: 2, name: 'Bob' } };\n * const result = every(obj, ['name', 'Alice']);\n * console.log(result); // false\n */\nexport function every>(\n object: T | null | undefined,\n doesMatchProperty: [keyof T[keyof T], unknown]\n): boolean;\n\n/**\n * Checks if every item in an object has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {T | null | undefined} object - The object to check through.\n * @param {string} propertyToCheck - The property name to check.\n * @returns {boolean} - `true` if every property value has the specified property, or `false` if at least one does not match.\n *\n * @example\n * // Using a property name\n * const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };\n * const result = every(obj, 'name');\n * console.log(result); // true\n */\nexport function every>(\n object: T | null | undefined,\n propertyToCheck: string\n): boolean;\n\n/**\n * Checks if every item in an object has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {T extends Record ? T : never} object - The object to check through.\n * @param {ArrayLike | Record | null | undefined} source - The source array or object to check through.\n * @param {((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string} doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.\n * @param {string} propertyToCheck - The property name to check.\n * @param {unknown} guard - Enables use as an iteratee for methods like `_.map`.\n * @returns {boolean} - `true` if every property value has the specified property, or `false` if at least one does not match.\n *\n * @example\n * // Using a property name\n * const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };\n * const result = every(obj, 'name');\n * console.log(result); // true\n */\nexport function every(\n source: ArrayLike | Record | null | undefined,\n doesMatch?: ((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string,\n guard?: unknown\n): boolean {\n if (!source) {\n return true;\n }\n const values = Array.isArray(source) ? source : Object.values(source);\n if (guard && isIterateeCall(source, doesMatch, guard)) {\n doesMatch = undefined;\n }\n\n if (!doesMatch) {\n doesMatch = identity;\n }\n\n switch (typeof doesMatch) {\n case 'function': {\n if (!Array.isArray(source)) {\n const keys = Object.keys(source) as Array;\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = source[key];\n\n if (!doesMatch(value as T, key as number, source)) {\n return false;\n }\n }\n\n return true;\n }\n\n return values.every(doesMatch);\n }\n case 'object': {\n if (Array.isArray(doesMatch) && doesMatch.length === 2) {\n const key = doesMatch[0];\n const value = doesMatch[1];\n\n return values.every(matchesProperty(key, value));\n } else {\n return values.every(matches(doesMatch));\n }\n }\n case 'string': {\n return values.every(property(doesMatch));\n }\n }\n}\n","import { fill as fillToolkit } from '../../array/fill.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { isString } from '../predicate/isString.ts';\n\n/**\n * Fills the whole array with a specified value.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T\n * @param {unknown[] | null | undefined} array - The array to fill.\n * @param {T} value - The value to fill the array with.\n * @returns {T[]} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(array: unknown[] | null | undefined, value?: T): T[];\n/**\n * Fills the whole array with a specified value.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T\n * @param {ArrayLike | null | undefined} array - The array to fill.\n * @param {T} value - The value to fill the array with.\n * @returns {ArrayLike} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(array: ArrayLike | null | undefined, value?: T): ArrayLike;\n/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {Array | null | undefined} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(\n array: Array | null | undefined,\n value: U,\n start?: number,\n end?: number\n): Array;\n/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {ArrayLike | null | undefined} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {ArrayLike} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(\n array: ArrayLike | null | undefined,\n value: U,\n start?: number,\n end?: number\n): ArrayLike;\n/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {ArrayLike | null | undefined} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {ArrayLike} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(\n array: ArrayLike | null | undefined,\n value: U,\n start = 0,\n end = array ? array.length : 0\n): ArrayLike {\n if (!isArrayLike(array)) {\n return [];\n }\n if (isString(array)) {\n // prevent TypeError: Cannot assign to read only property of string\n return array;\n }\n start = Math.floor(start);\n end = Math.floor(end);\n\n if (!start) {\n start = 0;\n }\n if (!end) {\n end = 0;\n }\n\n return fillToolkit(array as any, value, start, end);\n}\n","/**\n * Fills the whole array with a specified value.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {Array} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @returns {Array} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(array: unknown[], value: T): T[];\n/**\n * Fills elements of an array with a specified value from the start position up to the end of the array.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {Array} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @returns {Array} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(array: Array, value: U, start: number): Array;\n/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {Array} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(array: Array, value: U, start: number, end: number): Array;\n/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {Array} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill(array: Array, value: U, start = 0, end = array.length): Array {\n const length = array.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n for (let i = finalStart; i < finalEnd; i++) {\n array[i] = value;\n }\n\n return array;\n}\n","import { identity } from '../../function/identity.ts';\nimport { property } from '../object/property.ts';\nimport { isArray } from '../predicate/isArray.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Filters items from a array and returns an array of elements.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to iterate over.\n * @param {(item: T, index: number, arr: T[]) => unknown} doesMatch - The function invoked per iteration.\n * @returns {T[]} - Returns a new array of elements that satisfy the given doesMatch function.\n *\n * @example\n * filter([1, 2, 3], n => n % 2 === 0)\n * // => [2]\n */\nexport function filter(\n arr: ArrayLike | null | undefined,\n doesMatch?: (item: T, index: number, arr: readonly T[]) => unknown\n): T[];\n\n/**\n * Filters elements in a arr that match the properties of the given partial object.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to iterate over.\n * @param {Partial} doesMatch - A partial object that specifies the properties to match.\n * @returns {T[]} - Returns a new array of elements that match the given properties.\n *\n * @example\n * const arr = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * filter(arr, { name: 'Bob' });\n * // => [{ id: 2, name: 'Bob' }]\n */\nexport function filter(arr: ArrayLike | null | undefined, doesMatch: Partial): T[];\n\n/**\n * Filters elements in a arr that match the given key-value pair.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to iterate over.\n * @param {[keyof T, unknown]} doesMatchProperty - The key-value pair to match.\n * @returns {T[]} - Returns a new array of elements that match the given key-value pair.\n *\n * @example\n * const arr = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * filter(arr, ['name', 'Alice']);\n * // => [{ id: 1, name: 'Alice' }]\n */\nexport function filter(arr: ArrayLike | null | undefined, doesMatchProperty: [keyof T, unknown]): T[];\n\n/**\n * Filters the arr, returning elements that contain the given property name.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to iterate over.\n * @param {string} propertyToCheck - The property name to check.\n * @returns {T[]} - Returns a new array of elements that match the given property name.\n *\n * @example\n * const arr = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }, { id: 3, age: 28 }];\n * filter(arr, 'name');\n * // => [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]\n */\nexport function filter(arr: ArrayLike | null | undefined, propertyToCheck: string): T[];\n\n/**\n * Filters items from a object and returns an array of elements that match the given predicate function.\n *\n * @template T\n * @param {T | null | undefined} object - The object to iterate over.\n * @param {(value: T[keyof T], key: keyof T, object: T) => unknown} doesMatch - The function invoked per iteration.\n * @returns {T[]} - Returns a new array of elements that satisfy the given predicate function.\n *\n * @example\n * const obj = { item1: { a: 0 }, item2: { a: 1 }, item3: { a: 0 } }\n * filter(obj, value => value.a)\n * // => [{ a: 1 }]\n *\n * const obj = { a: 1, b: 2, c: 3 };\n * filter(obj, value => value > 2)\n * // => [3]\n */\nexport function filter>(\n object: T | null | undefined,\n doesMatch: (value: T[keyof T], key: keyof T, object: T) => unknown\n): T[];\n\n/**\n * Filters elements in a object that match the properties of the given partial object.\n *\n * @template T\n * @param {T | null | undefined} object - The object to iterate over.\n * @param {Partial} doesMatch - The partial object to match\n * @returns {T[]} - Returns a new array of elements that match the given properties.pair.\n *\n * @example\n * const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };\n * filter(obj, { name: 'Bob' });\n * // => [{ id: 2, name: 'Bob' }]\n */\nexport function filter>(\n object: T | null | undefined,\n doesMatch: Partial\n): T[];\n\n/**\n * Filters elements in a arr that match the given key-value pair.\n *\n * @template T\n * @param {T | null | undefined} object - The object to iterate over.\n * @param {[keyof T[keyof T], unknown]} doesMatchProperty - The key-value pair to match.\n * @returns {T[]} - Returns a new array of elements that match the given key-value pair.\n *\n * @example\n * const obj = { alice: { id: 1, name: 'Alice' }, bob: { id: 2, name: 'Bob' } };\n * filter(obj, ['name', 'Alice']);\n * // => [{ id: 1, name: 'Alice' }]\n */\nexport function filter>(\n object: T | null | undefined,\n doesMatchProperty: [keyof T[keyof T], unknown]\n): T[];\n\n/**\n * Filters the object, returning elements that contain the given property name.\n *\n * @template T\n * @param {T | null | undefined} object - The object to iterate over.\n * @param {string} propertyToCheck - The property name to check.\n * @returns {T[]} - Returns a new array of elements that match the given property name.\n *\n * @example\n * const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' }, c: { id: 3, age: 28 } };\n * filter(obj, 'name');\n * // => [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]\n */\nexport function filter>(object: T | null | undefined, propertyToCheck: string): T[];\n\n/**\n * Iterates over the collection and filters elements based on the given predicate.\n * If a function is provided, it is invoked for each element in the collection.\n *\n * @template T\n * @param {ArrayLike | Record | null | undefined} source - The array or object to iterate over.\n * @param {((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string} [predicate=identity] - The function invoked per iteration.\n * @returns {T[]} - Returns a new array of filtered elements that satisfy the predicate.\n *\n * @example\n * filter([{ a: 1 }, { a: 2 }, { b: 1 }], 'a');\n * // => [{ a: 1 }, { a: 2 }]\n *\n * filter([{ a: 1 }, { a: 2 }, { b: 1 }], { b: 1 });\n * // => [{ b: 1 }]\n *\n * filter({ item1: { a: 0, b: true }, item2: { a: 1, b: true }, item3: { a: 2, b: false }}, { b: false })\n * // => [{ a: 2, b: false }]\n *\n * filter([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);\n * // => [{ a: 2 }]\n */\nexport function filter(\n source: ArrayLike | Record | null | undefined,\n predicate?: ((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string\n): T[] {\n if (!source) {\n return [];\n }\n if (!predicate) {\n predicate = identity;\n }\n\n const collection = isArray(source) ? source : Object.values(source);\n\n switch (typeof predicate) {\n case 'function': {\n if (!Array.isArray(source)) {\n const result: T[] = [];\n const keys = Object.keys(source) as Array;\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = source[key] as T;\n\n if (predicate(value, key as number, source)) {\n result.push(value);\n }\n }\n\n return result;\n }\n\n return collection.filter(predicate);\n }\n case 'object': {\n return isArray(predicate)\n ? collection.filter(matchesProperty(predicate[0], predicate[1]))\n : collection.filter(matches(predicate));\n }\n case 'string': {\n return collection.filter(property(predicate));\n }\n }\n}\n","import { property } from '../object/property.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Finds the first item in an array that matches the given predicate function.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {(item: T, index: number, arr: T[]) => unknown} doesMatch - A function that takes an item, its index, and the array, and returns a truthy value if the item matches the criteria.\n * @returns {T | undefined} - The first item that matches the predicate, or `undefined` if no match is found.\n *\n * @example\n * // Using a predicate function\n * const items = [1, 2, 3, 4, 5];\n * const result = find(items, (item) => item > 3);\n * console.log(result); // 4\n */\nexport function find(\n arr: ArrayLike | null | undefined,\n doesMatch: (item: T, index: number, arr: readonly T[]) => unknown\n): T | undefined;\n\n/**\n * Finds the first item in an array that matches the given partial object.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {Partial} doesMatch - A partial object that specifies the properties to match.\n * @returns {T | undefined} - The first item that matches the partial object, or `undefined` if no match is found.\n *\n * @example\n * // Using a partial object\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = find(items, { name: 'Bob' });\n * console.log(result); // { id: 2, name: 'Bob' }\n */\nexport function find(arr: ArrayLike | null | undefined, doesMatch: Partial): T | undefined;\n\n/**\n * Finds the first item in an array that matches a property with a specific value.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {[keyof T, unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.\n * @returns {T | undefined} - The first item that has the specified property value, or `undefined` if no match is found.\n *\n * @example\n * // Using a property-value pair\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = find(items, ['name', 'Alice']);\n * console.log(result); // { id: 1, name: 'Alice' }\n */\nexport function find(arr: ArrayLike | null | undefined, doesMatchProperty: [keyof T, unknown]): T | undefined;\n\n/**\n * Finds the first item in an array that has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {string} propertyToCheck - The property name to check.\n * @returns {T | undefined} - The first item that has the specified property, or `undefined` if no match is found.\n *\n * @example\n * // Using a property name\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = find(items, 'name');\n * console.log(result); // { id: 1, name: 'Alice' }\n */\nexport function find(arr: ArrayLike | null | undefined, propertyToCheck: string): T | undefined;\n\n/**\n * Finds the first item in an object that matches the given predicate function.\n *\n * @template T\n * @param {T | null | undefined} object - The object to search through.\n * @param {(item: T[keyof T], index: number, arr: T) => unknown} doesMatch - A function that takes an item, its key, and the object, and returns a truthy value if the item matches the criteria.\n * @returns {T | undefined} - The first property value that matches the predicate, or `undefined` if no match is found.\n *\n * @example\n * // Using a predicate function\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = find(obj, (item) => item > 2);\n * console.log(result); // 3\n */\nexport function find>(\n object: T | null | undefined,\n doesMatch: (item: T[keyof T], index: keyof T, object: T) => unknown\n): T | undefined;\n\n/**\n * Finds the first item in an object that matches the given partial value.\n *\n * @template T\n * @param {T | null | undefined} object - The object to search through.\n * @param {Partial} doesMatch - A partial value to match against the values of the object.\n * @returns {T | undefined} - The first property value that matches the partial value, or `undefined` if no match is found.\n *\n * @example\n * // Using a partial value\n * const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };\n * const result = find(obj, { name: 'Bob' });\n * console.log(result); // { id: 2, name: 'Bob' }\n */\nexport function find>(\n object: T | null | undefined,\n doesMatch: Partial\n): T | undefined;\n\n/**\n * Finds the first item in an object that matches a property with a specific value.\n *\n * @template T\n * @param {T | null | undefined} object - The object to search through.\n * @param {[keyof T[keyof T], unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.\n * @returns {T | undefined} - The first item that has the specified property value, or `undefined` if no match is found.\n *\n * @example\n * // Using a property-value pair\n * const items = { alice: { id: 1, name: 'Alice' }, bob: { id: 2, name: 'Bob' } };\n * const result = find(items, ['name', 'Alice']);\n * console.log(result); // { id: 1, name: 'Alice' }\n */\nexport function find>(\n object: T | null | undefined,\n doesMatchProperty: [keyof T[keyof T], unknown]\n): T | undefined;\n\n/**\n * Finds the first item in an object that has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {T | null | undefined} object - The object to search through.\n * @param {string} propertyToCheck - The property name to check.\n * @returns {T | undefined} - The first property value that has the specified property, or `undefined` if no match is found.\n *\n * @example\n * // Using a property name\n * const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };\n * const result = find(obj, 'name');\n * console.log(result); // { id: 1, name: 'Alice' }\n */\nexport function find>(\n object: T | null | undefined,\n propertyToCheck: string\n): T | undefined;\n\n/**\n * Finds the first item in an object that has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {ArrayLike | Record | null | undefined} source - The source array or object to search through.\n * @param {((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string} doesMatch - The criteria to match. It can be a function, a partial object, a key-value pair, or a property name.\n * @returns {T | undefined} - The first property value that has the specified property, or `undefined` if no match is found.\n *\n * @example\n * // Using a property name\n * const obj = { a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } };\n * const result = find(obj, 'name');\n * console.log(result); // { id: 1, name: 'Alice' }\n */\nexport function find(\n source: ArrayLike | Record | null | undefined,\n doesMatch: ((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string\n): T | undefined {\n if (!source) {\n return undefined;\n }\n const values = Array.isArray(source) ? source : Object.values(source);\n\n switch (typeof doesMatch) {\n case 'function': {\n if (!Array.isArray(source)) {\n const keys = Object.keys(source) as Array;\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = source[key] as T;\n\n if (doesMatch(value, key as number, source)) {\n return value;\n }\n }\n\n return undefined;\n }\n\n return values.find(doesMatch);\n }\n case 'object': {\n if (Array.isArray(doesMatch) && doesMatch.length === 2) {\n const key = doesMatch[0];\n const value = doesMatch[1];\n\n return values.find(matchesProperty(key, value));\n } else {\n return values.find(matches(doesMatch));\n }\n }\n case 'string': {\n return values.find(property(doesMatch));\n }\n }\n}\n","import { property } from '../object/property.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Finds the index of the first item in an array that matches the given predicate function.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {(item: T, index: number, arr: T[]) => unknown} doesMatch - A function that takes an item, its index, and the array, and returns a truthy value if the item matches the criteria.\n * @param {number} [fromIndex=0] - The index to start the search from, defaults to 0.\n * @returns {number} - The index of the first item that matches the predicate, or `undefined` if no match is found.\n *\n * @example\n * // Using a predicate function\n * const items = [1, 2, 3, 4, 5];\n * const result = find(items, (item) => item > 3);\n * console.log(result); // 4\n */\nexport function findIndex(\n arr: ArrayLike | null | undefined,\n doesMatch: (item: T, index: number, arr: readonly T[]) => unknown,\n fromIndex?: number\n): number;\n\n/**\n * Finds the index of the first item in an array that matches the given partial object.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {Partial} doesMatch - A partial object that specifies the properties to match.\n * @param {number} [fromIndex=0] - The index to start the search from, defaults to 0.\n * @returns {number} - The index of the first item that matches the partial object, or `undefined` if no match is found.\n *\n * @example\n * // Using a partial object\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = findIndex(items, { name: 'Bob' });\n * console.log(result); // 1\n */\nexport function findIndex(arr: ArrayLike | null | undefined, doesMatch: Partial, fromIndex?: number): number;\n\n/**\n * Finds the index of the first item in an array that matches a property with a specific value.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {[keyof T, unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.\n * @param {number} [fromIndex=0] - The index to start the search from, defaults to 0.\n * @returns {number} - The index of the first item that has the specified property value, or `undefined` if no match is found.\n *\n * @example\n * // Using a property-value pair\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = findIndex(items, ['name', 'Alice']);\n * console.log(result); // 0\n */\nexport function findIndex(\n arr: ArrayLike | null | undefined,\n doesMatchProperty: [keyof T, unknown],\n fromIndex?: number\n): number;\n\n/**\n * Finds the index of the first item in an array that has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {string} propertyToCheck - The property name to check.\n * @param {number} [fromIndex=0] - The index to start the search from, defaults to 0.\n * @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.\n *\n * @example\n * // Using a property name\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = findIndex(items, 'name');\n * console.log(result); // 0\n */\nexport function findIndex(arr: ArrayLike | null | undefined, propertyToCheck: string, fromIndex?: number): number;\n\n/**\n * Finds the index of the first item in an array that has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string} doesMatch - The criteria to match against the items in the array. This can be a function, a partial object, a key-value pair, or a property name.\n * @param {string} propertyToCheck - The property name to check for in the items of the array.\n * @param {number} [fromIndex=0] - The index to start the search from, defaults to 0.\n * @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.\n *\n * @example\n * // Using a property name\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = findIndex(items, 'name');\n * console.log(result); // 0\n */\nexport function findIndex(\n arr: ArrayLike | null | undefined,\n doesMatch: ((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string,\n fromIndex: number = 0\n): number {\n if (!arr) {\n return -1;\n }\n if (fromIndex < 0) {\n fromIndex = Math.max(arr.length + fromIndex, 0);\n }\n const subArray = Array.from(arr).slice(fromIndex);\n let index = -1;\n switch (typeof doesMatch) {\n case 'function': {\n index = subArray.findIndex(doesMatch);\n break;\n }\n case 'object': {\n if (Array.isArray(doesMatch) && doesMatch.length === 2) {\n const key = doesMatch[0];\n const value = doesMatch[1];\n\n index = subArray.findIndex(matchesProperty(key, value));\n } else {\n index = subArray.findIndex(matches(doesMatch));\n }\n break;\n }\n case 'string': {\n index = subArray.findIndex(property(doesMatch));\n }\n }\n return index === -1 ? -1 : index + fromIndex;\n}\n","/**\n * Finds the key of the first element in the object that satisfies the provided testing function.\n *\n * @param {T} obj - The object to search.\n * @param {(value: T[keyof T], key: keyof T, obj: T) => boolean} predicate - The function to execute on each value in the object. It takes three arguments:\n * - value: The current value being processed in the object.\n * - key: The key of the current value being processed in the object.\n * - obj: The object that findKey was called upon.\n * @returns {keyof T | undefined} The key of the first element in the object that passes the test, or undefined if no element passes.\n *\n * @example\n * const users = {\n * 'barney': { 'age': 36, 'active': true },\n * 'fred': { 'age': 40, 'active': false },\n * 'pebbles': { 'age': 1, 'active': true }\n * };\n * findKey(users, function(o) { return o.age < 40; }); => 'barney'\n */\nexport function findKey>(\n obj: T,\n predicate: (value: T[keyof T], key: keyof T, obj: T) => boolean\n): keyof T | undefined {\n const keys = Object.keys(obj) as Array;\n\n return keys.find(key => predicate(obj[key], key, obj));\n}\n","import { toArray } from '../_internal/toArray.ts';\nimport { property } from '../object/property.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Iterates through an array in reverse order and returns the index of the first item that matches the given predicate function.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {(item: T, index: number, arr: T[]) => unknown} doesMatch - A function that takes an item, its index, and the array, and returns a truthy value if the item matches the criteria.\n * @param {number} [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.\n * @returns {number} - The index of the first item that matches the predicate, or `undefined` if no match is found.\n *\n * @example\n * // Using a predicate function\n * const items = [1, 2, 3, 4, 5];\n * const result = findLastIndex(items, (item) => item > 3)\n * console.log(result); // 4\n */\nexport function findLastIndex(\n arr: ArrayLike | null | undefined,\n doesMatch: (item: T, index: number, arr: readonly T[]) => unknown,\n fromIndex?: number\n): number;\n\n/**\n * Finds the index of the first item in an array that matches the given partial object.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {Partial} doesMatch - A partial object that specifies the properties to match.\n * @param {number} [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.\n * @returns {number} - The index of the first item that matches the partial object, or `undefined` if no match is found.\n *\n * @example\n * // Using a partial object\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = findLastIndex(items, { name: 'Bob' });\n * console.log(result); // 1\n */\nexport function findLastIndex(\n arr: ArrayLike | null | undefined,\n doesMatch: Partial,\n fromIndex?: number\n): number;\n\n/**\n * Finds the index of the first item in an array that matches a property with a specific value.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {[keyof T, unknown]} doesMatchProperty - An array where the first element is the property key and the second element is the value to match.\n * @param {number} [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.\n * @returns {number} - The index of the first item that has the specified property value, or `undefined` if no match is found.\n *\n * @example\n * // Using a property-value pair\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = findLastIndex(items, ['name', 'Alice']);\n * console.log(result); // 0\n */\nexport function findLastIndex(\n arr: ArrayLike | null | undefined,\n doesMatchProperty: [keyof T, unknown],\n fromIndex?: number\n): number;\n\n/**\n * Finds the index of the first item in an array that has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {string} propertyToCheck - The property name to check.\n * @param {number} [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.\n * @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.\n *\n * @example\n * // Using a property name\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = findLastIndex(items, 'name');\n * console.log(result); // 1\n */\nexport function findLastIndex(\n arr: ArrayLike | null | undefined,\n propertyToCheck: string,\n fromIndex?: number\n): number;\n\n/**\n * Finds the index of the first item in an array that has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr - The array to search through.\n * @param {((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string} doesMatch - The property name to check.\n * @param {number} [fromIndex=arr.length - 1] - The index to start the search from, defaults to the last index of the array.\n * @returns {number} - The index of the first item that has the specified property, or `undefined` if no match is found.\n *\n * @example\n * // Using a property name\n * const items = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];\n * const result = findLastIndex(items, 'name');\n * console.log(result); // 1\n */\nexport function findLastIndex(\n arr: ArrayLike | null | undefined,\n doesMatch: ((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string,\n fromIndex: number = arr ? arr.length - 1 : 0\n): number {\n if (!arr) {\n return -1;\n }\n if (fromIndex < 0) {\n fromIndex = Math.max(arr.length + fromIndex, 0);\n } else {\n fromIndex = Math.min(fromIndex, arr.length - 1);\n }\n\n const subArray = toArray(arr).slice(0, fromIndex + 1);\n\n switch (typeof doesMatch) {\n case 'function': {\n return subArray.findLastIndex(doesMatch);\n }\n case 'object': {\n if (Array.isArray(doesMatch) && doesMatch.length === 2) {\n const key = doesMatch[0];\n const value = doesMatch[1];\n\n return subArray.findLastIndex(matchesProperty(key, value));\n } else {\n return subArray.findLastIndex(matches(doesMatch));\n }\n }\n case 'string': {\n return subArray.findLastIndex(property(doesMatch));\n }\n }\n}\n","import { flatten } from './flatten.ts';\n\n/**\n * Maps each element in the array using the iteratee function and flattens the result up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template U - The type of elements within the returned array from the iteratee function.\n * @template D - The depth to which the array should be flattened.\n * @param {T[]} arr - The array to flatten.\n * @param {(item: T) => U} iteratee - The function that produces the new array elements.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array>} The new array with the mapped and flattened elements.\n *\n * @example\n * const arr = [1, 2, 3];\n *\n * flatMap(arr, (item: number) => [item, item]);\n * // [1, 1, 2, 2, 3, 3]\n *\n * flatMap(arr, (item: number) => [[item, item]], 2);\n * // [1, 1, 2, 2, 3, 3]\n */\nexport function flatMap(\n arr: readonly T[],\n iteratee: (item: T) => U,\n depth = 1 as D\n): Array> {\n return flatten(\n arr.map(item => iteratee(item)),\n depth\n );\n}\n","import { ExtractNestedArrayType, flattenDeep } from './flattenDeep.ts';\n\n/**\n * Recursively maps each element in an array using a provided iteratee function and then deeply flattens the resulting array.\n *\n * @template T - The type of elements within the array.\n * @template U - The type of elements within the returned array from the iteratee function.\n * @param {T[]} arr - The array to flatten.\n * @param {(item: T) => U} iteratee - The function that produces the new array elements.\n * @returns {Array>} A new array that has been flattened.\n *\n * @example\n * const result = flatMapDeep([1, 2, 3], n => [[n, n]]);\n * // [1, 1, 2, 2, 3, 3]\n */\nexport function flatMapDeep(arr: readonly T[], iteratee: (item: T) => U): Array> {\n return flattenDeep(arr.map((item: T) => iteratee(item)));\n}\n","import { flatten } from './flatten.ts';\n\n/**\n * Utility type for recursively unpacking nested array types to extract the type of the innermost element\n *\n * @example\n * ExtractNestedArrayType<(number | (number | number[])[])[]>\n * // number\n *\n * ExtractNestedArrayType<(boolean | (string | number[])[])[]>\n * // string | number | boolean\n */\nexport type ExtractNestedArrayType = T extends ReadonlyArray ? ExtractNestedArrayType : T;\n\n/**\n * Flattens all depths of a nested array.\n *\n * @template T - The type of elements within the array.\n * @param {T[]} arr - The array to flatten.\n * @returns {Array>} A new array that has been flattened.\n *\n * @example\n * const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flattenDeep(arr: readonly T[]): Array> {\n return flatten(arr, Infinity) as Array>;\n}\n","import { flatten } from './flatten.ts';\n\n/**\n * Utility type for recursively unpacking nested array types to extract the type of the innermost element\n *\n * @example\n * ExtractNestedArrayType<(number | (number | number[])[])[]>\n * // number\n *\n * ExtractNestedArrayType<(boolean | (string | number[])[])[]>\n * // string | number | boolean\n */\ntype ExtractNestedArrayType = T extends ReadonlyArray ? ExtractNestedArrayType : T;\n\n/**\n * Flattens all depths of a nested array.\n *\n * @template T - The type of elements within the array.\n * @param {ArrayLike} value - The value to flatten.\n * @returns {Array> | []} A new array that has been flattened.\n *\n * @example\n * const value = flattenDeep([1, [2, [3]], [4, [5, 6]]]);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flattenDeep(value: ArrayLike | null | undefined): Array> | [] {\n return flatten(value, Infinity) as Array>;\n}\n","import { flatten } from './flatten.ts';\n\n/**\n * Flattens an array up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template D - The depth to which the array should be flattened.\n * @param {ArrayLike | null | undefined} value - The value to flatten.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array> | []} A new array that has been flattened.\n *\n * @example\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);\n * // Returns: [1, 2, 3, 4, [5, 6]]\n *\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flattenDepth(\n value: ArrayLike | null | undefined,\n depth = 1 as D\n): Array> | [] {\n return flatten(value, depth);\n}\n","/**\n * Reverses the order of arguments for a given function.\n *\n * @template F - The type of the function being flipped.\n * @param {F} func - The function whose arguments will be reversed.\n * @returns {(...args: Reversed>) => ReturnType} A new function that takes the\n * reversed arguments and returns the result of calling `func`.\n *\n * @example\n * function fn(a: string, b: string, c: string, d: string) {\n * return [a, b, c, d];\n * }\n *\n * const flipped = flip(fn);\n * flipped('a', 'b', 'c', 'd'); // => ['d', 'c', 'b', 'a']\n */\n\nexport function flip any>(func: F): (...args: Reversed>) => ReturnType {\n return function (this: any, ...args: Reversed>) {\n return func.apply(this, args.reverse());\n };\n}\n\ntype Reversed = T extends [infer First, ...infer Rest] ? [...Reversed, First] : [];\n","import { decimalAdjust } from '../_internal/decimalAdjust.ts';\n\n/**\n * Computes number rounded down to precision.\n *\n * @param {number | string} number The number to round down.\n * @param {number | string} precision The precision to round down to.\n * @returns {number} Returns the rounded down number.\n *\n * @example\n * floor(4.006); // => 4\n * floor(0.046, 2); // => 0.04\n * floor(4060, -2); // => 4000\n */\nexport function floor(number: number | string, precision: number | string = 0): number {\n return decimalAdjust('floor', number, precision);\n}\n","import { flatten } from '../../array/flatten.ts';\nimport { flow as flowToolkit } from '../../function/flow.ts';\n\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {() => R} f The function to invoke.\n * @returns {() => R} Returns the new composite function.\n *\n * @example\n * function noArgFunc() {\n * return 42;\n * }\n *\n * const combined = flow(noArgFunc);\n * console.log(combined()); // 42\n */\nexport function flow(f: () => R): () => R;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R} f1 The function to invoke.\n * @returns {(...args: A) => R} Returns the new composite function.\n *\n * @example\n * function oneArgFunc(a: number) {\n * return a * 2;\n * }\n *\n * const combined = flow(oneArgFunc);\n * console.log(combined(5)); // 10\n */\nexport function flow(f1: (...args: A) => R): (...args: A) => R;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @returns {(...args: A) => R2} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n *\n * const combined = flow(add, square);\n * console.log(combined(1, 2)); // 9\n */\nexport function flow(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @returns {(...args: A) => R3} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n *\n * const combined = flow(add, square, double);\n * console.log(combined(1, 2)); // 18\n */\nexport function flow(\n f1: (...args: A) => R1,\n f2: (a: R1) => R2,\n f3: (a: R2) => R3\n): (...args: A) => R3;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R3) => R4} f4 The function to invoke.\n * @returns {(...args: A) => R4} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n * const toStr = (n: number) => n.toString();\n *\n * const combined = flow(add, square, double, toStr);\n * console.log(combined(1, 2)); // '18'\n */\nexport function flow(\n f1: (...args: A) => R1,\n f2: (a: R1) => R2,\n f3: (a: R2) => R3,\n f4: (a: R3) => R4\n): (...args: A) => R4;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R3) => R4} f4 The function to invoke.\n * @param {(a: R4) => R5} f5 The function to invoke.\n * @returns {(...args: A) => R5} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n * const toStr = (n: number) => n.toString();\n * const split = (s: string) => s.split('');\n *\n * const combined = flow(add, square, double, toStr, split);\n * console.log(combined(1, 2)); // ['1', '8']\n */\nexport function flow(\n f1: (...args: A) => R1,\n f2: (a: R1) => R2,\n f3: (a: R2) => R3,\n f4: (a: R3) => R4,\n f5: (a: R4) => R5\n): (...args: A) => R5;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {Array<((...args: any[]) => any) | Array<(...args: any[]) => any>>} funcs The functions to invoke.\n * @returns {(...args: any[]) => any} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n *\n * const combined = flow([add, square], double);\n * console.log(combined(1, 2)); // 18\n */\nexport function flow(\n ...funcs: Array<((...args: any[]) => any) | Array<(...args: any[]) => any>>\n): (...args: any[]) => any;\n/**\n * Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * @param {Array<((...args: any[]) => any) | Array<(...args: any[]) => any>>} funcs The functions to invoke.\n * @returns {(...args: any[]) => any} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n *\n * const combined = flow([add, square], double);\n * console.log(combined(1, 2)); // 18\n */\nexport function flow(\n ...funcs: Array<((...args: any[]) => any) | Array<(...args: any[]) => any>>\n): (...args: any[]) => any {\n const flattenFuncs = flatten(funcs, 1);\n if (flattenFuncs.some(func => typeof func !== 'function')) {\n throw new TypeError('Expected a function');\n }\n return flowToolkit(...flattenFuncs);\n}\n","import { flatten } from '../../array/flatten.ts';\nimport { flowRight as flowRightToolkit } from '../../function/flowRight.ts';\n\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {() => R} f The function to invoke.\n * @returns {() => R} Returns the new composite function.\n *\n * @example\n * function noArgFunc() {\n * return 42;\n * }\n * const combined = flowRight(noArgFunc);\n * console.log(combined()); // 42\n */\nexport function flowRight(f: () => R): () => R;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(...args: A) => R} f1 The function to invoke.\n * @returns {(...args: A) => R} Returns the new composite function.\n *\n * @example\n * function oneArgFunc(a: number) {\n * return a * 2;\n * }\n * const combined = flowRight(oneArgFunc);\n * console.log(combined(5)); // 10\n */\nexport function flowRight(f1: (...args: A) => R): (...args: A) => R;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @returns {(...args: A) => R2} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n *\n * const combined = flowRight(square, add);\n * console.log(combined(1, 2)); // 9\n */\nexport function flowRight(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @returns {(...args: A) => R3} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n *\n * const combined = flowRight(double, square, add);\n * console.log(combined(1, 2)); // 18\n */\nexport function flowRight(\n f3: (a: R2) => R3,\n f2: (a: R1) => R2,\n f1: (...args: A) => R1\n): (...args: A) => R3;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(a: R3) => R4} f4 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @returns {(...args: A) => R4} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n * const toStr = (n: number) => n.toString();\n *\n * const combined = flowRight(toStr, double, square, add);\n * console.log(combined(1, 2)); // '18'\n */\nexport function flowRight(\n f4: (a: R3) => R4,\n f3: (a: R2) => R3,\n f2: (a: R1) => R2,\n f1: (...args: A) => R1\n): (...args: A) => R4;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(a: R4) => R5} f5 The function to invoke.\n * @param {(a: R3) => R4} f4 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @returns {(...args: A) => R5} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n * const toStr = (n: number) => n.toString();\n * const split = (s: string) => s.split('');\n *\n * const combined = flowRight(split, toStr, double, square, add);\n * console.log(combined(1, 2)); // ['1', '8']\n */\nexport function flowRight(\n f5: (a: R4) => R5,\n f4: (a: R3) => R4,\n f3: (a: R2) => R3,\n f2: (a: R1) => R2,\n f1: (...args: A) => R1\n): (...args: A) => R5;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {Array<((...args: any[]) => any) | Array<(...args: any[]) => any>>} funcs The functions to invoke.\n * @returns {(...args: any[]) => any} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n *\n * const combined = flowRight(double, [square, add]);\n * console.log(combined(1, 2)); // 18\n */\nexport function flowRight(\n ...funcs: Array<((...args: any[]) => any) | Array<(...args: any[]) => any>>\n): (...args: any[]) => any;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {Array<((...args: any[]) => any) | Array<(...args: any[]) => any>>} funcs The functions to invoke.\n * @returns {(...args: any[]) => any} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n *\n * const combined = flowRight(double, [square, add]);\n * console.log(combined(1, 2)); // 18\n */\nexport function flowRight(\n ...funcs: Array<((...args: any[]) => any) | Array<(...args: any[]) => any>>\n): (...args: any[]) => any {\n const flattenFuncs = flatten(funcs, 1);\n if (flattenFuncs.some(func => typeof func !== 'function')) {\n throw new TypeError('Expected a function');\n }\n return flowRightToolkit(...flattenFuncs);\n}\n","import { flow } from './flow.ts';\n\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {() => R} f The function to invoke.\n * @returns {() => R} Returns the new composite function.\n *\n * @example\n * function noArgFunc() {\n * return 42;\n * }\n * const combined = flowRight(noArgFunc);\n * console.log(combined()); // 42\n */\nexport function flowRight(f: () => R): () => R;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(...args: A) => R} f1 The function to invoke.\n * @returns {(...args: A) => R} Returns the new composite function.\n *\n * @example\n * function oneArgFunc(a: number) {\n * return a * 2;\n * }\n * const combined = flowRight(oneArgFunc);\n * console.log(combined(5)); // 10\n */\nexport function flowRight(f1: (...args: A) => R): (...args: A) => R;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @returns {(...args: A) => R2} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n *\n * const combined = flowRight(square, add);\n * console.log(combined(1, 2)); // 9\n */\nexport function flowRight(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @returns {(...args: A) => R3} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n *\n * const combined = flowRight(double, square, add);\n * console.log(combined(1, 2)); // 18\n */\nexport function flowRight(\n f3: (a: R2) => R3,\n f2: (a: R1) => R2,\n f1: (...args: A) => R1\n): (...args: A) => R3;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(a: R3) => R4} f4 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @returns {(...args: A) => R4} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n * const toStr = (n: number) => n.toString();\n *\n * const combined = flowRight(toStr, double, square, add);\n * console.log(combined(1, 2)); // '18'\n */\nexport function flowRight(\n f4: (a: R3) => R4,\n f3: (a: R2) => R3,\n f2: (a: R1) => R2,\n f1: (...args: A) => R1\n): (...args: A) => R4;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(a: R4) => R5} f5 The function to invoke.\n * @param {(a: R3) => R4} f4 The function to invoke.\n * @param {(a: R2) => R3} f3 The function to invoke.\n * @param {(a: R1) => R2} f2 The function to invoke.\n * @param {(...args: A) => R1} f1 The function to invoke.\n * @returns {(...args: A) => R5} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n * const double = (n: number) => n * 2;\n * const toStr = (n: number) => n.toString();\n * const split = (s: string) => s.split('');\n *\n * const combined = flowRight(split, toStr, double, square, add);\n * console.log(combined(1, 2)); // ['1', '8']\n */\nexport function flowRight(\n f5: (a: R4) => R5,\n f4: (a: R3) => R4,\n f3: (a: R2) => R3,\n f2: (a: R1) => R2,\n f1: (...args: A) => R1\n): (...args: A) => R5;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(...args: any[]) => any} funcs The functions to invoke.\n * @returns {(...args: any[]) => any} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n *\n * const combined = flowRight(square, add);\n * console.log(combined(1, 2)); // 9\n */\nexport function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;\n/**\n * Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.\n *\n * The `this` context of the returned function is also passed to the functions provided as parameters.\n *\n * This method is like `flow` except that it creates a function that invokes the given functions from right to left.\n *\n * @param {(...args: any[]) => any} funcs The functions to invoke.\n * @returns {(...args: any[]) => any} Returns the new composite function.\n *\n * @example\n * const add = (x: number, y: number) => x + y;\n * const square = (n: number) => n * n;\n *\n * const combined = flowRight(square, add);\n * console.log(combined(1, 2)); // 9\n */\nexport function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any {\n return flow(...funcs.reverse());\n}\n","/**\n * Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to iterate over.\n * @param {(value: T, index: number, arr: T[]) => void} callback - The function invoked per iteration.\n * The callback function receives three arguments:\n * - 'value': The current element being processed in the array.\n * - 'index': The index of the current element being processed in the array.\n * - 'arr': The array 'forEachRight' was called upon.\n *\n * @example\n * const array = [1, 2, 3];\n * const result: number[] = [];\n *\n * // Use the forEachRight function to iterate through the array and add each element to the result array.\n * forEachRight(array, (value) => {\n * result.push(value);\n * })\n *\n * console.log(result) // Output: [3, 2, 1]\n */\nexport function forEachRight(arr: T[], callback: (value: T, index: number, arr: T[]) => void): void;\n/**\n * Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to iterate over.\n * @param {(value: T, index: number, arr: T[]) => void} callback - The function invoked per iteration.\n * The callback function receives three arguments:\n * - 'value': The current element being processed in the array.\n * - 'index': The index of the current element being processed in the array.\n * - 'arr': The array 'forEachRight' was called upon.\n *\n * @example\n * const array = [1, 2, 3];\n * const result: number[] = [];\n *\n * // Use the forEachRight function to iterate through the array and add each element to the result array.\n * forEachRight(array, (value) => {\n * result.push(value);\n * })\n *\n * console.log(result) // Output: [3, 2, 1]\n */\nexport function forEachRight(\n arr: readonly T[],\n callback: (value: T, index: number, arr: readonly T[]) => void\n): void;\n\n/**\n * Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to iterate over.\n * @param {(value: T, index: number, arr: T[]) => void} callback - The function invoked per iteration.\n * The callback function receives three arguments:\n * - 'value': The current element being processed in the array.\n * - 'index': The index of the current element being processed in the array.\n * - 'arr': The array 'forEachRight' was called upon.\n *\n * @example\n * const array = [1, 2, 3];\n * const result: number[] = [];\n *\n * // Use the forEachRight function to iterate through the array and add each element to the result array.\n * forEachRight(array, (value) => {\n * result.push(value);\n * })\n *\n * console.log(result) // Output: [3, 2, 1]\n */\nexport function forEachRight(arr: readonly T[], callback: (value: T, index: number, arr: T[]) => void): void {\n for (let i = arr.length - 1; i >= 0; i--) {\n const element = arr[i];\n callback(element, i, arr as T[]);\n }\n}\n","import { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Converts an array of key-value pairs into an object.\n *\n * @param {any[]} pairs - An array of key-value pairs where each key is a `PropertyKey` and each value is of type `U`.\n * @returns {Record} - An object where the keys are from the first element and values are from the second element.\n *\n * @example\n * const pairs = [['a', 1], ['b', 2]];\n * const result = fromPairs(pairs);\n * // result will be: { a: 1, b: 2 }\n */\nexport function fromPairs(pairs: readonly any[]): Record;\n/**\n * Converts an array of key-value pairs into an object.\n *\n * @template T - The type of the keys in the resulting object. It must extend `PropertyKey`.\n * @template U - The type of the values in the resulting object.\n *\n * @param {Array<[T, U]>} pairs - An array of key-value pairs where each key is a `PropertyKey` and each value is of type `U`.\n * @returns {Record} - An object where the keys are of type `T` and the values are of type `U`.\n *\n * @example\n * const pairs = [['a', 1], ['b', 2]];\n * const result = fromPairs(pairs);\n * // result will be: { a: 1, b: 2 }\n */\nexport function fromPairs(pairs: ReadonlyArray<[T, U]> | Map): Record;\n/**\n * Converts an array of key-value pairs into an object.\n *\n * @template T - The type of the keys in the resulting object. It must extend `PropertyKey`.\n * @template U - The type of the values in the resulting object.\n *\n * @param {Array<[T, U]>} pairs - An array of key-value pairs where each key is a `PropertyKey` and each value is of type `U`.\n * @returns {Record} - An object where the keys are of type `T` and the values are of type `U`.\n *\n * @example\n * const pairs = [['a', 1], ['b', 2]];\n * const result = fromPairs(pairs);\n * // result will be: { a: 1, b: 2 }\n */\nexport function fromPairs(pairs: ReadonlyArray<[T, U]> | Map): Record {\n if (!isArrayLike(pairs) && !(pairs instanceof Map)) {\n return {} as Record;\n }\n\n const result = {} as Record;\n\n for (const [key, value] of pairs) {\n result[key as T] = value;\n }\n\n return result;\n}\n","/**\n * Groups the elements of an array based on a provided key-generating function.\n *\n * This function takes an array and a function that generates a key from each element. It returns\n * an object where the keys are the generated keys and the values are arrays of elements that share\n * the same key.\n *\n * @template T - The type of elements in the array.\n * @template K - The type of keys.\n * @param {T[]} arr - The array to group.\n * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.\n * @returns {Record} An object where each key is associated with an array of elements that\n * share that key.\n *\n * @example\n * const array = [\n * { category: 'fruit', name: 'apple' },\n * { category: 'fruit', name: 'banana' },\n * { category: 'vegetable', name: 'carrot' }\n * ];\n * const result = groupBy(array, item => item.category);\n * // result will be:\n * // {\n * // fruit: [\n * // { category: 'fruit', name: 'apple' },\n * // { category: 'fruit', name: 'banana' }\n * // ],\n * // vegetable: [\n * // { category: 'vegetable', name: 'carrot' }\n * // ]\n * // }\n */\nexport function groupBy(arr: readonly T[], getKeyFromItem: (item: T) => K): Record {\n const result = Object.create(null) as Record;\n\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n const key = getKeyFromItem(item);\n\n if (result[key] == null) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n","import { inRange as inRangeToolkit } from '../../math/inRange.ts';\n\n/**\n * Checks if the value is less than the maximum.\n *\n * @param {number} value The value to check.\n * @param {number} maximum The upper bound of the range (exclusive).\n * @returns {boolean} `true` if the value is less than the maximum, otherwise `false`.\n *\n * @example\n * const result = inRange(3, 5); // result will be true.\n * const result2 = inRange(5, 5); // result2 will be false.\n */\nexport function inRange(value: number, maximum: number): boolean;\n\n/**\n * Checks if the value is within the range defined by minimum (inclusive) and maximum (exclusive).\n *\n * @param {number} value The value to check.\n * @param {number} minimum The lower bound of the range (inclusive).\n * @param {number} maximum The upper bound of the range (exclusive).\n * @returns {boolean} `true` if the value is within the specified range, otherwise `false`.\n *\n * @example\n * const result = inRange(3, 2, 5); // result will be true.\n * const result2 = inRange(1, 2, 5); // result2 will be false.\n */\nexport function inRange(value: number, minimum: number, maximum: number): boolean;\n\n/**\n * Checks if the value is within a specified range.\n *\n * @param {number} value The value to check.\n * @param {number} minimum The lower bound of the range (inclusive).\n * @param {number} maximum The upper bound of the range (exclusive).\n * @returns {boolean} `true` if the value is within the specified range, otherwise `false`.\n * @throws {Error} Throws an error if the `minimum` is greater or equal than the `maximum`.\n *\n * @example\n * const result1 = inRange(3, 5); // result1 will be true.\n * const result2 = inRange(1, 2, 5); // result2 will be false.\n * const result3 = inRange(1, 5, 2); // If the minimum is greater or equal than the maximum, an error is thrown.\n */\nexport function inRange(value: number, minimum: number, maximum?: number): boolean {\n if (!minimum) {\n minimum = 0;\n }\n\n if (maximum != null && !maximum) {\n maximum = 0;\n }\n\n if (minimum != null && typeof minimum !== 'number') {\n minimum = Number(minimum);\n }\n\n if (maximum == null && minimum === 0) {\n return false;\n }\n\n if (maximum != null && typeof maximum !== 'number') {\n maximum = Number(maximum);\n }\n\n if (maximum != null && minimum > maximum) {\n [minimum, maximum] = [maximum, minimum];\n }\n\n if (minimum === maximum) {\n return false;\n }\n\n return inRangeToolkit(value, minimum, maximum!);\n}\n","/**\n * Checks if the value is less than the maximum.\n *\n * @param {number} value The value to check.\n * @param {number} maximum The upper bound of the range (exclusive).\n * @returns {boolean} `true` if the value is less than the maximum, otherwise `false`.\n *\n * @example\n * const result = inRange(3, 5); // result will be true.\n * const result2 = inRange(5, 5); // result2 will be false.\n */\nexport function inRange(value: number, maximum: number): boolean;\n\n/**\n * Checks if the value is within the range defined by minimum (inclusive) and maximum (exclusive).\n *\n * @param {number} value The value to check.\n * @param {number} minimum The lower bound of the range (inclusive).\n * @param {number} maximum The upper bound of the range (exclusive).\n * @returns {boolean} `true` if the value is within the specified range, otherwise `false`.\n *\n * @example\n * const result = inRange(3, 2, 5); // result will be true.\n * const result2 = inRange(1, 2, 5); // result2 will be false.\n */\nexport function inRange(value: number, minimum: number, maximum: number): boolean;\n\n/**\n * Checks if the value is within a specified range.\n *\n * @param {number} value The value to check.\n * @param {number} minimum The lower bound of the range (inclusive).\n * @param {number} maximum The upper bound of the range (exclusive).\n * @returns {boolean} `true` if the value is within the specified range, otherwise `false`.\n * @throws {Error} Throws an error if the `minimum` is greater or equal than the `maximum`.\n *\n * @example\n * const result1 = inRange(3, 5); // result1 will be true.\n * const result2 = inRange(1, 2, 5); // result2 will be false.\n * const result3 = inRange(1, 5, 2); // If the minimum is greater or equal than the maximum, an error is thrown.\n */\nexport function inRange(value: number, minimum: number, maximum?: number): boolean {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n\n if (minimum >= maximum) {\n throw new Error('The maximum value must be greater than the minimum value.');\n }\n\n return minimum <= value && value < maximum;\n}\n","import { isString } from '../predicate/isString.ts';\nimport { eq } from '../util/eq.ts';\nimport { toInteger } from '../util/toInteger.ts';\n\n/**\n * Checks if an item is included in an array.\n *\n * @param {T[]} arr - The array to search in.\n * @param {T} item - The item to search for.\n * @param {number} [fromIndex=0] - The index to start searching from. If negative, it is treated as an offset from the end of the array.\n * @returns {boolean} `true` if the item is found in the array, `false` otherwise.\n *\n * @example\n * includes([1, 2, 3], 2); // true\n * includes([1, 2, 3], 4); // false\n * includes([1, 2, 3], 3, -1); // true\n */\nexport function includes(arr: readonly T[], item: T, fromIndex?: number): boolean;\n\n/**\n * Checks if a value is included in an object.\n *\n * @param {T} obj - The object to search in.\n * @param {T[keyof T]} value - The value to search for.\n * @param {number} [fromIndex=0] - The index to start searching from. If negative, it is treated as an offset from the end of the array.\n * @returns {boolean} `true` if the value is found in the object, `false` otherwise.\n *\n * @example\n * includes({ a: 1, b: 'a', c: NaN }, 1); // true\n * includes({ a: 1, b: 'a', c: NaN }, 'a'); // true\n * includes({ a: 1, b: 'a', c: NaN }, NaN); // true\n * includes({ [Symbol('sym1')]: 1 }, 1); // false\n */\nexport function includes>(obj: T, value: T[keyof T], fromIndex?: number): boolean;\n\n/**\n * Checks if a substring is included in a string.\n *\n * @param {string} str - The string to search in.\n * @param {string} substr - The substring to search for.\n * @param {number} [fromIndex=0] - The index to start searching from. If negative, it is treated as an offset from the end of the string.\n * @returns {boolean} `true` if the substring is found in the string, `false` otherwise.\n *\n * @example\n * includes('hello world', 'world'); // true\n * includes('hello world', 'test'); // false\n * includes('hello world', 'o', 5); // true\n */\nexport function includes(str: string, substr: string, fromIndex?: number): boolean;\n\n/**\n * Checks if a specified value exists within a given source, which can be an array, an object, or a string.\n *\n * The comparison uses SameValueZero to check for inclusion.\n *\n * @param {T[] | Record | string} source - The source to search in. It can be an array, an object, or a string.\n * @param {T} [target] - The value to search for in the source.\n * @param {number} [fromIndex=0] - The index to start searching from. If negative, it is treated as an offset from the end of the source.\n * @returns {boolean} `true` if the value is found in the source, `false` otherwise.\n *\n * @example\n * includes([1, 2, 3], 2); // true\n * includes({ a: 1, b: 'a', c: NaN }, 'a'); // true\n * includes('hello world', 'world'); // true\n * includes('hello world', 'test'); // false\n */\nexport function includes(\n source: readonly T[] | Record | string,\n target?: T,\n fromIndex?: number\n): boolean;\n\n/**\n * Checks if a specified value exists within a given source, which can be an array, an object, or a string.\n *\n * The comparison uses SameValueZero to check for inclusion.\n *\n * @param {T[] | Record | string} source - The source to search in. It can be an array, an object, or a string.\n * @param {T} [target] - The value to search for in the source.\n * @param {number} [fromIndex=0] - The index to start searching from. If negative, it is treated as an offset from the end of the source.\n * @returns {boolean} `true` if the value is found in the source, `false` otherwise.\n *\n * @example\n * includes([1, 2, 3], 2); // true\n * includes({ a: 1, b: 'a', c: NaN }, 'a'); // true\n * includes('hello world', 'world'); // true\n * includes('hello world', 'test'); // false\n */\nexport function includes(\n source: readonly unknown[] | Record | string,\n target?: unknown,\n fromIndex?: number,\n guard?: unknown\n): boolean {\n if (source == null) {\n return false;\n }\n\n if (guard || !fromIndex) {\n fromIndex = 0;\n } else {\n fromIndex = toInteger(fromIndex);\n }\n\n if (isString(source)) {\n if (fromIndex > source.length || target instanceof RegExp) {\n return false;\n }\n\n if (fromIndex < 0) {\n fromIndex = Math.max(0, source.length + fromIndex);\n }\n\n return source.includes(target as any, fromIndex);\n }\n\n if (Array.isArray(source)) {\n return source.includes(target, fromIndex);\n }\n\n const keys = Object.keys(source);\n\n if (fromIndex < 0) {\n fromIndex = Math.max(0, keys.length + fromIndex);\n }\n\n for (let i = fromIndex; i < keys.length; i++) {\n const value = Reflect.get(source, keys[i]);\n\n if (eq(value, target)) {\n return true;\n }\n }\n\n return false;\n}\n","import { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Finds the index of the first occurrence of a value in an array.\n *\n * This method is similar to `Array.prototype.indexOf`, but it also finds `NaN` values.\n * It uses strict equality (`===`) to compare elements.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} array - The array to search.\n * @param {T} searchElement - The value to search for.\n * @param {number} [fromIndex] - The index to start the search at.\n * @returns {number} The index (zero-based) of the first occurrence of the value in the array, or `-1` if the value is not found.\n *\n * @example\n * const array = [1, 2, 3, NaN];\n * indexOf(array, 3); // => 2\n * indexOf(array, NaN); // => 3\n */\nexport function indexOf(array: ArrayLike | null | undefined, searchElement: T, fromIndex?: number): number {\n if (!isArrayLike(array)) {\n return -1;\n }\n\n // `Array.prototype.indexOf` doesn't find `NaN` values, so we need to handle that case separately.\n if (Number.isNaN(searchElement)) {\n fromIndex = fromIndex ?? 0;\n\n if (fromIndex < 0) {\n fromIndex = Math.max(0, array.length + fromIndex);\n }\n\n for (let i = fromIndex; i < array.length; i++) {\n if (Number.isNaN(array[i])) {\n return i;\n }\n }\n\n return -1;\n }\n\n // Array.prototype.indexOf already handles `fromIndex < -array.length`, `fromIndex >= array.length` and converts `fromIndex` to an integer, so we don't need to handle those cases here.\n // And it uses strict equality (===) to compare elements like `lodash/indexOf` does.\n return Array.from(array).indexOf(searchElement, fromIndex);\n}\n","/**\n * Returns an empty array when the input is a tuple containing exactly one element.\n *\n * @template T The type of the single element.\n * @param {[T]} arr - A tuple containing exactly one element.\n * @returns {[]} An empty array since there is only one element.\n *\n * @example\n * const array = [100] as const;\n * const result = initial(array);\n * // result will be []\n */\nexport function initial(arr: readonly [T]): [];\n\n/**\n * Returns an empty array when the input array is empty.\n *\n * @returns {[]} Always returns an empty array for an empty input.\n *\n * @example\n * const array = [] as const;\n * const result = initial(array);\n * // result will be []\n */\nexport function initial(arr: readonly []): [];\n\n/**\n * Returns a new array containing all elements except the last one from a tuple with multiple elements.\n *\n * @template T The types of the initial elements.\n * @template U The type of the last element in the tuple.\n * @param {[...T[], U]} arr - A tuple with one or more elements.\n * @returns {T[]} A new array containing all but the last element of the tuple.\n *\n * @example\n * const array = ['apple', 'banana', 'cherry'] as const;\n * const result = initial(array);\n * // result will be ['apple', 'banana']\n */\nexport function initial(arr: readonly [...T[], U]): T[];\n\n/**\n * Returns a new array containing all elements except the last one from the input array.\n * If the input array is empty or has only one element, the function returns an empty array.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The input array.\n * @returns {T[]} A new array containing all but the last element of the input array.\n *\n * @example\n * const arr = [1, 2, 3, 4];\n * const result = initial(arr);\n * // result will be [1, 2, 3]\n */\nexport function initial(arr: readonly T[]): T[];\n\n/**\n * Returns a new array containing all elements except the last one from the input array.\n * If the input array is empty or has only one element, the function returns an empty array.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The input array.\n * @returns {T[]} A new array containing all but the last element of the input array.\n *\n * @example\n * const arr = [1, 2, 3, 4];\n * const result = initial(arr);\n * // result will be [1, 2, 3]\n */\nexport function initial(arr: readonly T[]): T[] {\n return arr.slice(0, -1);\n}\n","import { intersection as intersectionToolkit } from '../../array/intersection.ts';\nimport { uniq } from '../../array/uniq.ts';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\n\n/**\n * Returns the intersection of multiple arrays.\n *\n * This function takes multiple arrays and returns a new array containing the elements that are\n * present in all provided arrays. It effectively filters out any elements that are not found\n * in every array.\n *\n * @template T - The type of elements in the arrays.\n * @param {...(ArrayLike | null | undefined)} arrays - The arrays to compare.\n * @returns {T[]} A new array containing the elements that are present in all arrays.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [3, 4, 5, 6, 7];\n * const result = intersection(array1, array2);\n * // result will be [3, 4, 5] since these elements are in both arrays.\n */\nexport function intersection(...arrays: Array | null | undefined>): T[] {\n if (arrays.length === 0) {\n return [];\n }\n\n if (!isArrayLikeObject(arrays[0])) {\n return [];\n }\n\n let result: T[] = uniq(Array.from(arrays[0]));\n\n for (let i = 1; i < arrays.length; i++) {\n const array = arrays[i];\n\n if (!isArrayLikeObject(array)) {\n return [];\n }\n\n result = intersectionToolkit(result, Array.from(array));\n }\n\n return result;\n}\n","import { intersectionBy as intersectionByToolkit } from '../../array/intersectionBy.ts';\nimport { last } from '../../array/last.ts';\nimport { uniq } from '../../array/uniq.ts';\nimport { identity } from '../../function/identity.ts';\nimport { property } from '../object/property.ts';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\n\n/**\n * Returns the intersection of multiple arrays after applying the iteratee function to their elements.\n *\n * This function takes multiple arrays and an iteratee function (or property key) to\n * compare the elements after transforming them. It returns a new array containing the elements from\n * the first array that are present in all subsequent arrays after applying the iteratee to each element.\n *\n * @template T1, T2\n * @param {ArrayLike | null | undefined} array - The first array to compare.\n * @param {ArrayLike} values - The second array to compare.\n * @param {(value: T1 | T2) => unknown | string} iteratee - The iteratee invoked on each element\n * for comparison. It can also be a property key to compare based on that property.\n * @returns {T1[]} A new array containing the elements from the first array that are present\n * in all subsequent arrays after applying the iteratee.\n *\n * @example\n * const array1 = [{ x: 1 }, { x: 2 }, { x: 3 }];\n * const array2 = [{ x: 2 }, { x: 3 }, { x: 4 }];\n * const result = intersectionBy(array1, array2, 'x');\n * // result will be [{ x: 2 }, { x: 3 }] since these elements have the same `x` property.\n *\n * const array1 = [{ x: 1 }, { x: 2 }, { x: 3 }];\n * const array2 = [{ x: 2 }, { x: 3 }, { x: 4 }];\n * const result = intersectionBy(array1, array2, value => value.x);\n * // result will be [{ x: 2 }, { x: 3 }] since these elements have the same `x` property.\n */\nexport function intersectionBy(\n array: ArrayLike | null | undefined,\n values: ArrayLike,\n iteratee: ((value: T1 | T2) => unknown) | string\n): T1[];\n\n/**\n * Returns the intersection of multiple arrays after applying the iteratee function to their elements.\n *\n * This function takes multiple arrays and an iteratee function (or property key) to\n * compare the elements after transforming them. It returns a new array containing the elements from\n * the first array that are present in all subsequent arrays after applying the iteratee to each element.\n *\n * @template T1, T2, T3\n * @param {ArrayLike | null | undefined} array - The first array to compare.\n * @param {ArrayLike} values1 - The second array to compare.\n * @param {ArrayLike} values2 - The third array to compare.\n * @param {(value: T1 | T2 | T3) => unknown | string} iteratee - The iteratee invoked on each element\n * for comparison. It can also be a property key to compare based on that property.\n * @returns {T1[]} A new array containing the elements from the first array that are present\n * in all subsequent arrays after applying the iteratee.\n *\n * @example\n * const array1 = [{ x: 1 }, { x: 2 }, { x: 3 }];\n * const array2 = [{ x: 2 }, { x: 3 }];\n * const array3 = [{ x: 3 }];\n * const result = intersectionBy(array1, array2, array3, 'x');\n * // result will be [{ x: 3 }] since this element has the same `x` property in all arrays.\n *\n * const array1 = [{ x: 1 }, { x: 2 }, { x: 3 }];\n * const array2 = [{ x: 2 }, { x: 3 }];\n * const array3 = [{ x: 3 }];\n * const result = intersectionBy(array1, array2, array3, value => value.x);\n * // result will be [{ x: 3 }] since this element has the same `x` property in all arrays.\n */\nexport function intersectionBy(\n array: ArrayLike | null | undefined,\n values1: ArrayLike,\n values2: ArrayLike,\n iteratee: ((value: T1 | T2 | T3) => unknown) | string\n): T1[];\n\n/**\n * Returns the intersection of multiple arrays after applying the iteratee function to their elements.\n *\n * This function takes multiple arrays and an iteratee function (or property key) to\n * compare the elements after transforming them. It returns a new array containing the elements from\n * the first array that are present in all subsequent arrays after applying the iteratee to each element.\n *\n * @template T1, T2, T3, T4\n * @param {ArrayLike | null | undefined} array - The first array to compare.\n * @param {ArrayLike} values1 - The second array to compare.\n * @param {ArrayLike} values2 - The third array to compare.\n * @param {...(ArrayLike | ((value: T1 | T2 | T3 | T4) => unknown) | string)} values - Additional arrays to compare, or the iteratee function.\n * @returns {T1[]} A new array containing the elements from the first array that are present\n * in all subsequent arrays after applying the iteratee.\n *\n * @example\n * const array1 = [{ x: 1 }, { x: 2 }, { x: 3 }];\n * const array2 = [{ x: 2 }, { x: 3 }];\n * const array3 = [{ x: 3 }];\n * const array4 = [{ x: 3 }, { x: 4 }];\n * const result = intersectionBy(array1, array2, array3, array4, 'x');\n * // result will be [{ x: 3 }] since this element has the same `x` property in all arrays.\n *\n * const array1 = [{ x: 1 }, { x: 2 }, { x: 3 }];\n * const array2 = [{ x: 2 }, { x: 3 }];\n * const array3 = [{ x: 3 }];\n * const array4 = [{ x: 3 }, { x: 4 }];\n * const result = intersectionBy(array1, array2, array3, array4, value => value.x);\n * // result will be [{ x: 3 }] since this element has the same `x` property in all arrays.\n */\nexport function intersectionBy(\n array: ArrayLike | null | undefined,\n values1: ArrayLike,\n values2: ArrayLike,\n ...values: Array | ((value: T1 | T2 | T3 | T4) => unknown) | string>\n): T1[];\n\n/**\n * Returns the intersection of multiple arrays after applying the iteratee function to their elements.\n *\n * This function takes multiple arrays and an iteratee function (or property key) to\n * compare the elements after transforming them. It returns a new array containing the elements from\n * the first array that are present in all subsequent arrays after applying the iteratee to each element.\n *\n * @template T\n * @param {ArrayLike | null | undefined} [array] - The first array to compare.\n * @param {...ArrayLike} values - Additional arrays to compare.\n * @returns {T[]} A new array containing the elements from the first array that are present\n * in all subsequent arrays after applying the iteratee.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [2, 3];\n * const array3 = [3];\n * const result = intersectionBy(array1, array2, array3);\n * // result will be [3] since these all elements have the same value 3.\n */\nexport function intersectionBy(array?: ArrayLike | null | undefined, ...values: Array>): T[];\n\n/**\n * Returns the intersection of multiple arrays after applying the iteratee function to their elements.\n *\n * This function takes multiple arrays and an optional iteratee function (or property key)\n * to compare the elements after transforming them. It returns a new array containing the elements from\n * the first array that are present in all subsequent arrays after applying the iteratee to each element.\n * If no iteratee is provided, the identity function is used.\n *\n * If the first array is `null` or `undefined`, an empty array is returned.\n *\n * @template T\n * @param {ArrayLike | null | undefined} array - The first array to compare.\n * @param {...(ArrayLike | ((value: T) => unknown) | string)} values - The arrays to compare, or the iteratee function.\n * @returns {T[]} A new array containing the elements from the first array that are present\n * in all subsequent arrays after applying the iteratee.\n *\n * @example\n * const array1 = [{ x: 1 }, { x: 2 }, { x: 3 }];\n * const array2 = [{ x: 2 }, { x: 3 }];\n * const result = intersectionBy(array1, array2, 'x');\n * // result will be [{ x: 2 }, { x: 3 }] since these elements have the same `x` property.\n *\n * @example\n * const array1 = [1.1, 2.2, 3.3];\n * const array2 = [2.3, 3.3];\n * const result = intersectionBy(array1, array2, Math.floor);\n * // result will be [2.3, 3.3] since it shares the same integer part when `Math.floor` is applied.\n */\nexport function intersectionBy(\n array: ArrayLike | null | undefined,\n ...values: Array | ((value: T) => unknown) | string>\n): T[] {\n if (!isArrayLikeObject(array)) {\n return [];\n }\n\n const lastValue = last(values);\n if (lastValue === undefined) {\n return Array.from(array);\n }\n\n let result = uniq(Array.from(array));\n\n const count = isArrayLikeObject(lastValue) ? values.length : values.length - 1;\n\n for (let i = 0; i < count; ++i) {\n const value = values[i];\n\n if (!isArrayLikeObject(value)) {\n return [];\n }\n\n if (isArrayLikeObject(lastValue)) {\n result = intersectionByToolkit(result, Array.from(value), identity);\n } else if (typeof lastValue === 'function') {\n result = intersectionByToolkit(result, Array.from(value), value => lastValue(value));\n } else if (typeof lastValue === 'string') {\n result = intersectionByToolkit(result, Array.from(value), property(lastValue));\n }\n }\n\n return result;\n}\n","/**\n * Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.\n *\n * @param {unknown} condition - The condition to evaluate.\n * @param {string} [message] - The error message to throw if the condition is false.\n * @returns {void} Returns void if the condition is true.\n * @throws {Error} Throws an error if the condition is false.\n *\n * @example\n * // This call will succeed without any errors\n * invariant(true, 'This should not throw');\n *\n * // This call will fail and throw an error with the message 'This should throw'\n * invariant(false, 'This should throw');\n *\n * // Example of using invariant with a condition\n * invariant(condition, 'Expected condition is false');\n *\n * // Ensure that the value is neither null nor undefined\n * invariant(value !== null && value !== undefined, 'Value should not be null or undefined');\n *\n * // Example of using invariant to check if a number is positive\n * invariant(number > 0, 'Number must be positive');\n */\nexport function invariant(condition: unknown, message: string): asserts condition {\n if (condition) {\n return;\n }\n\n throw new Error(message);\n}\n","/**\n * Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.\n *\n * This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,\n * the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping\n * of the input object's key-value pairs.\n *\n * @template K - Type of the keys in the input object (string, number, symbol)\n * @template V - Type of the values in the input object (string, number, symbol)\n * @param {Record} obj - The input object whose keys and values are to be inverted\n * @returns {Record} - A new object with keys and values inverted\n *\n * @example\n * invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }\n * invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }\n * invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }\n * invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }\n */\nexport function invert(obj: Record): Record {\n const result = {} as Record;\n\n const keys = Object.keys(obj) as K[];\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = obj[key];\n result[value] = key;\n }\n\n return result;\n}\n","import { identity } from '../../function/identity.ts';\nimport { isNil } from '../../predicate/isNil.ts';\n\n/**\n * Creates a new object that reverses the keys and values of the given object, similar to the invert.\n *\n * The `iteratee` function specifies how the values are reversed into keys. If no `iteratee` function is provided, the values are used as keys as-is.\n *\n * The values of the new object are arrays of keys that correspond to the value returned by the `iteratee` function.\n *\n * @param {Record} object - The object to iterate over.\n * @param {(value: V) => string} [iteratee] - Optional. A function that generates a key based on each value in the object.\n * If not provided, the function defaults to using the value as a string.\n *\n * @returns {Record} An object where the keys are generated by the iteratee, and the values\n * are arrays of property names (keys) from the input object that correspond to those keys.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 1 };\n * const result = invertBy(obj);\n * // result => { '1': ['a', 'c'], '2': ['b'] }\n *\n * @example\n * const obj = { a: 1, b: 2, c: 1 };\n * const result = invertBy(obj, value => `group${value}`);\n * // result => { 'group1': ['a', 'c'], 'group2': ['b'] }\n */\nexport function invertBy(\n object: Record,\n iteratee?: (value: V) => string\n): Record {\n const result = {} as Record;\n\n if (isNil(object)) {\n return result;\n }\n\n if (iteratee == null) {\n iteratee = identity as (value: V) => string;\n }\n\n const keys = Object.keys(object);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i] as K;\n\n const value = object[key];\n const valueStr = iteratee(value);\n\n if (Array.isArray(result[valueStr])) {\n result[valueStr].push(key);\n } else {\n result[valueStr] = [key];\n }\n }\n\n return result;\n}\n","import { isArrayBuffer as isArrayBufferToolkit } from '../../predicate/isArrayBuffer.ts';\n\n/**\n * Checks if a given value is `ArrayBuffer`.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`.\n *\n * @param {unknown} value The value to check if it is a `ArrayBuffer`.\n * @returns {value is ArrayBuffer} Returns `true` if `value` is a `ArrayBuffer`, else `false`.\n *\n * @example\n * const value1 = new ArrayBuffer();\n * const value2 = new Array();\n * const value3 = new Map();\n *\n * console.log(isArrayBuffer(value1)); // true\n * console.log(isArrayBuffer(value2)); // false\n * console.log(isArrayBuffer(value3)); // false\n */\n\nexport function isArrayBuffer(value?: unknown): value is ArrayBuffer {\n return isArrayBufferToolkit(value);\n}\n","/**\n * Checks if a given value is `ArrayBuffer`.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `ArrayBuffer`.\n *\n * @param {unknown} value The value to check if it is a `ArrayBuffer`.\n * @returns {value is ArrayBuffer} Returns `true` if `value` is a `ArrayBuffer`, else `false`.\n *\n * @example\n * const value1 = new ArrayBuffer();\n * const value2 = new Array();\n * const value3 = new Map();\n *\n * console.log(isArrayBuffer(value1)); // true\n * console.log(isArrayBuffer(value2)); // false\n * console.log(isArrayBuffer(value3)); // false\n */\n\nexport function isArrayBuffer(value: unknown): value is ArrayBuffer {\n return value instanceof ArrayBuffer;\n}\n","/**\n * Checks if the given value is boolean.\n *\n * This function tests whether the provided value is strictly `boolean`.\n * It returns `true` if the value is `boolean`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.\n *\n * @param {unknown} value - The Value to test if it is boolean.\n * @returns {value is boolean} True if the value is boolean, false otherwise.\n *\n * @example\n *\n * const value1 = true;\n * const value2 = 0;\n * const value3 = 'abc';\n *\n * console.log(isBoolean(value1)); // true\n * console.log(isBoolean(value2)); // false\n * console.log(isBoolean(value3)); // false\n *\n */\nexport function isBoolean(value?: unknown): value is boolean {\n return typeof value === 'boolean' || value instanceof Boolean;\n}\n","import { isDate as isDateToolkit } from '../../predicate/isDate.ts';\n\n/**\n * Checks if `value` is a Date object.\n *\n * @param {unknown} value The value to check.\n * @returns {value is Date} Returns `true` if `value` is a Date object, `false` otherwise.\n *\n * @example\n * const value1 = new Date();\n * const value2 = '2024-01-01';\n *\n * console.log(isDate(value1)); // true\n * console.log(isDate(value2)); // false\n */\nexport function isDate(value?: unknown): value is Date {\n return isDateToolkit(value);\n}\n","/**\n * Checks if `value` is a Date object.\n *\n * @param {unknown} value The value to check.\n * @returns {value is Date} Returns `true` if `value` is a Date object, `false` otherwise.\n *\n * @example\n * const value1 = new Date();\n * const value2 = '2024-01-01';\n *\n * console.log(isDate(value1)); // true\n * console.log(isDate(value2)); // false\n */\nexport function isDate(value: unknown): value is Date {\n return value instanceof Date;\n}\n","import { isArguments } from './isArguments.ts';\nimport { isArrayLike } from './isArrayLike.ts';\nimport { isTypedArray } from './isTypedArray.ts';\nimport { isPrototype } from '../_internal/isPrototype.ts';\n\ndeclare let Buffer:\n | {\n isBuffer: (a: any) => boolean;\n }\n | undefined;\n\n/**\n * Checks if a given value is empty.\n *\n * @returns {true} Always returns true when no arguments are provided.\n *\n * @example\n * isEmpty(); // true\n */\nexport function isEmpty(): true;\n\n/**\n * Checks if a given string is empty.\n *\n * @param {string} value - The string to check.\n * @returns {boolean} `true` if the string is empty, `false` otherwise.\n *\n * @example\n * isEmpty(\"\"); // true\n * isEmpty(\"hello\"); // false\n */\nexport function isEmpty(value: string): value is '';\n\n/**\n * Checks if a given Map is empty.\n *\n * @param {Map} value - The Map to check.\n * @returns {boolean} `true` if the Map is empty, `false` otherwise.\n *\n * @example\n * isEmpty(new Map()); // true\n * isEmpty(new Map([[\"key\", \"value\"]])); // false\n */\nexport function isEmpty(value: Map): boolean;\n\n/**\n * Checks if a given Set is empty.\n *\n * @param {Set} value - The Set to check.\n * @returns {boolean} `true` if the Set is empty, `false` otherwise.\n *\n * @example\n * isEmpty(new Set()); // true\n * isEmpty(new Set([1, 2, 3])); // false\n */\nexport function isEmpty(value: Set): boolean;\n\n/**\n * Checks if a given array is empty.\n *\n * @param {any[]} value - The array to check.\n * @returns {boolean} `true` if the array is empty, `false` otherwise.\n *\n * @example\n * isEmpty([]); // true\n * isEmpty([1, 2, 3]); // false\n */\nexport function isEmpty(value: any[]): value is [];\n\n/**\n * Checks if a given object is empty.\n *\n * @param {T | null | undefined} value - The object to check.\n * @returns {boolean} `true` if the object is empty, `false` otherwise.\n *\n * @example\n * isEmpty({}); // true\n * isEmpty({ a: 1 }); // false\n */\nexport function isEmpty>(\n value: T | null | undefined\n): value is Record | null | undefined;\n\n/**\n * Checks if a given value is empty.\n *\n * @param {unknown} value - The value to check.\n * @returns {boolean} `true` if the value is empty, `false` otherwise.\n *\n * @example\n * isEmpty(null); // true\n * isEmpty(undefined); // true\n * isEmpty(42); // true\n */\nexport function isEmpty(value: unknown): boolean;\n\n/**\n * Checks if a given value is empty.\n *\n * - If the given value is a string, checks if it is an empty string.\n * - If the given value is an array, `Map`, or `Set`, checks if its size is 0.\n * - If the given value is an [array-like object](../predicate/isArrayLike.md), checks if its length is 0.\n * - If the given value is an object, checks if it is an empty object with no properties.\n * - Primitive values (strings, booleans, numbers, or bigints) are considered empty.\n *\n * @param {unknown} [value] - The value to check.\n * @returns {boolean} `true` if the value is empty, `false` otherwise.\n *\n * @example\n * isEmpty(); // true\n * isEmpty(null); // true\n * isEmpty(\"\"); // true\n * isEmpty([]); // true\n * isEmpty({}); // true\n * isEmpty(new Map()); // true\n * isEmpty(new Set()); // true\n * isEmpty(\"hello\"); // false\n * isEmpty([1, 2, 3]); // false\n * isEmpty({ a: 1 }); // false\n * isEmpty(new Map([[\"key\", \"value\"]])); // false\n * isEmpty(new Set([1, 2, 3])); // false\n */\nexport function isEmpty(value?: unknown): boolean {\n if (value == null) {\n return true;\n }\n\n // Objects like { \"length\": 0 } are not empty in lodash\n if (isArrayLike(value)) {\n if (\n typeof (value as any).splice !== 'function' &&\n typeof value !== 'string' &&\n (typeof Buffer === 'undefined' || !Buffer.isBuffer(value)) &&\n !isTypedArray(value) &&\n !isArguments(value)\n ) {\n return false;\n }\n\n return value.length === 0;\n }\n\n if (typeof value === 'object') {\n if (value instanceof Map || value instanceof Set) {\n return value.size === 0;\n }\n\n const keys = Object.keys(value);\n\n if (isPrototype(value)) {\n return keys.filter(x => x !== 'constructor').length === 0;\n }\n\n return keys.length === 0;\n }\n\n return true;\n}\n","export function isPrototype(value: {}) {\n const constructor = value.constructor;\n const prototype = typeof constructor === 'function' ? constructor.prototype : Object.prototype;\n\n return value === prototype;\n}\n","import { isEqualWith } from './isEqualWith.ts';\nimport { noop } from '../function/noop.ts';\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @returns {boolean} `true` if the values are equal, otherwise `false`.\n *\n * @example\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n */\nexport function isEqual(a: any, b: any): boolean {\n return isEqualWith(a, b, noop);\n}\n","import { after } from '../../function/after.ts';\nimport { noop } from '../../function/noop.ts';\nimport { isEqualWith as isEqualWithToolkit } from '../../predicate/isEqualWith.ts';\n\n/**\n * Compares two values for equality using a custom comparison function.\n *\n * The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.\n *\n * This function also uses the custom equality function to compare values inside objects,\n * arrays, maps, sets, and other complex structures, ensuring a deep comparison.\n *\n * This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.\n *\n * The custom comparison function can take up to six parameters:\n * - `x`: The value from the first object `a`.\n * - `y`: The value from the second object `b`.\n * - `property`: The property key used to get `x` and `y`.\n * - `xParent`: The parent of the first value `x`.\n * - `yParent`: The parent of the second value `y`.\n * - `stack`: An internal stack (Map) to handle circular references.\n *\n * @param {unknown} a - The first value to compare.\n * @param {unknown} b - The second value to compare.\n * @param {(x: any, y: any, property?: PropertyKey, xParent?: any, yParent?: any, stack?: Map) => boolean | void} [areValuesEqual=noop] - A function to customize the comparison.\n * If it returns a boolean, that result will be used. If it returns undefined,\n * the default equality comparison will be used.\n * @returns {boolean} `true` if the values are equal according to the customizer, otherwise `false`.\n *\n * @example\n * const customizer = (a, b) => {\n * if (typeof a === 'string' && typeof b === 'string') {\n * return a.toLowerCase() === b.toLowerCase();\n * }\n * };\n * isEqualWith('Hello', 'hello', customizer); // true\n * isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true\n * isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true\n */\nexport function isEqualWith(\n a: any,\n b: any,\n areValuesEqual: (\n a: any,\n b: any,\n property?: PropertyKey,\n aParent?: any,\n bParent?: any,\n stack?: Map\n ) => boolean | void = noop\n): boolean {\n if (typeof areValuesEqual !== 'function') {\n areValuesEqual = noop;\n }\n\n return isEqualWithToolkit(a, b, (...args): boolean | void => {\n const result = areValuesEqual(...args);\n\n if (result !== undefined) {\n return Boolean(result);\n }\n\n if (a instanceof Map && b instanceof Map) {\n return isEqualWith(\n Array.from(a),\n Array.from(b),\n // areValuesEqual should not be called for converted values\n after(2, areValuesEqual)\n );\n }\n\n if (a instanceof Set && b instanceof Set) {\n return isEqualWith(\n Array.from(a),\n Array.from(b),\n // areValuesEqual should not be called for converted values\n after(2, areValuesEqual)\n );\n }\n });\n}\n","import { getTag } from '../_internal/getTag.ts';\n\n/**\n * Checks if `value` is an Error object.\n *\n * @param {unknown} value The value to check.\n * @returns {value is Error} Returns `true` if `value` is an Error object, `false` otherwise.\n *\n * @example\n * ```typescript\n * console.log(isError(new Error())); // true\n * console.log(isError('Error')); // false\n * console.log(isError({ name: 'Error', message: '' })); // false\n * ```\n */\nexport function isError(value?: unknown): value is Error {\n return getTag(value) === '[object Error]';\n}\n","import { isBlob } from './isBlob.ts';\n\n/**\n * Checks if the given value is a File.\n *\n * This function tests whether the provided value is an instance of `File`.\n * It returns `true` if the value is an instance of `File`, and `false` otherwise.\n *\n * @param {unknown} x - The value to test if it is a File.\n * @returns {x is File} True if the value is a File, false otherwise.\n *\n * @example\n * const value1 = new File([\"content\"], \"example.txt\");\n * const value2 = {};\n * const value3 = new Blob([\"content\"], { type: \"text/plain\" });\n *\n * console.log(isFile(value1)); // true\n * console.log(isFile(value2)); // false\n * console.log(isFile(value3)); // false\n */\nexport function isFile(x: unknown): x is File {\n // Return false if File is not supported in the environment\n if (typeof File === 'undefined') {\n return false;\n }\n\n return isBlob(x) && x instanceof File;\n}\n","/**\n * Checks if `value` is a finite number.\n *\n * @param {unknown} value The value to check.\n * @returns {value is number} Returns `true` if `value` is a finite number, `false` otherwise.\n *\n * @example\n * ```typescript\n * const value1 = 100;\n * const value2 = Infinity;\n * const value3 = '100';\n *\n * console.log(isFinite(value1)); // true\n * console.log(isFinite(value2)); // false\n * console.log(isFinite(value3)); // false\n * ```\n */\nexport function isFinite(value: unknown): value is number {\n return Number.isFinite(value);\n}\n","/**\n * Checks if `value` is a function.\n *\n * @param {unknown} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n *\n * @example\n * isFunction(Array.prototype.slice); // true\n * isFunction(async function () {}); // true\n * isFunction(function* () {}); // true\n * isFunction(Proxy); // true\n * isFunction(Int8Array); // true\n */\nexport function isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n return typeof value === 'function';\n}\n","/**\n * Checks if `value` is an integer.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`.\n *\n * @param {unknown} value - The value to check\n * @returns {boolean} `true` if `value` is integer, otherwise `false`.\n *\n * @example\n * isInteger(3); // Returns: true\n * isInteger(Infinity); // Returns: false\n * isInteger('3'); // Returns: false\n * isInteger([]); // Returns: false\n */\nexport function isInteger(value?: unknown): value is number {\n return Number.isInteger(value);\n}\n","import { isMap as isMapToolKit } from '../../predicate/isMap.ts';\n\n/**\n * Checks if a given value is `Map`.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`.\n *\n * @param {unknown} value The value to check if it is a `Map`.\n * @returns {value is Map} Returns `true` if `value` is a `Map`, else `false`.\n *\n * @example\n * const value1 = new Map();\n * const value2 = new Set();\n * const value3 = new WeakMap();\n *\n * console.log(isMap(value1)); // true\n * console.log(isMap(value2)); // false\n * console.log(isMap(value3)); // false\n */\n\nexport function isMap(value?: unknown): value is Map {\n return isMapToolKit(value);\n}\n","/**\n * Checks if a given value is `Map`.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Map`.\n *\n * @param {unknown} value The value to check if it is a `Map`.\n * @returns {value is Map} Returns `true` if `value` is a `Map`, else `false`.\n *\n * @example\n * const value1 = new Map();\n * const value2 = new Set();\n * const value3 = new WeakMap();\n *\n * console.log(isMap(value1)); // true\n * console.log(isMap(value2)); // false\n * console.log(isMap(value3)); // false\n */\n\nexport function isMap(value: unknown): value is Map {\n return value instanceof Map;\n}\n","/**\n * Checks if the value is NaN.\n *\n * @param {unknown} value - The value to check.\n * @returns {value is typeof NaN} `true` if the value is NaN, `false` otherwise.\n *\n * @example\n * isNaN(NaN); // true\n * isNaN(0); // false\n * isNaN('NaN'); // false\n * isNaN(undefined); // false\n */\nexport function isNaN(value: unknown): value is typeof NaN {\n return Number.isNaN(value);\n}\n","/**\n * Checks if the given value is not null nor undefined.\n *\n * The main use of this function is to be used with TypeScript as a type predicate.\n *\n * @template T - The type of value.\n * @param {T | null | undefined} x - The value to test if it is not null nor undefined.\n * @returns {x is T} True if the value is not null nor undefined, false otherwise.\n *\n * @example\n * // Here the type of `arr` is (number | undefined)[]\n * const arr = [1, undefined, 3];\n * // Here the type of `result` is number[]\n * const result = arr.filter(isNotNil);\n * // result will be [1, 3]\n */\nexport function isNotNil(x: T | null | undefined): x is T {\n return x != null;\n}\n","/**\n * Checks if the given value is null.\n *\n * This function tests whether the provided value is strictly equal to `null`.\n * It returns `true` if the value is `null`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `null`.\n *\n * @param {unknown} x - The value to test if it is null.\n * @returns {x is null} True if the value is null, false otherwise.\n *\n * @example\n * const value1 = null;\n * const value2 = undefined;\n * const value3 = 42;\n *\n * console.log(isNull(value1)); // true\n * console.log(isNull(value2)); // false\n * console.log(isNull(value3)); // false\n */\nexport function isNull(x: unknown): x is null {\n return x === null;\n}\n","/**\n * Checks if a given value is a number.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`.\n *\n * @param {unknown} value The value to check if it is a number.\n * @returns {value is number} Returns `true` if `value` is a number, else `false`.\n *\n * @example\n * const value1 = 123;\n * const value2 = 'abc';\n * const value3 = true;\n *\n * console.log(isNumber(value1)); // true\n * console.log(isNumber(value2)); // false\n * console.log(isNumber(value3)); // false\n */\nexport function isNumber(value?: unknown): value is number {\n return typeof value === 'number' || value instanceof Number;\n}\n","import { isRegExp as isRegExpToolkit } from '../../predicate/isRegExp.ts';\n\n/**\n * Checks if `value` is a RegExp.\n *\n * @param {unknown} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a RegExp, `false` otherwise.\n *\n * @example\n * const value1 = /abc/;\n * const value2 = '/abc/';\n *\n * console.log(isRegExp(value1)); // true\n * console.log(isRegExp(value2)); // false\n */\nexport function isRegExp(value?: unknown): value is RegExp {\n return isRegExpToolkit(value);\n}\n","/**\n * Checks if `value` is a RegExp.\n *\n * @param {unknown} value The value to check.\n * @returns {value is RegExp} Returns `true` if `value` is a RegExp, `false` otherwise.\n *\n * @example\n * const value1 = /abc/;\n * const value2 = '/abc/';\n *\n * console.log(isRegExp(value1)); // true\n * console.log(isRegExp(value2)); // false\n */\nexport function isRegExp(value: unknown): value is RegExp {\n return value instanceof RegExp;\n}\n","/**\n * Checks if `value` is a safe integer (between -(2^53 – 1) and (2^53 – 1), inclusive).\n *\n * A safe integer is an integer that can be precisely represented as a `number` in JavaScript,\n * without any other integer being rounded to it.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `number`.\n *\n * @param {unknown} value - The value to check\n * @returns {boolean} `true` if `value` is an integer and between the safe values, otherwise `false`\n *\n * @example\n * isSafeInteger(3); // Returns: true\n * isSafeInteger(Number.MIN_SAFE_INTEGER - 1); // Returns: false\n * isSafeInteger(1n); // Returns: false\n * isSafeInteger('1'); // Returns: false\n */\nexport function isSafeInteger(value?: unknown): value is number {\n return Number.isSafeInteger(value);\n}\n","import { isSet as isSetToolkit } from '../../predicate/isSet.ts';\n\n/**\n * Checks if a given value is `Set`.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Set`.\n *\n * @param {unknown} value The value to check if it is a `Set`.\n * @returns {value is Set} Returns `true` if `value` is a `Set`, else `false`.\n *\n * @example\n * const value1 = new Set();\n * const value2 = new Map();\n * const value3 = new WeakSet();\n *\n * console.log(isSet(value1)); // true\n * console.log(isSet(value2)); // false\n * console.log(isSet(value3)); // false\n */\n\nexport function isSet(value?: unknown): value is Set {\n return isSetToolkit(value);\n}\n","/**\n * Checks if a given value is `Set`.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Set`.\n *\n * @param {unknown} value The value to check if it is a `Set`.\n * @returns {value is Set} Returns `true` if `value` is a `Set`, else `false`.\n *\n * @example\n * const value1 = new Set();\n * const value2 = new Map();\n * const value3 = new WeakSet();\n *\n * console.log(isSet(value1)); // true\n * console.log(isSet(value2)); // false\n * console.log(isSet(value3)); // false\n */\n\nexport function isSet(value: unknown): value is Set {\n return value instanceof Set;\n}\n","import { difference } from '../array/difference.ts';\n\n/**\n * Checks if the `subset` array is entirely contained within the `superset` array.\n *\n *\n * @template T - The type of elements contained in the arrays.\n * @param {T[]} superset - The array that may contain all elements of the subset.\n * @param {T[]} subset - The array to check against the superset.\n * @returns {boolean} - Returns `true` if all elements of the `subset` are present in the `superset`, otherwise returns `false`.\n *\n * @example\n * ```typescript\n * const superset = [1, 2, 3, 4, 5];\n * const subset = [2, 3, 4];\n * isSubset(superset, subset); // true\n * ```\n *\n * @example\n * ```typescript\n * const superset = ['a', 'b', 'c'];\n * const subset = ['a', 'd'];\n * isSubset(superset, subset); // false\n * ```\n */\n\nexport function isSubset(superset: readonly T[], subset: readonly T[]): boolean {\n return difference(subset, superset).length === 0;\n}\n","import { differenceWith } from './differenceWith.ts';\n\n/**\n * Checks if the `subset` array is entirely contained within the `superset` array based on a custom equality function.\n *\n * This function takes two arrays and a custom comparison function. It returns a boolean indicating\n * whether all elements in the subset array are present in the superset array, as determined by the provided\n * custom equality function.\n *\n * @template T - The type of elements contained in the arrays.\n * @param {T[]} superset - The array that may contain all elements of the subset.\n * @param {T[]} subset - The array to check against the superset.\n * @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.\n * @returns {boolean} - Returns `true` if all elements of the subset are present in the superset\n * according to the custom equality function, otherwise returns `false`.\n *\n * @example\n * ```typescript\n * const superset = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const subset = [{ id: 2 }, { id: 1 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * isSubsetWith(superset, subset, areItemsEqual); // true\n * ```\n *\n * @example\n * ```typescript\n * const superset = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const subset = [{ id: 4 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * isSubsetWith(superset, subset, areItemsEqual); // false\n * ```\n */\nexport function isSubsetWith(\n superset: readonly T[],\n subset: readonly T[],\n areItemsEqual: (x: T, y: T) => boolean\n): boolean {\n return differenceWith(subset, superset, areItemsEqual).length === 0;\n}\n","/**\n * Checks if the given value is undefined.\n *\n * This function tests whether the provided value is strictly equal to `undefined`.\n * It returns `true` if the value is `undefined`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `undefined`.\n *\n * @param {unknown} x - The value to test if it is undefined.\n * @returns {x is undefined} true if the value is undefined, false otherwise.\n *\n * @example\n * const value1 = undefined;\n * const value2 = null;\n * const value3 = 42;\n *\n * console.log(isUndefined(value1)); // true\n * console.log(isUndefined(value2)); // false\n * console.log(isUndefined(value3)); // false\n */\nexport function isUndefined(x: unknown): x is undefined {\n return x === undefined;\n}\n","import { isWeakMap as isWeakMapToolkit } from '../../predicate/isWeakMap.ts';\n\n/**\n * Checks if the given value is a `WeakMap`.\n *\n * This function tests whether the provided value is an instance of `WeakMap`.\n * It returns `true` if the value is a `WeakMap`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakMap`.\n *\n * @param {unknown} value - The value to test if it is a `WeakMap`.\n * @returns {value is WeakMap} true if the value is a `WeakMap`, false otherwise.\n *\n * @example\n * const value1 = new WeakMap();\n * const value2 = new Map();\n * const value3 = new Set();\n *\n * console.log(isWeakMap(value1)); // true\n * console.log(isWeakMap(value2)); // false\n * console.log(isWeakMap(value3)); // false\n */\nexport function isWeakMap(value?: unknown): value is WeakMap {\n return isWeakMapToolkit(value);\n}\n","/**\n * Checks if the given value is a `WeakMap`.\n *\n * This function tests whether the provided value is an instance of `WeakMap`.\n * It returns `true` if the value is a `WeakMap`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakMap`.\n *\n * @param {unknown} value - The value to test if it is a `WeakMap`.\n * @returns {value is WeakMap} true if the value is a `WeakMap`, false otherwise.\n *\n * @example\n * const value1 = new WeakMap();\n * const value2 = new Map();\n * const value3 = new Set();\n *\n * console.log(isWeakMap(value1)); // true\n * console.log(isWeakMap(value2)); // false\n * console.log(isWeakMap(value3)); // false\n */\nexport function isWeakMap(value: unknown): value is WeakMap {\n return value instanceof WeakMap;\n}\n","import { isWeakSet as isWeakSetToolkit } from '../../predicate/isWeakSet.ts';\n\n/**\n * Checks if the given value is a `WeakSet`.\n *\n * This function tests whether the provided value is an instance of `WeakSet`.\n * It returns `true` if the value is a `WeakSet`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakSet`.\n *\n * @param {unknown} value - The value to test if it is a `WeakSet`.\n * @returns {value is WeakSet} true if the value is a `WeakSet`, false otherwise.\n *\n * @example\n * const value1 = new WeakSet();\n * const value2 = new Map();\n * const value3 = new Set();\n *\n * console.log(isWeakSet(value1)); // true\n * console.log(isWeakSet(value2)); // false\n * console.log(isWeakSet(value3)); // false\n */\nexport function isWeakSet(value?: unknown): value is WeakSet {\n return isWeakSetToolkit(value);\n}\n","/**\n * Checks if the given value is a `WeakSet`.\n *\n * This function tests whether the provided value is an instance of `WeakSet`.\n * It returns `true` if the value is a `WeakSet`, and `false` otherwise.\n *\n * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `WeakSet`.\n *\n * @param {unknown} value - The value to test if it is a `WeakSet`.\n * @returns {value is WeakSet} true if the value is a `WeakSet`, false otherwise.\n *\n * @example\n * const value1 = new WeakSet();\n * const value2 = new Map();\n * const value3 = new Set();\n *\n * console.log(isWeakSet(value1)); // true\n * console.log(isWeakSet(value2)); // false\n * console.log(isWeakSet(value3)); // false\n */\nexport function isWeakSet(value: unknown): value is WeakSet {\n return value instanceof WeakSet;\n}\n","import { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Joins elements of an array into a string.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} array - The array to join.\n * @param {string} separator - The separator used to join the elements, default is common separator `,`.\n * @returns {string} - Returns a string containing all elements of the array joined by the specified separator.\n *\n * @example\n * const arr = [\"a\", \"b\", \"c\"];\n * const result = join(arr, \"~\");\n * console.log(result); // Output: \"a~b~c\"\n */\nexport function join(array: ArrayLike | null | undefined, separator = ','): string {\n if (!isArrayLike(array)) {\n return '';\n }\n return Array.from(array).join(separator);\n}\n","import { kebabCase as kebabCaseToolkit } from '../../string/kebabCase.ts';\nimport { normalizeForCase } from '../_internal/normalizeForCase.ts';\n\n/**\n * Converts a string to kebab case.\n *\n * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.\n *\n * @param {string | object} str - The string that is to be changed to kebab case.\n * @returns {string} - The converted string to kebab case.\n *\n * @example\n * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'\n * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'\n * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'\n * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'\n */\nexport function kebabCase(str?: string | object): string {\n return kebabCaseToolkit(normalizeForCase(str));\n}\n","import { words as getWords } from './words.ts';\n\n/**\n * Converts a string to kebab case.\n *\n * Kebab case is the naming convention in which each word is written in lowercase and separated by a dash (-) character.\n *\n * @param {string} str - The string that is to be changed to kebab case.\n * @returns {string} - The converted string to kebab case.\n *\n * @example\n * const convertedStr1 = kebabCase('camelCase') // returns 'camel-case'\n * const convertedStr2 = kebabCase('some whitespace') // returns 'some-whitespace'\n * const convertedStr3 = kebabCase('hyphen-text') // returns 'hyphen-text'\n * const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'\n */\n\nexport function kebabCase(str: string): string {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('-');\n}\n","/**\n * Maps each element of an array based on a provided key-generating function.\n *\n * This function takes an array and a function that generates a key from each element. It returns\n * an object where the keys are the generated keys and the values are the corresponding elements.\n * If there are multiple elements generating the same key, the last element among them is used\n * as the value.\n *\n * @template T - The type of elements in the array.\n * @template K - The type of keys.\n * @param {T[]} arr - The array of elements to be mapped.\n * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.\n * @returns {Record} An object where keys are mapped to each element of an array.\n *\n * @example\n * const array = [\n * { category: 'fruit', name: 'apple' },\n * { category: 'fruit', name: 'banana' },\n * { category: 'vegetable', name: 'carrot' }\n * ];\n * const result = keyBy(array, item => item.category);\n * // result will be:\n * // {\n * // fruit: { category: 'fruit', name: 'banana' },\n * // vegetable: { category: 'vegetable', name: 'carrot' }\n * // }\n */\nexport function keyBy(arr: readonly T[], getKeyFromItem: (item: T) => K): Record {\n const result = {} as Record;\n\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n const key = getKeyFromItem(item);\n result[key] = item;\n }\n\n return result;\n}\n","import { lowerCase as lowerCaseToolkit } from '../../string/lowerCase.ts';\nimport { normalizeForCase } from '../_internal/normalizeForCase.ts';\n\n/**\n * Converts a string to lower case.\n *\n * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.\n *\n * @param {string | object} str - The string that is to be changed to lower case.\n * @returns {string} - The converted string to lower case.\n *\n * @example\n * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'\n * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'\n * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'\n * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'\n */\nexport function lowerCase(str?: string | object): string {\n return lowerCaseToolkit(normalizeForCase(str));\n}\n","import { words as getWords } from './words.ts';\n\n/**\n * Converts a string to lower case.\n *\n * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.\n *\n * @param {string} str - The string that is to be changed to lower case.\n * @returns {string} - The converted string to lower case.\n *\n * @example\n * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'\n * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'\n * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'\n * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'\n */\nexport function lowerCase(str: string): string {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join(' ');\n}\n","/**\n * Converts the first character of string to lower case.\n *\n * @param {string} str - The string that is to be changed\n * @returns {string} - The converted string.\n *\n * @example\n * const convertedStr1 = lowerCase('fred') // returns 'fred'\n * const convertedStr2 = lowerCase('Fred') // returns 'fred'\n * const convertedStr3 = lowerCase('FRED') // returns 'fRED'\n */\nexport function lowerFirst(str: string): string {\n return str.substring(0, 1).toLowerCase() + str.substring(1);\n}\n","import { property } from './property.ts';\nimport { identity } from '../../function/identity.ts';\nimport { mapKeys as mapKeysToolkit } from '../../object/mapKeys.ts';\n\n/**\n * Creates a new object with the same values as the given object, but with keys generated\n * by running each own enumerable property of the object through the iteratee function.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the keys in the object.\n *\n * @param {T} object - The object to iterate over.\n * @param {PropertyKey | PropertyKey[]} getNewKey - The path of the property to get to generate the new keys.\n * @returns {Record} - Returns the new mapped object.\n *\n * @example\n * // Example usage:\n * const obj = { a: 1, b: 2 };\n * const result = mapKeys(obj, (value, key) => key + value);\n * console.log(result); // { a1: 1, b2: 2 }\n */\nexport function mapKeys(\n object: T,\n getNewKey?: PropertyKey | readonly PropertyKey[]\n): Record;\n\n/**\n * Creates a new object with the same values as the given object, but with keys generated\n * by running each own enumerable property of the object through the iteratee function.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the keys in the object.\n * @template K2 - The type of the new keys generated by the iteratee function.\n *\n * @param {T} object - The object to iterate over.\n * @param {(value: T[K1], key: K1, object: T) => K2} getNewKey - The function invoked per own enumerable property.\n * @returns {Record} - Returns the new mapped object.\n *\n * @example\n * // Example usage:\n * const obj = { a: 1, b: 2 };\n * const result = mapKeys(obj, (value, key) => key + value);\n * console.log(result); // { a1: 1, b2: 2 }\n */\nexport function mapKeys(\n object: T,\n getNewKey?: (value: T[K1], key: K1, object: T) => K2\n): Record;\n\n/**\n * Creates a new object with the same values as the given object, but with keys generated\n * by running each own enumerable property of the object through the iteratee function.\n *\n * @template T - The type of the object.\n * @template K1 - The type of the keys in the object.\n * @template K2 - The type of the new keys generated by the iteratee function.\n *\n * @param {T} object - The object to iterate over.\n * @param {(value: T[K1], key: K1, object: T) => K2} [getNewKey] - The function invoked per own enumerable property, or a path to generate new keys.\n * @returns {Record} - Returns the new mapped object.\n *\n * @example\n * // Example usage:\n * const obj = { a: 1, b: 2 };\n * const result = mapKeys(obj, (value, key) => key + value);\n * console.log(result); // { a1: 1, b2: 2 }\n */\nexport function mapKeys(\n object: T,\n getNewKey?: PropertyKey | readonly PropertyKey[] | ((value: T[keyof T], key: keyof T, object: T) => K)\n): Record {\n getNewKey = getNewKey ?? (identity as (value: T[keyof T], key: keyof T, object: T) => K);\n\n switch (typeof getNewKey) {\n case 'string':\n case 'symbol':\n case 'number':\n case 'object': {\n return mapKeysToolkit(object, property(getNewKey));\n }\n case 'function': {\n return mapKeysToolkit(object, getNewKey);\n }\n }\n}\n","import { property } from './property.ts';\nimport { identity } from '../../function/identity.ts';\nimport { mapValues as mapValuesToolkit } from '../../object/mapValues.ts';\n\n/**\n * Creates a new object with the same keys as the given object, but with values generated\n * by running each own enumerable property of the object through the iteratee function.\n *\n * @template T - The type of the object.\n * @template K - The type of the keys in the object.\n * @template V - The type of the new values generated by the iteratee function.\n *\n * @param {T} object - The object to iterate over.\n * @param {(value: T[K], key: K, object: T) => V} getNewValue - The function invoked per own enumerable property.\n * @returns {Record} - Returns the new mapped object.\n *\n * @example\n * // Example usage:\n * const obj = { a: 1, b: 2 };\n * const result = mapValues(obj, (value) => value * 2);\n * console.log(result); // { a: 2, b: 4 }\n */\nexport function mapValues(\n object: T,\n getNewValue?: PropertyKey | readonly PropertyKey[] | null | undefined\n): Record;\n\n/**\n * Creates a new object with the same keys as the given object, but with values generated\n * by running each own enumerable property of the object through the iteratee function.\n *\n * @template T - The type of the object.\n * @template K - The type of the keys in the object.\n * @template V - The type of the new values generated by the iteratee function.\n *\n * @param {T} object - The object to iterate over.\n * @param {(value: T[K], key: K, object: T) => V} getNewValue - The function invoked per own enumerable property.\n * @returns {Record} - Returns the new mapped object.\n *\n * @example\n * // Example usage:\n * const obj = { a: 1, b: 2 };\n * const result = mapValues(obj, (value) => value * 2);\n * console.log(result); // { a: 2, b: 4 }\n */\nexport function mapValues(\n object: T,\n getNewValue: (value: T[K], key: K, object: T) => V\n): Record;\n\n/**\n * Creates a new object with the same keys as the given object, but with values generated\n * by running each own enumerable property of the object through the iteratee function.\n *\n * @template T - The type of the object.\n * @template K - The type of the keys in the object.\n * @template V - The type of the new values generated by the iteratee function.\n *\n * @param {T} object - The object to iterate over.\n * @param {(value: T[K], key: K, object: T) => V | PropertyKey | readonly PropertyKey[] | null | undefined} [getNewValue] -\n * The function invoked per own enumerable property, or a path to generate new values.\n * @returns {Record} - Returns the new mapped object.\n *\n * @example\n * // Example usage:\n * const obj = { a: 1, b: 2 };\n * const result = mapValues(obj, (value) => value * 2);\n * console.log(result); // { a: 2, b: 4 }\n */\nexport function mapValues(\n object: T,\n getNewValue?: PropertyKey | readonly PropertyKey[] | null | undefined | ((value: T[K], key: K, object: T) => V)\n): Record {\n getNewValue = getNewValue ?? (identity as (value: T[K], key: K, object: T) => V);\n\n switch (typeof getNewValue) {\n case 'string':\n case 'symbol':\n case 'number':\n case 'object': {\n return mapValuesToolkit(object, property(getNewValue));\n }\n case 'function': {\n return mapValuesToolkit(object, getNewValue);\n }\n }\n}\n","/**\n * Finds the element in an array that has the maximum value.\n *\n * @param {[T, ...T[]]} items - The array of elements to search.\n * @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.\n * @example\n * // Returns 9\n * max([3, 1, 4, 1, 5, 9]);\n *\n * @example\n * // Returns 8\n * max([0, -3, 2, 8, 7]);\n */\nexport function max(items: readonly [T, ...T[]]): T;\n/**\n * Finds the element in an array that has the maximum value.\n * Returns undefined when no arguments are provided.\n * @returns {undefined}\n */\nexport function max(): undefined;\n/**\n * Finds the element in an array that has the maximum value.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} [items] - The array of elements to search. Defaults to an empty array.\n * @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.\n */\nexport function max(items?: readonly T[]): T | undefined;\n/**\n * Finds the element in an array that has the maximum value.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} [items] - The array of elements to search. Defaults to an empty array.\n * @returns {T | undefined} - The element with the maximum value, or undefined if the array is empty.\n */\nexport function max(items: readonly T[] = []): T | undefined {\n let maxElement = items[0];\n let max: any = undefined;\n\n for (let i = 0; i < items.length; i++) {\n const element = items[i];\n if (max == null || element > max) {\n max = element;\n maxElement = element;\n }\n }\n\n return maxElement;\n}\n","/**\n * Finds the element in an array that has the maximum value when applying\n * the `getValue` function to each element.\n *\n * @template T - The type of elements in the array.\n * @param {[T, ...T[]]} items The nonempty array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T} The element with the maximum value as determined by the `getValue` function.\n * @example\n * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }\n * maxBy([], x => x.a); // Returns: undefined\n * maxBy(\n * [\n * { name: 'john', age: 30 },\n * { name: 'jane', age: 28 },\n * { name: 'joe', age: 26 },\n * ],\n * x => x.age\n * ); // Returns: { name: 'john', age: 30 }\n */\nexport function maxBy(items: readonly [T, ...T[]], getValue: (element: T) => number): T;\n/**\n * Finds the element in an array that has the maximum value when applying\n * the `getValue` function to each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T | undefined} The element with the maximum value as determined by the `getValue` function.\n * @example\n * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }\n * maxBy([], x => x.a); // Returns: undefined\n * maxBy(\n * [\n * { name: 'john', age: 30 },\n * { name: 'jane', age: 28 },\n * { name: 'joe', age: 26 },\n * ],\n * x => x.age\n * ); // Returns: { name: 'john', age: 30 }\n */\nexport function maxBy(items: readonly T[], getValue: (element: T) => number): T | undefined;\n/**\n * Finds the element in an array that has the maximum value when applying\n * the `getValue` function to each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T | undefined} The element with the maximum value as determined by the `getValue` function.\n * @example\n * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }\n * maxBy([], x => x.a); // Returns: undefined\n * maxBy(\n * [\n * { name: 'john', age: 30 },\n * { name: 'jane', age: 28 },\n * { name: 'joe', age: 26 },\n * ],\n * x => x.age\n * ); // Returns: { name: 'john', age: 30 }\n */\nexport function maxBy(items: readonly T[], getValue: (element: T) => number): T {\n let maxElement = items[0];\n let max = -Infinity;\n\n for (let i = 0; i < items.length; i++) {\n const element = items[i];\n const value = getValue(element);\n if (value > max) {\n max = value;\n maxElement = element;\n }\n }\n\n return maxElement;\n}\n","import { mean } from './mean.ts';\n\n/**\n * Calculates the average of an array of numbers when applying\n * the `getValue` function to each element.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items An array to calculate the average.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {number} The average of all the numbers as determined by the `getValue` function.\n *\n * @example\n * meanBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 2\n * meanBy([], x => x.a); // Returns: NaN\n */\nexport function meanBy(items: readonly T[], getValue: (element: T) => number): number {\n const nums = items.map(x => getValue(x));\n\n return mean(nums);\n}\n","import { median } from './median.ts';\n\n/**\n * Calculates the median of an array of elements when applying\n * the `getValue` function to each element.\n *\n * The median is the middle value of a sorted array.\n * If the array has an odd number of elements, the median is the middle value.\n * If the array has an even number of elements, it returns the average of the two middle values.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items An array to calculate the median.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {number} The median of all the numbers as determined by the `getValue` function.\n *\n * @example\n * medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }], x => x.a); // Returns: 3\n * medianBy([{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }], x => x.a); // Returns: 2.5\n * medianBy([], x => x.a); // Returns: NaN\n */\nexport function medianBy(items: readonly T[], getValue: (element: T) => number): number {\n const nums = items.map(x => getValue(x));\n\n return median(nums);\n}\n","/**\n * Creates a memoized version of the provided function. The memoized function caches\n * results based on the argument it receives, so if the same argument is passed again,\n * it returns the cached result instead of recomputing it.\n *\n * This function works with functions that take zero or just one argument. If your function\n * originally takes multiple arguments, you should refactor it to take a single object or array\n * that combines those arguments.\n *\n * If the argument is not primitive (e.g., arrays or objects), provide a\n * `getCacheKey` function to generate a unique cache key for proper caching.\n *\n * @template F - The type of the function to be memoized.\n * @param {F} fn - The function to be memoized. It should accept a single argument and return a value.\n * @param {MemoizeOptions[0], ReturnType>} [options={}] - Optional configuration for the memoization.\n * @param {MemoizeCache} [options.cache] - The cache object used to store results. Defaults to a new `Map`.\n * @param {(args: A) => unknown} [options.getCacheKey] - An optional function to generate a unique cache key for each argument.\n *\n * @returns The memoized function with an additional `cache` property that exposes the internal cache.\n *\n * @example\n * // Example using the default cache\n * const add = (x: number) => x + 10;\n * const memoizedAdd = memoize(add);\n *\n * console.log(memoizedAdd(5)); // 15\n * console.log(memoizedAdd(5)); // 15 (cached result)\n * console.log(memoizedAdd.cache.size); // 1\n *\n * @example\n * // Example using a custom resolver\n * const sum = (arr: number[]) => arr.reduce((x, y) => x + y, 0);\n * const memoizedSum = memoize(sum, { getCacheKey: (arr: number[]) => arr.join(',') });\n * console.log(memoizedSum([1, 2])); // 3\n * console.log(memoizedSum([1, 2])); // 3 (cached result)\n * console.log(memoizedSum.cache.size); // 1\n *\n * @example\n * // Example using a custom cache implementation\n * class CustomCache implements MemoizeCache {\n * private cache = new Map();\n *\n * set(key: K, value: T): void {\n * this.cache.set(key, value);\n * }\n *\n * get(key: K): T | undefined {\n * return this.cache.get(key);\n * }\n *\n * has(key: K): boolean {\n * return this.cache.has(key);\n * }\n *\n * delete(key: K): boolean {\n * return this.cache.delete(key);\n * }\n *\n * clear(): void {\n * this.cache.clear();\n * }\n *\n * get size(): number {\n * return this.cache.size;\n * }\n * }\n * const customCache = new CustomCache();\n * const memoizedSumWithCustomCache = memoize(sum, { cache: customCache });\n * console.log(memoizedSumWithCustomCache([1, 2])); // 3\n * console.log(memoizedSumWithCustomCache([1, 2])); // 3 (cached result)\n * console.log(memoizedAddWithCustomCache.cache.size); // 1\n */\nexport function memoize any>(\n fn: F,\n options: {\n cache?: MemoizeCache>;\n getCacheKey?: (args: Parameters[0]) => unknown;\n } = {}\n): F & { cache: MemoizeCache> } {\n const { cache = new Map>(), getCacheKey } = options;\n\n const memoizedFn = function (this: unknown, arg: Parameters[0]): ReturnType {\n const key = getCacheKey ? getCacheKey(arg) : arg;\n\n if (cache.has(key)) {\n return cache.get(key)!;\n }\n\n const result = fn.call(this, arg);\n\n cache.set(key, result);\n\n return result;\n };\n\n memoizedFn.cache = cache;\n\n return memoizedFn as F & { cache: MemoizeCache> };\n}\n\n/**\n * Represents a cache for memoization, allowing storage and retrieval of computed values.\n *\n * @template K - The type of keys used to store values in the cache.\n * @template V - The type of values stored in the cache.\n */\nexport interface MemoizeCache {\n /**\n * Stores a value in the cache with the specified key.\n *\n * @param key - The key to associate with the value.\n * @param value - The value to store in the cache.\n */\n set(key: K, value: V): void;\n\n /**\n * Retrieves a value from the cache by its key.\n *\n * @param key - The key of the value to retrieve.\n * @returns The value associated with the key, or undefined if the key does not exist.\n */\n get(key: K): V | undefined;\n\n /**\n * Checks if a value exists in the cache for the specified key.\n *\n * @param key - The key to check for existence in the cache.\n * @returns True if the cache contains the key, false otherwise.\n */\n has(key: K): boolean;\n\n /**\n * Deletes a value from the cache by its key.\n *\n * @param key - The key of the value to delete.\n * @returns True if the value was successfully deleted, false otherwise.\n */\n delete(key: K): boolean | void;\n\n /**\n * Clears all values from the cache.\n */\n clear(): void;\n\n /**\n * The number of entries in the cache.\n */\n size: number;\n}\n","import { mergeWith } from './mergeWith.ts';\nimport { noop } from '../../function/noop.ts';\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {O} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S} source - The first source object whose properties will be merged into the target object.\n * @returns {O & S} The updated target object with properties from the source object(s) merged in.\n *\n * @template O - Type of the target object.\n * @template S - Type of the first source object.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [3], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [1, 2, 3] }\n */\nexport function merge(object: O, source: S): O & S;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {O} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S1} source1 - The first source object to be merged into the target object.\n * @param {S2} source2 - The second source object to be merged into the target object.\n * @returns {O & S1 & S2} The updated target object with properties from the source objects merged in.\n *\n * @template O - Type of the target object.\n * @template S1 - Type of the first source object.\n * @template S2 - Type of the second source object.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [3], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [1, 2, 3] }\n */\nexport function merge(object: O, source1: S1, source2: S2): O & S1 & S2;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {O} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S1} source1 - The first source object whose properties will be merged into the target object.\n * @param {S2} source2 - The second source object whose properties will be merged into the target object.\n * @param {S3} source3 - The third source object whose properties will be merged into the target object.\n * @returns {O & S1 & S2 & S3} The updated target object with properties from the source object(s) merged in.\n *\n * @template O - Type of the target object.\n * @template S1 - Type of the first source object.\n * @template S2 - Type of the second source object.\n * @template S3 - Type of the third source object.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [3], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [1, 2, 3] }\n */\nexport function merge(object: O, source1: S1, source2: S2, source3: S3): O & S1 & S2 & S3;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {O} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {S1} source1 - The first source object whose properties will be merged into the target object.\n * @param {S2} source2 - The second source object whose properties will be merged into the target object.\n * @param {S3} source3 - The third source object whose properties will be merged into the target object.\n * @param {S4} source4 - The fourth source object whose properties will be merged into the target object.\n * @returns {O & S1 & S2 & S3 & S4} The updated target object with properties from the source object(s) merged in.\n *\n * @template O - Type of the target object.\n * @template S1 - Type of the first source object.\n * @template S2 - Type of the second source object.\n * @template S3 - Type of the third source object.\n * @template S4 - Type of the fourth source object.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [3], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [1, 2, 3] }\n */\nexport function merge(\n object: O,\n source1: S1,\n source2: S2,\n source3: S3,\n source4: S4\n): O & S1 & S2 & S3;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {any} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {any[]} sources - The source objects whose properties will be merged into the target object.\n * @returns {any} The updated target object with properties from the source object(s) merged in.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [3], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [1, 2, 3] }\n */\nexport function merge(object: any, ...sources: any[]): any;\n\n/**\n * Merges the properties of one or more source objects into the target object.\n *\n * This function performs a deep merge, recursively merging nested objects and arrays.\n * If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * If a property in the source object is `undefined`, it will not overwrite a defined property in the target object.\n *\n * The function can handle multiple source objects and will merge them all into the target object.\n *\n * @param {any} object - The target object into which the source object properties will be merged. This object is modified in place.\n * @param {any[]} sources - The source objects whose properties will be merged into the target object.\n * @returns {any} The updated target object with properties from the source object(s) merged in.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [3], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = merge(target, source);\n * console.log(result);\n * // Output: { a: [1, 2, 3] }\n */\nexport function merge(object: any, ...sources: any[]): any {\n return mergeWith(object, ...sources, noop);\n}\n","/**\n * Finds the element in an array that has the minimum value.\n *\n * @template T - The type of elements in the array.\n * @param {[T, ...T[]]} items - The array of elements to search.\n * @returns {T | undefined} - The element with the minimum value, or undefined if the array is empty.\n * @example\n * // Returns 1\n * min([3, 1, 4, 1, 5, 9]);\n *\n * @example\n * // Returns -3\n * min([0, -3, 2, 8, 7]);\n */\nexport function min(items: readonly [T, ...T[]]): T;\n\n/**\n * Finds the element in an array that has the minimum value.\n * Returns undefined when no arguments are provided.\n * @returns {undefined}\n */\nexport function min(): undefined;\n\n/**\n * Finds the element in an array that has the minimum value.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} [items] - The array of elements to search. Defaults to an empty array.\n * @returns {T | undefined} - The element with the minimum value, or undefined if the array is empty.\n */\nexport function min(items?: readonly T[]): T | undefined;\n\n/**\n * Finds the element in an array that has the minimum value.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} [items] - The array of elements to search. Defaults to an empty array.\n * @returns {T} - The element with the minimum value.\n */\nexport function min(items: readonly T[] = []): T {\n let minElement = items[0];\n let min: any = undefined;\n\n for (let i = 0; i < items.length; i++) {\n const element = items[i];\n if (min == null || element < min) {\n min = element;\n minElement = element;\n }\n }\n\n return minElement;\n}\n","/**\n * Finds the element in an array that has the minimum value when applying\n * the `getValue` function to each element.\n *\n * @template T - The type of elements in the array.\n * @param {[T, ...T[]]} items The nonempty array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T} The element with the minimum value as determined by the `getValue` function.\n * @example\n * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }\n * minBy([], x => x.a); // Returns: undefined\n * minBy(\n * [\n * { name: 'john', age: 30 },\n * { name: 'jane', age: 28 },\n * { name: 'joe', age: 26 },\n * ],\n * x => x.age\n * ); // Returns: { name: 'joe', age: 26 }\n */\nexport function minBy(items: readonly [T, ...T[]], getValue: (element: T) => number): T;\n/**\n * Finds the element in an array that has the minimum value when applying\n * the `getValue` function to each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T | undefined} The element with the minimum value as determined by the `getValue` function.\n * @example\n * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }\n * minBy([], x => x.a); // Returns: undefined\n * minBy(\n * [\n * { name: 'john', age: 30 },\n * { name: 'jane', age: 28 },\n * { name: 'joe', age: 26 },\n * ],\n * x => x.age\n * ); // Returns: { name: 'joe', age: 26 }\n */\nexport function minBy(items: readonly T[], getValue: (element: T) => number): T | undefined;\n/**\n * Finds the element in an array that has the minimum value when applying\n * the `getValue` function to each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T | undefined} The element with the minimum value as determined by the `getValue` function.\n * @example\n * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }\n * minBy([], x => x.a); // Returns: undefined\n * minBy(\n * [\n * { name: 'john', age: 30 },\n * { name: 'jane', age: 28 },\n * { name: 'joe', age: 26 },\n * ],\n * x => x.age\n * ); // Returns: { name: 'joe', age: 26 }\n */\nexport function minBy(items: readonly T[], getValue: (element: T) => number): T | undefined {\n let minElement = items[0];\n let min = Infinity;\n\n for (let i = 0; i < items.length; i++) {\n const element = items[i];\n const value = getValue(element);\n if (value < min) {\n min = value;\n minElement = element;\n }\n }\n\n return minElement;\n}\n","/**\n * Creates a function that negates the result of the predicate function.\n *\n * @template F - The type of the function to negate.\n * @param {F} func - The function to negate.\n * @returns {F} The new negated function, which negates the boolean result of `func`.\n *\n * @example\n * const array = [1, 2, 3, 4, 5, 6];\n * const isEven = (n: number) => n % 2 === 0;\n * const result = array.filter(negate(isEven));\n * // result will be [1, 3, 5]\n */\nexport function negate boolean>(func: F): F {\n return ((...args: any[]) => !func(...args)) as F;\n}\n","import { unset } from './unset.ts';\nimport { cloneDeep } from '../../object/cloneDeep.ts';\n\n/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\nexport function omit, K extends keyof T>(obj: T, keys: readonly K[]): Omit;\n\n/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and a variable number of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * Deep keys can be specified for keys.\n *\n * @template T - The type of object.\n * @param {T} obj - The object to omit keys from.\n * @param {...(PropertyKey | PropertyKey[] | PropertyKey[][])} keys - A variable number of keys to be omitted from the object.\n * @returns {Partial} A new object with the specified keys omitted.\n */\nexport function omit<\n // eslint-disable-next-line\n T extends {},\n>(\n obj: T | null | undefined,\n ...keys: Array>\n): Partial;\n\n/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and a variable number of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys. Note that keys can be deep.\n *\n * Deep keys can be specified for keys.\n *\n * @template T - The type of object.\n * @param {T} obj - The object to omit keys from.\n * @param {...(PropertyKey | PropertyKey[] | PropertyKey[][])} keysArr - A variable number of keys to be omitted from the object.\n * @returns {Partial} A new object with the specified keys omitted.\n */\nexport function omit<\n // eslint-disable-next-line\n T extends {},\n>(\n obj: T | null | undefined,\n ...keysArr: Array>\n): Partial {\n if (obj == null) {\n return {};\n }\n\n const result = cloneDeep(obj);\n\n for (let i = 0; i < keysArr.length; i++) {\n let keys = keysArr[i];\n\n switch (typeof keys) {\n case 'object': {\n if (!Array.isArray(keys)) {\n // eslint-disable-next-line\n // @ts-ignore\n keys = Array.from(keys) as PropertyKey[];\n }\n\n for (let j = 0; j < keys.length; j++) {\n const key = keys[j];\n\n unset(result, key);\n }\n\n break;\n }\n case 'string':\n case 'symbol':\n case 'number': {\n unset(result, keys);\n break;\n }\n }\n }\n\n return result;\n}\n","/**\n * Creates a new object composed of the properties that do not satisfy the predicate function.\n *\n * This function takes an object and a predicate function, and returns a new object that\n * includes only the properties for which the predicate function returns false.\n *\n * @template T - The type of object.\n * @param {T} obj - The object to omit properties from.\n * @param {(value: T[string], key: keyof T) => boolean} shouldOmit - A predicate function that determines\n * whether a property should be omitted. It takes the property's key and value as arguments and returns `true`\n * if the property should be omitted, and `false` otherwise.\n * @returns {Partial} A new object with the properties that do not satisfy the predicate function.\n *\n * @example\n * const obj = { a: 1, b: 'omit', c: 3 };\n * const shouldOmit = (value) => typeof value === 'string';\n * const result = omitBy(obj, shouldOmit);\n * // result will be { a: 1, c: 3 }\n */\nexport function omitBy>(\n obj: T,\n shouldOmit: (value: T[keyof T], key: keyof T) => boolean\n): Partial {\n const result: Partial = {};\n\n const keys = Object.keys(obj) as Array;\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = obj[key];\n\n if (!shouldOmit(value, key)) {\n result[key] = value;\n }\n }\n\n return result;\n}\n","/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F extends () => any} func - The function to restrict.\n * @returns {F} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once any>(func: F): F;\n/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F extends (...args: any[]) => void} func - The function to restrict with arguments.\n * @returns {F} A new function that invokes `func` once.\n *\n * @example\n * const log = once(console.log);\n *\n * log('Hello, world!'); // prints 'Hello, world!' and doesn't return anything\n * log('Hello, world!'); // doesn't print anything and doesn't return anything\n */\nexport function once void>(func: F): F;\n/**\n * Creates a function that is restricted to invoking the provided function `func` once.\n * Repeated calls to the function will return the value from the first invocation.\n *\n * @template F - The type of function.\n * @param {F} func - The function to restrict.\n * @returns {(...args: Parameters) => ReturnType} A new function that invokes `func` once and caches the result.\n *\n * @example\n * const initialize = once(() => {\n * console.log('Initialized!');\n * return true;\n * });\n *\n * initialize(); // Logs: 'Initialized!' and returns true\n * initialize(); // Returns true without logging\n */\nexport function once any) | ((...args: any[]) => void)>(func: F): F {\n let called = false;\n let cache: ReturnType;\n\n return function (...args: Parameters): ReturnType {\n if (!called) {\n called = true;\n cache = func(...args);\n }\n\n return cache;\n } as F;\n}\n","import { pad as padToolkit } from '../../string/pad.ts';\nimport { toString } from '../util/toString.ts';\n\n/**\n * Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.\n * If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.\n *\n * @param {string} str - The string to pad.\n * @param {number} [length] - The length of the resulting string once padded.\n * @param {string} [chars] - The character(s) to use for padding.\n * @returns {string} - The padded string, or the original string if padding is not required.\n *\n * @example\n * const result1 = pad('abc', 8); // result will be ' abc '\n * const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'\n * const result3 = pad('abc', 3); // result will be 'abc'\n * const result4 = pad('abc', 2); // result will be 'abc'\n *\n */\nexport function pad(str: string, length: number, chars = ' '): string {\n return padToolkit(toString(str), length, chars);\n}\n","/**\n * Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.\n * If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.\n *\n * @param {string} str - The string to pad.\n * @param {number} [length] - The length of the resulting string once padded.\n * @param {string} [chars] - The character(s) to use for padding.\n * @returns {string} - The padded string, or the original string if padding is not required.\n *\n * @example\n * const result1 = pad('abc', 8); // result will be ' abc '\n * const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'\n * const result3 = pad('abc', 3); // result will be 'abc'\n * const result4 = pad('abc', 2); // result will be 'abc'\n *\n */\nexport function pad(str: string, length: number, chars = ' '): string {\n return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars);\n}\n","import { toString } from '../util/toString.ts';\n\n/**\n * Pads the end of a string with a given character until it reaches the specified length.\n *\n * If the length is less than or equal to the original string's length, or if the padding character is an empty string,\n * the original string is returned unchanged.\n *\n * @param {string} str - The string to pad.\n * @param {number} [length] - The length of the resulting string once padded.\n * @param {string} [chars] - The character(s) to use for padding.\n * @returns {string} - The padded string, or the original string if padding is not required.\n *\n * @example\n * const result1 = padEnd('abc', 6); // result will be 'abc '\n * const result2 = padEnd('abc', 6, '_-'); // result will be 'abc_-_'\n * const result3 = padEnd('abc', 3); // result will be 'abc'\n * const result4 = padEnd('abc', 2); // result will be 'abc'\n */\n\nexport function padEnd(str: string, length = 0, chars = ' '): string {\n return toString(str).padEnd(length, chars);\n}\n","import { toString } from '../util/toString.ts';\n\n/**\n * Pads the start of a string with a given character until it reaches the specified length.\n *\n * If the length is less than or equal to the original string's length, or if the padding character is an empty string,\n * the original string is returned unchanged.\n *\n * @param {string} str - The string to pad.\n * @param {number} [length] - The length of the resulting string once padded.\n * @param {string} [chars] - The character(s) to use for padding.\n * @returns {string} - The padded string, or the original string if padding is not required.\n *\n * @example\n * const result1 = padStart('abc', 6); // result will be ' abc'\n * const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc'\n * const result3 = padStart('abc', 3); // result will be 'abc'\n * const result4 = padStart('abc', 2); // result will be 'abc'\n */\nexport function padStart(str: string, length = 0, chars = ' '): string {\n return toString(str).padStart(length, chars);\n}\n","/**\n * Converts `string` to an integer of the specified radix. If `radix` is undefined or 0, a `radix` of 10 is used unless `string` is a hexadecimal, in which case a `radix` of 16 is used.\n *\n * @param {string} string The string to convert to an integer.\n * @param {number} radix The radix to use when converting the string to an integer. Defaults to `0`.\n * @param {unknown} guard Enables use as an iteratee for methods like `Array#map`.\n * @returns {number} Returns the converted integer.\n *\n * @example\n * parseInt('08'); // => 8\n * parseInt('0x20'); // => 32\n *\n * parseInt('08', 10); // => 8\n * parseInt('0x20', 16); // => 32\n *\n * ['6', '08', '10'].map(parseInt); // => [6, 8, 10]\n */\nexport function parseInt(string: string, radix = 0, guard?: unknown): number {\n if (guard) {\n radix = 0;\n }\n return Number.parseInt(string, radix);\n}\n","/**\n * Splits an array into two groups based on a predicate function.\n *\n * This function takes an array and a predicate function. It returns a tuple of two arrays:\n * the first array contains elements for which the predicate function returns true, and\n * the second array contains elements for which the predicate function returns false.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to partition.\n * @param {(value: T) => boolean} isInTruthy - A predicate function that determines\n * whether an element should be placed in the truthy array. The function is called with each\n * element of the array.\n * @returns {[T[], T[]]} A tuple containing two arrays: the first array contains elements for\n * which the predicate returned true, and the second array contains elements for which the\n * predicate returned false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const isEven = x => x % 2 === 0;\n * const [even, odd] = partition(array, isEven);\n * // even will be [2, 4], and odd will be [1, 3, 5]\n */\nexport function partition(arr: readonly T[], isInTruthy: (value: T) => boolean): [truthy: T[], falsy: T[]] {\n const truthy: T[] = [];\n const falsy: T[] = [];\n\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n if (isInTruthy(item)) {\n truthy.push(item);\n } else {\n falsy.push(item);\n }\n }\n\n return [truthy, falsy];\n}\n","import { capitalize } from './capitalize.ts';\nimport { words as getWords } from './words.ts';\n\n/**\n * Converts a string to Pascal case.\n *\n * Pascal case is the naming convention in which each word is capitalized and concatenated without any separator characters.\n *\n * @param {string} str - The string that is to be changed to pascal case.\n * @returns {string} - The converted string to Pascal case.\n *\n * @example\n * const convertedStr1 = pascalCase('pascalCase') // returns 'PascalCase'\n * const convertedStr2 = pascalCase('some whitespace') // returns 'SomeWhitespace'\n * const convertedStr3 = pascalCase('hyphen-text') // returns 'HyphenText'\n * const convertedStr4 = pascalCase('HTTPRequest') // returns 'HttpRequest'\n */\nexport function pascalCase(str: string): string {\n const words = getWords(str);\n return words.map(word => capitalize(word)).join('');\n}\n","import { get } from './get.ts';\nimport { has } from './has.ts';\nimport { set } from './set.ts';\nimport { isNil } from '../predicate/isNil.ts';\n\n/**\n * Creates a new object composed of the picked object properties.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * includes only the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to pick keys from.\n * @param {K[]} keys - An array of keys to be picked from the object.\n * @returns {Pick} A new object with the specified keys picked.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, ['a', 'c']);\n * // result will be { a: 1, c: 3 }\n */\nexport function pick, K extends keyof T>(obj: T, keys: readonly K[]): Pick;\n\n/**\n * Creates a new object composed of the picked object properties.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * includes only the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @param {T | null | undefined} obj - The object to pick keys from.\n * @param {...any} keys\n * @param {PropertyKey | PropertyKey[] | PropertyKey[][]}} keys - An array of keys to be picked from the object. received keys goes through a flattening process before being used.\n * @returns {Partial} A new object with the specified keys picked.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, ['a', 'c']);\n * // result will be { a: 1, c: 3 }\n *\n * // each path can be passed individually as an argument\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, 'a', 'c');\n *\n * // pick a key over a path\n * const obj = { 'a.b': 1, a: { b: 2 } };\n * const result = pick(obj, 'a.b');\n * // result will be { 'a.b': 1 }\n */\nexport function pick<\n // eslint-disable-next-line\n T extends {},\n>(\n obj: T | null | undefined,\n ...keys: Array>\n): Partial;\n\n/**\n * Creates a new object composed of the picked object properties.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * includes only the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @param {T | null | undefined} obj - The object to pick keys from.\n * @param {...any} keysArr - An array of keys to be picked from the object. received keys goes through a flattening process before being used.\n * @param {PropertyKey | PropertyKey[] | PropertyKey[][]}} keys - An array of keys to be picked from the object. received keys goes through a flattening process before being used.\n * @returns {Partial} A new object with the specified keys picked.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, ['a', 'c']);\n * // result will be { a: 1, c: 3 }\n *\n * // each path can be passed individually as an argument\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = pick(obj, 'a', 'c');\n *\n * // pick a key over a path\n * const obj = { 'a.b': 1, a: { b: 2 } };\n * const result = pick(obj, 'a.b');\n * // result will be { 'a.b': 1 }\n */\nexport function pick<\n // eslint-disable-next-line\n T extends {},\n>(\n obj: T | null | undefined,\n ...keysArr: Array>\n): Partial {\n if (isNil(obj)) {\n return {};\n }\n\n const result: any = {};\n\n for (let i = 0; i < keysArr.length; i++) {\n let keys = keysArr[i];\n switch (typeof keys) {\n case 'object': {\n if (!Array.isArray(keys)) {\n // eslint-disable-next-line\n // @ts-ignore\n keys = Array.from(keys) as PropertyKey[];\n }\n break;\n }\n case 'string':\n case 'symbol':\n case 'number': {\n keys = [keys];\n break;\n }\n }\n\n for (const key of keys) {\n const value = get(obj, key);\n\n if (value === undefined && !has(obj, key)) {\n continue;\n }\n\n if (typeof key === 'string' && Object.hasOwn(obj, key)) {\n result[key] = value;\n } else {\n set(result, key, value);\n }\n }\n }\n\n return result;\n}\n","/**\n * Creates a new object composed of the properties that satisfy the predicate function.\n *\n * This function takes an object and a predicate function, and returns a new object that\n * includes only the properties for which the predicate function returns true.\n *\n * @template T - The type of object.\n * @param {T} obj - The object to pick properties from.\n * @param {(value: T[keyof T], key: keyof T) => boolean} shouldPick - A predicate function that determines\n * whether a property should be picked. It takes the property's key and value as arguments and returns `true`\n * if the property should be picked, and `false` otherwise.\n * @returns {Partial} A new object with the properties that satisfy the predicate function.\n *\n * @example\n * const obj = { a: 1, b: 'pick', c: 3 };\n * const shouldPick = (value) => typeof value === 'string';\n * const result = pickBy(obj, shouldPick);\n * // result will be { b: 'pick' }\n */\nexport function pickBy>(\n obj: T,\n shouldPick: (value: T[keyof T], key: keyof T) => boolean\n): Partial {\n const result: Partial = {};\n\n const keys = Object.keys(obj) as Array;\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = obj[key];\n\n if (shouldPick(value, key)) {\n result[key] = value;\n }\n }\n\n return result;\n}\n","import { at } from './at.ts';\n\n/**\n * Removes elements from an array at specified indices and returns the removed elements.\n *\n * This function supports negative indices, which count from the end of the array.\n *\n * @template T\n * @param {T[]} arr - The array from which elements will be removed.\n * @param {number[]} indicesToRemove - An array of indices specifying the positions of elements to remove.\n * @returns {Array} An array containing the elements that were removed from the original array.\n *\n * @example\n * import { pullAt } from './pullAt';\n *\n * const numbers = [10, 20, 30, 40, 50];\n * const removed = pullAt(numbers, [1, 3, 4]);\n * console.log(removed); // [20, 40, 50]\n * console.log(numbers); // [10, 30]\n */\nexport function pullAt(arr: T[], indicesToRemove: number[]): Array {\n const removed = at(arr, indicesToRemove);\n const indices = new Set(indicesToRemove.slice().sort((x, y) => y - x));\n\n for (const index of indices) {\n arr.splice(index, 1);\n }\n\n return removed;\n}\n","import { clamp } from './clamp.ts';\nimport { random as randomToolkit } from '../../math/random.ts';\nimport { randomInt as randomIntToolkit } from '../../math/randomInt.ts';\n\n/**\n * Generate a random number within 0 and 1.\n *\n * @returns {number} A random number between 0 (inclusive) and 1 (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `0`.\n *\n * @example\n * const result = random(); // Returns a random number between 0 and 1.\n */\nexport function random(floating?: boolean): number;\n\n/**\n * Generate a random number within 0 and 1.\n *\n * @returns {number} A random number between 0 (inclusive) and 1 (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `0`.\n *\n * @example\n * const result = random(); // Returns a random number between 0 and 1.\n */\nexport function random(min: number, index: string | number, guard: object): number;\n\n/**\n * Generate a random number within the given range.\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between 0 (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `0`.\n *\n * @example\n * const result1 = random(5); // Returns a random number between 0 and 5.\n * const result2 = random(0); // Returns a random number between 0 and 0 (which is 0).\n */\nexport function random(maximum: number, floating?: boolean): number;\n\n/**\n * Generate a random number within the given range.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result1 = random(0, 5); // Returns a random number between 0 and 5.\n * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown.\n * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.\n */\nexport function random(minimum: number, maximum: number, floating?: boolean): number;\n\n/**\n * Generate a random number within the given range.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result1 = random(0, 5); // Returns a random number between 0 and 5.\n * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown.\n * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.\n */\nexport function random(...args: any[]): number {\n let minimum = 0;\n let maximum = 1;\n let floating = false;\n\n switch (args.length) {\n case 1: {\n if (typeof args[0] === 'boolean') {\n floating = args[0];\n } else {\n maximum = args[0];\n }\n\n break;\n }\n case 2: {\n if (typeof args[1] === 'boolean') {\n maximum = args[0];\n floating = args[1];\n } else {\n minimum = args[0];\n maximum = args[1];\n }\n }\n // eslint-disable-next-line no-fallthrough\n case 3: {\n if (typeof args[2] === 'object' && args[2] != null && args[2][args[1]] === args[0]) {\n minimum = 0;\n maximum = args[0];\n floating = false;\n } else {\n minimum = args[0];\n maximum = args[1];\n floating = args[2];\n }\n }\n }\n\n if (typeof minimum !== 'number') {\n minimum = Number(minimum);\n }\n\n if (typeof maximum !== 'number') {\n minimum = Number(maximum);\n }\n\n if (!minimum) {\n minimum = 0;\n }\n\n if (!maximum) {\n maximum = 0;\n }\n\n if (minimum > maximum) {\n [minimum, maximum] = [maximum, minimum];\n }\n\n minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n\n if (minimum === maximum) {\n return minimum;\n }\n\n if (floating) {\n return randomToolkit(minimum, maximum + 1);\n } else {\n return randomIntToolkit(minimum, maximum + 1);\n }\n}\n","/**\n * Returns an array of numbers from `end` (exclusive) to `0` (inclusive), decrementing by `1`.\n *\n * @param {number} end - The end number of the range (exclusive).\n * @returns {number[]} An array of numbers from `end` (exclusive) to `0` (inclusive) with a step of `1`.\n *\n * @example\n * // Returns [3, 2, 1, 0]\n * rangeRight(4);\n */\nexport function rangeRight(end: number): number[];\n\n/**\n * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `1`.\n *\n * @param {number} start - The starting number of the range (inclusive).\n * @param {number} end - The end number of the range (exclusive).\n * @returns {number[]} An array of numbers from `end` (exclusive) to `start` (inclusive) with a step of `1`.\n *\n * @example\n * // Returns [3, 2, 1]\n * rangeRight(1, 4);\n */\nexport function rangeRight(start: number, end: number): number[];\n\n/**\n * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `step`.\n *\n * @param {number} start - The starting number of the range (inclusive).\n * @param {number} end - The end number of the range (exclusive).\n * @param {number} step - The step value for the range.\n * @returns {number[]} An array of numbers from `end` (exclusive) to `start` (inclusive) with the specified `step`.\n *\n * @example\n * // Returns [15, 10, 5, 0]\n * rangeRight(0, 20, 5);\n */\nexport function rangeRight(start: number, end: number, step: number): number[];\n\n/**\n * Returns an array of numbers from `end` (exclusive) to `start` (inclusive), decrementing by `step`.\n *\n * @param {number} start - The starting number of the range (inclusive).\n * @param {number} end - The end number of the range (exclusive).\n * @param {number} step - The step value for the range.\n * @returns {number[]} An array of numbers from `end` (exclusive) to `start` (inclusive) with the specified `step`.\n * @throws {Error} Throws an error if the step value is not a non-zero integer.\n *\n * @example\n * // Returns [3, 2, 1, 0]\n * rangeRight(4);\n *\n * @example\n * // Returns [-3, -2, -1, 0]\n * rangeRight(0, -4, -1);\n */\nexport function rangeRight(start: number, end?: number, step: number = 1): number[] {\n if (end == null) {\n end = start;\n start = 0;\n }\n\n if (!Number.isInteger(step) || step === 0) {\n throw new Error(`The step value must be a non-zero integer.`);\n }\n\n const length = Math.max(Math.ceil((end - start) / step), 0);\n const result = new Array(length);\n\n for (let i = 0; i < length; i++) {\n result[i] = start + (length - i - 1) * step;\n }\n\n return result;\n}\n","import { flatten } from '../array/flatten.ts';\n\n/**\n * Creates a function that invokes `func` with arguments arranged according to the specified `indices`\n * where the argument value at the first index is provided as the first argument,\n * the argument value at the second index is provided as the second argument, and so on.\n *\n * @template F The type of the function to re-arrange.\n * @param {F} func The function to rearrange arguments for.\n * @param {Array} indices The arranged argument indices.\n * @returns {(...args: any[]) => ReturnType} Returns the new function.\n *\n * @example\n * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;\n * const rearrangedGreet = rearg(greet, 1, 0);\n * console.log(rearrangedGreet('World', 'Hello')); // Output: \"Hello, World!\"\n */\nexport function rearg any>(\n func: F,\n ...indices: Array\n): (...args: any[]) => ReturnType {\n const flattenIndices = flatten(indices);\n\n return function (this: any, ...args: any[]) {\n const reorderedArgs: any[] = flattenIndices.map(i => args[i]).slice(0, args.length);\n\n for (let i = reorderedArgs.length; i < args.length; i++) {\n reorderedArgs.push(args[i]);\n }\n\n return func.apply(this, reorderedArgs);\n };\n}\n","/**\n * Repeats the given string n times.\n *\n * If n is less than 1, an empty string is returned, or if the string is an empty string,\n * the original string is returned unchanged.\n *\n * @param {string} str - The string to repeat.\n * @param {number} n - The number of times to repeat the string.\n * @returns {string} - The repeated string, or an empty string if n is less than 1.\n *\n * @example\n * repeat('abc', 0); // ''\n * repeat('abc', 2); // 'abcabc'\n */\nexport function repeat(str: string, n: number): string {\n return str.repeat(n);\n}\n","import { toString } from '../util/toString.ts';\n\n/**\n * Replaces the matched pattern with the replacement string.\n *\n * @param {string} target - The target string.\n * @param {string | RegExp} pattern - The pattern to match.\n * @param {string | ((substring: string, ...args: any[]) => string)} replacement - The replacement string or a function that returns the replacement string.\n * @returns {string} The new string with the matched pattern replaced.\n *\n * @example\n * replace('abcde', 'de', '123'); // 'abc123'\n * replace('abcde', /[bd]/g, '-'); // 'a-c-e'\n * replace('abcde', 'de', substring => substring.toUpperCase()); // 'abcDE'\n * replace('abcde', /[bd]/g, substring => substring.toUpperCase()); // 'aBcDe'\n */\nexport function replace(\n target = '',\n pattern: string | RegExp,\n replacement: string | ((substring: string, ...args: any[]) => string)\n): string {\n if (arguments.length < 3) {\n return toString(target);\n }\n\n return toString(target).replace(pattern, replacement as any);\n}\n","import { rest as restToolkit } from '../../function/rest.ts';\n\n/**\n * Creates a function that transforms the arguments of the provided function `func`.\n * The transformed arguments are passed to `func` such that the arguments starting from a specified index\n * are grouped into an array, while the previous arguments are passed as individual elements.\n *\n * @template F - The type of the function being transformed.\n * @param {F} func - The function whose arguments are to be transformed.\n * @param {number} [start=func.length - 1] - The index from which to start grouping the remaining arguments into an array.\n * Defaults to `func.length - 1`, grouping all arguments after the last parameter.\n * @returns {(...args: any[]) => ReturnType} A new function that, when called, returns the result of calling `func` with the transformed arguments.\n *\n * The transformed arguments are:\n * - The first `start` arguments as individual elements.\n * - The remaining arguments from index `start` onward grouped into an array.\n * @example\n * function fn(a, b, c) {\n * return [a, b, c];\n * }\n *\n * // Using default start index (func.length - 1, which is 2 in this case)\n * const transformedFn = rest(fn);\n * console.log(transformedFn(1, 2, 3, 4)); // [1, 2, [3, 4]]\n *\n * // Using start index 1\n * const transformedFnWithStart = rest(fn, 1);\n * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]]\n *\n * // With fewer arguments than the start index\n * console.log(transformedFn(1)); // [1, undefined, []]\n */\nexport function rest any>(\n func: F,\n start = func.length - 1\n): (...args: any[]) => ReturnType {\n start = Number.parseInt(start as any, 10);\n\n if (Number.isNaN(start) || start < 0) {\n start = func.length - 1;\n }\n\n return restToolkit(func, start);\n}\n","/**\n * Creates a function that transforms the arguments of the provided function `func`.\n * The transformed arguments are passed to `func` such that the arguments starting from a specified index\n * are grouped into an array, while the previous arguments are passed as individual elements.\n *\n * @template F - The type of the function being transformed.\n * @param {F} func - The function whose arguments are to be transformed.\n * @param {number} [startIndex=func.length - 1] - The index from which to start grouping the remaining arguments into an array.\n * Defaults to `func.length - 1`, grouping all arguments after the last parameter.\n * @returns {(...args: any[]) => ReturnType} A new function that, when called, returns the result of calling `func` with the transformed arguments.\n *\n * The transformed arguments are:\n * - The first `start` arguments as individual elements.\n * - The remaining arguments from index `start` onward grouped into an array.\n * @example\n * function fn(a, b, c) {\n * return [a, b, c];\n * }\n *\n * // Using default start index (func.length - 1, which is 2 in this case)\n * const transformedFn = rest(fn);\n * console.log(transformedFn(1, 2, 3, 4)); // [1, 2, [3, 4]]\n *\n * // Using start index 1\n * const transformedFnWithStart = rest(fn, 1);\n * console.log(transformedFnWithStart(1, 2, 3, 4)); // [1, [2, 3, 4]]\n *\n * // With fewer arguments than the start index\n * console.log(transformedFn(1)); // [1, undefined, []]\n */\nexport function rest any>(\n func: F,\n startIndex = func.length - 1\n): (...args: any[]) => ReturnType {\n return function (this: any, ...args: any[]) {\n const rest = args.slice(startIndex);\n const params = args.slice(0, startIndex);\n while (params.length < startIndex) {\n params.push(undefined);\n }\n return func.apply(this, [...params, rest]);\n };\n}\n","import { decimalAdjust } from '../_internal/decimalAdjust.ts';\n\n/**\n * Computes number rounded to precision.\n *\n * @param {number | string} number The number to round.\n * @param {number | string} precision The precision to round to.\n * @returns {number} Returns the rounded number.\n *\n * @example\n * round(4.006); // => 4\n * round(4.006, 2); // => 4.01\n * round(4060, -2); // => 4100\n */\nexport function round(number: number | string, precision: number | string = 0): number {\n return decimalAdjust('round', number, precision);\n}\n","import { sample as sampleToolkit } from '../../array/sample.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Returns a random element from an array.\n *\n * @template T\n * @param {T[]} array - The array to sample from.\n * @returns {T | undefined} A random element from the array, or `undefined` if the array is empty.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = sample(array);\n * console.log(result); // Output: 1, 2, or 3 (randomly selected)\n */\nexport function sample(array: readonly T[]): T | undefined;\n\n/**\n * Returns a random character from a string.\n *\n * @param {string} str - The string to sample from.\n * @returns {string | undefined} A random character from the string, or `undefined` if the string is empty.\n *\n * @example\n * const str = \"hello\";\n * const result = sample(str);\n * console.log(result); // Output: 'h', 'e', 'l', 'l', or 'o' (randomly selected)\n */\nexport function sample(str: string): string | undefined;\n\n/**\n * Returns a random element from an array.\n *\n * @template T\n * @param {ArrayLike} array - The array-like object to sample from.\n * @returns {T | undefined} A random element from the array, or `undefined` if the array is empty.\n *\n * @example\n * const arrayLike: ArrayLike = { 0: 'a', 1: 'b', 2: 'c', length: 3 };\n * const result = sample(arrayLike);\n * console.log(result); // Output: 'a', 'b', or 'c' (randomly selected)\n */\nexport function sample(array: ArrayLike): T | undefined;\n\n/**\n * Returns a random value from an object.\n *\n * @template T - The type of values in the object.\n * @param {Record} obj - The object to sample from.\n * @returns {T | undefined} A random value from the object, or `undefined` if the object is empty.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = sample(obj);\n * console.log(result); // Output: 1, 2, or 3 (randomly selected)\n */\nexport function sample(obj: Record): T | undefined;\n\n/**\n * Returns a random element from an array-like object or a regular object.\n *\n * This function takes an array-like object (such as an array or string) or a regular object,\n * and returns a randomly selected element or value. If the collection is empty or invalid, it returns `undefined`.\n *\n * @template T - The type of elements in the collection.\n * @param {ArrayLike | Record} collection - The collection to sample from.\n * @returns {T | string | undefined} A random element from the collection, or `undefined` if the collection is empty or invalid.\n *\n * @example\n * // Array example\n * const array = [1, 2, 3];\n * const result = sample(array);\n * console.log(result); // Output: 1, 2, or 3 (randomly selected)\n *\n * // String example\n * const str = 'abc';\n * const result2 = sample(str);\n * console.log(result2); // Output: 'a', 'b', or 'c' (randomly selected)\n *\n * // Object example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result3 = sample(obj);\n * console.log(result3); // Output: 1, 2, or 3 (randomly selected)\n */\nexport function sample(collection: ArrayLike | Record): T | string | undefined;\n\n/**\n * The implementation for the overloaded sample function.\n *\n * This function takes an array, string, or object and returns a single element selected randomly.\n * If the input is empty, or if it's null or undefined, the function returns `undefined`.\n *\n * @template T - The type of elements in the collection.\n * @param {ArrayLike | Record} collection - The collection to sample from.\n * @returns {T | string | undefined} A random element from the collection, or `undefined` if the collection is empty or invalid.\n */\nexport function sample(collection: ArrayLike | Record): T | string | undefined {\n if (collection == null) {\n return undefined;\n }\n\n if (isArrayLike(collection)) {\n return sampleToolkit(toArray(collection));\n }\n\n return sampleToolkit(Object.values(collection));\n}\n","import { randomInt } from '../math/randomInt.ts';\n\n/**\n * Returns a sample element array of a specified `size`.\n *\n * This function takes an array and a number, and returns an array containing the sampled elements using Floyd's algorithm.\n *\n * {@link https://www.nowherenearithaca.com/2013/05/robert-floyds-tiny-and-beautiful.html Floyd's algorithm}\n *\n * @template T - The type of elements in the array.\n * @param {T[]} array - The array to sample from.\n * @param {number} size - The size of sample.\n * @returns {T[]} A new array with sample size applied.\n * @throws {Error} Throws an error if `size` is greater than the length of `array`.\n *\n * @example\n * const result = sampleSize([1, 2, 3], 2)\n * // result will be an array containing two of the elements from the array.\n * // [1, 2] or [1, 3] or [2, 3]\n */\nexport function sampleSize(array: readonly T[], size: number): T[] {\n if (size > array.length) {\n throw new Error('Size must be less than or equal to the length of array.');\n }\n\n const result = new Array(size);\n const selected = new Set();\n\n for (let step = array.length - size, resultIndex = 0; step < array.length; step++, resultIndex++) {\n let index = randomInt(0, step + 1);\n\n if (selected.has(index)) {\n index = step;\n }\n\n selected.add(index);\n\n result[resultIndex] = array[index];\n }\n\n return result;\n}\n","/**\n * Randomizes the order of elements in an array using the Fisher-Yates algorithm.\n *\n * This function takes an array and returns a new array with its elements shuffled in a random order.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to shuffle.\n * @returns {T[]} A new array with its elements shuffled in random order.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const shuffledArray = shuffle(array);\n * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]\n */\nexport function shuffle(arr: readonly T[]): T[] {\n const result = arr.slice();\n\n /**\n * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n for (let i = result.length - 1; i >= 1; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n","import { isNil } from '../../predicate/isNil.ts';\n\n/**\n * Returns the length of an array, string, or object.\n *\n * This function takes an array, string, or object and returns its length.\n * For arrays and strings, it returns the number of elements or characters, respectively.\n * For objects, it returns the number of enumerable properties.\n *\n * @template T - The type of the input value.\n * @param {T[] | object | string | Map | Set | null | undefined } target - The value whose size is to be determined. It can be an array, string, or object.\n * @returns {number} The size of the input value.\n *\n * @example\n * const arr = [1, 2, 3];\n * const arrSize = size(arr);\n * // arrSize will be 3\n *\n * const str = 'hello';\n * const strSize = size(str);\n * // strSize will be 5\n *\n * const obj = { a: 1, b: 2, c: 3 };\n * const objSize = size(obj);\n * // objSize will be 3\n *\n * const emptyArr = [];\n * const emptyArrSize = size(emptyArr);\n * // emptyArrSize will be 0\n *\n * const emptyStr = '';\n * const emptyStrSize = size(emptyStr);\n * // emptyStrSize will be 0\n *\n * const emptyObj = {};\n * const emptyObjSize = size(emptyObj);\n * // emptyObjSize will be 0\n */\nexport function size(target: readonly T[] | object | string | Map | Set | null | undefined): number {\n if (isNil(target)) {\n return 0;\n }\n\n if (target instanceof Map || target instanceof Set) {\n return target.size;\n }\n\n return Object.keys(target).length;\n}\n","import { isIterateeCall } from '../_internal/isIterateeCall.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { toInteger } from '../util/toInteger.ts';\n\n/**\n * Create a slice of `array` from `start` up to, but not including, `end`.\n *\n * It does not return a dense array for sparse arrays unlike the native `Array.prototype.slice`.\n *\n * @template T - The type of the array elements.\n * @param {ArrayLike | null | undefined} array - The array to slice.\n * @param {number} [start=0] - The start position.\n * @param {number} [end=array.length] - The end position.\n * @returns {T[]} - Returns the slice of `array`.\n *\n * @example\n * slice([1, 2, 3], 1, 2); // => [2]\n * slice(new Array(3)); // => [undefined, undefined, undefined]\n */\nexport function slice(array: ArrayLike | null | undefined, start?: number, end?: number): T[] {\n if (!isArrayLike(array)) {\n return [];\n }\n\n const length = array.length;\n\n if (end === undefined) {\n end = length;\n } else if (typeof end !== 'number' && isIterateeCall(array, start, end)) {\n // support for expression like `_.map(slice)`\n start = 0;\n end = length;\n }\n\n start = toInteger(start);\n end = toInteger(end);\n\n if (start < 0) {\n start = Math.max(length + start, 0);\n } else {\n start = Math.min(start, length);\n }\n\n if (end < 0) {\n end = Math.max(length + end, 0);\n } else {\n end = Math.min(end, length);\n }\n\n const resultLength = Math.max(end - start, 0);\n const result = new Array(resultLength);\n\n for (let i = 0; i < resultLength; ++i) {\n result[i] = array[start + i];\n }\n\n return result;\n}\n","import { snakeCase as snakeCaseToolkit } from '../../string/snakeCase.ts';\nimport { normalizeForCase } from '../_internal/normalizeForCase.ts';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string | object} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\nexport function snakeCase(str?: string | object): string {\n return snakeCaseToolkit(normalizeForCase(str));\n}\n","import { words as getWords } from './words.ts';\n\n/**\n * Converts a string to snake case.\n *\n * Snake case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to snake case.\n * @returns {string} - The converted string to snake case.\n *\n * @example\n * const convertedStr1 = snakeCase('camelCase') // returns 'camel_case'\n * const convertedStr2 = snakeCase('some whitespace') // returns 'some_whitespace'\n * const convertedStr3 = snakeCase('hyphen-text') // returns 'hyphen_text'\n * const convertedStr4 = snakeCase('HTTPRequest') // returns 'http_request'\n */\n\nexport function snakeCase(str: string): string {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join('_');\n}\n","import { identity } from '../../function/identity.ts';\nimport { property } from '../object/property.ts';\nimport { matches } from '../predicate/matches.ts';\nimport { matchesProperty } from '../predicate/matchesProperty.ts';\n\n/**\n * Checks if there is an element in an array that is truthy.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr The array to iterate over.\n * @returns {boolean} Returns `true` if any element is truthy, else `false`.\n *\n * @example\n * some([1, 2, 3, 4]);\n * // => true\n */\nexport function some(arr: ArrayLike | null | undefined): boolean;\n\n/**\n * Checks if there is an element in an array that matches the given predicate function.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr The array to iterate over.\n * @param {(item: T, index: number, arr: readonly T[]) => unknown} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.\n *\n * @example\n * some([1, 2, 3, 4], n => n % 2 === 0);\n * // => true\n */\nexport function some(\n arr: ArrayLike | null | undefined,\n predicate: (item: T, index: number, arr: readonly T[]) => unknown\n): boolean;\n\n/**\n * Checks if there is an element in an array that matches the given key-value pair.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr The array to iterate over.\n * @param {[keyof T, unknown]} predicate The key-value pair to match.\n * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.\n *\n * @example\n * some([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);\n * // => true\n */\nexport function some(arr: ArrayLike | null | undefined, predicate: [keyof T, unknown]): boolean;\n\n/**\n * Checks if there is an element in an array that has a truthy value for the given property name.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr The array to iterate over.\n * @param {string} propertyToCheck The property name to check.\n * @returns {boolean} Returns `true` if any element has a truthy value for the property, else `false`.\n *\n * @example\n * some([{ a: 1 }, { a: 2 }, { a: 3 }], 'a');\n * // => true\n */\nexport function some(arr: ArrayLike | null | undefined, propertyToCheck: string): boolean;\n\n/**\n * Checks if there is an element in an array that matches the given partial object.\n *\n * @template T\n * @param {ArrayLike | null | undefined} arr The array to iterate over.\n * @param {Partial} doesMatch The partial object to match.\n * @returns {boolean} Returns `true` if any element matches the partial object, else `false`.\n *\n * @example\n * some([{ a: 1 }, { a: 2 }, { a: 3 }], { a: 2 });\n * // => true\n */\nexport function some(arr: ArrayLike | null | undefined, doesMatch: Partial): boolean;\n\n/**\n * Checks if there is an element in an object that matches the given predicate function.\n *\n * @template T\n * @param {T | null | undefined} object The object to iterate over.\n * @returns {boolean} Returns `true` if any element is truthy, else `false`.\n *\n * @example\n * some({ a: 1, b: 2, c: 3 });\n * // => true\n */\nexport function some>(object: T | null | undefined): boolean;\n\n/**\n * Checks if there is an element in an object that matches the given predicate function.\n *\n * @template T\n * @param {T | null | undefined} object The object to iterate over.\n * @param {(value: T[keyof T], key: keyof T, object: T) => unknown} doesMatch A function that takes an value, its key, and the object, and returns a truthy value if the item matches the criteria.\n * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.\n *\n * @example\n * some({ a: 1, b: 2, c: 3 }, n => n % 2 === 0);\n * // => true\n */\nexport function some>(\n object: T | null | undefined,\n doesMatch: (value: T[keyof T], key: keyof T, object: T) => unknown\n): boolean;\n\n/**\n * Checks if there is an element in an object that matches the given partial value.\n *\n * @template T\n * @param {T | null | undefined} object The object to iterate over.\n * @param {Partial} doesMatch A partial value to match against the values of the object.\n * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.\n *\n * @example\n * some({ a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } }, { name: 'Bob' });\n * // => true\n */\nexport function some>(\n object: T | null | undefined,\n doesMatch: Partial\n): boolean;\n\n/**\n * Checks if there is an element in an object that matches a property with a specific value.\n *\n * @template T\n * @param {T | null | undefined} object The object to iterate over.\n * @param {[keyof T, unknown]} doesMatchProperty An array where the first element is the property key and the second element is the value to match.\n * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.\n *\n * @example\n * const obj = { alice: { id: 1, name: 'Alice' }, bob: { id: 2, name: 'Bob' } };\n * const result = some(obj, ['name', 'Alice']);\n * // => true\n */\nexport function some>(\n object: T | null | undefined,\n doesMatchProperty: [keyof T[keyof T], unknown]\n): boolean;\n\n/**\n * Checks if there is an element in an object that has a specific property, where the property name is provided as a string.\n *\n * @template T\n * @param {T | null | undefined} object The object to iterate over.\n * @param {string} propertyToCheck The property name to check.\n * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.\n *\n * @example\n * const obj = { alice: { id: 1, name: 'Alice' }, bob: { id: 2, name: 'Bob' } };\n * const result = some(obj, 'name');\n * // => true\n */\nexport function some>(object: T | null | undefined, propertyToCheck: string): boolean;\n/**\n * Checks if there is an element in an array that matches the given predicate.\n *\n * Iteration is stopped once there is an element that matches `predicate`.\n *\n * @template T\n * @param {ArrayLike | Record | null | undefined} source The source to iterate over.\n * @param {((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string} [predicate=identity] The function invoked per iteration.\n * If a property name or an object is provided it will be used to create a predicate function.\n * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`.\n *\n * @example\n * some([1, 2, 3, 4], n => n % 2 === 0);\n * // => true\n *\n * some([{ a: 1 }, { a: 2 }, { a: 3 }], { a: 2 });\n * // => true\n *\n * some([{ a: 1 }, { a: 2 }, { a: 3 }], ['a', 2]);\n * // => true\n *\n * some([{ a: 1 }, { a: 2 }, { a: 3 }], 'a');\n * // => true\n *\n * some({ a: 1, b: 2, c: 3 }, n => n % 2 === 0);\n * // => true\n *\n * some({ a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } }, { name: 'Bob' });\n * // => true\n *\n * some({ a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } }, ['name', 'Alice']);\n * // => true\n *\n * some({ a: { id: 1, name: 'Alice' }, b: { id: 2, name: 'Bob' } }, 'name');\n * // => true\n */\nexport function some(\n source: ArrayLike | Record | null | undefined,\n predicate?: ((item: T, index: number, arr: any) => unknown) | Partial | [keyof T, unknown] | string,\n guard?: unknown\n): boolean {\n if (!source) {\n return false;\n }\n if (guard != null) {\n predicate = undefined;\n }\n\n if (!predicate) {\n predicate = identity;\n }\n\n const values = Array.isArray(source) ? source : Object.values(source);\n\n switch (typeof predicate) {\n case 'function': {\n if (!Array.isArray(source)) {\n const keys = Object.keys(source) as Array;\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = source[key];\n\n if (predicate(value as T, key as number, source)) {\n return true;\n }\n }\n\n return false;\n }\n return values.some(predicate);\n }\n case 'object': {\n if (Array.isArray(predicate) && predicate.length === 2) {\n const key = predicate[0];\n const value = predicate[1];\n\n return values.some(matchesProperty(key, value));\n } else {\n return values.some(matches(predicate));\n }\n }\n case 'string': {\n return values.some(property(predicate));\n }\n }\n}\n","import { Criterion, orderBy } from './orderBy.ts';\nimport { flatten } from '../../array/flatten.ts';\nimport { isIterateeCall } from '../_internal/isIterateeCall.ts';\n\n/**\n * Sorts an array of objects based on multiple properties and their corresponding order directions.\n *\n * This function takes an array of objects, an array of criteria to sort by.\n * It returns the ascending sorted array, ordering by each key.\n * If values for a key are equal, it moves to the next key to determine the order.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | object | null | undefined} collection - The array of objects to be sorted.\n * @param {Array | Criterion>>} criteria - An array of criteria (property names or property paths or custom key functions) to sort by.\n * @returns {T[]} - The ascending sorted array.\n *\n * @example\n * // Sort an array of objects by 'user' in ascending order and 'age' in descending order.\n * const users = [\n * { user: 'fred', age: 48 },\n * { user: 'barney', age: 34 },\n * { user: 'fred', age: 40 },\n * { user: 'barney', age: 36 },\n * ];\n * const result = sortBy(users, ['user', (item) => item.age])\n * // result will be:\n * // [\n * // { user: 'barney', age: 34 },\n * // { user: 'barney', age: 36 },\n * // { user: 'fred', age: 40 },\n * // { user: 'fred', age: 48 },\n * // ]\n */\nexport function sortBy(\n collection: ArrayLike | object | null | undefined,\n ...criteria: Array | Array>>\n): T[] {\n const length = criteria.length;\n // Enables use as an iteratee for methods like `_.reduce` and `_.map`.\n if (length > 1 && isIterateeCall(collection, criteria[0], criteria[1])) {\n criteria = [];\n } else if (length > 2 && isIterateeCall(criteria[0], criteria[1], criteria[2])) {\n criteria = [criteria[0]];\n }\n return orderBy(collection, flatten(criteria), ['asc']);\n}\n","/**\n * Creates a new function that spreads elements of an array argument into individual arguments\n * for the original function. The array argument is positioned based on the `argsIndex` parameter.\n *\n * @template F - A function type with any number of parameters and any return type.\n * @param {F} func - The function to be transformed. It can be any function with any number of arguments.\n * @param {number} [argsIndex=0] - The index where the array argument is positioned among the other arguments.\n * If `argsIndex` is negative or `NaN`, it defaults to `0`. If it's a fractional number, it is rounded to the nearest integer.\n * @returns {(...args: any[]) => ReturnType} - A new function that takes multiple arguments, including an array of arguments at the specified `argsIndex`,\n * and returns the result of calling the original function with those arguments.\n *\n * @example\n * function add(a, b) {\n * return a + b;\n * }\n *\n * const spreadAdd = spread(add);\n * console.log(spreadAdd([1, 2])); // Output: 3\n *\n * @example\n * // Example function to spread arguments over\n * function add(a, b) {\n * return a + b;\n * }\n *\n * // Create a new function that uses `spread` to combine arguments\n * const spreadAdd = spread(add, 1);\n *\n * // Calling `spreadAdd` with an array as the second argument\n * console.log(spreadAdd(1, [2])); // Output: 3\n *\n * @example\n * // Function with default arguments\n * function greet(name, greeting = 'Hello') {\n * return `${greeting}, ${name}!`;\n * }\n *\n * // Create a new function that uses `spread` to position the argument array at index 0\n * const spreadGreet = spread(greet, 0);\n *\n * // Calling `spreadGreet` with an array of arguments\n * console.log(spreadGreet(['Alice'])); // Output: Hello, Alice!\n * console.log(spreadGreet(['Bob', 'Hi'])); // Output: Hi, Bob!\n */\nexport function spread any>(func: F, argsIndex = 0): (...args: any[]) => ReturnType {\n argsIndex = Number.parseInt(argsIndex as any, 10);\n\n if (Number.isNaN(argsIndex) || argsIndex < 0) {\n argsIndex = 0;\n }\n\n return function (this: any, ...args: any[]) {\n const array = args[argsIndex];\n const params = args.slice(0, argsIndex);\n\n if (array) {\n params.push(...array);\n }\n\n return func.apply(this, params);\n };\n}\n","import { words as getWords } from '../../string/words.ts';\nimport { normalizeForCase } from '../_internal/normalizeForCase.ts';\n\n/**\n * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.\n *\n * Start case is the naming convention in which each word is written with an initial capital letter.\n * @param {string | object} str - The string to convert.\n * @returns {string} The converted string.\n *\n * @example\n * const result1 = startCase('hello world'); // result will be 'Hello World'\n * const result2 = startCase('HELLO WORLD'); // result will be 'HELLO WORLD'\n * const result3 = startCase('hello-world'); // result will be 'Hello World'\n * const result4 = startCase('hello_world'); // result will be 'Hello World'\n */\nexport function startCase(str?: string | object): string {\n const words = getWords(normalizeForCase(str).trim());\n\n let result = '';\n\n for (let i = 0; i < words.length; i++) {\n const word = words[i];\n\n if (result) {\n result += ' ';\n }\n\n if (word === word.toUpperCase()) {\n result += word;\n } else {\n result += word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n\n return result;\n}\n","/**\n * Checks if a string contains another string at the beginning of the string.\n *\n * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.\n *\n * @param {string} str - The string that might contain the target string.\n * @param {string} target - The string to search for.\n * @param {number} position - An optional offset to start searching in the str string\n * @returns {boolean} - True if the str string starts with the target string.\n *\n * @example\n * const isPrefix = startsWith('fooBar', 'foo') // returns true\n * const isPrefix = startsWith('fooBar', 'bar') // returns false\n * const isPrefix = startsWith('fooBar', 'abc') // returns false\n * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true\n * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false\n */\nexport function startsWith(str: string, target: string, position = 0): boolean {\n return str.startsWith(target, position);\n}\n","import { sumBy } from './sumBy';\n\n/**\n * Computes the sum of the `number` values in `array`.\n *\n * @param {ArrayLike | null | undefined} array - The array to iterate over.\n * @returns {number} Returns the sum.\n *\n * @example\n * sum([1, 2, 3]); // => 6\n * sum(null); // => 0\n * sum(undefined); // => 0\n */\nexport function sum(array: ArrayLike | null | undefined): number;\n\n/**\n * Computes the sum of the `bigint` values in `array`.\n *\n * @param {ArrayLike} array - The array to iterate over.\n * @returns {bigint} Returns the sum.\n *\n * @example\n * sum([1n, 2n, 3n]); // => 6n\n */\nexport function sum(array: ArrayLike): bigint;\n\n/**\n * Computes the sum of the values in `array`.\n *\n * It does not coerce values to `number`.\n *\n * @param {ArrayLike | null | undefined} array - The array to iterate over.\n * @returns {unknown} Returns the sum.\n *\n * @example\n * sum([\"1\", \"2\"]); // => \"12\"\n * sum([1, undefined, 2]); // => 3\n */\nexport function sum(array: ArrayLike | null | undefined): unknown;\n\n/**\n * Compmutes the sum of the values that are returned by the `iteratee` function.\n *\n * It does not coerce values to `number`.\n *\n * @param {ArrayLike | null | undefined} array - The array to iterate over.\n * @returns {unknown} Returns the sum.\n *\n * @example\n * sum([1, 2, 3]); // => 6\n * sum([1n, 2n, 3n]); // => 6n\n * sum([\"1\", \"2\"]); // => \"12\"\n * sum([1, undefined, 2]); // => 3\n * sum(null); // => 0\n * sum(undefined); // => 0\n */\nexport function sum(array: ArrayLike | null | undefined): unknown {\n return sumBy(array);\n}\n","import { tail as tailToolkit } from '../../array/tail.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Returns a new array with all elements except for the first.\n *\n * This function takes an array and returns a new array containing all the elements\n * except for the first one. If the input array is empty or has only one element,\n * an empty array is returned.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array to get the tail of.\n * @returns {T[]} A new array containing all elements of the input array except for the first one.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const result = tail(arr1);\n * // result will be [2, 3]\n *\n * const arr2 = [1];\n * const result2 = tail(arr2);\n * // result2 will be []\n *\n * const arr3 = [];\n * const result3 = tail(arr3);\n * // result3 will be []\n */\nexport function tail(arr: ArrayLike | null | undefined): T[] {\n if (!isArrayLike(arr)) {\n return [];\n }\n return tailToolkit(toArray(arr));\n}\n","/**\n * Returns an empty array when the input is a single-element array.\n *\n * @template T - The type of the single element in the array.\n * @param {[T]} arr - The single-element array to process.\n * @returns {[]} An empty array.\n *\n * @example\n * const arr = [1];\n * const result = tail(arr);\n * // result will be []\n */\nexport function tail(arr: readonly [T]): [];\n\n/**\n * Returns an empty array when the input is an empty array.\n *\n * @template T - The type of elements in the array.\n * @param {[]} arr - The empty array to process.\n * @returns {[]} An empty array.\n *\n * @example\n * const arr = [];\n * const result = tail(arr);\n * // result will be []\n */\nexport function tail(arr: readonly []): [];\n\n/**\n * Returns a new array with all elements except for the first when the input is a tuple array.\n *\n * @template T - The type of the first element in the tuple array.\n * @template U - The type of the remaining elements in the tuple array.\n * @param {[T, ...U[]]} arr - The tuple array to process.\n * @returns {U[]} A new array containing all elements of the input array except for the first one.\n *\n * @example\n * const arr = [1, 2, 3];\n * const result = tail(arr);\n * // result will be [2, 3]\n */\nexport function tail(arr: readonly [T, ...U[]]): U[];\n\n/**\n * Returns a new array with all elements except for the first.\n *\n * This function takes an array and returns a new array containing all the elements\n * except for the first one. If the input array is empty or has only one element,\n * an empty array is returned.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to get the tail of.\n * @returns {T[]} A new array containing all elements of the input array except for the first one.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const result = tail(arr1);\n * // result will be [2, 3]\n *\n * const arr2 = [1];\n * const result2 = tail(arr2);\n * // result2 will be []\n *\n * const arr3 = [];\n * const result3 = tail(arr3);\n * // result3 will be []\n */\nexport function tail(arr: readonly T[]): T[];\n\n/**\n * Returns a new array with all elements except for the first.\n *\n * This function takes an array and returns a new array containing all the elements\n * except for the first one. If the input array is empty or has only one element,\n * an empty array is returned.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to get the tail of.\n * @returns {T[]} A new array containing all elements of the input array except for the first one.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const result = tail(arr1);\n * // result will be [2, 3]\n *\n * const arr2 = [1];\n * const result2 = tail(arr2);\n * // result2 will be []\n *\n * const arr3 = [];\n * const result3 = tail(arr3);\n * // result3 will be []\n */\nexport function tail(arr: readonly T[]): T[] {\n return arr.slice(1);\n}\n","import { take as takeToolkit } from '../../array/take.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { toInteger } from '../util/toInteger.ts';\n\n/**\n * Returns a new array containing the first `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {ArrayLike | null | undefined} arr - The array to take elements from.\n * @param {number} [count=1] - The number of elements to take.\n * @param {unknown} [guard] - Enables use as an iteratee for methods like `_.map`.\n * @returns {T[]} A new array containing the first `count` elements from `arr`.\n *\n * @example\n * // Returns [1, 2, 3]\n * take([1, 2, 3, 4, 5], 3);\n *\n * @example\n * // Returns ['a', 'b']\n * take(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * take([1, 2, 3], 5);\n */\nexport function take(arr: ArrayLike | null | undefined, count: number = 1, guard?: unknown): T[] {\n count = guard ? 1 : toInteger(count);\n if (count < 1 || !isArrayLike(arr)) {\n return [];\n }\n\n return takeToolkit(toArray(arr), count);\n}\n","/**\n * Returns a new array containing the first `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {number} count - The number of elements to take.\n * @returns {T[]} A new array containing the first `count` elements from `arr`.\n *\n * @example\n * // Returns [1, 2, 3]\n * take([1, 2, 3, 4, 5], 3);\n *\n * @example\n * // Returns ['a', 'b']\n * take(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * take([1, 2, 3], 5);\n */\nexport function take(arr: readonly T[], count: number): T[] {\n return arr.slice(0, count);\n}\n","import { takeRight as takeRightToolkit } from '../../array/takeRight.ts';\nimport { toArray } from '../_internal/toArray.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\nimport { toInteger } from '../util/toInteger.ts';\n\n/**\n * Returns a new array containing the last `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array to take elements from.\n * @param {number} [count=1] - The number of elements to take.\n * @param {unknown} [guard] - Enables use as an iteratee for methods like `_.map`.\n * @returns {T[]} A new array containing the last `count` elements from `arr`.\n *\n * @example\n * // Returns [4, 5]\n * takeRight([1, 2, 3, 4, 5], 2);\n *\n * @example\n * // Returns ['b', 'c']\n * takeRight(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * takeRight([1, 2, 3], 5);\n */\nexport function takeRight(arr: ArrayLike | null | undefined, count: number = 1, guard?: unknown): T[] {\n count = guard ? 1 : toInteger(count);\n if (count <= 0 || !isArrayLike(arr)) {\n return [];\n }\n\n return takeRightToolkit(toArray(arr), count);\n}\n","/**\n * Returns a new array containing the last `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to take elements from.\n * @param {number} [count=1] - The number of elements to take.\n * @returns {T[]} A new array containing the last `count` elements from `arr`.\n *\n * @example\n * // Returns [4, 5]\n * takeRight([1, 2, 3, 4, 5], 2);\n *\n * @example\n * // Returns ['b', 'c']\n * takeRight(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * takeRight([1, 2, 3], 5);\n */\nexport function takeRight(arr: readonly T[], count = 1): T[] {\n if (count <= 0) {\n return [];\n }\n\n return arr.slice(-count);\n}\n","/**\n * Takes elements from the end of the array while the predicate function returns `true`.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {(item: T) => boolean} shouldContinueTaking - The function invoked per element.\n * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.\n *\n * @example\n * // Returns [3, 2, 1]\n * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);\n *\n * @example\n * // Returns []\n * takeRightWhile([1, 2, 3], n => n > 3);\n */\nexport function takeRightWhile(arr: readonly T[], shouldContinueTaking: (item: T) => boolean): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!shouldContinueTaking(arr[i])) {\n return arr.slice(i + 1);\n }\n }\n\n return arr.slice();\n}\n","/**\n * Returns a new array containing the leading elements of the provided array\n * that satisfy the provided predicate function. It stops taking elements as soon\n * as an element does not satisfy the predicate.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @param {(element: T) => boolean} shouldContinueTaking - The predicate function that is called with each element. Elements are included in the result as long as this function returns true.\n * @returns {T[]} A new array containing the leading elements that satisfy the predicate.\n *\n * @example\n * // Returns [1, 2]\n * takeWhile([1, 2, 3, 4], x => x < 3);\n *\n * @example\n * // Returns []\n * takeWhile([1, 2, 3, 4], x => x > 3);\n */\nexport function takeWhile(arr: readonly T[], shouldContinueTaking: (element: T) => boolean): T[] {\n const result: T[] = [];\n\n for (let i = 0; i < arr.length; i++) {\n const item = arr[i];\n if (!shouldContinueTaking(item)) {\n break;\n }\n\n result.push(item);\n }\n\n return result;\n}\n","import { debounce } from './debounce.ts';\n\ninterface ThrottleOptions {\n /**\n * An optional AbortSignal to cancel the function invocation on the trailing edge.\n */\n signal?: AbortSignal;\n\n /**\n * If `true`, the function will be invoked on the leading edge of the timeout.\n * @default true\n */\n leading?: boolean;\n\n /**\n * If `true`, the function will be invoked on the trailing edge of the timeout.\n * @default true\n */\n trailing?: boolean;\n}\n\n/**\n * Creates a throttled function that only invokes the provided function at most once\n * per every `throttleMs` milliseconds. Subsequent calls to the throttled function\n * within the wait time will not trigger the execution of the original function.\n *\n * @template F - The type of function.\n * @param {F} func - The function to throttle.\n * @param {number} throttleMs - The number of milliseconds to throttle executions to.\n * @param {ThrottleOptions} options - The options object\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the throttled function.\n * @param {boolean} options.leading - If `true`, the function will be invoked on the leading edge of the timeout.\n * @param {boolean} options.trailing - If `true`, the function will be invoked on the trailing edge of the timeout.\n * @returns {(...args: Parameters) => void} A new throttled function that accepts the same parameters as the original function.\n *\n * @example\n * const throttledFunction = throttle(() => {\n * console.log('Function executed');\n * }, 1000);\n *\n * // Will log 'Function executed' immediately\n * throttledFunction();\n *\n * // Will not log anything as it is within the throttle time\n * throttledFunction();\n *\n * // After 1 second\n * setTimeout(() => {\n * throttledFunction(); // Will log 'Function executed'\n * }, 1000);\n */\nexport function throttle any>(\n func: F,\n throttleMs = 0,\n options: ThrottleOptions = {}\n): ((...args: Parameters) => ReturnType | undefined) & {\n cancel: () => void;\n flush: () => void;\n} {\n if (typeof options !== 'object') {\n options = {};\n }\n\n const { leading = true, trailing = true, signal } = options;\n\n return debounce(func, throttleMs, { leading, trailing, signal, maxWait: throttleMs });\n}\n","import { toInteger } from './toInteger.ts';\n\n/**\n * Invokes the getValue function n times, returning an array of the results.\n *\n * @template R The return type of the getValue function.\n * @param {number} n - The number of times to invoke getValue.\n * @param {(index: number) => R} getValue - The function to invoke for each index.\n * @returns {R[]} An array containing the results of invoking getValue n times.\n * @example\n * times(3, (i) => i * 2); // => [0, 2, 4]\n * times(2, () => 'es-toolkit'); // => ['es-toolkit', 'es-toolkit']\n */\nexport function times(n?: number, getValue?: (index: number) => R): R[] {\n n = toInteger(n);\n\n if (n < 1 || !Number.isSafeInteger(n)) {\n return [];\n }\n\n const result = new Array(n);\n\n for (let i = 0; i < n; i++) {\n result[i] = typeof getValue === 'function' ? getValue(i) : i;\n }\n\n return result;\n}\n","import { cloneDeep } from './cloneDeep.ts';\nimport { defaults } from './defaults.ts';\n\n/**\n * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`.\n * It assigns default values to properties that are either `undefined` or come from `Object.prototype`.\n *\n * You can provide multiple source objects to set these default values,\n * and they will be applied in the order they are given, from left to right.\n * Once a property has been set, any later values for that property will be ignored.\n *\n * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead.\n *\n * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead.\n *\n * @template T - The type of the object being processed.\n * @param {T} object - The target object.\n * @returns {T} The cloned object.\n */\nexport function toDefaulted(object: T): T;\n\n/**\n * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`.\n * It assigns default values to properties that are either `undefined` or come from `Object.prototype`.\n *\n * You can provide multiple source objects to set these default values,\n * and they will be applied in the order they are given, from left to right.\n * Once a property has been set, any later values for that property will be ignored.\n *\n * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead.\n *\n * @template T - The type of the object being processed.\n * @template S - The type of the object that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S} source - The object that specifies the default values to apply.\n * @returns {NonNullable} A new object that combines the target and default values, ensuring no properties are left undefined.\n */\nexport function toDefaulted(object: T, source: S): NonNullable;\n\n/**\n * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`.\n * It assigns default values to properties that are either `undefined` or come from `Object.prototype`.\n *\n * You can provide multiple source objects to set these default values,\n * and they will be applied in the order they are given, from left to right.\n * Once a property has been set, any later values for that property will be ignored.\n *\n * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead.\n *\n * @template T - The type of the object being processed.\n * @template S1 - The type of the first object that provides default values.\n * @template S2 - The type of the second object that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S1} source1 - The first object that specifies the default values to apply.\n * @param {S2} source2 - The second object that specifies the default values to apply.\n * @returns {NonNullable} A new object that combines the target and default values, ensuring no properties are left undefined.\n */\nexport function toDefaulted(\n object: T,\n source1: S1,\n source2: S2\n): NonNullable;\n\n/**\n * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`.\n * It assigns default values to properties that are either `undefined` or come from `Object.prototype`.\n *\n * You can provide multiple source objects to set these default values,\n * and they will be applied in the order they are given, from left to right.\n * Once a property has been set, any later values for that property will be ignored.\n *\n * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead.\n *\n * @template T - The type of the object being processed.\n * @template S1 - The type of the first object that provides default values.\n * @template S2 - The type of the second object that provides default values.\n * @template S3 - The type of the third object that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S1} source1 - The first object that specifies the default values to apply.\n * @param {S2} source2 - The second object that specifies the default values to apply.\n * @param {S3} source3 - The third object that specifies the default values to apply.\n * @returns {NonNullable} A new object that combines the target and default values, ensuring no properties are left undefined.\n */\nexport function toDefaulted(\n object: T,\n source1: S1,\n source2: S2,\n source3: S3\n): NonNullable;\n\n/**\n * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`.\n * It assigns default values to properties that are either `undefined` or come from `Object.prototype`.\n *\n * You can provide multiple source objects to set these default values,\n * and they will be applied in the order they are given, from left to right.\n * Once a property has been set, any later values for that property will be ignored.\n *\n * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead.\n *\n * @template T - The type of the object being processed.\n * @template S1 - The type of the first object that provides default values.\n * @template S2 - The type of the second object that provides default values.\n * @template S3 - The type of the third object that provides default values.\n * @template S4 - The type of the fourth object that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S1} source1 - The first object that specifies the default values to apply.\n * @param {S2} source2 - The second object that specifies the default values to apply.\n * @param {S3} source3 - The third object that specifies the default values to apply.\n * @param {S4} source4 - The fourth object that specifies the default values to apply.\n * @returns {NonNullable} A new object that combines the target and default values, ensuring no properties are left undefined.\n */\nexport function toDefaulted<\n T extends object,\n S1 extends object,\n S2 extends object,\n S3 extends object,\n S4 extends object,\n>(object: T, source1: S1, source2: S2, source3: S3, source4: S4): NonNullable;\n\n/**\n * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`.\n * It assigns default values to properties that are either `undefined` or come from `Object.prototype`.\n *\n * You can provide multiple source objects to set these default values,\n * and they will be applied in the order they are given, from left to right.\n * Once a property has been set, any later values for that property will be ignored.\n *\n * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead.\n *\n * @template T - The type of the object being processed.\n * @template S - The type of the objects that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S[]} sources - The objects that specifies the default values to apply.\n * @returns {object} A new object that combines the target and default values, ensuring no properties are left undefined.\n *\n * @example\n * toDefaulted({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 }\n * toDefaulted({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 }\n * toDefaulted({ a: null }, { a: 1 }); // { a: null }\n * toDefaulted({ a: undefined }, { a: 1 }); // { a: 1 }\n */\nexport function toDefaulted(object: T, ...sources: S[]): object;\n\n/**\n * Creates a new object based on the provided `object`, applying default values from the `sources` to ensure that no properties are left `undefined`.\n * It assigns default values to properties that are either `undefined` or come from `Object.prototype`.\n *\n * You can provide multiple source objects to set these default values,\n * and they will be applied in the order they are given, from left to right.\n * Once a property has been set, any later values for that property will be ignored.\n *\n * Note: This function creates a new object. If you want to modify the `object`, use the `defaults` function instead.\n *\n * @template T - The type of the object being processed.\n * @template S - The type of the objects that provides default values.\n * @param {T} object - The target object that will receive default values.\n * @param {S[]} sources - The objects that specifies the default values to apply.\n * @returns {object} A new object that combines the target and default values, ensuring no properties are left undefined.\n *\n * @example\n * toDefaulted({ a: 1 }, { a: 2, b: 2 }, { c: 3 }); // { a: 1, b: 2, c: 3 }\n * toDefaulted({ a: 1, b: 2 }, { b: 3 }, { c: 3 }); // { a: 1, b: 2, c: 3 }\n * toDefaulted({ a: null }, { a: 1 }); // { a: null }\n * toDefaulted({ a: undefined }, { a: 1 }); // { a: 1 }\n */\nexport function toDefaulted(object: T, ...sources: S[]): object {\n const cloned = cloneDeep(object);\n\n return defaults(cloned, ...sources);\n}\n","/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @template T - The type of elements in the original array.\n * @template U - The type of the value to fill the new array with.\n * @param {Array} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @returns {Array} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\nexport function toFilled(arr: readonly T[], value: U): Array;\n\n/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @template T - The type of elements in the original array.\n * @template U - The type of the value to fill the new array with.\n * @param {Array} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @returns {Array} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\nexport function toFilled(arr: readonly T[], value: U, start: number): Array;\n\n/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @template T - The type of elements in the original array.\n * @template U - The type of the value to fill the new array with.\n * @param {Array} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\nexport function toFilled(arr: readonly T[], value: U, start: number, end: number): Array;\n\n/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @template T - The type of elements in the original array.\n * @template U - The type of the value to fill the new array with.\n * @param {Array} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array} The new array with the filled values.\n */\nexport function toFilled(arr: readonly T[], value: U, start = 0, end = arr.length): Array {\n const length = arr.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n const newArr: Array = arr.slice();\n\n for (let i = finalStart; i < finalEnd; i++) {\n newArr[i] = value;\n }\n\n return newArr;\n}\n","import { MAX_ARRAY_LENGTH } from '../_internal/MAX_ARRAY_LENGTH.ts';\nimport { clamp } from '../math/clamp.ts';\n\n/**\n * Converts the value to a valid index. A valid index is an integer that is greater than or equal to `0` and less than or equal to `2^32 - 1`.\n *\n * It converts the given value to a number and floors it to an integer. If the value is less than `0`, it returns `0`. If the value exceeds `2^32 - 1`, it returns `2^32 - 1`.\n *\n * @param {unknown} value - The value to convert to a valid index.\n * @returns {number} The converted value.\n *\n * @example\n * toLength(3.2) // => 3\n * toLength(-1) // => 0\n * toLength(1.9) // => 1\n * toLength('42') // => 42\n * toLength(null) // => 0\n */\nexport function toLength(value?: unknown): number {\n if (value == null) {\n return 0;\n }\n\n const length = Math.floor(Number(value));\n\n return clamp(length, 0, MAX_ARRAY_LENGTH);\n}\n","export const MAX_ARRAY_LENGTH = 4_294_967_295;\n","import { cloneDeep } from './cloneDeep.ts';\nimport { merge } from './merge.ts';\n\n/**\n * Merges the properties of the source object into a deep clone of the target object.\n * Unlike `merge`, This function does not modify the original target object.\n *\n * This function performs a deep merge, meaning nested objects and arrays are merged recursively.\n *\n * - If a property in the source object is an array or object and the corresponding property in the target object is also an array or object, they will be merged.\n * - If a property in the source object is undefined, it will not overwrite a defined property in the target object.\n *\n * Note that this function does not mutate the target object.\n *\n * @param {T} target - The target object to be cloned and merged into. This object is not modified directly.\n * @param {S} source - The source object whose properties will be merged into the cloned target object.\n * @returns {T & S} A new object with properties from the source object merged into a deep clone of the target object.\n *\n * @template T - Type of the target object.\n * @template S - Type of the source object.\n *\n * @example\n * const target = { a: 1, b: { x: 1, y: 2 } };\n * const source = { b: { y: 3, z: 4 }, c: 5 };\n *\n * const result = toMerged(target, source);\n * console.log(result);\n * // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }\n *\n * @example\n * const target = { a: [1, 2], b: { x: 1 } };\n * const source = { a: [3], b: { y: 2 } };\n *\n * const result = toMerged(target, source);\n * console.log(result);\n * // Output: { a: [3, 2], b: { x: 1, y: 2 } }\n *\n * @example\n * const target = { a: null };\n * const source = { a: [1, 2, 3] };\n *\n * const result = toMerged(target, source);\n * console.log(result);\n * // Output: { a: [1, 2, 3] }\n */\nexport function toMerged, S extends Record>(\n target: T,\n source: S\n): T & S {\n return merge(cloneDeep(target), source);\n}\n","import { toInteger } from './toInteger.ts';\nimport { MAX_SAFE_INTEGER } from '../_internal/MAX_SAFE_INTEGER.ts';\nimport { clamp } from '../math/clamp.ts';\n\n/**\n * Converts `value` to a safe integer.\n *\n * A safe integer can be compared and represented correctly.\n *\n * @param {unknown} value - The value to convert.\n * @returns {number} Returns the value converted to a safe integer.\n *\n * @example\n * toSafeInteger(3.2); // => 3\n * toSafeInteger(Number.MAX_VALUE); // => 9007199254740991\n * toSafeInteger(Infinity); // => 9007199254740991\n * toSafeInteger('3.2'); // => 3\n * toSafeInteger(NaN); // => 0\n * toSafeInteger(null); // => 0\n * toSafeInteger(-Infinity); // => -9007199254740991\n */\nexport function toSafeInteger(value?: unknown): number {\n if (value == null) {\n return 0;\n }\n\n return clamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);\n}\n","import { trim as trimToolkit } from '../../string/trim.ts';\n\n/**\n * Removes leading and trailing whitespace or specified characters from a string.\n *\n * @param {string} str - The string from which leading and trailing characters will be trimmed.\n * @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `\" \"`.\n * @returns {string} - The resulting string after the specified leading and trailing characters have been removed.\n *\n * @example\n * trim(\" hello \"); // \"hello\"\n * trim(\"--hello--\", \"-\"); // \"hello\"\n * trim(\"##hello##\", [\"#\", \"o\"]); // \"hell\"\n */\nexport function trim(str: string, chars?: string | string[], guard?: unknown): string {\n if (str == null) {\n return '';\n }\n\n if (guard != null || chars == null) {\n return str.toString().trim();\n }\n\n switch (typeof chars) {\n case 'string': {\n return trimToolkit(str, chars.toString().split(''));\n }\n case 'object': {\n if (Array.isArray(chars)) {\n return trimToolkit(\n str,\n chars.map(x => x.toString())\n );\n } else {\n return trimToolkit(str, (chars as any).toString().split(''));\n }\n }\n }\n}\n","import { trimEnd as trimEndToolkit } from '../../string/trimEnd.ts';\n\n/**\n * Removes trailing whitespace or specified characters from a string.\n *\n * @param {string} str - The string from which trailing characters will be trimmed.\n * @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `\" \"`.\n * @returns {string} - The resulting string after the specified trailing character has been removed.\n *\n * @example\n * const trimmedStr1 = trimEnd('hello---', '-') // returns 'hello'\n * const trimmedStr2 = trimEnd('123000', '0') // returns '123'\n * const trimmedStr3 = trimEnd('abcabcabc', 'c') // returns 'abcabcab'\n * const trimmedStr4 = trimEnd('trimmedxxx', 'x') // returns 'trimmed'\n */\nexport function trimEnd(str: string, chars?: string | string[], guard?: unknown): string {\n if (str == null) {\n return '';\n }\n\n if (guard != null || chars == null) {\n return str.toString().trimEnd();\n }\n\n switch (typeof chars) {\n case 'string': {\n return trimEndToolkit(str, chars.toString().split(''));\n }\n case 'object': {\n if (Array.isArray(chars)) {\n return trimEndToolkit(\n str,\n chars.map(x => x.toString())\n );\n } else {\n return trimEndToolkit(str, (chars as any).toString().split(''));\n }\n }\n }\n}\n","import { trimStart as trimStartToolkit } from '../../string/trimStart.ts';\n\n/**\n * Removes leading whitespace or specified characters from a string.\n *\n * @param {string} str - The string from which leading characters will be trimmed.\n * @param {string | string[]} chars - The character(s) to remove from the end of the string. Defaults to `\" \"`.\n * @returns {string} - The resulting string after the specified leading character has been removed.\n *\n * @example\n * const trimmedStr1 = ltrim('---hello', '-') // returns 'hello'\n * const trimmedStr2 = ltrim('000123', '0') // returns '123'\n * const trimmedStr3 = ltrim('abcabcabc', 'a') // returns 'bcabcabc'\n * const trimmedStr4 = ltrim('xxxtrimmed', 'x') // returns 'trimmed'\n */\nexport function trimStart(str: string, chars?: string | string[], guard?: unknown): string {\n if (str == null) {\n return '';\n }\n\n if (guard != null || chars == null) {\n return str.toString().trimStart();\n }\n\n switch (typeof chars) {\n case 'string': {\n return trimStartToolkit(str, chars.toString().split(''));\n }\n case 'object': {\n if (Array.isArray(chars)) {\n return trimStartToolkit(\n str,\n chars.map(x => x.toString())\n );\n } else {\n return trimStartToolkit(str, (chars as any).toString().split(''));\n }\n }\n }\n}\n","import { ary } from './ary.ts';\n\n/**\n * Creates a function that accepts up to one argument, ignoring any additional arguments.\n *\n * @template F - The type of the function.\n * @param {F} func - The function to cap arguments for.\n * @returns {(...args: any[]) => ReturnType} Returns the new capped function.\n *\n * @example\n * function fn(a, b, c) {\n * console.log(arguments);\n * }\n *\n * unary(fn)(1, 2, 3); // [Arguments] { '0': 1 }\n */\nexport function unary any>(func: F): (...args: any[]) => ReturnType {\n return ary(func, 1);\n}\n","import { flatten } from './flatten.ts';\nimport { uniq } from '../../array/uniq.ts';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\n\n/**\n * This function takes multiple arrays and returns a new array containing only the unique values\n * from all input arrays, preserving the order of their first occurrence.\n *\n * @template T - The type of elements in the arrays.\n * @param {Array | null | undefined>} arrays - The arrays to inspect.\n * @returns {T[]} Returns the new array of combined unique values.\n *\n * @example\n * // Returns [2, 1]\n * union([2], [1, 2]);\n *\n * @example\n * // Returns [2, 1, 3]\n * union([2], [1, 2], [2, 3]);\n *\n * @example\n * // Returns [1, 3, 2, [5], [4]] (does not deeply flatten nested arrays)\n * union([1, 3, 2], [1, [5]], [2, [4]]);\n *\n * @example\n * // Returns [0, 2, 1] (ignores non-array values like 3 and { '0': 1 })\n * union([0], 3, { '0': 1 }, null, [2, 1]);\n * @example\n * // Returns [0, 'a', 2, 1] (treats array-like object { 0: 'a', length: 1 } as a valid array)\n * union([0], { 0: 'a', length: 1 }, [2, 1]);\n */\nexport function union(...arrays: Array | null | undefined>): T[] {\n const validArrays = arrays.filter(isArrayLikeObject);\n\n const flattened = flatten(validArrays, 1);\n\n return uniq(flattened) as T[];\n}\n","import { uniq as uniqToolkit } from '../../array/uniq.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @template T - The type of elements in the array.\n * @param {ArrayLike | null | undefined} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq(arr: ArrayLike | null | undefined): T[] {\n if (!isArrayLike(arr)) {\n return [];\n }\n return uniqToolkit(Array.from(arr));\n}\n","import { flatten } from './flatten';\nimport { last } from './last';\nimport { uniq as uniqToolkit } from '../../array/uniq.ts';\nimport { uniqBy as uniqByToolkit } from '../../array/uniqBy';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject';\nimport { iteratee as createIteratee } from '../util/iteratee.ts';\n\n/**\n * Creates a duplicate-free version of an array using a transform function for comparison.\n *\n * @template T\n * @param {ArrayLike} array - The array to inspect.\n * @param {(value: T) => unknown} iteratee - The transform function.\n * @returns {T[]} Returns the new duplicate-free array.\n *\n * @example\n * uniqBy([2.1, 1.2, 2.3], Math.floor);\n * // => [2.1, 1.2]\n */\nexport function uniqBy(array: ArrayLike, iteratee: (value: T) => unknown): T[];\n\n/**\n * Creates a duplicate-free version of an array using a property name for comparison.\n *\n * @template T\n * @param {ArrayLike} array - The array to inspect.\n * @param {string} path - The property path to get values from.\n * @returns {T[]} Returns the new duplicate-free array.\n *\n * @example\n * const users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 },\n * { 'user': 'barney', 'age': 37 }\n * ];\n * uniqBy(users, 'user');\n * // => [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }]\n */\nexport function uniqBy(array: ArrayLike, path: string): T[];\n\n/**\n * Creates a duplicate-free version of an array using a property index for comparison.\n *\n * @template T\n * @param {ArrayLike} array - The array to inspect.\n * @param {number} index - The index to get values from.\n * @returns {T[]} Returns the new duplicate-free array.\n *\n * @example\n * const arrays = [[2], [3], [1], [2], [3], [1]];\n * uniqBy(arrays, 0);\n * // => [[2], [3], [1]]\n */\nexport function uniqBy(array: ArrayLike, index: number): T[];\n\n/**\n * Creates a duplicate-free version of an array, combining multiple arrays and using an optional transform function.\n *\n * @template T\n * @param {ArrayLike} array - The array to inspect.\n * @param {...Array | ((value: T) => unknown) | string>} values - Additional arrays and/or iteratee.\n * @returns {T[]} Returns the new duplicate-free array.\n *\n * @example\n * uniqBy([1, 2], [2, 3], [3, 4], Math.floor);\n * // => [1, 2, 3, 4]\n */\nexport function uniqBy(\n array: ArrayLike | null | undefined,\n ...values: Array | ((value: T) => unknown) | string>\n): T[];\n\n/**\n * Implementation of the uniqBy function.\n */\nexport function uniqBy(\n arr: ArrayLike | null | undefined,\n ...values: Array | ((value: T) => unknown) | string | number>\n): T[] {\n if (!isArrayLikeObject(arr)) {\n return [];\n }\n\n const iteratee = last(values);\n if (iteratee === undefined) {\n return Array.from(arr);\n }\n\n const validArrays = values.slice(0, -1).filter(isArrayLikeObject);\n const flattenedArrays = flatten(validArrays) as T[];\n const allValues = [...Array.from(arr), ...flattenedArrays];\n\n if (isArrayLikeObject(iteratee)) {\n return uniqToolkit(allValues);\n }\n\n return uniqByToolkit(allValues, createIteratee(iteratee));\n}\n","import { unzip as unzipToolkit } from '../../array/unzip.ts';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\n\n/**\n * Gathers elements in the same position in an internal array\n * from a grouped array of elements and returns them as a new array.\n *\n * @template T - The type of elements in the nested array.\n * @param {T[][] | ArrayLike> | null | undefined} array - The nested array to unzip.\n * @returns {T[][]} A new array of unzipped elements.\n *\n * @example\n * const zipped = [['a', true, 1],['b', false, 2]];\n * const result = unzip(zipped);\n * // result will be [['a', 'b'], [true, false], [1, 2]]\n */\nexport function unzip(array: T[][] | ArrayLike> | null | undefined): T[][] {\n if (!isArrayLikeObject(array) || !array.length) {\n return [];\n }\n if (Array.isArray(array)) {\n return unzipToolkit(array);\n }\n return unzipToolkit(Array.from(array, value => Array.from(value)));\n}\n","/**\n * Unzips an array of arrays, applying an `iteratee` function to regrouped elements.\n *\n * @template T, R\n * @param {T[][]} target - The nested array to unzip. This is an array of arrays,\n * where each inner array contains elements to be unzipped.\n * @param {(...args: T[]) => R} iteratee - A function to transform the unzipped elements.\n * @returns {R[]} A new array of unzipped and transformed elements.\n *\n * @example\n * const nestedArray = [[1, 2], [3, 4], [5, 6]];\n * const result = unzipWith(nestedArray, (item, item2, item3) => item + item2 + item3);\n * // result will be [9, 12]\n */\nexport function unzipWith(target: readonly T[][], iteratee: (...args: T[]) => R): R[] {\n const maxLength = Math.max(...target.map(innerArray => innerArray.length));\n const result: R[] = new Array(maxLength);\n\n for (let i = 0; i < maxLength; i++) {\n const group = new Array(target.length);\n\n for (let j = 0; j < target.length; j++) {\n group[j] = target[j][i];\n }\n\n result[i] = iteratee(...group);\n }\n\n return result;\n}\n","import { upperCase as upperCaseToolkit } from '../../string/upperCase.ts';\nimport { normalizeForCase } from '../_internal/normalizeForCase.ts';\n\n/**\n * Converts a string to upper case.\n *\n * Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character.\n *\n * @param {string | object} str - The string that is to be changed to upper case.\n * @returns {string} - The converted string to upper case.\n *\n * @example\n * const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE'\n * const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE'\n * const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT'\n * const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST'\n */\nexport function upperCase(str?: string | object): string {\n return upperCaseToolkit(normalizeForCase(str));\n}\n","import { words as getWords } from './words.ts';\n\n/**\n * Converts a string to upper case.\n *\n * Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character.\n *\n * @param {string} str - The string that is to be changed to upper case.\n * @returns {string} - The converted string to upper case.\n *\n * @example\n * const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE'\n * const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE'\n * const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT'\n * const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST'\n */\nexport function upperCase(str: string): string {\n const words = getWords(str);\n\n let result = '';\n\n for (let i = 0; i < words.length; i++) {\n result += words[i].toUpperCase();\n if (i < words.length - 1) {\n result += ' ';\n }\n }\n\n return result;\n}\n","/**\n * Converts the first character of string to upper case.\n *\n * @param {string} str - The string that is to be changed\n * @returns {string} - The converted string.\n *\n * @example\n * const convertedStr1 = upperFirst('fred') // returns 'Fred'\n * const convertedStr2 = upperFirst('Fred') // returns 'Fred'\n * const convertedStr3 = upperFirst('FRED') // returns 'FRED'\n */\nexport function upperFirst(str: string): string {\n return str.substring(0, 1).toUpperCase() + str.substring(1);\n}\n","import { timeout } from './timeout.ts';\n\n/**\n * Executes an async function and enforces a timeout.\n *\n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n *\n * @template T\n * @param {() => Promise} run - A function that returns a promise to be executed.\n * @param {number} ms - The timeout duration in milliseconds.\n * @returns {Promise} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n *\n * @example\n * async function fetchData() {\n * const response = await fetch('https://example.com/data');\n * return response.json();\n * }\n *\n * try {\n * const data = await withTimeout(fetchData, 1000);\n * console.log(data); // Logs the fetched data if `fetchData` is resolved within 1 second.\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError' if `fetchData` is not resolved within 1 second.\n * }\n */\nexport async function withTimeout(run: () => Promise, ms: number): Promise {\n return Promise.race([run(), timeout(ms)]);\n}\n","import { without as withoutToolkit } from '../../array/without.ts';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\n\n/**\n * Creates an array that excludes all specified values.\n *\n * It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero).\n *\n * @template T The type of elements in the array.\n * @param {ArrayLike | null | undefined} array - The array to filter.\n * @param {...T[]} values - The values to exclude.\n * @returns {T[]} A new array without the specified values.\n *\n * @example\n * // Removes the specified values from the array\n * without([1, 2, 3, 4, 5], 2, 4);\n * // Returns: [1, 3, 5]\n *\n * @example\n * // Removes specified string values from the array\n * without(['a', 'b', 'c', 'a'], 'a');\n * // Returns: ['b', 'c']\n */\nexport function without(array: ArrayLike | null | undefined, ...values: T[]): T[] {\n if (!isArrayLikeObject(array)) {\n return [];\n }\n return withoutToolkit(Array.from(array), ...values);\n}\n","import { difference } from './difference.ts';\n\n/**\n * Creates an array that excludes all specified values.\n *\n * It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero).\n *\n * @template T The type of elements in the array.\n * @param {T[]} array - The array to filter.\n * @param {...T[]} values - The values to exclude.\n * @returns {T[]} A new array without the specified values.\n *\n * @example\n * // Removes the specified values from the array\n * without([1, 2, 3, 4, 5], 2, 4);\n * // Returns: [1, 3, 5]\n *\n * @example\n * // Removes specified string values from the array\n * without(['a', 'b', 'c', 'a'], 'a');\n * // Returns: ['b', 'c']\n */\nexport function without(array: readonly T[], ...values: T[]): T[] {\n return difference(array, values);\n}\n","import { difference } from './difference.ts';\nimport { intersection } from './intersection.ts';\nimport { union } from './union.ts';\n\n/**\n * Computes the symmetric difference between two arrays. The symmetric difference is the set of elements\n * which are in either of the arrays, but not in their intersection.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both.\n *\n * @example\n * // Returns [1, 2, 5, 6]\n * xor([1, 2, 3, 4], [3, 4, 5, 6]);\n *\n * @example\n * // Returns ['a', 'c']\n * xor(['a', 'b'], ['b', 'c']);\n */\nexport function xor(arr1: readonly T[], arr2: readonly T[]): T[] {\n return difference(union(arr1, arr2), intersection(arr1, arr2));\n}\n","import { uniq } from './uniq.ts';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","import { differenceBy } from './differenceBy.ts';\nimport { intersectionBy } from './intersectionBy.ts';\nimport { unionBy } from './unionBy.ts';\n\n/**\n * Computes the symmetric difference between two arrays using a custom mapping function.\n * The symmetric difference is the set of elements which are in either of the arrays,\n * but not in their intersection, determined by the result of the mapping function.\n *\n * @template T - Type of elements in the input arrays.\n * @template U - Type of the values returned by the mapping function.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = obj => obj.id;\n * xorBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 3 }]\n */\nexport function xorBy(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[] {\n const union = unionBy(arr1, arr2, mapper);\n const intersection = intersectionBy(arr1, arr2, mapper);\n\n return differenceBy(union, intersection, mapper);\n}\n","import { differenceWith } from './differenceWith.ts';\nimport { intersectionWith } from './intersectionWith.ts';\nimport { unionWith } from './unionWith.ts';\n\n/**\n * Computes the symmetric difference between two arrays using a custom equality function.\n * The symmetric difference is the set of elements which are in either of the arrays,\n * but not in their intersection.\n *\n * @template T - Type of elements in the input arrays.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item1: T, item2: T) => boolean} areElementsEqual - The custom equality function to compare elements.\n * @returns {T[]} An array containing the elements that are present in either `arr1` or `arr2` but not in both, based on the custom equality function.\n *\n * @example\n * // Custom equality function for objects with an 'id' property\n * const areObjectsEqual = (a, b) => a.id === b.id;\n * xorWith([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], areObjectsEqual);\n * // Returns [{ id: 1 }, { id: 3 }]\n */\nexport function xorWith(\n arr1: readonly T[],\n arr2: readonly T[],\n areElementsEqual: (item1: T, item2: T) => boolean\n): T[] {\n const union = unionWith(arr1, arr2, areElementsEqual);\n const intersection = intersectionWith(arr1, arr2, areElementsEqual);\n\n return differenceWith(union, intersection, areElementsEqual);\n}\n","import { zip as zipToolkit } from '../../array/zip.ts';\nimport { isArrayLikeObject } from '../predicate/isArrayLikeObject.ts';\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T\n * @param {ArrayLike} arr1 - The first array to zip.\n * @returns {Array<[T | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const result = zip(arr1);\n * // result will be [[1], [2], [3]]\n */\nexport function zip(arr1: ArrayLike): Array<[T | undefined]>;\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T, U\n * @param {ArrayLike} arr1 - The first array to zip.\n * @param {ArrayLike} arr2 - The second array to zip.\n * @returns {Array<[T | undefined, U | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const result = zip(arr1, arr2);\n * // result will be [[1, 'a'], [2, 'b'], [3, 'c']]\n */\nexport function zip(arr1: ArrayLike, arr2: ArrayLike): Array<[T | undefined, U | undefined]>;\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T, U, V\n * @param {ArrayLike} arr1 - The first array to zip.\n * @param {ArrayLike} arr2 - The second array to zip.\n * @param {ArrayLike} arr3 - The third array to zip.\n * @returns {Array<[T | undefined, U | undefined, V | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const arr3 = [true, false];\n * const result = zip(arr1, arr2, arr3);\n * // result will be [[1, 'a', true], [2, 'b', false], [3, 'c', undefined]]\n */\nexport function zip(\n arr1: ArrayLike,\n arr2: ArrayLike,\n arr3: ArrayLike\n): Array<[T | undefined, U | undefined, V | undefined]>;\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T, U, V, W\n * @param {ArrayLike} arr1 - The first array to zip.\n * @param {ArrayLike} arr2 - The second array to zip.\n * @param {ArrayLike} arr3 - The third array to zip.\n * @param {ArrayLike} arr4 - The fourth array to zip.\n * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const arr3 = [true, false];\n * const arr4 = [null, null, null];\n * const result = zip(arr1, arr2, arr3, arr4);\n * // result will be [[1, 'a', true, null], [2, 'b', false, null], [3, 'c', undefined, null]]\n */\nexport function zip(\n arr1: ArrayLike,\n arr2: ArrayLike,\n arr3: ArrayLike,\n arr4: ArrayLike\n): Array<[T | undefined, U | undefined, V | undefined, W | undefined]>;\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T, U, V, W\n * @param {ArrayLike} arr1 - The first array to zip.\n * @param {ArrayLike} arr2 - The second array to zip.\n * @param {ArrayLike} arr3 - The third array to zip.\n * @param {ArrayLike} arr4 - The fourth array to zip.\n * @param {ArrayLike} arr5 - The fifth array to zip.\n * @returns {Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const arr3 = [true, false];\n * const arr4 = [null, null, null];\n * const arr5 = [undefined, undefined, undefined];\n * const result = zip(arr1, arr2, arr3, arr4, arr5);\n * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]\n */\nexport function zip(\n arr1: ArrayLike,\n arr2: ArrayLike,\n arr3: ArrayLike,\n arr4: ArrayLike,\n arr5: ArrayLike\n): Array<[T | undefined, U | undefined, V | undefined, W | undefined, X | undefined]>;\n\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T\n * @param {Array | null | undefined>} arrays - The arrays to zip.\n * @returns {Array>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const arr3 = [true, false];\n * const arr4 = [null, null, null];\n * const arr5 = [undefined, undefined, undefined];\n * const result = zip(arr1, arr2, arr3, arr4, arr5);\n * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]\n */\nexport function zip(...arrays: Array | null | undefined>): Array>;\n/**\n * Combines multiple arrays into a single array of tuples.\n *\n * This function takes multiple arrays and returns a new array where each element is a tuple\n * containing the corresponding elements from the input arrays. If the input arrays are of\n * different lengths, the resulting array will have the length of the longest input array,\n * with undefined values for missing elements.\n *\n * @template T\n * @param {Array | null | undefined>} arrays - The arrays to zip.\n * @returns {Array>} A new array of tuples containing the corresponding elements from the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const arr3 = [true, false];\n * const arr4 = [null, null, null];\n * const arr5 = [undefined, undefined, undefined];\n * const result = zip(arr1, arr2, arr3, arr4, arr5);\n * // result will be [[1, 'a', true, null, undefined], [2, 'b', false, null, undefined], [3, 'c', undefined, null, undefined]]\n */\nexport function zip(...arrays: Array | null | undefined>): Array> {\n if (!arrays.length) {\n return [];\n }\n // @ts-expect-error - TS doesn't support array types with a spread operator\n return zipToolkit(...arrays.filter(group => isArrayLikeObject(group)));\n}\n","/**\n * Combines two arrays, one of property names and one of corresponding values, into a single object.\n *\n * This function takes two arrays: one containing property names and another containing corresponding values.\n * It returns a new object where the property names from the first array are keys, and the corresponding elements\n * from the second array are values. If the `keys` array is longer than the `values` array, the remaining keys will\n * have `undefined` as their values.\n *\n * @template P - The type of elements in the array.\n * @template V - The type of elements in the array.\n * @param {P[]} keys - An array of property names.\n * @param {V[]} values - An array of values corresponding to the property names.\n * @returns {Record} - A new object composed of the given property names and values.\n *\n * @example\n * const keys = ['a', 'b', 'c'];\n * const values = [1, 2, 3];\n * const result = zipObject(keys, values);\n * // result will be { a: 1, b: 2, c: 3 }\n *\n * const keys2 = ['a', 'b', 'c'];\n * const values2 = [1, 2];\n * const result2 = zipObject(keys2, values2);\n * // result2 will be { a: 1, b: 2, c: undefined }\n *\n * const keys2 = ['a', 'b'];\n * const values2 = [1, 2, 3];\n * const result2 = zipObject(keys2, values2);\n * // result2 will be { a: 1, b: 2 }\n */\nexport function zipObject

(keys: readonly P[], values: readonly V[]): Record {\n const result = {} as Record;\n\n for (let i = 0; i < keys.length; i++) {\n result[keys[i]] = values[i];\n }\n\n return result;\n}\n","import { zip } from '../../array/zip.ts';\nimport { set } from '../object/set.ts';\nimport { isArrayLike } from '../predicate/isArrayLike.ts';\n\n/**\n * Creates a deeply nested object given arrays of paths and values.\n *\n * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values.\n * It returns a new object where paths from the first array are used as key paths to set values, with corresponding elements from the second array as values.\n * Paths can be dot-separated strings or arrays of property names.\n *\n * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values.\n *\n * @template P - The type of property paths.\n * @template V - The type of values corresponding to the property paths.\n * @param {ArrayLike

} keys - An array of property paths, each path can be a dot-separated string or an array of property names.\n * @param {ArrayLike} values - An array of values corresponding to the property paths.\n * @returns {Record} A new object composed of the given property paths and values.\n *\n * @example\n * const paths = ['a.b.c', 'd.e.f'];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }\n *\n * @example\n * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }\n *\n * @example\n * const paths = ['a.b[0].c', 'a.b[1].d'];\n * const values = [1, 2];\n * const result = zipObjectDeep(paths, values);\n * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }\n */\nexport function zipObjectDeep

(keys: ArrayLike

, values: ArrayLike): Record {\n const result = {} as { [K in P]: V };\n if (!isArrayLike(keys)) {\n return result;\n }\n if (!isArrayLike(values)) {\n values = [];\n }\n const zipped = zip

(Array.from(keys), Array.from(values));\n\n for (let i = 0; i < zipped.length; i++) {\n const [key, value] = zipped[i];\n\n if (key != null) {\n set(result, key, value);\n }\n }\n\n return result;\n}\n","/**\n * Combines multiple arrays into a single array using a custom combiner function.\n *\n * This function takes multiple arrays and a combiner function, and returns a new array where each element\n * is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @template T - The type of elements in the first array.\n * @template R - The type of elements in the resulting array.\n * @param {T[]} arr1 - The first array to zip.\n * @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.\n * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @example\n * // Example usage with two arrays:\n * const arr1 = [1, 2, 3];\n * const arr2 = [4, 5, 6];\n * const result = zipWith(arr1, arr2, (a, b) => a + b);\n * // result will be [5, 7, 9]\n *\n * @example\n * // Example usage with three arrays:\n * const arr1 = [1, 2];\n * const arr2 = [3, 4];\n * const arr3 = [5, 6];\n * const result = zipWith(arr1, arr2, arr3, (a, b, c) => `${a}${b}${c}`);\n * // result will be [`135`, `246`]\n */\nexport function zipWith(arr1: readonly T[], combine: (item: T) => R): R[];\n/**\n * Combines two arrays into a single array using a custom combiner function.\n *\n * @template T - The type of elements in the first array.\n * @template U - The type of elements in the second array.\n * @template R - The type of elements in the resulting array.\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} arr2 - The second array to zip.\n * @param {(item1: T, item2: U) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.\n * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.\n */\nexport function zipWith(arr1: readonly T[], arr2: readonly U[], combine: (item1: T, item2: U) => R): R[];\n/**\n * Combines three arrays into a single array using a custom combiner function.\n *\n * @template T - The type of elements in the first array.\n * @template U - The type of elements in the second array.\n * @template V - The type of elements in the third array.\n * @template R - The type of elements in the resulting array.\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} arr2 - The second array to zip.\n * @param {V[]} arr3 - The third array to zip.\n * @param {(item1: T, item2: U, item3: V) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.\n * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.\n */\nexport function zipWith(\n arr1: readonly T[],\n arr2: readonly U[],\n arr3: readonly V[],\n combine: (item1: T, item2: U, item3: V) => R\n): R[];\n/**\n * Combines four arrays into a single array using a custom combiner function.\n *\n * @template T - The type of elements in the first array.\n * @template U - The type of elements in the second array.\n * @template V - The type of elements in the third array.\n * @template W - The type of elements in the fourth array.\n * @template R - The type of elements in the resulting array.\n * @param {T[]} arr1 - The first array to zip.\n * @param {U[]} arr2 - The second array to zip.\n * @param {V[]} arr3 - The third array to zip.\n * @param {W[]} arr4 - The fourth array to zip.\n * @param {(item1: T, item2: U, item3: V, item4: W) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.\n * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.\n */\nexport function zipWith(\n arr1: readonly T[],\n arr2: readonly U[],\n arr3: readonly V[],\n arr4: readonly W[],\n combine: (item1: T, item2: U, item3: V, item4: W) => R\n): R[];\n\n/**\n * Combines multiple arrays into a single array using a custom combiner function.\n *\n * This function takes one array and a variable number of additional arrays,\n * applying the provided combiner function to the corresponding elements of each array.\n * If the input arrays are of different lengths, the resulting array will have the length\n * of the longest input array, with undefined values for missing elements.\n *\n * @template T - The type of elements in the input arrays.\n * @template R - The type of elements in the resulting array.\n * @param {T[]} arr1 - The first array to zip.\n * @param {...Array} rest - The additional arrays to zip together, followed by the combiner function.\n * @param {(...items: T[]) => R} combine - The combiner function that takes corresponding elements from each array and returns a single value.\n * @returns {R[]} A new array where each element is the result of applying the combiner function to the corresponding elements of the input arrays.\n *\n * @example\n * const arr1 = [1, 2, 3];\n * const arr2 = ['a', 'b', 'c'];\n * const result = zipWith(arr1, arr2, (num, char) => `${num}${char}`);\n * // result will be ['1a', '2b', '3c']\n */\nexport function zipWith(arr1: readonly T[], ...rest: any[]): R[] {\n const arrs = [arr1, ...rest.slice(0, -1)];\n const combine = rest[rest.length - 1] as (...items: T[]) => R;\n\n const maxIndex = Math.max(...arrs.map(arr => arr.length));\n const result: R[] = Array(maxIndex);\n\n for (let i = 0; i < maxIndex; i++) {\n const elements: T[] = arrs.map(arr => arr[i]);\n result[i] = combine(...elements);\n }\n\n return result;\n}\n"],"names":["at","arr","indices","result","Array","length","i","index","Number","isInteger","Math","trunc","difference","firstArr","secondArr","secondSet","Set","filter","item","has","differenceBy","mapper","mappedSecondSet","map","differenceWith","areItemsEqual","firstItem","every","secondItem","dropRightWhile","canContinueDropping","slice","dropWhile","dropEndIndex","findIndex","flatten","depth","flooredDepth","floor","recursive","currentDepth","isArray","push","intersection","intersectionBy","intersectionWith","some","last","sample","random","minimum","maximum","Error","randomInt","uniq","from","uniqBy","Map","key","set","values","unionBy","arr1","arr2","concat","uniqWith","v","unionWith","unzip","zipped","maxLen","j","zip","arrs","rowCount","columnCount","row","AbortError","constructor","message","super","this","name","TimeoutError","after","n","func","counter","args","ary","apply","debounce","debounceMs","signal","edges","pendingThis","pendingArgs","leading","includes","trailing","invoke","undefined","timeoutId","schedule","clearTimeout","setTimeout","cancel","onTimerEnd","cancelTimer","debounced","aborted","isFirstCall","flush","addEventListener","once","flow","funcs","call","identity","x","noop","partial","partialArgs","providedArgs","startIndex","arg","placeholder","partialPlaceholder","Symbol","partialRight","placeholderLength","partialRightPlaceholder","rangeLength","max","providedIndex","mean","nums","sum","median","NaN","sorted","sort","a","b","middleIndex","range","start","end","step","ceil","isPrimitive","value","isTypedArray","ArrayBuffer","isView","DataView","clone","obj","SharedArrayBuffer","prototype","Object","getPrototypeOf","Constructor","Date","RegExp","newRegExp","lastIndex","buffer","newError","stack","cause","File","type","lastModified","newObject","create","assign","getSymbols","object","getOwnPropertySymbols","symbol","propertyIsEnumerable","cloneDeep","cloneDeepImpl","get","hasOwn","input","getTime","source","flags","add","Buffer","isBuffer","subarray","byteOffset","byteLength","copyProperties","Blob","target","keys","descriptor","getOwnPropertyDescriptor","writable","isPlainObject","proto","toString","flattenObjectImpl","prefix","prefixedKey","mapKeys","getNewKey","mapValues","getNewValue","merge","sourceKeys","sourceValue","targetValue","isObjectLike","isBlob","getTag","regexpTag","stringTag","numberTag","booleanTag","argumentsTag","symbolTag","dateTag","mapTag","setTag","arrayTag","functionTag","arrayBufferTag","objectTag","errorTag","dataViewTag","uint8ArrayTag","uint8ClampedArrayTag","uint16ArrayTag","uint32ArrayTag","bigUint64ArrayTag","int8ArrayTag","int16ArrayTag","int32ArrayTag","bigInt64ArrayTag","float32ArrayTag","float64ArrayTag","eq","other","isNaN","isEqualWith","areValuesEqual","isEqualWithImpl","property","aParent","bParent","is","areObjectsEqual","aTag","bTag","valueOf","aStack","bStack","size","entries","aValues","bValues","aValue","bValue","splice","Uint8Array","aKeys","bKeys","propKey","aProp","delete","isJSONValue","isJSONArray","isJSONObject","Reflect","ownKeys","isLength","isSafeInteger","isNil","delay","ms","Promise","resolve","reject","abortError","abortHandler","removeEventListener","async","timeout","capitalize","str","charAt","toUpperCase","toLowerCase","CASE_SPLIT_PATTERN","words","match","deburrMap","htmlEscapes","trimEnd","chars","endIndex","substring","trimStart","trim","htmlUnescapes","toArray","isArrayLike","isArrayLikeObject","array","lastToolkit","isDeepKey","toKey","toPath","deepKey","quoteChar","bracket","charCodeAt","char","path","defaultValue","getWithPath","current","String","isObject","isMatch","isArrayMatch","isMapMatch","isSetMatch","countedIndex","sourceItem","targetItem","matches","cloneDeepToolkit","iterator","IS_UNSIGNED_INTEGER","isIndex","MAX_SAFE_INTEGER","test","isArguments","resolvedPath","matchesProperty","iteratee","isSymbol","toNumber","toFinite","Infinity","MAX_VALUE","toInteger","finite","remainder","isIterateeCall","isString","Boolean","isConcatSpreadable","forEach","collection","callback","head","headToolkit","getPriority","compareValues","order","localeCompare","aPriority","bPriority","regexIsDeepProp","regexIsPlainProp","orderBy","criteria","orders","guard","getValueByNestedPath","preparedCriteria","criterion","isKey","original","getValueByCriterion","comparedResult","nextKey","attempt","e","bind","thisObj","bound","bindPlaceholder","bindKey","bindKeyPlaceholder","curry","arity","parseInt","wrapper","holders","makeCurry","curryPlaceholder","composeArgs","curryRight","makeCurryRight","curryRightPlaceholder","options","maxWait","pendingAt","_debounced","debounceToolkit","now","decimalAdjust","number","precision","min","magnitude","exponent","split","adjustedValue","newMagnitude","newExponent","clamp","bound1","bound2","clampToolkit","sumBy","iterateeToolkit","defaults","sources","objectProto","tag","toStringTag","isTypedArrayToolkit","mergeWith","otherArgs","mergeWithDeep","cloned","targetKeys","targetKey","merged","unset","unsetWithPath","parent","lastKey","conformsTo","predicate","join","normalizeForCase","replace","escape","string","escapeToolkit","esTemplateRegExp","unEscapedRegExp","noMatchExp","escapeMap","escapeString","templateSettings","evaluate","interpolate","variable","imports","_","template","delimitersRegExp","isEvaluated","matchAll","fullMatch","escapeValue","interpolateValue","esTemplateValue","evaluateValue","importsKeys","importValues","sourceURL","compiledFunction","Function","idCounter","aryToolkit","before","TypeError","camelCase","getWords","first","rest","word","camelCaseToolkit","castArray","arguments","chunk","chunkLength","chunkToolkit","compact","compactToolkit","conforms","constant","constantCase","countBy","deburr","normalize","defaultTo","defer","differenceToolkit","_values","flattenArrayLike","arrayLike","differenceByToolkit","createIteratee","drop","itemsCount","dropToolkit","dropRight","dropRightToolkit","dropRightWhileImpl","dropRightWhileToolkit","dropWhileImpl","dropWhileToolkit","endsWith","position","escapeRegExp","doesMatch","fill","finalStart","finalEnd","fillToolkit","find","fromIndex","subArray","findKey","findLastIndex","flatMap","flatMapDeep","flattenDeep","flattenDepth","flattenObject","flip","reverse","flattenFuncs","flowToolkit","flowRight","flowRightToolkit","forEachRight","fromPairs","pairs","groupBy","getKeyFromItem","inRange","inRangeToolkit","indexOf","searchElement","initial","arrays","intersectionToolkit","lastValue","count","intersectionByToolkit","invariant","condition","invert","invertBy","valueStr","isArrayBuffer","isArrayBufferToolkit","isBoolean","isDate","isDateToolkit","isEmpty","isPrototype","isEqual","isEqualWithToolkit","isError","isFile","isFinite","isFunction","isMap","isMapToolKit","isNotNil","isNull","isNumber","isRegExp","isRegExpToolkit","isSet","isSetToolkit","isSubset","superset","subset","isSubsetWith","isUndefined","isWeakMap","WeakMap","isWeakMapToolkit","isWeakSet","WeakSet","isWeakSetToolkit","separator","kebabCase","kebabCaseToolkit","keyBy","lowerCase","lowerCaseToolkit","lowerFirst","mapKeysToolkit","mapValuesToolkit","items","maxElement","element","maxBy","getValue","meanBy","medianBy","memoize","fn","cache","getCacheKey","memoizedFn","minElement","minBy","negate","omit","keysArr","omitBy","shouldOmit","called","pad","padStart","padEnd","padToolkit","radix","partition","isInTruthy","truthy","falsy","pascalCase","pick","pickBy","shouldPick","pullAt","indicesToRemove","removed","y","floating","randomToolkit","randomIntToolkit","rangeRight","rearg","flattenIndices","reorderedArgs","repeat","pattern","replacement","params","restToolkit","round","sampleToolkit","sampleSize","selected","resultIndex","shuffle","resultLength","snakeCase","snakeCaseToolkit","sortBy","spread","argsIndex","startCase","startsWith","tail","tailToolkit","take","takeToolkit","takeRight","takeRightToolkit","takeRightWhile","shouldContinueTaking","takeWhile","throttle","throttleMs","times","toDefaulted","toFilled","newArr","toLength","toMerged","toSafeInteger","trimToolkit","trimEndToolkit","trimStartToolkit","unary","unescape","union","uniqToolkit","flattenedArrays","allValues","uniqByToolkit","uniqueId","unzipToolkit","unzipWith","maxLength","innerArray","group","upperCase","upperCaseToolkit","upperFirst","withTimeout","run","race","without","withoutToolkit","xor","xorBy","xorWith","areElementsEqual","zipToolkit","zipObject","zipObjectDeep","zipWith","combine","maxIndex","elements"],"mappings":"+BAegB,SAAAA,GAAMC,EAAmBC,GACvC,MAAMC,EAAS,IAAIC,MAAqBF,EAAQG,QAC1CA,EAASJ,EAAII,OAEnB,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAQG,OAAQC,IAAK,CACvC,IAAIC,EAAQL,EAAQI,GAEpBC,EAAQC,OAAOC,UAAUF,GAASA,EAAQG,KAAKC,MAAMJ,IAAU,EAE3DA,EAAQ,IACVA,GAASF,GAGXF,EAAOG,GAAKL,EAAIM,EACjB,CAED,OAAOJ,CACT,CCVgB,SAAAS,aAAcC,EAAwBC,GACpD,MAAMC,EAAY,IAAIC,IAAIF,GAE1B,OAAOD,EAASI,QAAOC,IAASH,EAAUI,IAAID,IAChD,UCDgBE,eAAmBP,EAAwBC,EAAyBO,GAClF,MAAMC,EAAkB,IAAIN,IAAIF,EAAUS,KAAIL,GAAQG,EAAOH,MAE7D,OAAOL,EAASI,QAAOC,IACbI,EAAgBH,IAAIE,EAAOH,KAEvC,UCVgBM,eACdX,EACAC,EACAW,GAEA,OAAOZ,EAASI,QAAOS,GACdZ,EAAUa,OAAMC,IACbH,EAAcC,EAAWE,MAGvC,CCbgB,SAAAC,iBACd5B,EACA6B,GAEA,IAAK,IAAIxB,EAAIL,EAAII,OAAS,EAAGC,GAAK,EAAGA,IACnC,IAAKwB,EAAoB7B,EAAIK,GAAIA,EAAGL,GAClC,OAAOA,EAAI8B,MAAM,EAAGzB,EAAI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